first version of URL parameters. l=language, t=theme.
This commit is contained in:
parent
04b8fa02a8
commit
a444094779
1 changed files with 24 additions and 0 deletions
24
js/uhr.js
24
js/uhr.js
|
@ -130,9 +130,33 @@
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
this.currentMinute = -1;
|
this.currentMinute = -1;
|
||||||
var userTime = this.options.time;
|
var userTime = this.options.time;
|
||||||
|
var hash, params;
|
||||||
if (this.options.time === undefined) {
|
if (this.options.time === undefined) {
|
||||||
this.options.time = new Date();
|
this.options.time = new Date();
|
||||||
}
|
}
|
||||||
|
// parse the URL params
|
||||||
|
hash = window.location.hash;
|
||||||
|
if (hash !== undefined && typeof hash === 'string' && hash.charAt(0) === '#') {
|
||||||
|
hash = hash.substring(1);
|
||||||
|
hash = decodeURIComponent(hash);
|
||||||
|
params = hash.split('&');
|
||||||
|
params.forEach(function (element) {
|
||||||
|
var pair = element.split('=');
|
||||||
|
var key = pair[0];
|
||||||
|
var value = pair[1];
|
||||||
|
switch (key) {
|
||||||
|
case 'l':
|
||||||
|
this.options.language = value;
|
||||||
|
this.options.force = true;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
this.options.theme = value;
|
||||||
|
this.options.force = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
// end parse the URL params
|
||||||
setupHTML.bind(this)();
|
setupHTML.bind(this)();
|
||||||
wireFunctionality.bind(this)();
|
wireFunctionality.bind(this)();
|
||||||
if (userTime !== undefined) {
|
if (userTime !== undefined) {
|
||||||
|
|
Loading…
Reference in a new issue