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 isHostMethod(object, property) { | |
var t = typeof object[property]; | |
return t=='function' || | |
(!!(t=='object' && object[property])) || | |
t=='unknown'; | |
} |
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 eventUtility = { | |
addEvent: (function () { | |
if (typeof addEventListener !== "undefined") { | |
return function (obj, evt, fn) { | |
obj.addEventListener(evt, fn, false); | |
}; | |
} else { | |
return function (obj, evt, fn) { | |
obj.attachEvent("on" + evt, fn); | |
}; |
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 ajaxUtility = { | |
createXHR: function () { | |
if (typeof XMLHttpRequest !== "undefined") { | |
return new XMLHttpRequest(); | |
} else { | |
var versions = ["MSXML2.XmlHTTP.6.0", "MSXML2.XmlHTTP.3.0"]; | |
for (var i = 0; i < versions.length; i++) { | |
try { | |
var xhr = new ActiveXObject(versions[i]); |
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
<dl> | |
<dt>Would you like to learn more?</dt> | |
<dd>Yada Yada Such and Such</dd> | |
<dt>Would you like to learn more?</dt> | |
<dd>Yada Yada Such and Such</dd> | |
<dt>Would you like to learn more?</dt> | |
<dd>Yada Yada Such and Such</dd> | |
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
if (typeof Object.create !== 'function') { | |
Object.create = function(o) { | |
function F() {}; | |
f.prototype = o; | |
return new F(); | |
}; | |
} |
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 getElementsByClassName(node, className) { | |
if (node.getElementsByClassName) { | |
return node.getElementsByClassName(className); | |
} else { | |
var results = []; | |
var elems = node.getElementsByTagName("*"); | |
for (var i = 0, len = elems.length; i < len; i++) { | |
if (elems[i].className.indexOf(className) != -1) { | |
results.push(elem[i]); | |
} |
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 serialize(form) { | |
var parts = [], | |
field = null, | |
i, | |
len, | |
j, | |
optLen, | |
option, | |
optValue; | |
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 createCORSResquest(method, url) { | |
var xhr = new XMLHttpRequest(); | |
if ("withCredentials" in xhr) { | |
xhr.open(method, url, true); | |
} else if (typeof XDomainRequest != "undefined") { | |
xhr = new XDomainRequest(); | |
xhr.open(method, url); | |
} else { | |
xhr = null; | |
} |
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 Person(name, age, job) { | |
if (this instanceof Person) { | |
this.name = name; | |
this.age = age; | |
this.job = job; | |
} else { | |
return new Person(name, age, job) | |
} | |
} |
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 Polygon(sides) { | |
if (this instanceof Polygon) { | |
this.sides = sides; | |
this.getArea = function() { | |
return 0; | |
}; | |
} else { | |
return new Polygon(sides); | |
} | |
} |
OlderNewer