mirror of
https://github.com/novnc/noVNC.git
synced 2026-06-06 12:29:38 +00:00
Merge pull request #547 from pigshell/hashargs
Add hash fragment as an optional method to supply config variables. Closes #544
This commit is contained in:
@@ -97,7 +97,7 @@ var UI;
|
||||
UI.initSetting('path', 'websockify');
|
||||
UI.initSetting('repeaterID', '');
|
||||
|
||||
var autoconnect = WebUtil.getQueryVar('autoconnect', false);
|
||||
var autoconnect = WebUtil.getConfigVar('autoconnect', false);
|
||||
if (autoconnect === 'true' || autoconnect == '1') {
|
||||
autoconnect = true;
|
||||
UI.connect();
|
||||
@@ -355,7 +355,7 @@ var UI;
|
||||
// Initial page load read/initialization of settings
|
||||
initSetting: function(name, defVal) {
|
||||
// Check Query string followed by cookie
|
||||
var val = WebUtil.getQueryVar(name);
|
||||
var val = WebUtil.getConfigVar(name);
|
||||
if (val === null) {
|
||||
val = WebUtil.readSetting(name, defVal);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,29 @@ WebUtil.getQueryVar = function (name, defVal) {
|
||||
}
|
||||
};
|
||||
|
||||
// Read a hash fragment variable
|
||||
WebUtil.getHashVar = function (name, defVal) {
|
||||
"use strict";
|
||||
var re = new RegExp('.*[&#]' + name + '=([^&]*)'),
|
||||
match = document.location.hash.match(re);
|
||||
if (typeof defVal === 'undefined') { defVal = null; }
|
||||
if (match) {
|
||||
return decodeURIComponent(match[1]);
|
||||
} else {
|
||||
return defVal;
|
||||
}
|
||||
};
|
||||
|
||||
// Read a variable from the fragment or the query string
|
||||
// Fragment takes precedence
|
||||
WebUtil.getConfigVar = function (name, defVal) {
|
||||
"use strict";
|
||||
var val = WebUtil.getHashVar(name);
|
||||
if (val === null) {
|
||||
val = WebUtil.getQueryVar(name, defVal);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
/*
|
||||
* Cookie handling. Dervied from: http://www.quirksmode.org/js/cookies.html
|
||||
|
||||
Reference in New Issue
Block a user