Lib



Lib.js from del.icio.us

function emptyFunc(){}

function falseFunc(){ return false }

function addLoadEvent(f) { var old = window.onload

if (typeof old != 'function') window.onload = f

else { window.onload = function() { old(); f() }}

}

function prevent(e) {

if (window.event) window.event.returnValue = false

else e.preventDefault()

}

// return the time it takes to run a function in millisecs

function funcTimer(f){

var then = new Date().getTime()

f()

return (new Date().getTime() - then)

}

function extend(dest, src){

if(!src) return dest

for(var k in src) dest[k] = src[k]

return dest

}

function niceExtend(dest, src){

if(!src) return dest

if(src.html) { dest.innerHTML = src.html; delete src.html }

if(src.css) { dest.className = src.css; delete src.css }

if(src.attr) {

var s = src.attr

for(var k in s) dest.setAttribute(k, s[k])

delete src.attr

}

if(src.style) {

var d = dest.style, s = src.style

for(var k in s) d[k] = s[k]

delete src.style

}

for(var k in src) dest[k] = src[k]

return dest

}

function isArray(o) { if(o && typeof o == 'object' && o.constructor == Array) return true; return false }

extend( String.prototype, {

include: function(t) { return this.indexOf(t) >= 0 ? true : false },

trim: function(){ return this.replace(/^\s+|\s+$/g,'') },

splitrim: function(t){ return this.trim().split(new RegExp('\\s*'+t+'\\s*')) },

encodeTag: function() { return encodeURIComponent(this).replace(/%2F/g, '/') },

unescHtml: function(){ var i,e={'<':'','&':'&','"':'"'},t=this; for(i in e) t=t.replace(new RegExp(i,'g'),e[i]); return t },

escHtml: function(){ var i,e={'&':'&','':'>','"':'"'},t=this; for(i in e) t=t.replace(new RegExp(i,'g'),e[i]); return t },

escRegExp: function(){ return this.replace(/[\\$*+?()=!|,{}\[\]\.^]/g,'\\$&') }

})

Number.prototype.times = function(f){

var n = this

while(n > 0) { f(); n-- }

}

// make a cheep hash from an array

Object.fromArray = function(src, value){

if(typeof(value) == 'undefined') value = true

var r = {}, l = src.length

for (var i = 0; i < l; i++) r[src[i]] = value

return r

}

// copy an arraylike obj to an actual array

Array.from = function(src){

var l = src.length, r = []

for (var i=0; i ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related download