Ox.PATH: remove onload dependency on Ox.slice

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

View file

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