Просмотр исходного кода

Make compatible with jQuery. Slight API change.

Rename the $() selector to $D() so that it doesn't collide with
the jQuery name.

The API change is that the 'target' option for Canvas and RFB objects
must now be a DOM Canvas element. A string is no longer accepted
because this requires that a DOM lookup is done and the Canvas and RFB
should have no UI code in them. Modularity.
Joel Martin 14 лет назад
Родитель
Сommit
e46719100c
13 измененных файлов с 115 добавлено и 110 удалено
  1. 2 2
      include/canvas.js
  2. 6 6
      include/rfb.js
  3. 33 29
      include/ui.js
  4. 2 2
      include/webutil.js
  5. 1 1
      tests/base64.html
  6. 10 10
      tests/canvas.html
  7. 4 4
      tests/cursor.html
  8. 2 2
      tests/input.html
  9. 10 10
      tests/vnc_perf.html
  10. 14 14
      tests/vnc_playback.html
  11. 14 14
      tests/ws.html
  12. 10 10
      tests/wsencoding.html
  13. 7 6
      vnc_auto.html

+ 2 - 2
include/canvas.js

@@ -99,7 +99,7 @@ function constructor() {
     if (! conf.target) { throw("target must be set"); }
     if (! conf.target) { throw("target must be set"); }
 
 
     if (typeof conf.target === 'string') {
     if (typeof conf.target === 'string') {
-        conf.target = window.$(conf.target);
+        throw("target must be a DOM element");
     }
     }
 
 
     c = conf.target;
     c = conf.target;
@@ -215,7 +215,7 @@ function constructor() {
     return that ;
     return that ;
 }
 }
 
 
-/* Translate DOM key event to keysym value */
+/* Translate DOM key down/up event to keysym value */
 function getKeysym(e) {
 function getKeysym(e) {
     var evt, keysym;
     var evt, keysym;
     evt = (e ? e : window.event);
     evt = (e ? e : window.event);

+ 6 - 6
include/rfb.js

@@ -127,13 +127,13 @@ var that           = {},         // Public API interface
 function cdef(v, type, defval, desc) {
 function cdef(v, type, defval, desc) {
     Util.conf_default(conf, that, v, type, defval, desc); }
     Util.conf_default(conf, that, v, type, defval, desc); }
 
 
-cdef('target',         'str', 'VNC_canvas', 'VNC viewport rendering Canvas');
-cdef('focusContainer', 'dom', document, 'Area that traps keyboard input');
+cdef('target',            'str', null, 'VNC viewport rendering Canvas');
+cdef('focusContainer',    'dom', document, 'Area that traps keyboard input');
 
 
-cdef('encrypt',        'bool', false, 'Use TLS/SSL/wss encryption');
-cdef('true_color',     'bool', true,  'Request true color pixel data');
-cdef('local_cursor',   'bool', false, 'Request locally rendered cursor');
-cdef('shared',         'bool', true,  'Request shared mode');
+cdef('encrypt',         'bool', false, 'Use TLS/SSL/wss encryption');
+cdef('true_color',      'bool', true,  'Request true color pixel data');
+cdef('local_cursor',    'bool', false, 'Request locally rendered cursor');
+cdef('shared',          'bool', true,  'Request shared mode');
 
 
 cdef('connectTimeout',    'int', 2,    'Time (s) to wait for connection');
 cdef('connectTimeout',    'int', 2,    'Time (s) to wait for connection');
 cdef('disconnectTimeout', 'int', 3,    'Time (s) to wait for disconnection');
 cdef('disconnectTimeout', 'int', 3,    'Time (s) to wait for disconnection');

+ 33 - 29
include/ui.js

@@ -18,7 +18,11 @@ load: function(target) {
     var html = '', i, sheet, sheets, llevels;
     var html = '', i, sheet, sheets, llevels;
 
 
     /* Populate the 'target' DOM element with default UI */
     /* Populate the 'target' DOM element with default UI */
-    if (!target) { target = 'vnc'; }
+    if (!target) {
+        target = $D('vnc');
+    } else if (typeof target === 'string') {
+        target = $D(target);
+    }
 
 
     if ((!document.createElement('canvas').getContext) &&
     if ((!document.createElement('canvas').getContext) &&
         window.ActiveXObject) {
         window.ActiveXObject) {
@@ -31,7 +35,7 @@ load: function(target) {
         html += '  <a href="http://google.com/chromeframe" target="cframe">';
         html += '  <a href="http://google.com/chromeframe" target="cframe">';
         html += '  Google Chrome Frame.</a>';
         html += '  Google Chrome Frame.</a>';
         html += '</div></center>';
         html += '</div></center>';
-        $(target).innerHTML = html;
+        target.innerHTML = html;
         return;
         return;
     }
     }
 
 
@@ -114,7 +118,7 @@ load: function(target) {
     html += '    onblur="UI.canvasFocus();"';
     html += '    onblur="UI.canvasFocus();"';
     html += '    onchange="UI.clipSend();"></textarea>';
     html += '    onchange="UI.clipSend();"></textarea>';
     html += '</div>';
     html += '</div>';
-    $(target).innerHTML = html;
+    target.innerHTML = html;
 
 
     // Settings with immediate effects
     // Settings with immediate effects
     UI.initSetting('logging', 'warn');
     UI.initSetting('logging', 'warn');
@@ -134,15 +138,15 @@ load: function(target) {
     UI.initSetting('shared', true);
     UI.initSetting('shared', true);
     UI.initSetting('connectTimeout', 2);
     UI.initSetting('connectTimeout', 2);
 
 
-    UI.rfb = RFB({'target': 'VNC_canvas',
+    UI.rfb = RFB({'target': $D('VNC_canvas'),
                   'updateState': UI.updateState,
                   'updateState': UI.updateState,
                   'clipboardReceive': UI.clipReceive});
                   'clipboardReceive': UI.clipReceive});
 
 
     // Unfocus clipboard when over the VNC area
     // Unfocus clipboard when over the VNC area
-    $('VNC_screen').onmousemove = function () {
+    $D('VNC_screen').onmousemove = function () {
             var canvas = UI.rfb.get_canvas();
             var canvas = UI.rfb.get_canvas();
             if ((! canvas) || (! canvas.get_focused())) {
             if ((! canvas) || (! canvas.get_focused())) {
-                $('VNC_clipboard_text').blur();
+                $D('VNC_clipboard_text').blur();
             }
             }
         };
         };
 
 
@@ -150,7 +154,7 @@ load: function(target) {
 
 
 // Read form control compatible setting from cookie
 // Read form control compatible setting from cookie
 getSetting: function(name) {
 getSetting: function(name) {
-    var val, ctrl = $('VNC_' + name);
+    var val, ctrl = $D('VNC_' + name);
     val = WebUtil.readCookie(name);
     val = WebUtil.readCookie(name);
     if (ctrl.type === 'checkbox') {
     if (ctrl.type === 'checkbox') {
         if (val.toLowerCase() in {'0':1, 'no':1, 'false':1}) {
         if (val.toLowerCase() in {'0':1, 'no':1, 'false':1}) {
@@ -165,7 +169,7 @@ getSetting: function(name) {
 // Update cookie and form control setting. If value is not set, then
 // Update cookie and form control setting. If value is not set, then
 // updates from control to current cookie setting.
 // updates from control to current cookie setting.
 updateSetting: function(name, value) {
 updateSetting: function(name, value) {
-    var i, ctrl = $('VNC_' + name);
+    var i, ctrl = $D('VNC_' + name);
     // Save the cookie for this session
     // Save the cookie for this session
     if (typeof value !== 'undefined') {
     if (typeof value !== 'undefined') {
         WebUtil.createCookie(name, value);
         WebUtil.createCookie(name, value);
@@ -189,7 +193,7 @@ updateSetting: function(name, value) {
 
 
 // Save control setting to cookie
 // Save control setting to cookie
 saveSetting: function(name) {
 saveSetting: function(name) {
-    var val, ctrl = $('VNC_' + name);
+    var val, ctrl = $D('VNC_' + name);
     if (ctrl.type === 'checkbox') {
     if (ctrl.type === 'checkbox') {
         val = ctrl.checked;
         val = ctrl.checked;
     } else if (typeof ctrl.options !== 'undefined') {
     } else if (typeof ctrl.options !== 'undefined') {
@@ -232,7 +236,7 @@ clickSettingsMenu: function() {
             UI.updateSetting('cursor');
             UI.updateSetting('cursor');
         } else {
         } else {
             UI.updateSetting('cursor', false);
             UI.updateSetting('cursor', false);
-            $('VNC_cursor').disabled = true;
+            $D('VNC_cursor').disabled = true;
         }
         }
         UI.updateSetting('shared');
         UI.updateSetting('shared');
         UI.updateSetting('connectTimeout');
         UI.updateSetting('connectTimeout');
@@ -245,29 +249,29 @@ clickSettingsMenu: function() {
 
 
 // Open menu
 // Open menu
 openSettingsMenu: function() {
 openSettingsMenu: function() {
-    $('VNC_settings_menu').style.display = "block";
+    $D('VNC_settings_menu').style.display = "block";
     UI.settingsOpen = true;
     UI.settingsOpen = true;
 },
 },
 
 
 // Close menu (without applying settings)
 // Close menu (without applying settings)
 closeSettingsMenu: function() {
 closeSettingsMenu: function() {
-    $('VNC_settings_menu').style.display = "none";
+    $D('VNC_settings_menu').style.display = "none";
     UI.settingsOpen = false;
     UI.settingsOpen = false;
 },
 },
 
 
 // Disable/enable controls depending on connection state
 // Disable/enable controls depending on connection state
 settingsDisabled: function(disabled, rfb) {
 settingsDisabled: function(disabled, rfb) {
     //Util.Debug(">> settingsDisabled");
     //Util.Debug(">> settingsDisabled");
-    $('VNC_encrypt').disabled = disabled;
-    $('VNC_true_color').disabled = disabled;
+    $D('VNC_encrypt').disabled = disabled;
+    $D('VNC_true_color').disabled = disabled;
     if (rfb && rfb.get_canvas() && rfb.get_canvas().get_cursor_uri()) {
     if (rfb && rfb.get_canvas() && rfb.get_canvas().get_cursor_uri()) {
-        $('VNC_cursor').disabled = disabled;
+        $D('VNC_cursor').disabled = disabled;
     } else {
     } else {
         UI.updateSetting('cursor', false);
         UI.updateSetting('cursor', false);
-        $('VNC_cursor').disabled = true;
+        $D('VNC_cursor').disabled = true;
     }
     }
-    $('VNC_shared').disabled = disabled;
-    $('VNC_connectTimeout').disabled = disabled;
+    $D('VNC_shared').disabled = disabled;
+    $D('VNC_connectTimeout').disabled = disabled;
     //Util.Debug("<< settingsDisabled");
     //Util.Debug("<< settingsDisabled");
 },
 },
 
 
@@ -294,7 +298,7 @@ settingsApply: function() {
 
 
 
 
 setPassword: function() {
 setPassword: function() {
-    UI.rfb.sendPassword($('VNC_password').value);
+    UI.rfb.sendPassword($D('VNC_password').value);
     return false;
     return false;
 },
 },
 
 
@@ -304,10 +308,10 @@ sendCtrlAltDel: function() {
 
 
 updateState: function(rfb, state, oldstate, msg) {
 updateState: function(rfb, state, oldstate, msg) {
     var s, sb, c, cad, klass;
     var s, sb, c, cad, klass;
-    s = $('VNC_status');
-    sb = $('VNC_status_bar');
-    c = $('VNC_connect_button');
-    cad = $('sendCtrlAltDelButton');
+    s = $D('VNC_status');
+    sb = $D('VNC_status_bar');
+    c = $D('VNC_connect_button');
+    cad = $D('sendCtrlAltDelButton');
     switch (state) {
     switch (state) {
         case 'failed':
         case 'failed':
         case 'fatal':
         case 'fatal':
@@ -361,7 +365,7 @@ updateState: function(rfb, state, oldstate, msg) {
 
 
 clipReceive: function(rfb, text) {
 clipReceive: function(rfb, text) {
     Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "...");
     Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "...");
-    $('VNC_clipboard_text').value = text;
+    $D('VNC_clipboard_text').value = text;
     Util.Debug("<< UI.clipReceive");
     Util.Debug("<< UI.clipReceive");
 },
 },
 
 
@@ -371,9 +375,9 @@ connect: function() {
 
 
     UI.closeSettingsMenu();
     UI.closeSettingsMenu();
 
 
-    host = $('VNC_host').value;
-    port = $('VNC_port').value;
-    password = $('VNC_password').value;
+    host = $D('VNC_host').value;
+    port = $D('VNC_port').value;
+    password = $D('VNC_password').value;
     if ((!host) || (!port)) {
     if ((!host) || (!port)) {
         throw("Must set host and port");
         throw("Must set host and port");
     }
     }
@@ -402,12 +406,12 @@ canvasFocus: function() {
 },
 },
 
 
 clipClear: function() {
 clipClear: function() {
-    $('VNC_clipboard_text').value = "";
+    $D('VNC_clipboard_text').value = "";
     UI.rfb.clipboardPasteFrom("");
     UI.rfb.clipboardPasteFrom("");
 },
 },
 
 
 clipSend: function() {
 clipSend: function() {
-    var text = $('VNC_clipboard_text').value;
+    var text = $D('VNC_clipboard_text').value;
     Util.Debug(">> UI.clipSend: " + text.substr(0,40) + "...");
     Util.Debug(">> UI.clipSend: " + text.substr(0,40) + "...");
     UI.rfb.clipboardPasteFrom(text);
     UI.rfb.clipboardPasteFrom(text);
     Util.Debug("<< UI.clipSend");
     Util.Debug("<< UI.clipSend");

+ 2 - 2
include/webutil.js

@@ -16,8 +16,8 @@ var WebUtil = {}, $;
 /*
 /*
  * Simple DOM selector by ID
  * Simple DOM selector by ID
  */
  */
-if (!window.$) {
-    $ = function (id) {
+if (!window.$D) {
+    $D = function (id) {
         if (document.getElementById) {
         if (document.getElementById) {
             return document.getElementById(id);
             return document.getElementById(id);
         } else if (document.all) {
         } else if (document.all) {

+ 1 - 1
tests/base64.html

@@ -19,7 +19,7 @@
 <script> 
 <script> 
     function debug(str) {
     function debug(str) {
         console.log(str);
         console.log(str);
-        cell = $('debug');
+        cell = $D('debug');
         cell.innerHTML += str + "\n";
         cell.innerHTML += str + "\n";
         cell.scrollTop = cell.scrollHeight;
         cell.scrollTop = cell.scrollHeight;
     }
     }

+ 10 - 10
tests/canvas.html

@@ -40,7 +40,7 @@
 
 
         function message(str) {
         function message(str) {
             console.log(str);
             console.log(str);
-            cell = $('messages');
+            cell = $D('messages');
             cell.innerHTML += msg_cnt + ": " + str + "\n";
             cell.innerHTML += msg_cnt + ": " + str + "\n";
             cell.scrollTop = cell.scrollHeight;
             cell.scrollTop = cell.scrollHeight;
             msg_cnt += 1;
             msg_cnt += 1;
@@ -80,10 +80,10 @@
         }
         }
 
 
         function begin () {
         function begin () {
-            $('startButton').value = "Running";
-            $('startButton').disabled = true;
+            $D('startButton').value = "Running";
+            $D('startButton').disabled = true;
             setTimeout(start_delayed, 250);
             setTimeout(start_delayed, 250);
-            iterations = $('iterations').value;
+            iterations = $D('iterations').value;
         }
         }
 
 
         function start_delayed () {
         function start_delayed () {
@@ -109,14 +109,14 @@
                 canvas.resize(start_width, start_height, true);
                 canvas.resize(start_width, start_height, true);
                 test_functions();
                 test_functions();
             }
             }
-            $('startButton').disabled = false;
-            $('startButton').value = "Do Performance Test";
+            $D('startButton').disabled = false;
+            $D('startButton').value = "Do Performance Test";
         }
         }
 
 
         function run_test () {
         function run_test () {
             var width, height;
             var width, height;
-            width = $('width').value;
-            height = $('height').value;
+            width = $D('width').value;
+            height = $D('height').value;
             canvas.resize(width, height);
             canvas.resize(width, height);
             var color, start_time = (new Date()).getTime(), w, h;
             var color, start_time = (new Date()).getTime(), w, h;
             for (var i=0; i < iterations; i++) {
             for (var i=0; i < iterations; i++) {
@@ -137,8 +137,8 @@
 
 
         window.onload = function() {
         window.onload = function() {
             message("in onload");
             message("in onload");
-            $('iterations').value = 10;
-            canvas = Canvas({'target' : 'canvas'});
+            $D('iterations').value = 10;
+            canvas = new Canvas({'target' : $D('canvas')});
             canvas.resize(start_width, start_height, true);
             canvas.resize(start_width, start_height, true);
             message("Canvas initialized");
             message("Canvas initialized");
             test_functions();
             test_functions();

+ 4 - 4
tests/cursor.html

@@ -34,7 +34,7 @@
   <script> 
   <script> 
     function debug(str) {
     function debug(str) {
         console.log(str);
         console.log(str);
-        cell = $('debug');
+        cell = $D('debug');
         cell.innerHTML += str + "\n";
         cell.innerHTML += str + "\n";
         cell.scrollTop = cell.scrollHeight;
         cell.scrollTop = cell.scrollHeight;
     }
     }
@@ -119,16 +119,16 @@
         debug("onload");
         debug("onload");
         var canvas, cross, cursor, cursor64;
         var canvas, cross, cursor, cursor64;
 
 
-        canvas = new Canvas({'target' : "testcanvas"});
+        canvas = new Canvas({'target' : $D("testcanvas")});
         debug("canvas indicates Data URI cursor support is: " + canvas.get_cursor_uri());
         debug("canvas indicates Data URI cursor support is: " + canvas.get_cursor_uri());
 
 
-        $('button1').style.cursor="url(face.png), default";
+        $D('button1').style.cursor="url(face.png), default";
 
 
         cursor = makeCursor();
         cursor = makeCursor();
         cursor64 = Base64.encode(cursor);
         cursor64 = Base64.encode(cursor);
         //debug("cursor: " + cursor.slice(0,100) + " (" + cursor.length + ")");
         //debug("cursor: " + cursor.slice(0,100) + " (" + cursor.length + ")");
         //debug("cursor64: " + cursor64.slice(0,100) + " (" + cursor64.length + ")");
         //debug("cursor64: " + cursor64.slice(0,100) + " (" + cursor64.length + ")");
-        $('button2').style.cursor="url(data:image/x-icon;base64," + cursor64 + "), default";
+        $D('button2').style.cursor="url(data:image/x-icon;base64," + cursor64 + "), default";
 
 
         debug("onload complete");
         debug("onload complete");
     }
     }

+ 2 - 2
tests/input.html

@@ -29,7 +29,7 @@
 
 
         function message(str) {
         function message(str) {
             console.log(str);
             console.log(str);
-            cell = $('messages');
+            cell = $D('messages');
             cell.innerHTML += msg_cnt + ": " + str + "\n";
             cell.innerHTML += msg_cnt + ": " + str + "\n";
             cell.scrollTop = cell.scrollHeight;
             cell.scrollTop = cell.scrollHeight;
         }
         }
@@ -53,7 +53,7 @@
         }
         }
 
 
         window.onload = function() {
         window.onload = function() {
-            var canvas = Canvas({'target' : 'canvas'});
+            var canvas = new Canvas({'target' : $D('canvas')});
             canvas.resize(width, height, true);
             canvas.resize(width, height, true);
             canvas.start(keyPress, mouseButton, mouseMove);
             canvas.start(keyPress, mouseButton, mouseMove);
             message("Canvas initialized");
             message("Canvas initialized");

+ 10 - 10
tests/vnc_perf.html

@@ -47,7 +47,7 @@
 
 
         function msg(str) {
         function msg(str) {
             console.log(str);
             console.log(str);
-            var cell = $('messages');
+            var cell = $D('messages');
             cell.innerHTML += str + "\n";
             cell.innerHTML += str + "\n";
             cell.scrollTop = cell.scrollHeight;
             cell.scrollTop = cell.scrollHeight;
         }
         }
@@ -68,20 +68,20 @@
                     test_state = 'failed';
                     test_state = 'failed';
                     break;
                     break;
                 case 'loaded':
                 case 'loaded':
-                    $('startButton').disabled = false;
+                    $D('startButton').disabled = false;
                     break;
                     break;
             }
             }
             if (typeof mesg !== 'undefined') {
             if (typeof mesg !== 'undefined') {
-                $('VNC_status').innerHTML = mesg;
+                $D('VNC_status').innerHTML = mesg;
             }
             }
         }
         }
 
 
         function start() {
         function start() {
-            $('startButton').value = "Running";
-            $('startButton').disabled = true;
+            $D('startButton').value = "Running";
+            $D('startButton').disabled = true;
 
 
             mode = 'perftest'; // full-speed
             mode = 'perftest'; // full-speed
-            passes = $('passes').value;
+            passes = $D('passes').value;
             pass = 1;
             pass = 1;
             encIdx = 0;
             encIdx = 0;
 
 
@@ -123,8 +123,8 @@
                 if (pass > passes) {
                 if (pass > passes) {
                     // We are finished
                     // We are finished
                     rfb.get_canvas().stop();   // Shut-off event interception
                     rfb.get_canvas().stop();   // Shut-off event interception
-                    $('startButton').disabled = false;
-                    $('startButton').value = "Start";
+                    $D('startButton').disabled = false;
+                    $D('startButton').value = "Start";
                     finish_passes();
                     finish_passes();
                     return; // We are finished, terminate
                     return; // We are finished, terminate
                 }
                 }
@@ -189,8 +189,8 @@
                 enc = encOrder[i];
                 enc = encOrder[i];
                 dbgmsg("  " + enc + ": " + VNC_frame_data_multi[enc].length);
                 dbgmsg("  " + enc + ": " + VNC_frame_data_multi[enc].length);
             }
             }
-            rfb = RFB({'target': 'VNC_canvas',
-                    'updateState': updateState});
+            rfb = new RFB({'target': $D('VNC_canvas'),
+                           'updateState': updateState});
             rfb.testMode(send_array);
             rfb.testMode(send_array);
         }
         }
     </script>
     </script>

+ 14 - 14
tests/vnc_playback.html

@@ -45,7 +45,7 @@
 
 
         function message(str) {
         function message(str) {
             console.log(str);
             console.log(str);
-            var cell = $('messages');
+            var cell = $D('messages');
             cell.innerHTML += str + "\n";
             cell.innerHTML += str + "\n";
             cell.scrollTop = cell.scrollHeight;
             cell.scrollTop = cell.scrollHeight;
         }
         }
@@ -67,23 +67,23 @@
                     test_state = 'failed';
                     test_state = 'failed';
                     break;
                     break;
                 case 'loaded':
                 case 'loaded':
-                    $('startButton').disabled = false;
+                    $D('startButton').disabled = false;
                     break;
                     break;
             }
             }
             if (typeof msg !== 'undefined') {
             if (typeof msg !== 'undefined') {
-                $('VNC_status').innerHTML = msg;
+                $D('VNC_status').innerHTML = msg;
             }
             }
         }
         }
 
 
         function start() {
         function start() {
-            $('startButton').value = "Running";
-            $('startButton').disabled = true;
+            $D('startButton').value = "Running";
+            $D('startButton').disabled = true;
 
 
-            iterations = $('iterations').value;
+            iterations = $D('iterations').value;
             iteration = 0;
             iteration = 0;
             start_time = (new Date()).getTime();
             start_time = (new Date()).getTime();
 
 
-            if ($('mode1').checked) {
+            if ($D('mode1').checked) {
                 message("Starting performance playback (fullspeed) [" + iterations + " iteration(s)]");
                 message("Starting performance playback (fullspeed) [" + iterations + " iteration(s)]");
                 mode = 'perftest';
                 mode = 'perftest';
             } else {
             } else {
@@ -103,24 +103,24 @@
             message(iterations + " iterations took " + total_time + "ms, " +
             message(iterations + " iterations took " + total_time + "ms, " +
                     iter_time + "ms per iteration");
                     iter_time + "ms per iteration");
             rfb.get_canvas().stop();   // Shut-off event interception
             rfb.get_canvas().stop();   // Shut-off event interception
-            $('startButton').disabled = false;
-            $('startButton').value = "Start";
+            $D('startButton').disabled = false;
+            $D('startButton').value = "Start";
 
 
         }
         }
 
 
         window.onload = function() {
         window.onload = function() {
             iterations = WebUtil.getQueryVar('iterations', 3);
             iterations = WebUtil.getQueryVar('iterations', 3);
-            $('iterations').value = iterations;
+            $D('iterations').value = iterations;
             mode = WebUtil.getQueryVar('mode', 3);
             mode = WebUtil.getQueryVar('mode', 3);
             if (mode === 'realtime') {
             if (mode === 'realtime') {
-                $('mode2').checked = true;
+                $D('mode2').checked = true;
             } else {
             } else {
-                $('mode1').checked = true;
+                $D('mode1').checked = true;
             }
             }
             if (fname) {
             if (fname) {
                 message("VNC_frame_data.length: " + VNC_frame_data.length);
                 message("VNC_frame_data.length: " + VNC_frame_data.length);
-                rfb = RFB({'target': 'VNC_canvas',
-                        'updateState': updateState});
+                rfb = new RFB({'target': $D('VNC_canvas'),
+                               'updateState': updateState});
                 rfb.testMode(send_array);
                 rfb.testMode(send_array);
             }
             }
         }
         }

+ 14 - 14
tests/ws.html

@@ -47,7 +47,7 @@
 
 
         function error(str) {
         function error(str) {
             console.error(str);
             console.error(str);
-            cell = $('error');
+            cell = $D('error');
             cell.innerHTML += errors + ": " + str + "\n";
             cell.innerHTML += errors + ": " + str + "\n";
             cell.scrollTop = cell.scrollHeight;
             cell.scrollTop = cell.scrollHeight;
         }
         }
@@ -147,15 +147,15 @@
         }
         }
 
 
         function update_stats() {
         function update_stats() {
-            $('sent').innerHTML = sent;
-            $('received').innerHTML = received;
-            $('errors').innerHTML = errors;
+            $D('sent').innerHTML = sent;
+            $D('received').innerHTML = received;
+            $D('errors').innerHTML = errors;
         }
         }
 
 
         function init_ws() {
         function init_ws() {
             console.log(">> init_ws");
             console.log(">> init_ws");
             var scheme = "ws://";
             var scheme = "ws://";
-            if ($('encrypt').checked) {
+            if ($D('encrypt').checked) {
                 scheme = "wss://";
                 scheme = "wss://";
             }
             }
             var uri = scheme + host + ":" + port;
             var uri = scheme + host + ":" + port;
@@ -188,9 +188,9 @@
 
 
         function connect() {
         function connect() {
             console.log(">> connect");
             console.log(">> connect");
-            host = $('host').value;
-            port = $('port').value;
-            sendDelay = parseInt($('sendDelay').value, 10);
+            host = $D('host').value;
+            port = $D('port').value;
+            sendDelay = parseInt($D('sendDelay').value, 10);
             if ((!host) || (!port)) {
             if ((!host) || (!port)) {
                 console.log("must set host and port");
                 console.log("must set host and port");
                 return;
                 return;
@@ -202,8 +202,8 @@
             init_ws();
             init_ws();
             update_ref = setInterval(update_stats, 1);
             update_ref = setInterval(update_stats, 1);
 
 
-            $('connectButton').value = "Stop";
-            $('connectButton').onclick = disconnect;
+            $D('connectButton').value = "Stop";
+            $D('connectButton').onclick = disconnect;
             console.log("<< connect");
             console.log("<< connect");
         }
         }
 
 
@@ -218,8 +218,8 @@
             recv_seq = 0;
             recv_seq = 0;
             send_seq = 0;
             send_seq = 0;
 
 
-            $('connectButton').value = "Start";
-            $('connectButton').onclick = connect;
+            $D('connectButton').value = "Start";
+            $D('connectButton').onclick = connect;
             console.log("<< disconnect");
             console.log("<< disconnect");
         }
         }
 
 
@@ -244,8 +244,8 @@
                 WebSocket.__initialize();
                 WebSocket.__initialize();
             }
             }
             var url = document.location.href;
             var url = document.location.href;
-            $('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
-            $('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
+            $D('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
+            $D('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
         }
         }
     </script>
     </script>
 
 

+ 10 - 10
tests/wsencoding.html

@@ -34,7 +34,7 @@
 
 
         function message(str) {
         function message(str) {
             console.log(str);
             console.log(str);
-            cell = $('messages');
+            cell = $D('messages');
             cell.innerHTML += str + "\n";
             cell.innerHTML += str + "\n";
             cell.scrollTop = cell.scrollHeight;
             cell.scrollTop = cell.scrollHeight;
         }
         }
@@ -65,7 +65,7 @@
         function init_ws() {
         function init_ws() {
             console.log(">> init_ws");
             console.log(">> init_ws");
             var scheme = "ws://";
             var scheme = "ws://";
-            if ($('encrypt').checked) {
+            if ($D('encrypt').checked) {
                 scheme = "wss://";
                 scheme = "wss://";
             }
             }
             var uri = scheme + host + ":" + port;
             var uri = scheme + host + ":" + port;
@@ -97,8 +97,8 @@
 
 
         function connect() {
         function connect() {
             console.log(">> connect");
             console.log(">> connect");
-            host = $('host').value;
-            port = $('port').value;
+            host = $D('host').value;
+            port = $D('port').value;
             if ((!host) || (!port)) {
             if ((!host) || (!port)) {
                 console.log("must set host and port");
                 console.log("must set host and port");
                 return;
                 return;
@@ -109,8 +109,8 @@
             }
             }
             init_ws();
             init_ws();
 
 
-            $('connectButton').value = "Stop";
-            $('connectButton').onclick = disconnect;
+            $D('connectButton').value = "Stop";
+            $D('connectButton').onclick = disconnect;
             console.log("<< connect");
             console.log("<< connect");
         }
         }
 
 
@@ -120,8 +120,8 @@
                 ws.close();
                 ws.close();
             }
             }
 
 
-            $('connectButton').value = "Start";
-            $('connectButton').onclick = connect;
+            $D('connectButton').value = "Start";
+            $D('connectButton').onclick = connect;
             console.log("<< disconnect");
             console.log("<< disconnect");
         }
         }
 
 
@@ -143,8 +143,8 @@
                 WebSocket.__initialize();
                 WebSocket.__initialize();
             }
             }
             var url = document.location.href;
             var url = document.location.href;
-            $('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
-            $('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
+            $D('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
+            $D('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
         }
         }
     </script>
     </script>
 
 

+ 7 - 6
vnc_auto.html

@@ -42,7 +42,7 @@
         var rfb;
         var rfb;
 
 
         function setPassword() {
         function setPassword() {
-            rfb.sendPassword($('password_input').value);
+            rfb.sendPassword($D('password_input').value);
             return false;
             return false;
         }
         }
         function sendCtrlAltDel() {
         function sendCtrlAltDel() {
@@ -51,9 +51,9 @@
         }
         }
         function updateState(rfb, state, oldstate, msg) {
         function updateState(rfb, state, oldstate, msg) {
             var s, sb, cad, klass;
             var s, sb, cad, klass;
-            s = $('VNC_status');
-            sb = $('VNC_status_bar');
-            cad = $('sendCtrlAltDelButton');
+            s = $D('VNC_status');
+            sb = $D('VNC_status_bar');
+            cad = $D('sendCtrlAltDelButton');
             switch (state) {
             switch (state) {
                 case 'failed':
                 case 'failed':
                 case 'fatal':
                 case 'fatal':
@@ -90,7 +90,7 @@
         window.onload = function () {
         window.onload = function () {
             var host, port, password;
             var host, port, password;
 
 
-            $('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
+            $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
 
 
             host = WebUtil.getQueryVar('host', null);
             host = WebUtil.getQueryVar('host', null);
             port = WebUtil.getQueryVar('port', null);
             port = WebUtil.getQueryVar('port', null);
@@ -101,7 +101,8 @@
                 return;
                 return;
             }
             }
 
 
-            rfb = new RFB({'encrypt':      WebUtil.getQueryVar('encrypt', false),
+            rfb = new RFB({'target':       $D('VNC_canvas'),
+                           'encrypt':      WebUtil.getQueryVar('encrypt', false),
                            'true_color':   WebUtil.getQueryVar('true_color', true),
                            'true_color':   WebUtil.getQueryVar('true_color', true),
                            'local_cursor': WebUtil.getQueryVar('cursor', true),
                            'local_cursor': WebUtil.getQueryVar('cursor', true),
                            'shared':       WebUtil.getQueryVar('shared', true),
                            'shared':       WebUtil.getQueryVar('shared', true),