1
0
Fork 0
forked from 0x2620/oxjs

add Ox.Log, determine Ox.PATH by looking at the _last_ Ox.js script

This commit is contained in:
rlx 2011-10-23 14:26:37 +00:00
commit 116d0bfdbf
4 changed files with 23 additions and 5 deletions

View file

@ -77,7 +77,7 @@ Ox.SHORT_MONTHS = Ox.MONTHS.map(function(val) {
//@ Ox.PATH <str> 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]> <code>['K', 'M', 'G', 'T', 'P']</code>

View file

@ -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 <f> Prints its arguments to the console
(arg, ...) -> <s> String

View file

@ -79,7 +79,7 @@ Ox.loadFile = (function() {
element.onload = addFileToCache;
}
}
document.getElementsByTagName('head')[0].appendChild(element);
document.head.appendChild(element);
} else {
addFileToCache();
}