Query string cleanup and move it to util.js
This commit is contained in:
@@ -126,12 +126,6 @@ load: function(target) {
|
||||
};
|
||||
},
|
||||
|
||||
// Read a query string variable
|
||||
getQueryVar: function(name) {
|
||||
var re = new RegExp('[?].*' + name + '=([^&#]*)');
|
||||
return (document.location.href.match(re) || ['',null])[1];
|
||||
},
|
||||
|
||||
// Read form control compatible setting from cookie
|
||||
getSetting: function(name) {
|
||||
var val, ctrl = $('VNC_' + name);
|
||||
@@ -188,14 +182,14 @@ saveSetting: function(name) {
|
||||
|
||||
// Initial page load read/initialization of settings
|
||||
initSetting: function(name, defVal) {
|
||||
var val, DC = DefaultControls;
|
||||
var val;
|
||||
|
||||
// Check Query string followed by cookie
|
||||
val = DC.getQueryVar(name);
|
||||
val = Util.getQueryVar(name);
|
||||
if (val === null) {
|
||||
val = Util.readCookie(name, defVal);
|
||||
}
|
||||
DC.updateSetting(name, val);
|
||||
DefaultControls.updateSetting(name, val);
|
||||
Util.Debug("Setting '" + name + "' initialized to '" + val + "'");
|
||||
return val;
|
||||
},
|
||||
@@ -206,7 +200,7 @@ initSetting: function(name, defVal) {
|
||||
// On close, settings are applied
|
||||
clickSettingsMenu: function() {
|
||||
var DC = DefaultControls;
|
||||
if (DefaultControls.settingsOpen) {
|
||||
if (DC.settingsOpen) {
|
||||
DC.settingsApply();
|
||||
|
||||
DC.closeSettingsMenu();
|
||||
|
||||
@@ -160,6 +160,14 @@ Util.dirObj = function (obj, depth, parent) {
|
||||
return msg;
|
||||
};
|
||||
|
||||
// Read a query string variable
|
||||
Util.getQueryVar = function(name, defVal) {
|
||||
var re = new RegExp('[?][^#]*' + name + '=([^&#]*)');
|
||||
if (typeof defVal === 'undefined') { defVal = null; }
|
||||
return (document.location.href.match(re) || ['',defVal])[1];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Cross-browser routines
|
||||
*/
|
||||
@@ -264,6 +272,7 @@ Util.Flash = (function(){
|
||||
/*
|
||||
* Cookie handling. Dervied from: http://www.quirksmode.org/js/cookies.html
|
||||
*/
|
||||
|
||||
// No days means only for this browser session
|
||||
Util.createCookie = function(name,value,days) {
|
||||
var date, expires;
|
||||
|
||||
Reference in New Issue
Block a user