]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Add a separate dialog for the password prompt
authorSamuel Mannehed <samuel@cendio.se>
Mon, 29 Aug 2016 12:46:58 +0000 (14:46 +0200)
committerPierre Ossman <ossman@cendio.se>
Fri, 23 Sep 2016 12:39:21 +0000 (14:39 +0200)
The user might be queried for the password during the connect stage
if no password was previously provided. Add a separate dialog for
this rather than abusing the connect dialog.

app/styles/base.css
app/ui.js
vnc.html

index 81c45169e4b77090c1a07723eda1c5ba941b0ab5..96f830bb7b90ebe710df0090474e63a8d97dd403 100644 (file)
@@ -97,6 +97,32 @@ input[type=button]:active, select:active {
   margin-top: 3px;
 }
 
+/* ----------------------------------------
+ * WebKit centering hacks
+ * ----------------------------------------
+ */
+
+.noVNC_center {
+  /*
+   * This is a workaround because webkit misrenders transforms and
+   * uses non-integer coordinates, resulting in blurry content.
+   * Ideally we'd use "top: 50%; transform: translateY(-50%);" on
+   * the objects instead.
+   */
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  position: fixed;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  pointer-events: none;
+}
+.noVNC_center > * {
+  pointer-events: auto;
+}
+
 /* ----------------------------------------
  * Control Bar
  * ----------------------------------------
@@ -367,6 +393,29 @@ input[type=button]:active, select:active {
   content: url("../images/warning.svg") " ";
 }
 
+/* ----------------------------------------
+ * Password Dialog
+ * ----------------------------------------
+ */
+
+#noVNC_password_dlg {
+  transform: translateY(-50px);
+}
+#noVNC_password_dlg.noVNC_open {
+  transform: translateY(0);
+}
+#noVNC_password_dlg ul {
+  list-style: none;
+  margin: 0px;
+  padding: 0px;
+}
+#noVNC_password_dlg li {
+  padding-bottom:8px;
+}
+#noVNC_password_input {
+  width: 150px;
+}
+
 /* ----------------------------------------
  * Main Area
  * ----------------------------------------
index 9689852a5fa283d5b65d63b9daaeebe91205f94e..33e0e997c1e21b94b9cf0f53048468995232c86e 100644 (file)
--- a/app/ui.js
+++ b/app/ui.js
@@ -249,6 +249,9 @@ var UI;
                 .addEventListener('click', UI.disconnect);
             document.getElementById("noVNC_connect_button")
                 .addEventListener('click', UI.connect);
+
+            document.getElementById("noVNC_password_button")
+                .addEventListener('click', UI.setPassword);
         },
 
         addClipboardHandlers: function() {
@@ -323,11 +326,11 @@ var UI;
                         UI.showStatus(msg, 'normal');
                         break;
                     case 'password':
-                        UI.toggleConnectPanel();
-
-                        document.getElementById('noVNC_connect_button').value = "Send Password";
-                        document.getElementById('noVNC_connect_button').onclick = UI.setPassword;
-                        document.getElementById('noVNC_setting_password').focus();
+                        document.getElementById('noVNC_password_dlg')
+                            .classList.add('noVNC_open');
+                        setTimeout(function () {
+                                document.getElementById(('noVNC_password_input').focus());
+                            }, 100);
 
                         UI.showStatus(msg, 'warn');
                         break;
@@ -397,6 +400,10 @@ var UI;
             // It is enabled (toggled) by direct click on the button
             UI.setViewDrag(false);
 
+            // State change also closes the password dialog
+            document.getElementById('noVNC_password_dlg')
+                .classList.remove('noVNC_open');
+
             switch (UI.rfb_state) {
                 case 'fatal':
                 case 'failed':
@@ -827,12 +834,9 @@ var UI;
         },
 
         setPassword: function() {
-            UI.rfb.sendPassword(document.getElementById('noVNC_setting_password').value);
-            //Reset connect button.
-            document.getElementById('noVNC_connect_button').value = "Connect";
-            document.getElementById('noVNC_connect_button').onclick = UI.connect;
-            //Hide connection panel.
-            UI.toggleConnectPanel();
+            UI.rfb.sendPassword(document.getElementById('noVNC_password_input').value);
+            document.getElementById('noVNC_password_dlg')
+                .classList.remove('noVNC_open');
             return false;
         },
 
index a660988b84b6e5ab50c5780f5d62d0849e099929..9c677eec86f77801cf0dcdd73584a1e71dd629a6 100644 (file)
--- a/vnc.html
+++ b/vnc.html
 
     </div> <!-- End of noVNC_control_bar -->
 
+    <!-- Password Dialog -->
+    <div class="noVNC_center">
+    <div id="noVNC_password_dlg" class="noVNC_panel">
+        <ul>
+            <li><label><strong>Password: </strong><input id="noVNC_password_input" type="password" /></label></li>
+            <li><input id="noVNC_password_button" type="button" value="Send Password" class="noVNC_submit" /></li>
+        </ul>
+    </div>
+    </div>
+
     <div id="noVNC_container">
         <h1 id="noVNC_logo"><span>no</span><br />VNC</h1>