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 quickSort = function(arr){ | |
if(arr.length <= 1){ return arr;} | |
var pivotIndex = Math.floor(arr.length/2), | |
pivot = arr.splice(pivotIndex, 1)[0], | |
left = [], | |
right = []; | |
for(var i = 0,len = arr.length;i < len;i++){ | |
if(arr[i] < pivot){ | |
left.push(arr[i]); | |
}else{ |
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
/** | |
* 将含有html等特殊字符转义 | |
* 使用实例:$.html_encode("<p>li</p>") | |
*/ | |
(function($){ | |
$.extend({"html_encode":function(str) { | |
var s = ""; | |
if (str==null || typeof(str)=='undefined' || str.length == 0) return ""; | |
s = str.replace(/&/g, "&"); | |
s = s.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 myreg = /^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,4}$/; |
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
<script type="text/javascript"> | |
function loadScript(url,callback){ | |
var script = document.createElement("script"), | |
script.type = 'text/javascript'; | |
if(script.readyState){ //ie | |
script.onreadystatechange = function(){ | |
if(script.readyState == 'loaded' || script.readyState == 'complete'){ | |
script.onreadystatechange = null; | |
callback(); |
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
Object.prototype.Clone = function(){ | |
var objClone; | |
if (this.constructor == Object){ | |
objClone = new this.constructor(); | |
}else{ | |
objClone = new this.constructor(this.valueOf()); | |
} | |
for(var key in this){ | |
if ( objClone[key] != this[key] ){ | |
if ( typeof(this[key]) == ‘object’ ){ |
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
//以一个对象的x和y属性的方式返回滚动条的偏移量 | |
function(w){ | |
var w = w || window; | |
if(w.pageXOffset != null) return {x: x.pageXOffset, y: w.pageYOffset}; | |
var d = w.document; | |
if(document.compatMode == "CSS1Compat"){ | |
return {x:d.documentElement.scrollLeft,y:d.documentElement.scrollTop}; | |
}else{ | |
return {x:d.body.scrllLeft,y:d.body.scrollTop}; | |
} |
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 EVENT = (function(){ | |
var bind = function(b){ | |
var queue = this.__MSG_QS__; | |
if(!queue[b]){ | |
queue[b] = []; | |
} | |
for(var a = 1, len = arguments.length, Y; a < len; a++) { | |
queue[b].push(arguments[a]) | |
} |
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
$.fn.selectRange = function(start, end) { | |
return this.each(function() { | |
if (this.setSelectionRange) { | |
this.focus(); | |
this.setSelectionRange(start, end); | |
} else if (this.createTextRange) { | |
var range = this.createTextRange(); | |
range.collapse(true); | |
range.moveEnd('character', end); | |
range.moveStart('character', start); |
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 JSON;JSON||(JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty. |
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 loadFile (url, callback) { | |
var head = document.getElementsByTagName("head")[0] || document.documentElement | |
var baseElement = head.getElementsByTagName("base")[0] | |
var IS_CSS_RE = /\.css(?:\?|$)/i | |
var currentlyAddingScript | |
var interactiveScript | |
var isOldWebKit = +navigator.userAgent | |
.replace(/.*AppleWebKit\/(\d+)\..*/, "$1") < 536 |
OlderNewer