Ox.PATH: remove onload dependency on Ox.slice

This commit is contained in:
rolux 2013-12-01 13:10:00 +01:00
parent 137124a903
commit 3619316f78

View file

@ -88,11 +88,16 @@ Ox.SHORT_MONTHS = Ox.MONTHS.map(function(val) {
return val.slice(0, 3);
});
//@ Ox.PATH <str> Path of Ox.js
Ox.PATH = Ox.toArray(
document.getElementsByTagName('script')
).reverse().filter(function(element) {
return /Ox\.js(\?\d+|)$/.test(element.src);
})[0].src.replace(/Ox\.js(\?\d+|)$/, '');
Ox.PATH = (function() {
// IE8 can't apply slice to NodeLists, see Ox.slice
var index, scripts = document.getElementsByTagName('script');
for (index = scripts.length; index >= 0; index--) {
var src = element.src;
if (/Ox\.js(\?\d+|)$/.test(src)) {
return src.replace(/Ox\.js(\?\d+|)$/, '');
}
}
}());
//@ Ox.PREFIXES <[str]> `['', 'K', 'M', 'G', 'T', 'P']`
Ox.PREFIXES = ['', 'K', 'M', 'G', 'T', 'P'];
//@ Ox.SEASONS <[s]> Names of the seasons of the year