Created
February 14, 2010 15:59
-
-
Save sebmarkbage/304105 to your computer and use it in GitHub Desktop.
More MooTools
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: Array.Reduce.js | |
description: Extends Array with reduce and reduceRight methods in browsers that don't support them. | |
license: MIT-style license. | |
requires: | |
- /Array | |
provides: [Array.Reduce] | |
... | |
*/ | |
Array.implement({ | |
reduce: function(fn, value){ | |
for (var i = 0, l = this.length; i < l; i++) | |
if (i in this) | |
value = value === undefined ? this[i] : fn.call(null, value, this[i], i, this); | |
return value; | |
}, | |
reduceRight: function(fn, value){ | |
var i = this.length; | |
while (i--) | |
if (i in this) | |
value = value === undefined ? this[i] : fn.call(null, value, this[i], i, this); | |
return value; | |
} | |
}); |
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: Request.XML.js | |
description: Extends the basic Request Class by forcing a XML parsing even for unknown mime types. | |
license: MIT-style license. | |
requires: | |
- /Request | |
provides: [Request.XML] | |
... | |
*/ | |
Request.XML = new Class({ | |
Extends: Request, | |
success: function(text, xml){ | |
try { | |
if (!xml || !xml.documentElement){ | |
if (window.DOMParser){ | |
xml = new DOMParser().parseFromString(text, 'text/xml'); | |
} else { | |
try { xml = new ActiveXObject('MSXML2.DOMDocument'); } | |
catch (e){ xml = new ActiveXObject('Microsoft.XMLDOM'); } | |
xml.async = 'false'; | |
xml.loadXML(text); | |
} | |
} | |
} catch (e){ | |
xml = null; | |
} | |
this.response.xml = xml; | |
this.parent(text, xml); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment