Skip to content

Instantly share code, notes, and snippets.

//LevenshTeinDistance是俄罗斯科学家Vladimir Levenshtein在1965年提出的根据编辑距离(Edit Distance)计算字符串相似度的一种算法。
/*
* @name:LevenshteinDistance.js
* @description:
* @author:wondger@gmail.com
* @date:2012-04-17
* @param:
* @todo:
* @changelog:
*/
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;
@mingyun
mingyun / substr.js
Created January 8, 2014 12:37
按字节截取字符串
baidu.string.getByteLength = function(source) {
return String(source).replace(/[^\x00-\xff]/g, "ci").length;
};
/*
* Tangram
* Copyright 2009 Baidu Inc. All rights reserved.
*
* path: baidu/string/subByte.js
* author: dron, erik
* version: 1.1.0
if(typeof Welefen != "object")Welefen = {Class:{div:null}};
Welefen.Class.pinyinSelect = function(id,selectArray)
{
var pinyinId = document.getElementById(id);
var pinyinArray = selectArray;
var isSelected = 0;
pinyinId.onclick = function()
{
isSelected = 0;
var e = this;
/**http://www.oschina.net/code/snippet_574366_24869
* Created by JetBrains PhpStorm.
* User: lsl
* Date: 13-8-28
* Time: 下午2:58
* 敏感词过滤工具类
* 使用方法
* echo FilterTools::filterContent("你妈的我操一色狼杂种二山食物","*",DIR."config/word.txt",$GLOBALS["p_memcache"]["bad_words"]);
*/
@mingyun
mingyun / keymaster.min.js
Created January 6, 2014 03:33
test:key.filter = function filter(event) { var tagName = (event.target || event.srcElement).tagName; return ! (tagName === 'INPUT' || tagName === 'SELECT'); }; key('command+enter, ctrl+enter', function() { document.form.submit(); });
// keymaster.js
// (c) 2011-2012 Thomas Fuchs
// keymaster.js may be freely distributed under the MIT license.
(function(e){function f(e,t){var n=e.length;while(n--)if(e[n]===t)return n;return-1}function l(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function h(e){for(t in r)r[t]=e[c[t]]}function p(e,t){var i,o,u,l,c;i=e.keyCode,f(a,i)==-1&&a.push(i);if(i==93||i==224)i=91;if(i in r){r[i]=!0;for(u in s)s[u]==i&&(m[u]=!0);return}h(e);if(!m.filter.call(this,e))return;if(!(i in n))return;for(l=0;l<n[i].length;l++){o=n[i][l];if(o.scope==t||o.scope=="all"){c=o.mods.length>0;for(u in r)if(!r[u]&&f(o.mods,+u)>-1||r[u]&&f(o.mods,+u)==-1)c=!1;(o.mods.length==0&&!r[16]&&!r[18]&&!r[17]&&!r[91]||c)&&o.method(e,o)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}}function d(e){var t=e.keyCode,n,i=f(a,t);i>=0&&a.splice(i,1);if(t==93||t==224)t=91;if(t in r){r[t]=!1;for(n in s)
*:focus {
outline: none;
}
a {
color: #159;
outline: none;
text-decoration: none;
}
var areaJson = [{"t":"北京市","s":[{"t":"东城区","s":[{"t":"和平里街道"},{"t":"东直门街道"},{"t":"建国门街道"},{"t":"朝阳门街道"},{"t":"东四街道"},{"t":"北新桥街道"},{"t":"安定门街道"},{"t":"交道口街道"},{"t":"景山街道"},{"t":"东华门街道"}]},{"t":"西城区","s":[{"t":"什刹海街道"},{"t":"金融街街道"},{"t":"德胜街道"},{"t":"展览路街道"},{"t":"月坛街道"},{"t":"新街口街道"},{"t":"西长安街街道"}]},{"t":"崇文区 ","s":[{"t":"永定门外街道"},{"t":"天坛街道"},{"t":"体育馆路街道"},{"t":"龙潭街道"},{"t":"东花市街道"},{"t":"崇文门外街道"},{"t":"前门街道"}]},{"t":"宣武区","s":[{"t":"广安门外街道"},{"t":"白纸坊街道"},{"t":"牛街街道"},{"t":"广安门内街道"},{"t":"陶然亭街道"},{"t":"椿树街道"},{"t":"天桥街道"},{"t":"大栅栏街道"}]},{"t":"朝阳区","s":[{"t":"望京开发街道"},{"t":"首都机场街道"},{"t":"王四营地区(王四营乡)"},{"t":"豆各庄地区(豆各庄乡)"},{"t":"黑庄户地区(黑庄户乡)"},{"t":"东坝地区(东坝乡)"},{"t":"崔各庄地区(崔各庄乡)"},{"t":"孙河地区(孙河乡)"},{"t":"金盏地区(金盏乡)"},{"t":"管庄地区(管庄乡)"},{"t":"三间房地区(三间房乡)"},{"t":"常营回族地区(常营回族乡)"},{"t":"来广营地区(来广营乡)"},{"t":"奥运村地区(奥运村乡)"},{"t":"东风地区(东风乡)"},{"t":"平房地区(平房乡)"},{"t":"十八里店地区(十八里店乡)"},{"t":"小红门地区(小红门乡)"},{"t":"望京街道"},{"t":"大屯街道"},{"t":"太阳宫地区(太阳宫乡)"},{"t":"将台地区(将台乡)"},{"t":"高碑店地区(高碑店乡)"},{"t":"南磨房地区(南磨房乡)"},{"t":"垡头街道"},
@mingyun
mingyun / json2select.js
Created December 31, 2013 07:52
无限联动的下拉框插件
/*
* json2select 1.0.1
*
* Copyright (c) 2008 Shawphy (shawphy.com)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/*!
* == jQuery simpleTabs v2.2 ==
* QQ: 390514201[sole]
* 发布: 2012-09-25
* 更新: 2013/10/7 17:48
*/
;(function($){
$.fn.simpleTabs = function(o){
var defs = {
control : ".control a",