From 26945049be6de118520c951ca09cd413634d1bd1 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Fri, 14 Sep 2012 16:27:35 -0500 Subject: [PATCH] vnc.html, ui.js: move all Javascript to ui.js. Move all the inline Javascript event handlers from vnc.html to include/ui.js except the load handler which is moved to include/start.js). This is on the path towards a Chrome extension/packaged app since inline Javascript is prohibited in that situation. --- include/start.js | 1 + include/ui.js | 33 ++++++++++++++++++++++++++ vnc.html | 60 +++++++++++++++++------------------------------- 3 files changed, 55 insertions(+), 39 deletions(-) create mode 100644 include/start.js diff --git a/include/start.js b/include/start.js new file mode 100644 index 00000000..b5d90b4c --- /dev/null +++ b/include/start.js @@ -0,0 +1 @@ +window.onload = UI.load; diff --git a/include/ui.js b/include/ui.js index a2f91e70..aed1df02 100644 --- a/include/ui.js +++ b/include/ui.js @@ -118,11 +118,44 @@ start: function(callback) { UI.toggleConnectPanel(); } + // Add mouse event click/focus/blur event handlers to the UI + UI.addMouseHandlers(); + if (typeof callback === "function") { callback(UI.rfb); } }, +addMouseHandlers: function() { + // Setup interface handlers that can't be inline + $D("noVNC_view_drag_button").onclick = UI.setViewDrag; + $D("noVNC_mouse_button0").onclick = function () { UI.setMouseButton(1); }; + $D("noVNC_mouse_button1").onclick = function () { UI.setMouseButton(2); }; + $D("noVNC_mouse_button2").onclick = function () { UI.setMouseButton(4); }; + $D("noVNC_mouse_button4").onclick = function () { UI.setMouseButton(0); }; + $D("showKeyboard").onclick = UI.showKeyboard; + //$D("keyboardinput").onkeydown = function (event) { onKeyDown(event); }; + $D("keyboardinput").onblur = UI.keyInputBlur; + + $D("sendCtrlAltDelButton").onclick = UI.sendCtrlAltDel; + $D("clipboardButton").onclick = UI.toggleClipboardPanel; + $D("settingsButton").onclick = UI.toggleSettingsPanel; + $D("connectButton").onclick = UI.toggleConnectPanel; + $D("disconnectButton").onclick = UI.disconnect; + $D("descriptionButton").onclick = UI.toggleConnectPanel; + + $D("noVNC_clipboard_text").onfocus = UI.displayBlur; + $D("noVNC_clipboard_text").onblur = UI.displayFocus; + $D("noVNC_clipboard_text").onchange = UI.clipSend; + $D("noVNC_clipboard_clear_button").onclick = UI.clipClear; + + $D("noVNC_settings_menu").onmouseover = UI.displayBlur; + $D("noVNC_settings_menu").onmouseover = UI.displayFocus; + $D("noVNC_apply").onclick = UI.settingsApply; + + $D("noVNC_connect_button").onclick = UI.connect; +}, + // Read form control compatible setting from cookie getSetting: function(name) { var val, ctrl = $D('noVNC_' + name); diff --git a/vnc.html b/vnc.html index 1b886a43..a0715128 100644 --- a/vnc.html +++ b/vnc.html @@ -41,38 +41,34 @@ +
+
+ title="Move/Drag Viewport">
+ id="noVNC_mouse_button0" class="noVNC_status_button"> + id="noVNC_mouse_button1" class="noVNC_status_button"> + id="noVNC_mouse_button2" class="noVNC_status_button"> + id="noVNC_mouse_button4" class="noVNC_status_button"> + value="Keyboard" title="Show Keyboard"/> + id="keyboardinput" class="noVNC_status_button"/>
@@ -80,24 +76,19 @@
+ title="Send Ctrl-Alt-Del" /> + title="Clipboard" /> + title="Settings" /> + title="Connect" /> + title="Disconnect" />
@@ -113,25 +104,21 @@ and website for more information.
- +
-
+ value="Clear">
- +
  • Encrypt
  • True Color
  • @@ -156,8 +143,7 @@
    -
  • +
@@ -168,7 +154,7 @@
  • -
  • +
  • @@ -192,9 +178,5 @@ - -