* removing init.js and add loadExtras() to RFB namespace

This commit is contained in:
Antoine Mercadal 2010-07-22 10:51:08 +02:00
parent ed5573e806
commit 33ebb52b56
5 changed files with 54 additions and 10 deletions

View File

@ -10,8 +10,8 @@
/*jslint white: false, bitwise: false */
/*global window, $, Util */
Canvas_native = true;
Canvas_native = (typeof(Canvas_native) != "undefined") ? Canvas_native : true;
// Everything namespaced inside Canvas
Canvas = {
@ -34,6 +34,19 @@ keyPress : null,
mouseButton : null,
mouseMove : null,
loadExtra : function () {
var pre, start = "<script src='", end = "'><\/script>";
if (document.createElement('canvas').getContext) {
Canvas_native = true;
} else {
pre = (typeof VNC_uri_prefix !== "undefined") ?
VNC_uri_prefix : "include/";
//document.write(start + pre + "excanvas.js" + end);
Canvas_native = false;
}
},
onMouseButton: function(e, down) {
var evt, pos, bmask;
evt = (e ? e : window.event);
@ -148,8 +161,6 @@ init: function (id) {
Canvas.clear();
Canvas.rescale(0.5);
/*
* Determine browser Canvas feature support
* and select fastest rendering methods
@ -255,7 +266,7 @@ rescale: function (factor) {
y = c.height - c.height * factor;
Canvas.scale = factor;
if (c.style.zoom) {
if (typeof(c.style.zoom) != "undefined") {
c.style.zoom = Canvas.scale;
return
}

View File

@ -122,7 +122,6 @@ updateState: function(state, msg) {
c.disabled = false;
cad.disabled = false;
klass = "VNC_status_normal";
alert($('VNC_canvas').width)
break;
case 'disconnected':

View File

@ -245,4 +245,3 @@ Util.Flash = (function(){
version = v.match(/\d+/g);
return {version: parseInt(version[0] || 0 + '.' + version[1], 10) || 0, build: parseInt(version[2], 10) || 0};
}());

View File

@ -10,7 +10,7 @@
/*jslint white: false, nomen: false, browser: true, bitwise: false */
/*global window, WebSocket, Util, Canvas, VNC_uri_prefix, Base64, DES */
VNC_native_ws = (typeof(VNC_native_ws) != "undefined") ? VNC_native_ws : true;
VNC_native_ws = true;
/*
* RFB namespace
@ -18,6 +18,40 @@ VNC_native_ws = (typeof(VNC_native_ws) != "undefined") ? VNC_native_ws : true;
RFB = {
get_VNC_uri_prefix: function () {
return (typeof VNC_uri_prefix !== "undefined") ? VNC_uri_prefix : "include/";
},
loadExtras: function () {
var extra = "", start, end;
start = "<script src='" + RFB.get_VNC_uri_prefix();
end = "'><\/script>";
// Uncomment to activate firebug lite
//extra += "<script src='http://getfirebug.com/releases/lite/1.2/" +
// "firebug-lite-compressed.js'><\/script>";
extra += start + "util.js" + end;
extra += start + "base64.js" + end;
extra += start + "des.js" + end;
extra += start + "canvas.js" + end;
/* If no builtin websockets then load web_socket.js */
if (window.WebSocket) {
VNC_native_ws = true;
} else {
VNC_native_ws = false;
WebSocket__swfLocation = get_VNC_uri_prefix() +
"web-socket-js/WebSocketMain.swf";
extra += start + "web-socket-js/swfobject.js" + end;
extra += start + "web-socket-js/FABridge.js" + end;
extra += start + "web-socket-js/web_socket.js" + end;
}
document.write(extra);
},
/*
* External interface variables and methods
*/
@ -328,6 +362,7 @@ init_msg: function () {
}
RFB.updateState('Authentication',
"Authenticating using scheme: " + RFB.auth_scheme);
break;
// Fall through
case 'Authentication' :
@ -533,7 +568,7 @@ normal_msg: function () {
framebufferUpdate: function() {
var RQ = RFB.RQ, FBU = RFB.FBU, timing = RFB.timing,
now, fbu_rt_diff, last_bytes, last_rects,
ret = true, msg;
ret = true;
if (FBU.rects === 0) {
//Util.Debug("New FBU: RQ.slice(0,20): " + RQ.slice(0,20));
@ -1112,7 +1147,7 @@ encode_message: function(arr) {
},
decode_message: function(data) {
var raw, i, length, RQ = RFB.RQ;
var i, length, RQ = RFB.RQ;
//Util.Debug(">> decode_message: " + data);
if (RFB.b64encode) {
/* base64 decode */

View File

@ -10,7 +10,6 @@ noVNC example: simple example using default controls
<script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
-->
<script src="include/init.js"></script>
<script src="include/vnc.js"></script>
<script src="include/default_controls.js"></script>
</head>
@ -20,6 +19,7 @@ noVNC example: simple example using default controls
</body>
<script>
RFB.loadExtras();
window.onload = function () {
DefaultControls.load('vnc');
RFB.load();