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";
|
||||
/*jslint white: false, bitwise: false */
|
||||
/*global window, $, Util */
|
||||
/*global window, $, Util, Base64 */
|
||||
|
||||
var Canvas, Canvas_native;
|
||||
|
||||
(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;
|
||||
}
|
||||
}());
|
||||
// Globals defined here
|
||||
var Canvas;
|
||||
|
||||
// Everything namespaced inside Canvas
|
||||
Canvas = {
|
||||
|
@ -145,21 +134,12 @@ onMouseDisable: function (e) {
|
|||
|
||||
|
||||
init: function (id) {
|
||||
var c, imgTest, tval, i, curTest, curSave;
|
||||
var c, imgTest, tval, i, curDat, curSave;
|
||||
Util.Debug(">> Canvas.init");
|
||||
|
||||
Canvas.id = 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"); }
|
||||
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
|
||||
_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) {
|
||||
Canvas.fillRect(x+sx, y+sy, 1, 1, [arr[j+0], arr[j+1], arr[j+2]]);
|
||||
sx += 1;
|
||||
|
@ -419,7 +399,7 @@ _cmapImageData: 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;
|
||||
for (i=0, j=offset; i < (width * height); i+=1, j+=1) {
|
||||
Canvas.fillRect(x+sx, y+sy, 1, 1, [arr[j]]);
|
||||
|
@ -568,7 +548,7 @@ isCursor: function() {
|
|||
return Canvas.cursor_uri;
|
||||
},
|
||||
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);
|
||||
|
||||
if (!Canvas.cursor_uri) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* See README.md for usage and integration instructions.
|
||||
*/
|
||||
"use strict";
|
||||
/*global $, RFB, Canvas, VNC_uri_prefix, Element, Fx */
|
||||
/*global $, Util, RFB, Canvas, VNC_uri_prefix, Element, Fx */
|
||||
|
||||
var DefaultControls = {
|
||||
|
||||
|
@ -14,8 +14,7 @@ settingsOpen : false,
|
|||
|
||||
// Render default controls and initialize settings menu
|
||||
load: function(target) {
|
||||
var url, html, encrypt, cursor, base64, i, sheet, sheets,
|
||||
DC = DefaultControls;
|
||||
var html, i, DC = DefaultControls, sheet, sheets, llevels;
|
||||
|
||||
/* Handle state updates */
|
||||
RFB.setUpdateState(DC.updateState);
|
||||
|
@ -129,7 +128,7 @@ load: function(target) {
|
|||
|
||||
// Read a query string variable
|
||||
getQueryVar: function(name) {
|
||||
var re = new RegExp('[\?].*' + name + '=([^\&\#]*)');
|
||||
var re = new RegExp('[?].*' + name + '=([^&#]*)');
|
||||
return (document.location.href.match(re) || ['',null])[1];
|
||||
},
|
||||
|
||||
|
@ -189,7 +188,7 @@ saveSetting: function(name) {
|
|||
|
||||
// Initial page load read/initialization of settings
|
||||
initSetting: function(name, defVal) {
|
||||
var val, ctrl = $('VNC_' + name), DC = DefaultControls;
|
||||
var val, DC = DefaultControls;
|
||||
|
||||
// Check Query string followed by cookie
|
||||
val = DC.getQueryVar(name);
|
||||
|
@ -256,7 +255,7 @@ settingsDisabled: function(disabled) {
|
|||
// Save/apply settings when 'Apply' button is pressed
|
||||
settingsApply: function() {
|
||||
Util.Debug(">> settingsApply");
|
||||
var curSS, newSS, DC = DefaultControls;
|
||||
var DC = DefaultControls;
|
||||
DC.saveSetting('encrypt');
|
||||
DC.saveSetting('base64');
|
||||
DC.saveSetting('true_color');
|
||||
|
@ -276,7 +275,6 @@ settingsApply: function() {
|
|||
|
||||
|
||||
setPassword: function() {
|
||||
console.log("setPassword");
|
||||
RFB.sendPassword($('VNC_password').value);
|
||||
return false;
|
||||
},
|
||||
|
@ -286,7 +284,7 @@ sendCtrlAltDel: function() {
|
|||
},
|
||||
|
||||
updateState: function(state, msg) {
|
||||
var s, c, klass;
|
||||
var s, sb, c, cad, klass;
|
||||
s = $('VNC_status');
|
||||
sb = $('VNC_status_bar');
|
||||
c = $('VNC_connect_button');
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,7 @@
|
|||
|
||||
"use strict";
|
||||
/*jslint bitwise: false, white: false */
|
||||
/*global window, document, navigator, ActiveXObject*/
|
||||
/*global window, console, document, navigator, ActiveXObject*/
|
||||
|
||||
// Globals defined here
|
||||
var Util = {}, $;
|
||||
|
@ -43,7 +43,7 @@ Util.init_logging = function (level) {
|
|||
default:
|
||||
throw("invalid logging type '" + level + "'");
|
||||
}
|
||||
}
|
||||
};
|
||||
// Initialize logging level
|
||||
Util.init_logging( (document.location.href.match(
|
||||
/logging=([A-Za-z0-9\._\-]*)/) ||
|
||||
|
@ -266,12 +266,15 @@ Util.Flash = (function(){
|
|||
*/
|
||||
// No days means only for this browser session
|
||||
Util.createCookie = function(name,value,days) {
|
||||
var date, expires;
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date = new Date();
|
||||
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=/";
|
||||
};
|
||||
|
||||
|
@ -280,21 +283,21 @@ Util.readCookie = function(name, defaultValue) {
|
|||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
||||
while (c.charAt(0) === ' ') { c = c.substring(1,c.length); }
|
||||
if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length,c.length); }
|
||||
}
|
||||
return (typeof defaultValue !== 'undefined') ? defaultValue : null;
|
||||
};
|
||||
|
||||
Util.eraseCookie = function(name) {
|
||||
createCookie(name,"",-1);
|
||||
Util.createCookie(name,"",-1);
|
||||
};
|
||||
|
||||
/*
|
||||
* Alternate stylesheet selection
|
||||
*/
|
||||
Util.getStylesheets = function() { var i, links, sheets = [];
|
||||
links = document.getElementsByTagName("link")
|
||||
links = document.getElementsByTagName("link");
|
||||
for (i = 0; i < links.length; i++) {
|
||||
if (links[i].title &&
|
||||
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