JSLint. RFB obj to rfb.js; vnc.js the 'loader'.
Move the whole RFB object to rfb.js. vnc.js is now just the loader file. This allows an integrating project to easily replace vnc.js with an alternate loader mechanism (or just do it directly in the html file). Thanks for the idea primalmotion (http://github.com/primalmotion). Also, JSLint the various files.
This commit is contained in:
parent
19463eac1f
commit
a7a8962676
|
@ -8,21 +8,10 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/*jslint white: false, bitwise: false */
|
/*jslint white: false, bitwise: false */
|
||||||
/*global window, $, Util */
|
/*global window, $, Util, Base64 */
|
||||||
|
|
||||||
var Canvas, Canvas_native;
|
// Globals defined here
|
||||||
|
var Canvas;
|
||||||
(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;
|
|
||||||
}
|
|
||||||
}());
|
|
||||||
|
|
||||||
// Everything namespaced inside Canvas
|
// Everything namespaced inside Canvas
|
||||||
Canvas = {
|
Canvas = {
|
||||||
|
@ -145,21 +134,12 @@ onMouseDisable: function (e) {
|
||||||
|
|
||||||
|
|
||||||
init: function (id) {
|
init: function (id) {
|
||||||
var c, imgTest, tval, i, curTest, curSave;
|
var c, imgTest, tval, i, curDat, curSave;
|
||||||
Util.Debug(">> Canvas.init");
|
Util.Debug(">> Canvas.init");
|
||||||
|
|
||||||
Canvas.id = id;
|
Canvas.id = id;
|
||||||
c = $(Canvas.id);
|
c = $(Canvas.id);
|
||||||
|
|
||||||
if (Canvas_native) {
|
|
||||||
Util.Info("Using native canvas");
|
|
||||||
// Use default Canvas functions
|
|
||||||
} else {
|
|
||||||
Util.Warn("Using excanvas canvas emulation");
|
|
||||||
//G_vmlCanvasManager.init(c);
|
|
||||||
//G_vmlCanvasManager.initElement(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! c.getContext) { throw("No getContext method"); }
|
if (! c.getContext) { throw("No getContext method"); }
|
||||||
Canvas.ctx = c.getContext('2d');
|
Canvas.ctx = c.getContext('2d');
|
||||||
|
|
||||||
|
@ -392,7 +372,7 @@ _rgbxImageData: function(x, y, width, height, arr, offset) {
|
||||||
|
|
||||||
// really slow fallback if we don't have imageData
|
// really slow fallback if we don't have imageData
|
||||||
_rgbxImageFill: function(x, y, width, height, arr, offset) {
|
_rgbxImageFill: function(x, y, width, height, arr, offset) {
|
||||||
var sx = 0, sy = 0;
|
var i, j, sx = 0, sy = 0;
|
||||||
for (i=0, j=offset; i < (width * height); i+=1, j+=4) {
|
for (i=0, j=offset; i < (width * height); i+=1, j+=4) {
|
||||||
Canvas.fillRect(x+sx, y+sy, 1, 1, [arr[j+0], arr[j+1], arr[j+2]]);
|
Canvas.fillRect(x+sx, y+sy, 1, 1, [arr[j+0], arr[j+1], arr[j+2]]);
|
||||||
sx += 1;
|
sx += 1;
|
||||||
|
@ -419,7 +399,7 @@ _cmapImageData: function(x, y, width, height, arr, offset) {
|
||||||
},
|
},
|
||||||
|
|
||||||
_cmapImageFill: function(x, y, width, height, arr, offset) {
|
_cmapImageFill: function(x, y, width, height, arr, offset) {
|
||||||
var sx = 0, sy = 0;
|
var i, j, sx = 0, sy = 0, cmap;
|
||||||
cmap = Canvas.colourMap;
|
cmap = Canvas.colourMap;
|
||||||
for (i=0, j=offset; i < (width * height); i+=1, j+=1) {
|
for (i=0, j=offset; i < (width * height); i+=1, j+=1) {
|
||||||
Canvas.fillRect(x+sx, y+sy, 1, 1, [arr[j]]);
|
Canvas.fillRect(x+sx, y+sy, 1, 1, [arr[j]]);
|
||||||
|
@ -568,7 +548,7 @@ isCursor: function() {
|
||||||
return Canvas.cursor_uri;
|
return Canvas.cursor_uri;
|
||||||
},
|
},
|
||||||
changeCursor: function(pixels, mask, hotx, hoty, w, h) {
|
changeCursor: function(pixels, mask, hotx, hoty, w, h) {
|
||||||
var cur = [], cmap, IHDRsz, ANDsz, XORsz, url, idx, x, y;
|
var cur = [], cmap, rgb, IHDRsz, ANDsz, XORsz, url, idx, alpha, x, y;
|
||||||
//Util.Debug(">> changeCursor, x: " + hotx + ", y: " + hoty + ", w: " + w + ", h: " + h);
|
//Util.Debug(">> changeCursor, x: " + hotx + ", y: " + hoty + ", w: " + w + ", h: " + h);
|
||||||
|
|
||||||
if (!Canvas.cursor_uri) {
|
if (!Canvas.cursor_uri) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* See README.md for usage and integration instructions.
|
* See README.md for usage and integration instructions.
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
/*global $, RFB, Canvas, VNC_uri_prefix, Element, Fx */
|
/*global $, Util, RFB, Canvas, VNC_uri_prefix, Element, Fx */
|
||||||
|
|
||||||
var DefaultControls = {
|
var DefaultControls = {
|
||||||
|
|
||||||
|
@ -14,8 +14,7 @@ settingsOpen : false,
|
||||||
|
|
||||||
// Render default controls and initialize settings menu
|
// Render default controls and initialize settings menu
|
||||||
load: function(target) {
|
load: function(target) {
|
||||||
var url, html, encrypt, cursor, base64, i, sheet, sheets,
|
var html, i, DC = DefaultControls, sheet, sheets, llevels;
|
||||||
DC = DefaultControls;
|
|
||||||
|
|
||||||
/* Handle state updates */
|
/* Handle state updates */
|
||||||
RFB.setUpdateState(DC.updateState);
|
RFB.setUpdateState(DC.updateState);
|
||||||
|
@ -129,7 +128,7 @@ load: function(target) {
|
||||||
|
|
||||||
// Read a query string variable
|
// Read a query string variable
|
||||||
getQueryVar: function(name) {
|
getQueryVar: function(name) {
|
||||||
var re = new RegExp('[\?].*' + name + '=([^\&\#]*)');
|
var re = new RegExp('[?].*' + name + '=([^&#]*)');
|
||||||
return (document.location.href.match(re) || ['',null])[1];
|
return (document.location.href.match(re) || ['',null])[1];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -189,7 +188,7 @@ saveSetting: function(name) {
|
||||||
|
|
||||||
// Initial page load read/initialization of settings
|
// Initial page load read/initialization of settings
|
||||||
initSetting: function(name, defVal) {
|
initSetting: function(name, defVal) {
|
||||||
var val, ctrl = $('VNC_' + name), DC = DefaultControls;
|
var val, DC = DefaultControls;
|
||||||
|
|
||||||
// Check Query string followed by cookie
|
// Check Query string followed by cookie
|
||||||
val = DC.getQueryVar(name);
|
val = DC.getQueryVar(name);
|
||||||
|
@ -256,7 +255,7 @@ settingsDisabled: function(disabled) {
|
||||||
// Save/apply settings when 'Apply' button is pressed
|
// Save/apply settings when 'Apply' button is pressed
|
||||||
settingsApply: function() {
|
settingsApply: function() {
|
||||||
Util.Debug(">> settingsApply");
|
Util.Debug(">> settingsApply");
|
||||||
var curSS, newSS, DC = DefaultControls;
|
var DC = DefaultControls;
|
||||||
DC.saveSetting('encrypt');
|
DC.saveSetting('encrypt');
|
||||||
DC.saveSetting('base64');
|
DC.saveSetting('base64');
|
||||||
DC.saveSetting('true_color');
|
DC.saveSetting('true_color');
|
||||||
|
@ -276,7 +275,6 @@ settingsApply: function() {
|
||||||
|
|
||||||
|
|
||||||
setPassword: function() {
|
setPassword: function() {
|
||||||
console.log("setPassword");
|
|
||||||
RFB.sendPassword($('VNC_password').value);
|
RFB.sendPassword($('VNC_password').value);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -286,7 +284,7 @@ sendCtrlAltDel: function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
updateState: function(state, msg) {
|
updateState: function(state, msg) {
|
||||||
var s, c, klass;
|
var s, sb, c, cad, klass;
|
||||||
s = $('VNC_status');
|
s = $('VNC_status');
|
||||||
sb = $('VNC_status_bar');
|
sb = $('VNC_status_bar');
|
||||||
c = $('VNC_connect_button');
|
c = $('VNC_connect_button');
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/*jslint bitwise: false, white: false */
|
/*jslint bitwise: false, white: false */
|
||||||
/*global window, document, navigator, ActiveXObject*/
|
/*global window, console, document, navigator, ActiveXObject*/
|
||||||
|
|
||||||
// Globals defined here
|
// Globals defined here
|
||||||
var Util = {}, $;
|
var Util = {}, $;
|
||||||
|
@ -43,7 +43,7 @@ Util.init_logging = function (level) {
|
||||||
default:
|
default:
|
||||||
throw("invalid logging type '" + level + "'");
|
throw("invalid logging type '" + level + "'");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
// Initialize logging level
|
// Initialize logging level
|
||||||
Util.init_logging( (document.location.href.match(
|
Util.init_logging( (document.location.href.match(
|
||||||
/logging=([A-Za-z0-9\._\-]*)/) ||
|
/logging=([A-Za-z0-9\._\-]*)/) ||
|
||||||
|
@ -266,12 +266,15 @@ Util.Flash = (function(){
|
||||||
*/
|
*/
|
||||||
// No days means only for this browser session
|
// No days means only for this browser session
|
||||||
Util.createCookie = function(name,value,days) {
|
Util.createCookie = function(name,value,days) {
|
||||||
|
var date, expires;
|
||||||
if (days) {
|
if (days) {
|
||||||
var date = new Date();
|
date = new Date();
|
||||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
date.setTime(date.getTime()+(days*24*60*60*1000));
|
||||||
var expires = "; expires="+date.toGMTString();
|
expires = "; expires="+date.toGMTString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
expires = "";
|
||||||
}
|
}
|
||||||
else var expires = "";
|
|
||||||
document.cookie = name+"="+value+expires+"; path=/";
|
document.cookie = name+"="+value+expires+"; path=/";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -280,21 +283,21 @@ Util.readCookie = function(name, defaultValue) {
|
||||||
var ca = document.cookie.split(';');
|
var ca = document.cookie.split(';');
|
||||||
for(var i=0;i < ca.length;i++) {
|
for(var i=0;i < ca.length;i++) {
|
||||||
var c = ca[i];
|
var c = ca[i];
|
||||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
while (c.charAt(0) === ' ') { c = c.substring(1,c.length); }
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length,c.length); }
|
||||||
}
|
}
|
||||||
return (typeof defaultValue !== 'undefined') ? defaultValue : null;
|
return (typeof defaultValue !== 'undefined') ? defaultValue : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
Util.eraseCookie = function(name) {
|
Util.eraseCookie = function(name) {
|
||||||
createCookie(name,"",-1);
|
Util.createCookie(name,"",-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Alternate stylesheet selection
|
* Alternate stylesheet selection
|
||||||
*/
|
*/
|
||||||
Util.getStylesheets = function() { var i, links, sheets = [];
|
Util.getStylesheets = function() { var i, links, sheets = [];
|
||||||
links = document.getElementsByTagName("link")
|
links = document.getElementsByTagName("link");
|
||||||
for (i = 0; i < links.length; i++) {
|
for (i = 0; i < links.length; i++) {
|
||||||
if (links[i].title &&
|
if (links[i].title &&
|
||||||
links[i].rel.toUpperCase().indexOf("STYLESHEET") > -1) {
|
links[i].rel.toUpperCase().indexOf("STYLESHEET") > -1) {
|
||||||
|
|
1609
include/vnc.js
1609
include/vnc.js
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue