层叠选择器:
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
JS里将中文转为unicode编码很简单 | |
function convert2Unicode(str) { | |
return str.replace(/[\u0080-\uffff]/g, | |
function($0) { | |
var tmp = $0.charCodeAt(0).toString(16); | |
return "\u" + new Array(5 - tmp.length).join('0') + tmp; | |
}); | |
} | |
function unicode2utf8($str){ | |
if(!$str) return $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
//LevenshTeinDistance是俄罗斯科学家Vladimir Levenshtein在1965年提出的根据编辑距离(Edit Distance)计算字符串相似度的一种算法。 | |
/* | |
* @name:LevenshteinDistance.js | |
* @description: | |
* @author:wondger@gmail.com | |
* @date:2012-04-17 | |
* @param: | |
* @todo: | |
* @changelog: | |
*/ |
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
/* | |
Enlarge for jQuery v1.1 | |
2013 | |
http://keleyi.com/ | |
*/ | |
(function ($) { | |
// 默认参数 | |
var defaults = | |
{ |
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
/* | |
* @author duansong | |
* @email duansong@baidu.com | |
* @date 2014-1-14 | |
* @descrition 基于jquery的表单验证组件,支持ajax验证 | |
*/ | |
(function($,window){ | |
//配置文件 | |
var settings = { | |
//验证规则 |
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 put_ini_file ( $file , $array , $i = 0 ){ | |
$str = "" ; | |
foreach ( $array as $k => $v ){ | |
if ( is_array ( $v )){ | |
$str .= str_repeat ( " " , $i * 2 ). "[ $k ]" . PHP_EOL ; | |
$str .= put_ini_file ( "" , $v , $i + 1 ); | |
}else | |
$str .= str_repeat ( " " , $i * 2 ). " $k = $v " . PHP_EOL ; | |
} | |
if( $file ) |
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
获取一组radio被选中项的值 | |
var item = $(‘input[@name=items][@checked]‘).val(); | |
获取select被选中项的文本 | |
var item = $(“select[@name=items] option[@selected]“).text(); | |
select下拉框的第二个元素为当前选中值 | |
$(‘#select_id’)[0].selectedIndex = 1; | |
radio单选组的第二个元素为当前选中值 | |
$(‘input[@name=items]‘).get(1).checked = true; | |
获取值: | |
文本框,文本区域:$(“#txt”).attr(“value”); |
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
String.prototype.repeat = function(count) { | |
// Go for it | |
var a = ""; | |
for (var i = count; i > 0; i--) { | |
a += this.valueOf(); | |
} | |
return a; | |
}; | |
//nice | |
String.prototype.repeat = function(count) { |
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 checkBOM ($filename) { | |
global $auto; | |
$contents = file_get_contents($filename); | |
$charset[1] = substr($contents, 0, 1); | |
$charset[2] = substr($contents, 1, 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
var mode="zhuan"; | |
function encode(obj,btn){ | |
if(mode=="zhuan"){ | |
obj.value=obj.value.replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"\\u$2")}); | |
btn.value="还原"; | |
mode="huan"; | |
}else{ | |
obj.value=unescape(obj.value.replace(/\\u/g,'%u').replace(/;/g,'')); | |
btn.value="转化"; | |
mode="zhuan"; |