Skip to content

Instantly share code, notes, and snippets.

@weiland
Created September 8, 2014 12:10
Show Gist options
  • Select an option

  • Save weiland/b58dc5ab7de5a013a3f7 to your computer and use it in GitHub Desktop.

Select an option

Save weiland/b58dc5ab7de5a013a3f7 to your computer and use it in GitHub Desktop.
Chayns Debugger
(function (Chayns, window, undefined) {
'use strict';
var lh = window.location.href;
function chooseOS(c) {
var osList = [
new Chayns.SelectOption('Normal', '', false),
new Chayns.SelectOption('Webshadow', 'webshadow', false),
new Chayns.SelectOption('Webshadow mobile', 'webshadowmobile', false)
];
Chayns.Select(osList, false, function (os) {
if(os === null) {
return;
}
if(lh.indexOf('?') === -1) {
lh = lh + '?os=' + os;
} else if(lh.indexOf('os=') !== -1) {
lh = lh.replace(/os=(.*)/i, 'os=' + os);
} else {
lh = lh + '&os=' + os;
}
window.location.href = lh;
});
}
function reload(appendTime) {
if(typeof appendTime !== 'undefined' && appendTime) {
lh = lh + (lh.indexOf('?') === -1 ? '?' : '&') + 't=' + (new Date()).getTime();
}
window.location.href = lh;
}
function back() {
window.history.back();
}
Chayns.debugger = {
chooseOS: chooseOS,
refresh: reload.bind(null, true),
reload: reload,
back: back
};
})(Chayns, window);
Chayns.debugger.chooseOS(); // PROFIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment