-
Notifications
You must be signed in to change notification settings - Fork 25
/
iframe.js
57 lines (51 loc) · 1.29 KB
/
iframe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function loadConfig (configStr) {
var config = {};
configStr = configStr.replace(/^[\?#]/,'').split('&');
for (var i = 0; i < configStr.length; ++ i) {
var varStr = configStr[i];
var pos = varStr.search("=");
var key, value;
if (pos < 0) {
key = decodeURIComponent(varStr);
value = undefined;
}
else {
key = decodeURIComponent(varStr.slice(0,pos));
value = decodeURIComponent(varStr.slice(pos+1));
}
key = key.split('.');
var ctx = config;
var j = 0;
for (var m = key.length - 1; j < m; ++ j) {
var k = key[j];
if (k in ctx) {
ctx = ctx[k];
}
else {
ctx = ctx[k] = {};
}
}
ctx[key[j]] = value;
}
BrowserPonies.loadConfig(config);
if ('action' in config) {
BrowserPonies[config.action]();
}
if ('paddock' in config) {
BrowserPonies.Util.$('paddock-back').style.display = config.paddock.trim().toLowerCase() === "true" ?
'' : 'none';
}
if ('grass' in config && config.grass.trim().toLowerCase() === "true") {
document.body.style.background = 'url("grass.png")';
}
}
if (!BrowserPoniesBaseConfig.loaded) {
BrowserPonies.loadConfig(BrowserPoniesBaseConfig);
BrowserPoniesBaseConfig.loaded = true;
}
window.onhashchange = function () {
loadConfig(window.location.hash);
};
if (!BrowserPonies.running()) {
BrowserPonies.start();
}