State machine refactoring.
Add new states 'loaded', 'connect' and 'fatal': - Loaded state is first page state. Pass WebSockets mode message using this state. - Connect indicates that the user has issued a "connect" but we haven't gotten an WebSockets onopen yet. - Fatal is a condition that indicates inability to continue on: right now, lack of WebSockets/Flash or non-working canvas. Move much of the actual state transition code into updateState. Handle 'password' state better in default_controls.js; instead of disconnecting, prompt for password to send. Add comments to updateState indicating possible states.
This commit is contained in:
+20
-12
@@ -46,10 +46,26 @@ Connect parameters are provided in query string:
|
||||
sb = $('VNC_status_bar');
|
||||
cad = $('sendCtrlAltDelButton');
|
||||
switch (state) {
|
||||
case 'failed': klass = "VNC_status_error"; break;
|
||||
case 'normal': klass = "VNC_status_normal"; break;
|
||||
case 'disconnected': klass = "VNC_status_normal"; break;
|
||||
default: klass = "VNC_status_warn"; break;
|
||||
case 'failed':
|
||||
case 'fatal':
|
||||
klass = "VNC_status_error";
|
||||
break;
|
||||
case 'normal':
|
||||
klass = "VNC_status_normal";
|
||||
break;
|
||||
case 'disconnected':
|
||||
case 'loaded':
|
||||
klass = "VNC_status_normal";
|
||||
break;
|
||||
case 'password':
|
||||
msg = '<form onsubmit="return setPassword();"';
|
||||
msg += ' style="margin-bottom: 0px">';
|
||||
msg += 'Password Required: ';
|
||||
msg += '<input type=password size=10 id="password_input" class="VNC_status">';
|
||||
msg += '</form>';
|
||||
// Fall through
|
||||
default:
|
||||
klass = "VNC_status_warn";
|
||||
}
|
||||
|
||||
if (state === "normal") { cad.disabled = false; }
|
||||
@@ -59,14 +75,6 @@ Connect parameters are provided in query string:
|
||||
sb.setAttribute("class", klass);
|
||||
s.innerHTML = msg;
|
||||
}
|
||||
if (state === 'password') {
|
||||
html = '<form onsubmit="return setPassword();"';
|
||||
html += ' style="margin-bottom: 0px">';
|
||||
html += 'Password Required: ';
|
||||
html += '<input type=password size=10 id="password_input" class="VNC_status">';
|
||||
html += '</form>';
|
||||
s.innerHTML = html;
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
|
||||
Reference in New Issue
Block a user