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://zhuanlan.zhihu.com/p/22388052 | |
来源:知乎 | |
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 | |
(function(){ | |
//私有静态成员 | |
var user = ""; | |
//私有静态方法 |
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 convert(num){ | |
var result = "" | |
while(num){ | |
result = String.fromCharCode( --num % 26 + 65) + result | |
num = Math.floor(num / 26) | |
} | |
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
function _typeof(something){ | |
return Object.prototype.toString.call(something).slice(8,-1); | |
} |
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.links).filter(function() { | |
return this.hostname != window.location.hostname; | |
}).attr('target', '_blank'); |
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
<style type="text/css"> | |
/*IE 10 */ | |
select::-ms-expand{ | |
display: none; | |
} | |
select{ | |
/* Chrome */ | |
-webkit-appearance: none; | |
/* Firefox */ | |
-moz-appearance: none; |
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
/* | |
DOM结构说明: | |
ul.avatar-list | |
li | |
img.avatar | |
li | |
img.avatar | |
*/ | |
.avatar-list > li:nth-child(3n+2) img { | |
border-top-left-radius: 84%; |
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 lastTime = 0; | |
var vendors = ['webkit', 'moz']; | |
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { | |
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; | |
window.cancelAnimationFrame = | |
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; | |
} | |
if (!window.requestAnimationFrame) |
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 escapeHTML(a) { | |
a = "" + a; | |
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"); | |
; | |
} |
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 debounce(dom, event, fn, timeout) { | |
var timeout = timeout || 3; // 默认延迟3s内点击无效 | |
var timer = null; | |
// cornor cases | |
if (!dom || !event || !(event in dom) || typeof fn !== 'function') { | |
return | |
} | |
dom.addEventListener(event, function () { | |
var _this = this; |
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
//2.处理毫秒级的时间 | |
$.extend({ | |
handleTime:function(times){ | |
var nowTime = new Date(times), | |
year = nowTime.getFullYear(), | |
month = nowTime.getMonth(), | |
day = nowTime.getDate(); | |
return year+'.'+month+"."+day; |
OlderNewer