diff options
author | Samuel Mannehed <samuel@cendio.se> | 2016-08-29 14:42:03 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2016-09-23 14:39:21 +0200 |
commit | 8d7708c82edc9c0d3dc22a28ded5a563ce786bb2 (patch) | |
tree | 39cf3f1cdd86563af9abff90000edd0f6413c88b | |
parent | c8d4402f582e4d4fb62ca75aae3241f9e0917190 (diff) | |
download | novnc-8d7708c82edc9c0d3dc22a28ded5a563ce786bb2.tar.gz |
Abstract status dialog CSS class handling
-rw-r--r-- | app/ui.js | 83 |
1 files changed, 48 insertions, 35 deletions
@@ -308,43 +308,33 @@ var UI; updateState: function(rfb, state, oldstate, msg) { UI.rfb_state = state; - var klass; - var timeout; - switch (state) { - case 'failed': - case 'fatal': - klass = "noVNC_status_error"; - timeout = 0; // zero means no timeout - break; - case 'normal': - klass = "noVNC_status_normal"; - break; - case 'disconnected': - /* falls through */ - case 'loaded': - klass = "noVNC_status_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(); + if (typeof(msg) !== 'undefined') { + switch (state) { + case 'failed': + case 'fatal': + // zero means no timeout + UI.showStatus(msg, 'error', 0); + break; + case 'normal': + /* falls through */ + case 'disconnected': + case 'loaded': + UI.showStatus(msg, 'normal'); + break; + case 'password': + UI.toggleConnectPanel(); - klass = "noVNC_status_warn"; - break; - default: - klass = "noVNC_status_warn"; - break; - } + document.getElementById('noVNC_connect_button').value = "Send Password"; + document.getElementById('noVNC_connect_button').onclick = UI.setPassword; + document.getElementById('noVNC_setting_password').focus(); - if (typeof(msg) !== 'undefined') { - document.getElementById('noVNC_status') - .classList.remove("noVNC_status_normal", - "noVNC_status_warn", - "noVNC_status_error"); - document.getElementById('noVNC_status').classList.add(klass); - UI.showStatus(msg, timeout); + UI.showStatus(msg, 'warn'); + break; + default: + UI.showStatus(msg, 'warn'); + break; + } } UI.updateVisualState(); @@ -434,11 +424,34 @@ var UI; //Util.Debug("<< updateVisualState"); }, - showStatus: function(text, time) { + showStatus: function(text, status_type, time) { var statusElem = document.getElementById('noVNC_status'); clearTimeout(UI.statusTimeout); + if (typeof status_type === 'undefined') { + status_type = 'normal'; + } + + statusElem.classList.remove("noVNC_status_normal", + "noVNC_status_warn", + "noVNC_status_error"); + + switch (status_type) { + case 'warning': + case 'warn': + statusElem.classList.add("noVNC_status_warn"); + break; + case 'error': + statusElem.classList.add("noVNC_status_error"); + break; + case 'normal': + case 'info': + default: + statusElem.classList.add("noVNC_status_normal"); + break; + } + statusElem.innerHTML = text; statusElem.classList.add("noVNC_open"); |