Merge remote branch 'upstream/master'
Conflicts: include/canvas.js include/default_controls.js include/vnc.js
This commit is contained in:
commit
61bddad2ea
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
"use strict";
|
||||
/*jslint white: false, bitwise: false */
|
||||
/*global window, $, Util */
|
||||
|
||||
Canvas_native = true;
|
||||
/*global window, $, Util, Base64 */
|
||||
|
||||
// Globals defined here
|
||||
var Canvas;
|
||||
|
||||
// Everything namespaced inside Canvas
|
||||
Canvas = {
|
||||
|
|
@ -148,21 +148,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');
|
||||
|
||||
|
|
@ -448,7 +439,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;
|
||||
|
|
@ -475,7 +466,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]]);
|
||||
|
|
@ -624,7 +615,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);
|
||||
|
|
@ -101,18 +100,11 @@ load: function(target) {
|
|||
html += ' onfocus="DefaultControls.canvasBlur();"';
|
||||
html += ' onblur="DefaultControls.canvasFocus();"';
|
||||
html += ' onchange="DefaultControls.clipSend();"></textarea>';
|
||||
html += ' <br>';
|
||||
html += ' <input id="VNC_scale" type="text"';
|
||||
html += ' onfocus="DefaultControls.clipFocus();"';
|
||||
html += ' onblur="DefaultControls.clipBlur();"';
|
||||
html += ' value="1">'
|
||||
html += ' <input id="VNC_scale_button" type="button"';
|
||||
html += ' value="Set scale">';
|
||||
html += '</div>';
|
||||
$(target).innerHTML = html;
|
||||
|
||||
// Settings with immediate effects
|
||||
DC.initSetting('logging', 'default');
|
||||
DC.initSetting('logging', 'warn');
|
||||
Util.init_logging(DC.getSetting('logging'));
|
||||
DC.initSetting('stylesheet', 'default');
|
||||
Util.selectStylesheet(DC.getSetting('stylesheet'));
|
||||
|
|
@ -134,12 +126,6 @@ load: function(target) {
|
|||
};
|
||||
},
|
||||
|
||||
// Read a query string variable
|
||||
getQueryVar: function(name) {
|
||||
var re = new RegExp('[\?].*' + name + '=([^\&\#]*)');
|
||||
return (document.location.href.match(re) || ['',null])[1];
|
||||
},
|
||||
|
||||
// Read form control compatible setting from cookie
|
||||
getSetting: function(name) {
|
||||
var val, ctrl = $('VNC_' + name);
|
||||
|
|
@ -196,14 +182,14 @@ saveSetting: function(name) {
|
|||
|
||||
// Initial page load read/initialization of settings
|
||||
initSetting: function(name, defVal) {
|
||||
var val, ctrl = $('VNC_' + name), DC = DefaultControls;
|
||||
var val;
|
||||
|
||||
// Check Query string followed by cookie
|
||||
val = DC.getQueryVar(name);
|
||||
val = Util.getQueryVar(name);
|
||||
if (val === null) {
|
||||
val = Util.readCookie(name, defVal);
|
||||
}
|
||||
DC.updateSetting(name, val);
|
||||
DefaultControls.updateSetting(name, val);
|
||||
Util.Debug("Setting '" + name + "' initialized to '" + val + "'");
|
||||
return val;
|
||||
},
|
||||
|
|
@ -214,7 +200,7 @@ initSetting: function(name, defVal) {
|
|||
// On close, settings are applied
|
||||
clickSettingsMenu: function() {
|
||||
var DC = DefaultControls;
|
||||
if (DefaultControls.settingsOpen) {
|
||||
if (DC.settingsOpen) {
|
||||
DC.settingsApply();
|
||||
|
||||
DC.closeSettingsMenu();
|
||||
|
|
@ -225,7 +211,7 @@ clickSettingsMenu: function() {
|
|||
if (Canvas.isCursor()) {
|
||||
DC.updateSetting('cursor');
|
||||
} else {
|
||||
DC.updateSettings('cursor', false);
|
||||
DC.updateSetting('cursor', false);
|
||||
$('VNC_cursor').disabled = true;
|
||||
}
|
||||
DC.updateSetting('stylesheet');
|
||||
|
|
@ -255,7 +241,7 @@ settingsDisabled: function(disabled) {
|
|||
if (Canvas.isCursor()) {
|
||||
$('VNC_cursor').disabled = disabled;
|
||||
} else {
|
||||
DefaultControls.updateSettings('cursor', false);
|
||||
DefaultControls.updateSetting('cursor', false);
|
||||
$('VNC_cursor').disabled = true;
|
||||
}
|
||||
},
|
||||
|
|
@ -263,7 +249,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');
|
||||
|
|
@ -283,7 +269,6 @@ settingsApply: function() {
|
|||
|
||||
|
||||
setPassword: function() {
|
||||
console.log("setPassword");
|
||||
RFB.sendPassword($('VNC_password').value);
|
||||
return false;
|
||||
},
|
||||
|
|
@ -293,13 +278,10 @@ sendCtrlAltDel: function() {
|
|||
},
|
||||
|
||||
updateState: function(state, msg) {
|
||||
var s, c, z, klass;
|
||||
var s, sb, c, cad, klass;
|
||||
s = $('VNC_status');
|
||||
sb = $('VNC_status_bar');
|
||||
c = $('VNC_connect_button');
|
||||
z = $('VNC_scale');
|
||||
zb = $('VNC_scale_button');
|
||||
|
||||
cad = $('sendCtrlAltDelButton');
|
||||
switch (state) {
|
||||
case 'failed':
|
||||
|
|
@ -312,12 +294,10 @@ updateState: function(state, msg) {
|
|||
case 'normal':
|
||||
c.value = "Disconnect";
|
||||
c.onclick = DefaultControls.disconnect;
|
||||
zb.onclick = DefaultControls.setScale;
|
||||
c.disabled = false;
|
||||
cad.disabled = false;
|
||||
DefaultControls.settingsDisabled(true);
|
||||
klass = "VNC_status_normal";
|
||||
|
||||
break;
|
||||
case 'disconnected':
|
||||
case 'loaded':
|
||||
|
|
@ -404,12 +384,6 @@ clipSend: function() {
|
|||
Util.Debug(">> DefaultControls.clipSend: " + text.substr(0,40) + "...");
|
||||
RFB.clipboardPasteFrom(text);
|
||||
Util.Debug("<< DefaultControls.clipSend");
|
||||
},
|
||||
|
||||
|
||||
setScale: function() {
|
||||
var scaleFactor = parseFloat($('VNC_scale').value);
|
||||
Canvas.rescale(scaleFactor);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
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
|
||||
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\._\-]*)/) ||
|
||||
|
|
@ -160,6 +160,14 @@ Util.dirObj = function (obj, depth, parent) {
|
|||
return msg;
|
||||
};
|
||||
|
||||
// Read a query string variable
|
||||
Util.getQueryVar = function(name, defVal) {
|
||||
var re = new RegExp('[?][^#]*' + name + '=([^&#]*)');
|
||||
if (typeof defVal === 'undefined') { defVal = null; }
|
||||
return (document.location.href.match(re) || ['',defVal])[1];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Cross-browser routines
|
||||
*/
|
||||
|
|
@ -267,14 +275,18 @@ Util.Flash = (function(){
|
|||
/*
|
||||
* Cookie handling. Dervied from: http://www.quirksmode.org/js/cookies.html
|
||||
*/
|
||||
|
||||
// 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=/";
|
||||
};
|
||||
|
||||
|
|
@ -283,21 +295,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) {
|
||||
|
|
|
|||
1604
include/vnc.js
1604
include/vnc.js
File diff suppressed because it is too large
Load Diff
|
|
@ -41,6 +41,7 @@ Connect parameters are provided in query string:
|
|||
}
|
||||
function sendCtrlAltDel() {
|
||||
RFB.sendCtrlAltDel();
|
||||
return false;
|
||||
}
|
||||
function updateState(state, msg) {
|
||||
var s, sb, klass, html;
|
||||
|
|
@ -82,20 +83,19 @@ Connect parameters are provided in query string:
|
|||
window.onload = function () {
|
||||
var host, port, password;
|
||||
|
||||
url = document.location.href;
|
||||
host = (url.match(/host=([A-Za-z0-9.\-]*)/) || ['',''])[1];
|
||||
port = (url.match(/port=([0-9]*)/) || ['',''])[1];
|
||||
password = (url.match(/password=([^&#]*)/) || ['',''])[1];
|
||||
host = Util.getQueryVar('host', null);
|
||||
port = Util.getQueryVar('port', null);
|
||||
password = Util.getQueryVar('password', '');
|
||||
if ((!host) || (!port)) {
|
||||
updateState('failed',
|
||||
"Must specify host and port in URL");
|
||||
return;
|
||||
}
|
||||
|
||||
RFB.setEncrypt((url.match(/encrypt=([A-Za-z0-9]*)/) || ['',1])[1]);
|
||||
RFB.setBase64((url.match(/base64=([A-Za-z0-9]*)/) || ['',1])[1]);
|
||||
RFB.setTrueColor((url.match(/true_color=([A-Za-z0-9]*)/) || ['',1])[1]);
|
||||
RFB.setCursor((url.match(/cursor=([A-Za-z0-9]*)/) || ['',true])[1]);
|
||||
RFB.setEncrypt(Util.getQueryVar('encrypt', true));
|
||||
RFB.setBase64(Util.getQueryVar('base64', true));
|
||||
RFB.setTrueColor(Util.getQueryVar('true_color', true));
|
||||
RFB.setCursor(Util.getQueryVar('cursor', true));
|
||||
RFB.setUpdateState(updateState);
|
||||
|
||||
RFB.load();
|
||||
|
|
|
|||
Loading…
Reference in New Issue