|
@@ -0,0 +1,40 @@
|
|
1
|
+var params = {};
|
|
2
|
+function getConfigParamsFromUrl() {
|
|
3
|
+ if(!location.hash)
|
|
4
|
+ return {};
|
|
5
|
+ var hash = location.hash.substr(1);
|
|
6
|
+ var result = {};
|
|
7
|
+ hash.split("&").forEach(function(part) {
|
|
8
|
+ var item = part.split("=");
|
|
9
|
+ result[item[0]] = JSON.parse(
|
|
10
|
+ decodeURIComponent(item[1]).replace(/\\&/, "&"));
|
|
11
|
+ });
|
|
12
|
+ return result;
|
|
13
|
+}
|
|
14
|
+
|
|
15
|
+params = getConfigParamsFromUrl();
|
|
16
|
+
|
|
17
|
+var URLProcessor = {
|
|
18
|
+ setConfigParametersFromUrl: function () {
|
|
19
|
+ for(var k in params)
|
|
20
|
+ {
|
|
21
|
+ if(typeof k !== "string" || k.indexOf("config.") === -1)
|
|
22
|
+ continue;
|
|
23
|
+
|
|
24
|
+ var v = params[k];
|
|
25
|
+ var confKey = k.substr(7);
|
|
26
|
+ if(config[confKey] && typeof config[confKey] !== typeof v)
|
|
27
|
+ {
|
|
28
|
+ console.warn("The type of " + k +
|
|
29
|
+ " is wrong. That parameter won't be updated in config.js.");
|
|
30
|
+ continue;
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ config[confKey] = v;
|
|
34
|
+
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ }
|
|
38
|
+};
|
|
39
|
+
|
|
40
|
+module.exports = URLProcessor;
|