diff --git a/include/default_controls.js b/include/default_controls.js
new file mode 100644
index 00000000..2ad9d17e
--- /dev/null
+++ b/include/default_controls.js
@@ -0,0 +1,140 @@
+DefaultControls = {
+
+load: function(target) {
+ var url;
+
+ /* Handle state updates */
+ RFB.setUpdateState(DefaultControls.updateState);
+ RFB.setClipboardReceive(DefaultControls.clipReceive);
+
+ /* Populate the 'target' DOM element with default controls */
+ if (!target) { target = 'vnc'; }
+
+ html = "";
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '';
+ html += '
Loading
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '';
+ html += ' VNC Clipboard:';
+ html += ' ';
+ html += '
';
+ html += ' ';
+ html += '
';
+ $(target).innerHTML = html;
+
+ /* Populate the controls if defaults are provided in the URL */
+ url = document.location.href;
+ $('VNC_host').value = (url.match(/host=([A-Za-z0-9.\-]*)/) ||
+ ['',''])[1];
+ $('VNC_port').value = (url.match(/port=([0-9]*)/) ||
+ ['',''])[1];
+ $('VNC_password').value = (url.match(/password=([^]*)/) ||
+ ['',''])[1];
+ $('VNC_encrypt').checked = (url.match(/encrypt=([A-Za-z0-9]*)/) ||
+ ['',''])[1];
+},
+
+updateState: function(state, msg) {
+ var s, c, klass;
+ s = $('VNC_status');
+ c = $('VNC_connect_button');
+ switch (state) {
+ case 'failed':
+ c.disabled = true;
+ klass = "VNC_status_error";
+ break;
+ case 'normal':
+ c.value = "Disconnect";
+ c.onclick = DefaultControls.disconnect;
+ c.disabled = false;
+ klass = "VNC_status_normal";
+ break;
+ case 'disconnected':
+ c.value = "Connect";
+ c.onclick = DefaultControls.connect;
+
+ c.disabled = false;
+ klass = "VNC_status_normal";
+ break;
+ default:
+ c.disabled = true;
+ klass = "VNC_status_warn";
+ break;
+ }
+
+ if (typeof(msg) !== 'undefined') {
+ s.setAttribute("class", klass);
+ s.innerHTML = msg;
+ }
+
+},
+
+connect: function() {
+ var host, port, password, encrypt, true_color;
+ host = $('VNC_host').value;
+ port = $('VNC_port').value;
+ password = $('VNC_password').value;
+ encrypt = $('VNC_encrypt').checked;
+ true_color = $('VNC_true_color').checked;
+ if ((!host) || (!port)) {
+ alert("Must set host and port");
+ return;
+ }
+
+ RFB.connect(host, port, password, encrypt, true_color);
+},
+
+disconnect: function() {
+ RFB.disconnect();
+},
+
+clipFocus: function() {
+ RFB.clipboardFocus = true;
+},
+
+clipBlur: function() {
+ RFB.clipboardFocus = false;
+},
+
+clipClear: function() {
+ $('VNC_clipboard_text').value = "";
+ RFB.clipboardPasteFrom("");
+},
+
+clipReceive: function(text) {
+ console.log(">> DefaultControls.clipReceive: " + text.substr(0,40) + "...");
+ $('VNC_clipboard_text').value = text;
+ console.log("<< DefaultControls.clipReceive");
+},
+
+clipSend: function() {
+ var text = $('VNC_clipboard_text').value;
+ console.log(">> DefaultControls.clipSend: " + text.substr(0,40) + "...");
+ RFB.clipboardPasteFrom(text);
+ console.log("<< DefaultControls.clipSend");
+}
+
+}
diff --git a/vnc.html b/vnc.html
index e8706ffd..47fd4958 100644
--- a/vnc.html
+++ b/vnc.html
@@ -1,5 +1,7 @@
+
-
VNC Client
@@ -10,8 +12,11 @@
+
-
diff --git a/vnc.js b/vnc.js
index 074559bd..3c32dfb9 100644
--- a/vnc.js
+++ b/vnc.js
@@ -7,19 +7,20 @@
*/
"use strict";
-/*global window, WebSocket, $, Browser, Canvas, Base64, DES */
+/*global window, WebSocket, $, Browser, Canvas, VNC_uri_prefix Base64, DES */
// Globals defined here
var VNC_native_ws, RFB;
-
/*
* Load supporting scripts
*/
(function () {
var extra, start, end;
+
+ if (typeof VNC_uri_prefix === "undefined") { VNC_uri_prefix=""; }
extra = "";
- start = "
+
+