Implements the functionality to update config.js parameters via the URL.

pull/299/head 503
hristoterezov 10 years ago
parent cbeae8eb30
commit 5746261961
  1. 2
      app.js
  2. 2
      index.html
  3. 3342
      libs/app.bundle.js
  4. 40
      modules/URLProcessor/URLProcessor.js

@ -37,6 +37,8 @@ function init() {
$(document).ready(function () {
var URLPRocessor = require("./modules/URLProcessor/URLProcessor");
URLPRocessor.setConfigParametersFromUrl();
APP.init();
APP.translation.init();

@ -19,7 +19,7 @@
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
<script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
<script src="interface_config.js?v=5"></script>
<script src="libs/app.bundle.js?v=72"></script>
<script src="libs/app.bundle.js?v=73"></script>
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
<link rel="stylesheet" href="css/font.css?v=7"/>
<link rel="stylesheet" href="css/toastr.css?v=1">

File diff suppressed because it is too large Load Diff

@ -0,0 +1,40 @@
var params = {};
function getConfigParamsFromUrl() {
if(!location.hash)
return {};
var hash = location.hash.substr(1);
var result = {};
hash.split("&").forEach(function(part) {
var item = part.split("=");
result[item[0]] = JSON.parse(
decodeURIComponent(item[1]).replace(/\\&/, "&"));
});
return result;
}
params = getConfigParamsFromUrl();
var URLProcessor = {
setConfigParametersFromUrl: function () {
for(var k in params)
{
if(typeof k !== "string" || k.indexOf("config.") === -1)
continue;
var v = params[k];
var confKey = k.substr(7);
if(config[confKey] && typeof config[confKey] !== typeof v)
{
console.warn("The type of " + k +
" is wrong. That parameter won't be updated in config.js.");
continue;
}
config[confKey] = v;
}
}
};
module.exports = URLProcessor;
Loading…
Cancel
Save