This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.text.TextUtils; | |
import com.taobao.weex.adapter.IWXHttpAdapter; | |
import com.taobao.weex.common.WXRequest; | |
import com.taobao.weex.common.WXResponse; | |
import java.io.File; | |
import java.io.IOException; | |
import java.util.Set; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadToDataURL(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.responseType = 'blob'; | |
xhr.onload = function() { | |
var reader = new FileReader(); | |
reader.onloadend = function () { | |
callback(reader.result); | |
reader = null; | |
} | |
reader.readAsDataURL(xhr.response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 动画函数 | |
* @param {Object} opts 动画参数 | |
* @param {Number} opts.duration 持续时间 | |
* @param {Function} [opts.delta] 动画进度计算函数默认为线性 | |
* @param {Function} opts.complete 动画完成之后执行的函数 | |
* @param {Function} opts.render 动画渲染函数 | |
*/ | |
function animate(opts) { | |
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function TreeNode(val){ | |
this.val = val; | |
this.left = null; | |
this.right = null; | |
} | |
function addNodeToTree(root, val){ | |
if (val < root.val){ | |
if (!root.left){ | |
root.left = new TreeNode(val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//format('hello {0}!', 'world') => 'hello world!' | |
//format('hello {0}!{1}', 'world', 'OK') => 'hello world!OK' | |
//format('hello {0}!', ['world']) => 'hello world!' | |
//format('hello {0}!{1}', ['world', 'OK']) => 'hello world!' | |
function format(str){ | |
var dataList = (/array/i).test(Object.prototype.toString.apply(arguments[1])) ? arguments[1] : Array.prototype.slice.apply(arguments, [1]); | |
return str.replace(/\{(\d+)\}/g, function(target, index){ | |
index = parseInt(index, 10); | |
return dataList[index] || ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('WeixinJSBridgeReady', function(){ | |
//如果执行到这块的代码,就说明是在微信内部浏览器内打开的. | |
alert('当前页面在微信内嵌浏览器中打开!'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var countDown = (function($){ | |
var counts = {}, countTime, stopped = true, id = 0; | |
function count(){ | |
var length = 0; | |
$.each(counts, function(key, countObj){ | |
var timeObj, seconds = countObj.seconds - ((new Date().getTime() - countObj.startTime) /1000); | |
if(seconds > 0){ | |
timeObj = { |