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
alert("hi"); |
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
//判断奇数 | |
num & 1 == 1; | |
//判断偶数 | |
num & 1 == 0; | |
//parseInt | |
~~num |
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
chop: function(str, step){ | |
if (str == null) return []; | |
str = String(str); | |
step = ~~step; | |
return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str]; | |
} | |
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
//copy 字符串 | |
//这种每次加一个“0”的方式有些慢,可以参考underscore.string的优化 | |
function leftPad(numstr,length) { | |
while(numstr.length < length) { | |
numstr = "0"+numstr; | |
} | |
return numstr; | |
} |
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
//https://code.google.com/p/jslibs/wiki/JavascriptTips#Insert_an_array_in_another_array | |
var a = [1,2,3,7,8,9] | |
var b = [4,5,6] | |
var insertIndex = 3; | |
a.splice.apply(a, Array.concat(insertIndex, 0, b)); | |
Print(a); // prints: 1,2,3,4,5,6,7,8,9 |
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
/* | |
http://css-tricks.com/css-transparency-settings-for-all-broswers/ | |
*/ | |
.transparent { | |
zoom: 1; | |
filter: alpha(opacity=50); | |
opacity: 0.5; | |
} |
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
/* | |
http://css-tricks.com/almanac/properties/b/border-radius/ | |
*/ | |
.round { | |
/* Safari 3-4, iOS 1-3.2, Android 1.6- */ | |
-webkit-border-radius: 12px; | |
/* Firefox 1-3.6 */ | |
-moz-border-radius: 12px; |
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
/** | |
https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L214 | |
*/ | |
function clone(obj) { | |
if (typeof obj == "function" || Object(obj) !== obj) { | |
return obj; |
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
//ie8及以下浏览器 | |
if (window.attachEvent && !window.addEventListener) { | |
// "bad" IE | |
} | |
//ie7及以下浏览器 | |
if (window.attachEvent && !document.querySelector) { | |
// "bad" IE | |
} |
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
//Fuck ie6!!!! | |
//url length >= 2084 returns error code 0x7a | |
(function(length) { | |
var url = "http://zhushou.sogou.com/data/data.html?", | |
len = url.length, | |
str = new Array(length+1-len).join("u"), | |
img = new Image(); | |
img.src = url+str; |
OlderNewer