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
// requestAnimationFrame的向下兼容处理 | |
if (!window.requestAnimationFrame) { | |
window.requestAnimationFrame = function(fn) { | |
setTimeout(fn, 17); | |
}; | |
} | |
于是,动效绘制大致路数会变成这样: | |
var canvas = document.querySelector('canvas'); | |
var context = canvas.getContext('2d'); |
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
# first: | |
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done | |
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* | |
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following: | |
# go to /usr/local/lib and delete any node and node_modules | |
cd /usr/local/lib | |
sudo rm -rf node* |
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() { | |
var hidden = "hidden"; | |
// Standards: | |
if (hidden in document) | |
document.addEventListener("visibilitychange", onchange); | |
else if ((hidden = "mozHidden") in document) | |
document.addEventListener("mozvisibilitychange", onchange); | |
else if ((hidden = "webkitHidden") in document) | |
document.addEventListener("webkitvisibilitychange", onchange); |
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
$('body').on('touchmove', function(e){e.preventDefault()}); |
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 getElementsByClassName = function (searchClass, node,tag) { | |
if(document.getElementsByClassName){ | |
var nodes = (node || document).getElementsByClassName(searchClass),result = []; | |
for(var i=0 ;node = nodes[i++];){ | |
if(tag !== "*" && node.tagName === tag.toUpperCase()){ | |
result.push(node) | |
} | |
} | |
return result |
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 willSort = [ | |
{ | |
name:'shangwenhe', | |
age:25, | |
height:170 | |
}, | |
{ | |
name:'zhangsan', | |
age:31, | |
height:169 |
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
//取得ID | |
var $ = function (id) { | |
return "string" == typeof id ? document.getElementByIdx_x(id) : id; | |
}; | |
// 对象继承 | |
var Extend = function(destination, source) { | |
for (var property in source) { | |
destination[property] = source[property]; |
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 loadScript(url, callback){ | |
var script = document.createElement ("script") | |
script.type = "text/javascript"; | |
if (script.readyState){ //IE | |
script.onreadystatechange = function(){ | |
if (script.readyState == "loaded" || script.readyState == "complete"){ | |
script.onreadystatechange = null; | |
callback(); | |
} | |
}; |
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 ParseURL(arg){ | |
var url = arg, | |
regexp = /([^\?]*)\??([^#]*)#(.*)/g, | |
regexpParam = /([^&]*)=([^&]*)/g, | |
urlExec = regexp.exec(url), | |
_host = urlExec[1], | |
_urlparam = urlExec[2], | |
_hashparam = urlExec[3]; | |
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(){ | |
if(!window.console){window.console ={log:function(){}};return;} | |
var me = 19; | |
var Star = function(){ | |
this.x=0; | |
this.speed = 1; | |
this.y=0; | |
} | |
var score = 0; | |
var strs = function(){ |
NewerOlder