in ox dev loader, allow for switching to build version by passing true as first argument (can be used to avoid boilerplate when choosing build/ or dev/ dynamically)

This commit is contained in:
rolux 2012-06-26 19:17:27 +02:00
parent 2efbc53b33
commit 80e0a02ea3

View file

@ -11,18 +11,26 @@
path = getPath(), path = getPath(),
time = +new Date(); time = +new Date();
loadJSON(function(data) { if (args[0] === true) {
var previousOx = global.Ox; console.log('OK')
loadScriptsSerial(data.files, function() { path = path.replace(/dev\/$/, 'build/');
Ox.VERSION = data.version; loadScript('Ox.js', function() {
Ox.forEach(previousOx, function(value, key) { Ox.load.apply(null, Ox.slice(args, 1));
if (Ox.isUndefined(Ox[key])) {
Ox[key] = value;
}
});
Ox.load.apply(null, args);
}); });
}); } else {
loadJSON(function(data) {
var previousOx = global.Ox;
loadScriptsSerial(data.files, function() {
Ox.VERSION = data.version;
Ox.forEach(previousOx, function(value, key) {
if (Ox.isUndefined(Ox[key])) {
Ox[key] = value;
}
});
Ox.load.apply(null, args);
});
});
}
function getPath() { function getPath() {
var i, path, scripts = document.getElementsByTagName('script'); var i, path, scripts = document.getElementsByTagName('script');