1 From 280c1f8b3c07fde35282cd46d965bc1bc8f5649d Mon Sep 17 00:00:00 2001
2 From: Alexandre Derumier <aderumier@odiso.com>
3 Date: Thu, 25 Jun 2015 02:50:03 +0200
4 Subject: [PATCH] pveui : add promox code
6 Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
8 pveui.js | 724 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
9 1 file changed, 675 insertions(+), 49 deletions(-)
11 diff --git a/pveui.js b/pveui.js
12 index cb5717c..ceaa4fc 100644
15 @@ -39,10 +39,17 @@ var UI;
17 rememberedClipSetting: null,
19 + pveAllowMigratedVMTest: false, // set to true after a succesful conection
20 + pveCommandsOpen: false,
21 + consoletype: undefined,
24 + nodename: undefined,
26 // Setup rfb object, load settings from browser storage, then call
27 // UI.init to setup the UI/menus
28 load: function (callback) {
29 - WebUtil.initSettings(UI.start, callback);
30 + WebUtil.initSettings(UI.pve_start, callback);
33 // Render default UI and initialize settings menu
34 @@ -54,13 +61,13 @@ var UI;
35 var sheets = WebUtil.getStylesheets();
37 for (i = 0; i < sheets.length; i += 1) {
38 - UI.addOption($D('noVNC_stylesheet'),sheets[i].title, sheets[i].title);
39 + //UI.addOption($D('noVNC_stylesheet'),sheets[i].title, sheets[i].title);
42 // Logging selection dropdown
43 var llevels = ['error', 'warn', 'info', 'debug'];
44 for (i = 0; i < llevels.length; i += 1) {
45 - UI.addOption($D('noVNC_logging'),llevels[i], llevels[i]);
46 + //UI.addOption($D('noVNC_logging'),llevels[i], llevels[i]);
49 // Settings with immediate effects
50 @@ -84,20 +91,10 @@ var UI;
54 - /* Populate the controls if defaults are provided in the URL */
55 - UI.initSetting('host', window.location.hostname);
56 - UI.initSetting('port', port);
57 - UI.initSetting('password', '');
58 - UI.initSetting('encrypt', (window.location.protocol === "https:"));
59 - UI.initSetting('true_color', true);
60 - UI.initSetting('cursor', !UI.isTouchDevice);
61 - UI.initSetting('resize', 'off');
62 - UI.initSetting('shared', true);
63 - UI.initSetting('view_only', false);
64 - UI.initSetting('path', 'websockify');
66 UI.initSetting('repeaterID', '');
68 - var autoconnect = WebUtil.getQueryVar('autoconnect', false);
69 + var autoconnect = true;
70 if (autoconnect === 'true' || autoconnect == '1') {
73 @@ -140,7 +137,9 @@ var UI;
74 (document.documentElement.requestFullscreen ||
75 document.documentElement.mozRequestFullScreen ||
76 document.documentElement.webkitRequestFullscreen ||
77 - document.body.msRequestFullscreen)) {
78 + document.body.msRequestFullscreen)
79 + && UI.getSetting('resize') === 'scale'
81 $D('fullscreenButton').style.display = "inline";
82 Util.addEvent(window, 'fullscreenchange', UI.updateFullscreenButton);
83 Util.addEvent(window, 'mozfullscreenchange', UI.updateFullscreenButton);
84 @@ -177,13 +176,16 @@ var UI;
86 initRFB: function () {
88 + var scaleType = UI.getSetting('resize');
90 UI.rfb = new RFB({'target': $D('noVNC_canvas'),
91 'onUpdateState': UI.updateState,
92 'onXvpInit': UI.updateXvpVisualState,
93 'onClipboard': UI.clipReceive,
94 'onFBUComplete': UI.FBUComplete,
95 - 'onFBResize': UI.updateViewDrag,
96 - 'onDesktopName': UI.updateDocumentTitle});
97 + 'onFBResize': (typeof scaleType !== 'undefined') ? UI.updateFBSize : UI.updateViewDrag
98 + // 'onDesktopName': UI.updateDocumentTitle
102 UI.updateState(null, 'fatal', null, 'Unable to create RFB client -- ' + exc);
103 @@ -211,31 +213,34 @@ var UI;
104 $D("sendEscButton").onclick = UI.sendEsc;
106 $D("sendCtrlAltDelButton").onclick = UI.sendCtrlAltDel;
107 - $D("xvpShutdownButton").onclick = UI.xvpShutdown;
108 - $D("xvpRebootButton").onclick = UI.xvpReboot;
109 - $D("xvpResetButton").onclick = UI.xvpReset;
110 - $D("noVNC_status").onclick = UI.togglePopupStatus;
111 + //$D("xvpShutdownButton").onclick = UI.xvpShutdown;
112 + //$D("xvpRebootButton").onclick = UI.xvpReboot;
113 + //$D("xvpResetButton").onclick = UI.xvpReset;
114 + //$D("noVNC_status").onclick = UI.togglePopupStatus;
115 $D("noVNC_popup_status").onclick = UI.togglePopupStatus;
116 - $D("xvpButton").onclick = UI.toggleXvpPanel;
117 + //$D("xvpButton").onclick = UI.toggleXvpPanel;
118 $D("clipboardButton").onclick = UI.toggleClipboardPanel;
119 $D("fullscreenButton").onclick = UI.toggleFullscreen;
120 - $D("settingsButton").onclick = UI.toggleSettingsPanel;
121 - $D("connectButton").onclick = UI.toggleConnectPanel;
122 - $D("disconnectButton").onclick = UI.disconnect;
123 - $D("descriptionButton").onclick = UI.toggleConnectPanel;
124 + //$D("settingsButton").onclick = UI.toggleSettingsPanel;
125 + //$D("connectButton").onclick = UI.toggleConnectPanel;
126 + //$D("disconnectButton").onclick = UI.disconnect;
127 + //$D("descriptionButton").onclick = UI.toggleConnectPanel;
129 $D("noVNC_clipboard_text").onfocus = UI.displayBlur;
130 $D("noVNC_clipboard_text").onblur = UI.displayFocus;
131 $D("noVNC_clipboard_text").onchange = UI.clipSend;
132 $D("noVNC_clipboard_clear_button").onclick = UI.clipClear;
134 - $D("noVNC_settings_menu").onmouseover = UI.displayBlur;
135 - $D("noVNC_settings_menu").onmouseover = UI.displayFocus;
136 - $D("noVNC_apply").onclick = UI.settingsApply;
137 + //$D("noVNC_settings_menu").onmouseover = UI.displayBlur;
138 + //$D("noVNC_settings_menu").onmouseover = UI.displayFocus;
139 + //$D("noVNC_apply").onclick = UI.settingsApply;
141 - $D("noVNC_connect_button").onclick = UI.connect;
142 + //$D("noVNC_connect_button").onclick = UI.connect;
144 $D("noVNC_resize").onchange = UI.enableDisableViewClip;
146 + $D("pveCommandsButton").onclick = UI.togglePVECommandPanel;
147 + $D("showSendKeysButton").onclick = UI.togglePVESendKeysPanel;
150 onresize: function (callback) {
151 @@ -398,6 +403,9 @@ var UI;
152 toggleXvpPanel: function() {
153 // Close the description panel
154 $D('noVNC_description').style.display = "none";
155 + if (UI.pveCommandsOpen === true) {
156 + UI.togglePVECommandPanel();
158 // Close settings if open
159 if (UI.settingsOpen === true) {
161 @@ -413,12 +421,12 @@ var UI;
164 if (UI.xvpOpen === true) {
165 - $D('noVNC_xvp').style.display = "none";
166 - $D('xvpButton').className = "noVNC_status_button";
167 + //$D('noVNC_xvp').style.display = "none";
168 + //$D('xvpButton').className = "noVNC_status_button";
171 - $D('noVNC_xvp').style.display = "block";
172 - $D('xvpButton').className = "noVNC_status_button_selected";
173 + //$D('noVNC_xvp').style.display = "block";
174 + //$D('xvpButton').className = "noVNC_status_button_selected";
178 @@ -427,6 +435,12 @@ var UI;
179 toggleClipboardPanel: function() {
180 // Close the description panel
181 $D('noVNC_description').style.display = "none";
182 + if (UI.pveCommandsOpen === true) {
183 + UI.togglePVECommandPanel();
185 + if (UI.sendKeysVisible === true) {
186 + UI.togglePVESendKeysPanel();
188 // Close settings if open
189 if (UI.settingsOpen === true) {
191 @@ -497,6 +511,9 @@ var UI;
192 toggleConnectPanel: function() {
193 // Close the description panel
194 $D('noVNC_description').style.display = "none";
195 + if (UI.pveCommandsOpen === true) {
196 + UI.togglePVECommandPanel();
198 // Close connection settings if open
199 if (UI.settingsOpen === true) {
201 @@ -515,14 +532,14 @@ var UI;
202 // Toggle Connection Panel
203 if (UI.connSettingsOpen === true) {
204 $D('noVNC_controls').style.display = "none";
205 - $D('connectButton').className = "noVNC_status_button";
206 + //$D('connectButton').className = "noVNC_status_button";
207 UI.connSettingsOpen = false;
208 UI.saveSetting('host');
209 UI.saveSetting('port');
210 //UI.saveSetting('password');
212 $D('noVNC_controls').style.display = "block";
213 - $D('connectButton').className = "noVNC_status_button_selected";
214 + //$D('connectButton').className = "noVNC_status_button_selected";
215 UI.connSettingsOpen = true;
216 $D('noVNC_host').focus();
218 @@ -576,14 +593,14 @@ var UI;
221 $D('noVNC_settings').style.display = "block";
222 - $D('settingsButton').className = "noVNC_status_button_selected";
223 + //$D('settingsButton').className = "noVNC_status_button_selected";
224 UI.settingsOpen = true;
227 // Close menu (without applying settings)
228 closeSettingsMenu: function() {
229 $D('noVNC_settings').style.display = "none";
230 - $D('settingsButton').className = "noVNC_status_button";
231 + //$D('settingsButton').className = "noVNC_status_button";
232 UI.settingsOpen = false;
235 @@ -676,10 +693,15 @@ var UI;
238 klass = "noVNC_status_normal";
239 + UI.pveAllowMigratedVMTest = true;
242 $D('noVNC_logo').style.display = "block";
243 $D('noVNC_container').style.display = "none";
244 + if (UI.pveAllowMigratedVMTest) {
245 + UI.pveAllowMigratedVMTest = false;
246 + UI.pve_detect_migrated_vm();
250 klass = "noVNC_status_normal";
251 @@ -730,7 +752,7 @@ var UI;
254 UI.setMouseButton(1);
255 - $D('clipboardButton').style.display = "inline";
256 + $D('clipboardButton').style.display = (UI.consoletype !== 'kvm') ? "inline" : "none";
257 $D('showKeyboard').style.display = "inline";
258 $D('noVNC_extra_keys').style.display = "";
259 $D('sendCtrlAltDelButton').style.display = "inline";
260 @@ -751,18 +773,18 @@ var UI;
264 - $D('connectButton').style.display = "";
265 - $D('disconnectButton').style.display = "none";
266 + //$D('connectButton').style.display = "";
267 + //$D('disconnectButton').style.display = "none";
268 UI.connSettingsOpen = false;
269 UI.toggleConnectPanel();
272 - $D('connectButton').style.display = "";
273 - $D('disconnectButton').style.display = "none";
274 + //$D('connectButton').style.display = "";
275 + //$D('disconnectButton').style.display = "none";
278 - $D('connectButton').style.display = "none";
279 - $D('disconnectButton').style.display = "";
280 + //$D('connectButton').style.display = "none";
281 + //$D('disconnectButton').style.display = "";
285 @@ -772,9 +794,9 @@ var UI;
286 // Disable/enable XVP button
287 updateXvpVisualState: function(ver) {
289 - $D('xvpButton').style.display = 'inline';
290 + //$D('xvpButton').style.display = 'inline';
292 - $D('xvpButton').style.display = 'none';
293 + //$D('xvpButton').style.display = 'none';
294 // Close XVP panel if open
295 if (UI.xvpOpen === true) {
297 @@ -1200,7 +1222,611 @@ var UI;
299 var vncwidth = $D('noVNC_screen').style.offsetWidth;
300 $D('noVNC-control-bar').style.width = vncwidth + 'px';
303 + // Proxmox VE related code
305 + urlEncode: function(object) {
306 + var i,value, params = [];
308 + for (i in object) {
309 + if (object.hasOwnProperty(i)) {
311 + if (value === undefined) value = '';
312 + params.push(encodeURIComponent(i) + '=' + encodeURIComponent(String(value)));
316 + return params.join('&');
319 + API2Request: function(reqOpts) {
321 + reqOpts.method = reqOpts.method || 'GET';
323 + var xhr = new XMLHttpRequest();
325 + xhr.onload = function() {
326 + var scope = reqOpts.scope || this;
330 + if (xhr.readyState === 4) {
331 + var ctype = xhr.getResponseHeader('Content-Type');
332 + if (xhr.status === 200) {
333 + if (ctype.match(/application\/json;/)) {
334 + result = JSON.parse(xhr.responseText);
336 + errmsg = 'got unexpected content type ' + ctype;
339 + errmsg = 'Error ' + xhr.status + ': ' + xhr.statusText;
342 + errmsg = 'Connection error - server offline?';
345 + if (errmsg !== undefined) {
346 + if (reqOpts.failure) {
347 + reqOpts.failure.call(scope, errmsg);
350 + if (reqOpts.success) {
351 + reqOpts.success.call(scope, result);
354 + if (reqOpts.callback) {
355 + reqOpts.callback.call(scope, errmsg === undefined);
359 + var data = UI.urlEncode(reqOpts.params || {});
361 + if (reqOpts.method === 'GET') {
362 + xhr.open(reqOpts.method, "/api2/json" + reqOpts.url + '?' + data);
364 + xhr.open(reqOpts.method, "/api2/json" + reqOpts.url);
366 + xhr.setRequestHeader('Cache-Control', 'no-cache');
367 + if (reqOpts.method === 'POST' || reqOpts.method === 'PUT') {
368 + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
369 + xhr.setRequestHeader('CSRFPreventionToken', PVE.CSRFPreventionToken);
371 + } else if (reqOpts.method === 'GET') {
374 + throw "unknown method";
380 + // show msg for 5 seconds
381 + pve_show_msg: function(klass, msg, permanant) {
382 + var oldklass = $D('noVNC-control-bar').getAttribute("class");
383 + $D('noVNC-control-bar').setAttribute("class", klass);
384 + var oldmsg = $D('noVNC_status').innerHTML;
385 + $D('noVNC_status').innerHTML = msg;
386 + if (typeof permanent !== 'undefined' && permanent) return;
388 + setTimeout(function() {
389 + var curmsg = $D('noVNC_status').innerHTML;
390 + if (curmsg === msg) {
391 + $D('noVNC_status').innerHTML = oldmsg;
393 + var curklass = $D('noVNC-control-bar').getAttribute("class");
394 + if (curklass === klass) {
395 + $D('noVNC-control-bar').setAttribute("class", oldklass);
400 + pve_detect_migrated_vm: function() {
401 + if (!(UI.consoletype === 'kvm' || UI.consoletype === 'lxc')) {
405 + // try to detect migrated VM
407 + url: '/cluster/resources',
409 + success: function(result) {
410 + var list = result.data;
411 + list.every(function(item) {
412 + if ((item.type === 'qemu' || item.type === 'lxc') &&
413 + (item.vmid == UI.vmid)) {
414 + var url = "?" + UI.urlEncode({
415 + console: UI.consoletype,
422 + location.href = url;
423 + return false; // break
431 + pve_vm_command: function(cmd, params, reload) {
434 + if (UI.consoletype === 'kvm') {
435 + baseUrl = '/nodes/' + UI.nodename + '/qemu/' + UI.vmid;
436 + } else if (UI.consoletype === 'lxc') {
437 + baseUrl = '/nodes/' + UI.nodename + '/lxc/' + UI.vmid;
439 + throw "unknown VM type";
444 + url: baseUrl + "/status/" + cmd,
446 + failure: function(msg) {
447 + UI.pve_show_msg('noVNC_status_warn', msg);
449 + success: function() {
450 + UI.pve_show_msg('noVNC_status_normall', "VM command '" + cmd +"' successful");
452 + setTimeout(function() {
460 + pveCmdStart: function() {
461 + if (UI.pveCommandsOpen === true) {
462 + UI.togglePVECommandPanel();
464 + UI.pve_vm_command('start', {}, true);
467 + pveCmdShutdown: function() {
468 + if (UI.pveCommandsOpen === true) {
469 + UI.togglePVECommandPanel();
471 + var msg = gettext("Do you really want to shutdown VM {0}?");
472 + msg = msg.replace(/\{0\}/, UI.vmid);
474 + if (confirm(msg) === true) {
475 + UI.pve_vm_command('shutdown');
479 + pveCmdStop: function() {
480 + if (UI.pveCommandsOpen === true) {
481 + UI.togglePVECommandPanel();
484 + var msg = gettext("Do you really want to stop VM {0}?");
485 + msg = msg.replace(/\{0\}/, UI.vmid);
487 + if (confirm(msg) === true) {
488 + UI.pve_vm_command('stop');
492 + pveCmdReset: function() {
493 + if (UI.pveCommandsOpen === true) {
494 + UI.togglePVECommandPanel();
496 + var msg = gettext("Do you really want to reset VM {0}?");
497 + msg = msg.replace(/\{0\}/, UI.vmid);
499 + if (confirm(msg) === true) {
500 + UI.pve_vm_command('reset');
504 + pveCmdSuspend: function() {
505 + if (UI.pveCommandsOpen === true) {
506 + UI.togglePVECommandPanel();
508 + var msg = gettext("Do you really want to suspend VM {0}?");
509 + msg = msg.replace(/\{0\}/, UI.vmid);
511 + if (confirm(msg) === true) {
512 + UI.pve_vm_command('suspend');
516 + pveCmdResume: function() {
517 + if (UI.pveCommandsOpen === true) {
518 + UI.togglePVECommandPanel();
520 + UI.pve_vm_command('resume');
523 + pveCmdReload: function() {
524 + if (UI.pveCommandsOpen === true) {
525 + UI.togglePVECommandPanel();
530 + pveReload: function() {
534 + pve_send_key: function(keyname) {
537 + if (UI.consoletype === 'kvm') {
538 + baseUrl = '/nodes/' + UI.nodename + '/qemu/' + UI.vmid;
540 + throw "send key not implemented";
544 + params: { key: keyname },
545 + url: baseUrl + '/sendkey',
547 + failure: function(msg) {
548 + UI.pve_show_msg('noVNC_status_warn', msg);
553 + pve_start: function(callback) {
554 + UI.consoletype = WebUtil.getQueryVar('console');
555 + UI.vmid = WebUtil.getQueryVar('vmid');
556 + UI.vmname = WebUtil.getQueryVar('vmname');
557 + UI.nodename = WebUtil.getQueryVar('node');
558 + UI.resize = WebUtil.getQueryVar('resize');
562 + var params = { websocket: 1 };
565 + // add pve command buttons
566 + var cmdpanel = $D('noVNC_pve_command_menu');
569 + text: gettext('Start'),
570 + handler: UI.pveCmdStart,
571 + enable: { kvm: 1, lxc: 1 }
574 + text: gettext('Shutdown'),
575 + handler: UI.pveCmdShutdown,
576 + enable: { kvm: 1, lxc: 1 }
579 + text: gettext('Stop'),
580 + handler: UI.pveCmdStop,
581 + enable: { kvm: 1, lxc: 1 }
584 + text: gettext('Reset'),
585 + handler: UI.pveCmdReset,
589 + text: gettext('Suspend'),
590 + handler: UI.pveCmdSuspend,
594 + text: gettext('Resume'),
595 + handler: UI.pveCmdResume,
599 + text: gettext('Reload'),
600 + handler: UI.pveCmdReload,
604 + buttonlist.forEach(function(btn) {
605 + if (btn.enable.any || btn.enable[UI.consoletype]) {
606 + var el = document.createElement('input');
607 + el.setAttribute('type', 'button');
608 + el.setAttribute('value', btn.text);
609 + el.onclick = btn.handler;
610 + el.style.display = "block";
611 + el.style.width = "100%";
612 + el.style.minWidth = "150px";
613 + cmdpanel.appendChild(el);
617 + // add sendKeys buttons
618 + var skpanel = $D('noVNC_send_keys_panel');
622 + text: 'Tab', handler: function() {
623 + UI.pve_send_key('tab');
627 + text: 'Ctrl-Alt-Delete', handler: function() {
628 + UI.pve_send_key('ctrl-alt-delete');
632 + text: 'Ctrl-Alt-Backspace', handler: function() {
633 + UI.pve_send_key('ctrl-alt-backspace');
637 + text: 'Ctrl-Alt-F1', handler: function() {
638 + UI.pve_send_key('ctrl-alt-f1');
642 + text: 'Ctrl-Alt-F2', handler: function() {
643 + UI.pve_send_key('ctrl-alt-f2');
647 + text: 'Ctrl-Alt-F3', handler: function() {
648 + UI.pve_send_key('ctrl-alt-f3');
652 + text: 'Ctrl-Alt-F4', handler: function() {
653 + UI.pve_send_key('ctrl-alt-f4');
657 + text: 'Ctrl-Alt-F5', handler: function() {
658 + UI.pve_send_key('ctrl-alt-f5');
662 + text: 'Ctrl-Alt-F6', handler: function() {
663 + UI.pve_send_key('ctrl-alt-f6');
667 + text: 'Ctrl-Alt-F7', handler: function() {
668 + UI.pve_send_key('ctrl-alt-f7');
672 + text: 'Ctrl-Alt-F8', handler: function() {
673 + UI.pve_send_key('ctrl-alt-f8');
677 + text: 'Ctrl-Alt-F9', handler: function() {
678 + UI.pve_send_key('ctrl-alt-f9');
682 + text: 'Ctrl-Alt-F10', handler: function() {
683 + UI.pve_send_key('ctrl-alt-f10');
687 + text: 'Ctrl-Alt-F11', handler: function() {
688 + UI.pve_send_key('ctrl-alt-f11');
692 + text: 'Ctrl-Alt-F12', handler: function() {
693 + UI.pve_send_key('ctrl-alt-f12');
698 + buttonlist.forEach(function(btn) {
699 + var el = document.createElement('input');
700 + el.setAttribute('type', 'button');
701 + el.setAttribute('value', btn.text);
702 + el.onclick = function(handler) {
703 + return function() {
704 + if (UI.sendKeysVisible === true) {
705 + UI.togglePVESendKeysPanel();
708 + handler.call(this);
711 + el.style.display = "block";
712 + el.style.width = "100%";
713 + el.style.minWidth = "150px";
714 + skpanel.appendChild(el);
719 + if (UI.consoletype === 'kvm') {
720 + var baseUrl = '/nodes/' + UI.nodename + '/qemu/' + UI.vmid;
721 + url = baseUrl + '/vncproxy';
722 + wsurl = baseUrl + '/vncwebsocket';
723 + title = "VM " + UI.vmid;
725 + title += " ('" + UI.vmname + "')";
727 + } else if (UI.consoletype === 'lxc') {
728 + var baseUrl = '/nodes/' + UI.nodename + '/lxc/' + UI.vmid;
729 + url = baseUrl + '/vncproxy';
730 + wsurl = baseUrl + '/vncwebsocket';
731 + title = "CT " + UI.vmid;
733 + title += " ('" + UI.vmname + "')";
735 + } else if (UI.consoletype === 'shell') {
736 + var baseUrl = '/nodes/' + UI.nodename;
737 + url = baseUrl + '/vncshell';
738 + wsurl = baseUrl + '/vncwebsocket';
739 + title = "node '" + UI.nodename + "'";
740 + } else if (UI.consoletype === 'upgrade') {
741 + var baseUrl = '/nodes/' + UI.nodename;
742 + url = baseUrl + '/vncshell';
743 + wsurl = baseUrl + '/vncwebsocket';
744 + params.upgrade = 1;
745 + title = gettext('System upgrade on node {0}');
746 + title = title.replace(/\{0\}/, UI.nodename);
748 + throw "implement me";
751 + document.title = title;
753 + var start_vnc_viewer = function(param) {
754 + var wsparams = UI.urlEncode({
756 + vncticket: param.ticket
759 + UI.updateSetting('host', window.location.hostname);
760 + UI.updateSetting('port', window.location.port || 443);
761 + UI.updateSetting('password', param.ticket);
762 + UI.updateSetting('encrypt', true);
763 + UI.updateSetting('true_color', true);
764 + UI.updateSetting('cursor', !UI.isTouchDevice);
765 + UI.updateSetting('shared', true);
766 + UI.updateSetting('view_only', false);
767 + UI.updateSetting('resize', UI.resize);
769 + UI.updateSetting('path', 'api2/json' + wsurl + "?" + wsparams);
771 + UI.start(callback);
778 + success: function(result) {
779 + start_vnc_viewer(result.data);
781 + failure: function(msg) {
782 + UI.pve_show_msg('noVNC_status_error', msg, 1);
787 + lastFBWidth: undefined,
788 + lastFBHeight: undefined,
789 + sizeUpdateTimer: undefined,
791 + updateFBSize: function(rfb, width, height) {
793 + // Note1: CSS Canvas size is wrong by a few pixels in Chrome
794 + // Note2: window size must be even number for firefox
795 + UI.lastFBWidth = Math.floor((width + 1)/2)*2;;
796 + UI.lastFBHeight = Math.floor((height + 1)/2)*2;
798 + if (UI.sizeUpdateTimer !== undefined) {
799 + clearInterval(UI.sizeUpdateTimer);
801 + if (UI.getSetting('clip')) return;
803 + var update_size = function() {
807 + if (window.innerHeight) {
808 + oh = window.innerHeight;
809 + ow = window.innerWidth;
810 + } else if (document.documentElement &&
811 + document.documentElement.clientHeight) {
812 + oh = document.documentElement.clientHeight;
813 + ow = document.documentElement.clientWidth;
814 + } else if (document.body) {
815 + oh = document.body.clientHeight;
816 + ow = document.body.clientWidth;
818 + throw "can't get window size";
821 + // see base.css/noVNC_screen_pad
822 + var toolbar_height = 36;
824 + var offsetw = UI.lastFBWidth - ow;
825 + var offseth = UI.lastFBHeight + toolbar_height - oh;
826 + if (offsetw !== 0 || offseth !== 0) {
827 + //console.log("try resize by " + offsetw + " " + offseth);
828 + window.resizeBy(offsetw, offseth);
833 + UI.sizeUpdateTimer = setInterval(update_size, 1000);
839 + // Open/close PVE commandand menu
840 + togglePVECommandPanel: function() {
841 + // Close the description panel
842 + $D('noVNC_description').style.display = "none";
843 + if (UI.sendKeysVisible === true) {
844 + UI.togglePVESendKeysPanel();
846 + // Close clipboard panel if open
847 + if (UI.clipboardOpen === true) {
848 + UI.toggleClipboardPanel();
850 + // Close connection settings if open
851 + if (UI.connSettingsOpen === true) {
852 + UI.toggleConnectPanel();
854 + // Close popup status panel if open
855 + if (UI.popupStatusOpen === true) {
856 + UI.togglePopupStatusPanel();
858 + // Close XVP panel if open
859 + if (UI.xvpOpen === true) {
860 + UI.toggleXvpPanel();
862 + if (UI.pveCommandsOpen) {
863 + $D('noVNC_pve_commands').style.display = "none";
864 + $D('pveCommandsButton').className = "noVNC_status_button";
865 + UI.pveCommandsOpen = false;
867 + $D('noVNC_pve_commands').style.display = "block";
868 + $D('pveCommandsButton').className = "noVNC_status_button_selected";
869 + UI.pveCommandsOpen = true;
873 + // Open/close PVE SendKeys menu
874 + togglePVESendKeysPanel: function() {
875 + // Close the description panel
876 + $D('noVNC_description').style.display = "none";
877 + if (UI.pveCommandsOpen === true) {
878 + UI.togglePVECommandPanel();
880 + // Close clipboard panel if open
881 + if (UI.clipboardOpen === true) {
882 + UI.toggleClipboardPanel();
884 + // Close connection settings if open
885 + if (UI.connSettingsOpen === true) {
886 + UI.toggleConnectPanel();
888 + // Close popup status panel if open
889 + if (UI.popupStatusOpen === true) {
890 + UI.togglePopupStatusPanel();
892 + // Close XVP panel if open
893 + if (UI.xvpOpen === true) {
894 + UI.toggleXvpPanel();
896 + if (UI.sendKeysVisible) {
897 + $D('noVNC_send_keys').style.display = "none";
898 + $D('showSendKeysButton').className = "noVNC_status_button";
899 + UI.sendKeysVisible = false;
901 + $D('noVNC_send_keys').style.display = "block";
902 + $D('showSendKeysButton').className = "noVNC_status_button_selected";
903 + UI.sendKeysVisible = true;