diff --git a/source/Ox.js b/source/Ox.js index 1100597f..f0995b1b 100644 --- a/source/Ox.js +++ b/source/Ox.js @@ -27,12 +27,13 @@ Ox = { }); function getPath() { - var i, scripts = document.getElementsByTagName('script'); + var i, path, scripts = document.getElementsByTagName('script'); for (i = 0; i < scripts.length; i++) { if (/Ox\.js$/.test(scripts[i].src)) { - return scripts[i].src.replace(/Ox\.js$/, ''); + path = scripts[i].src.replace(/Ox\.js$/, ''); } } + return path; } function loadJSON(callback) { @@ -82,7 +83,7 @@ Ox = { element.onload = callback; element.src = path + script + '?' + parseInt(Math.random() * 1000000); element.type = 'text/javascript'; - document.getElementsByTagName('head')[0].appendChild(element); + document.head.appendChild(element); } } diff --git a/source/Ox/js/Constants.js b/source/Ox/js/Constants.js index 95fab5aa..9353ae2f 100644 --- a/source/Ox/js/Constants.js +++ b/source/Ox/js/Constants.js @@ -77,7 +77,7 @@ Ox.SHORT_MONTHS = Ox.MONTHS.map(function(val) { //@ Ox.PATH Path of Ox.js Ox.PATH = Ox.makeArray( document.getElementsByTagName('script') -).filter(function(element) { +).reverse().filter(function(element) { return /Ox\.js$/.test(element.src); })[0].src.replace(/Ox\.js$/, ''); //@ Ox.PREFIXES <[str]> ['K', 'M', 'G', 'T', 'P'] diff --git a/source/Ox/js/Core.js b/source/Ox/js/Core.js index 0cccb1aa..d708bd0f 100644 --- a/source/Ox/js/Core.js +++ b/source/Ox/js/Core.js @@ -121,6 +121,23 @@ Ox.load = function() { }); }; +Ox.Log = (function() { + var filter = /.*?/, + that = function() { + Ox.Log.log.apply(null, arguments); + return that; + }; + that.filter = function(regexp) { + filter = regexp; + }; + that.log = function() { + if (filter.test(JSON.stringify(arguments))) { + Ox.print.apply(null, arguments); + } + }; + return that; +}()); + /*@ Ox.print Prints its arguments to the console (arg, ...) -> String diff --git a/source/Ox/js/Request.js b/source/Ox/js/Request.js index 6a842b5b..039bdf6d 100644 --- a/source/Ox/js/Request.js +++ b/source/Ox/js/Request.js @@ -79,7 +79,7 @@ Ox.loadFile = (function() { element.onload = addFileToCache; } } - document.getElementsByTagName('head')[0].appendChild(element); + document.head.appendChild(element); } else { addFileToCache(); }