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 globalEval = function(text) { | |
var s = doc.createElement('script'); | |
s.appendChild(doc.createTextNode(text)) | |
doc.querySelector('head').appendChild(s) | |
} |
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 setCursor(input) { | |
input.focus() | |
if (window.netscape) { | |
setTimeout(function() { //方法一 W3C,不过除firefox的浏览器可以直接用input.value = input.value搞定 | |
var n = input.value.length | |
input.setSelectionRange(n, n); | |
input.focus() | |
}, 0) | |
var n = input.value.length //方法二 | |
input.selectionStart = 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
function getTransitionEndEventName() { | |
var obj = { | |
TransitionEvent: "transitionend", | |
WebKitTransitionEvent: "webkittransitionEnd", | |
OTransitionEvent: "OTransitionEnd", | |
otransitionEvent: "otransitionEnd", | |
MSTransitionEvent: "MSTransitionEnd" | |
} | |
// var ev = document.createEvent("TransitionEvent"); // FIXME: un-specified | |
// ev.initTransitionEvent("transitionend", true, true, "some-unknown-prop", -4.75); |
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
//加法 | |
Number.prototype.add = function(arg){ | |
var r1,r2,m,n; | |
try{r1 = this.toString().split(".")[1].length}catch(e){r1=0} | |
try{r2 = arg.toString().split(".")[1].length}catch(e){r2=0} | |
m=Math.pow(10,Math.max(r1,r2)); | |
n=(r1>=r2)?r1:r2; | |
return ((this*m+arg*m)/m).toFixed(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
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 |
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
$.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 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
//以一个对象的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
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’ ){ |
NewerOlder