Cleans code.

This commit is contained in:
Lars Jung 2012-09-19 23:59:53 +02:00
parent 26d0de5985
commit ede2316f53
2 changed files with 29 additions and 23 deletions

View file

@ -198,7 +198,7 @@ options, types and langs
/* [all]
Adds Piwik tracker javascript code.
baseURL without protocol
"baseURL" without protocol
*/
"piwik-analytics": {
"enabled": false,

View file

@ -25,8 +25,6 @@
globalConfigHref = $scriptTag.attr('src').replace(/scripts.js$/, '../config.json'),
localConfigHref = $scriptTag.data('config') || './_h5ai.config.json',
ajaxOpts = {dataType: 'text'},
parse = function (response) {
return response.replace ? JSON.parse(response.replace(/\/\*[\s\S]*?\*\/|\/\/.*?(\n|$)/g, '')) : {};
@ -40,6 +38,33 @@
});
},
loadConfig = function (callback) {
var ajaxOpts = {
dataType: 'text'
},
config = {
options: {},
types: {},
langs: {}
};
$.ajax(globalConfigHref, ajaxOpts).always(function (g) {
extendLevel1(config, parse(g));
if (localConfigHref === 'ignore') {
callback(config);
return;
}
$.ajax(localConfigHref, ajaxOpts).always(function (l) {
extendLevel1(config, parse(l));
callback(config);
});
});
},
run = function (config) {
/*global amplify, Base64, jQuery, Modernizr, moment, _ */
@ -57,27 +82,8 @@
modulejs.require($('body').attr('id'));
});
},
config = {
options: {},
types: {},
langs: {}
};
$.ajax(globalConfigHref, ajaxOpts).always(function (g) {
extendLevel1(config, parse(g));
if (localConfigHref === 'ignore') {
run(config);
return;
}
$.ajax(localConfigHref, ajaxOpts).always(function (l) {
extendLevel1(config, parse(l));
run(config);
});
});
loadConfig(run);
}(jQuery));