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
/*code is far away from bug with the animal protecting | |
* ┏┓ ┏┓ | |
*┏┛┻━━━┛┻┓ | |
*┃ ┃ | |
*┃ ━ ┃ | |
*┃ ┳┛ ┗┳ ┃ | |
*┃ ┃ | |
*┃ ┻ ┃ | |
*┃ ┃ | |
*┗━┓ ┏━┛ |
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 htmlDecode(str){ | |
return str | |
.replace(/'/g, '\'') | |
.replace(/<br\s*(\/)?\s*>/g, '\n') | |
.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
/* | |
* 判断URL中是否有此参数 | |
*/ | |
hasQueryStringRegExp: function(url, name){ | |
var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i"); | |
if(reg.test(url)){ | |
return true | |
}else{ | |
return false | |
} |
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
// 按不同的时间段显示不同的“问好”信息,一般做法是 | |
// if(hour>=0 && hour <=5;){ | |
// }else if(hour>=6 && hour <=8;){ | |
// }else if(hour>=9 && hour <=11;){} | |
// ... | |
// 这里换了一种做法,看起来相对简洁一点! | |
/* | |
Test case: | |
for(var i = 0,iMax = 23; i <=iMax;i++){ |
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
$('#Participants').val().split(';').filter(function (n) { return n != '' }) |
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
/* 部分替换 | |
需求: <link href="/" rel="canonical"> 需要将href替换成data-href | |
解决:通过()获取某一组固定字符串,用$1表示,再进行替换 | |
*/ | |
var str = '<link href="/" rel="canonical"><link href="/" rel="canonical"><link data-id="" href="/" rel="canonical">'; | |
res = str.replace(/(link.*?)href/ig, '$1data-href'); | |
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
// 1. 设置变量为undefined | |
var UNDEFINED = void 0; | |
// 2. 判断支不支持touch事件 | |
var IsTouch = 'ontouchend' in window; | |
// 3. 各端事件兼容 | |
START_EVENT = IsTouch ? 'touchstart' : 'mousedown'; |
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 CSS_PREFIX_MAP = ["webkit", "moz", "ms", "o", ""], | |
NUMBER_REG = /\-?[0-9]+\.?[0-9]*/g; | |
var setTransition = function(ele, css) { | |
var name, prefix, _i, _len, _results; | |
_results = []; | |
for (_i = 0, _len = CSS_PREFIX_MAP.length; _i < _len; _i++) { | |
prefix = CSS_PREFIX_MAP[_i]; | |
name = prefix ? "" + prefix + "Transition" : "transition"; |
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
/* | |
* 名称:本地存储函数 | |
* 功能:兼容各大浏览器存储 | |
* 作者:轩枫 | |
* 日期:2015/06/11 | |
* 版本:V2.0 | |
*/ | |
/** | |
* LocalStorage 本地存储兼容函数 |
OlderNewer