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
$('#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
// 按不同的时间段显示不同的“问好”信息,一般做法是 | |
// 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
/* | |
* 判断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
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
// 时间格式化 | |
// 使用:var d = new Date().format('yyyy-MM-dd'); | |
Date.prototype.format = function(format) { | |
var date = { | |
"M+": this.getMonth() + 1, | |
"d+": this.getDate(), | |
"h+": this.getHours(), | |
"m+": this.getMinutes(), | |
"s+": this.getSeconds(), | |
"q+": Math.floor((this.getMonth() + 3) / 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 passwordLevel(password) { | |
var Modes = 0; | |
for (i = 0; i < password.length; i++) { | |
Modes |= CharMode(password.charCodeAt(i)); | |
} | |
return bitTotal(Modes); | |
//CharMode函数 | |
function CharMode(iN) { | |
if (iN >= 48 && iN <= 57)//数字 |
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
/* | |
** randomWord 产生任意长度随机字母数字组合 | |
** randomFlag-是否任意长度 min-任意长度最小位[固定位数] max-任意长度最大位 | |
** xuanfeng 2014-08-28 | |
*/ | |
function randomWord(randomFlag, min, max){ | |
var str = "", | |
range = min, | |
arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; |
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(){ | |
// 定义对象 | |
var Draw = {}; | |
// 共有方法 | |
Draw.init = function(){}; | |
// 私有方法 | |
Draw._private = function(){}; | |
// 外部接口 |