* adding customizable default size

* Removing useless test.
* Ready to merge upstream
This commit is contained in:
primalmotion
2010-07-24 11:18:22 +02:00
parent 9046dbf244
commit edd9a72c0e
3 changed files with 19 additions and 42 deletions
+5 -13
View File
@@ -11,7 +11,7 @@
/*global window, $, Util, Base64 */
// Globals defined here
var Canvas;
// var Canvas;
// Everything namespaced inside Canvas
Canvas = {
@@ -27,6 +27,8 @@ scale: 1,
c_wx : 0,
c_wy : 0,
ctx : null,
defaut_canvas_w: 800,
defaut_canvas_h: 490,
prevStyle: "",
@@ -239,15 +241,12 @@ start: function (keyPress, mouseButton, mouseMove) {
},
clear: function () {
Canvas.resize(640, 20);
Canvas.resize(RFB.defaut_canvas_w, RFB.defaut_canvas_h);
Canvas.ctx.clearRect(0, 0, Canvas.c_wx, Canvas.c_wy);
},
resize: function (width, height, true_color) {
var c = $(Canvas.id);
if (!c)
return
if (typeof true_color !== "undefined") {
Canvas.true_color = true_color;
@@ -267,11 +266,7 @@ rescale: function (factor) {
properties = ['transform', 'WebkitTransform', 'MozTransform', 'oTransform', null];
origin = ['transformOrigin', 'WebkitTransformOrigin', 'MozTransformOrigin', 'oTransformOrigin', null];
c = $(Canvas.id);
if (!c)
return
c = $(Canvas.id);
x = c.width - c.width * factor;
y = c.height - c.height * factor;
Canvas.scale = factor;
@@ -309,9 +304,6 @@ rescale: function (factor) {
stop: function () {
var c = $(Canvas.id);
if (!c)
return
Util.removeEvent(document, 'keydown', Canvas.onKeyDown);
Util.removeEvent(document, 'keyup', Canvas.onKeyUp);
Util.removeEvent(c, 'mousedown', Canvas.onMouseDown);
+5 -8
View File
@@ -1419,9 +1419,7 @@ updateState: function(state, statusMsg) {
if (Canvas.ctx) {
Canvas.stop();
if (! /__debug__$/i.test(document.location.href)) {
Canvas.clear();
}
Canvas.clear();
}
RFB.show_timings();
@@ -1468,12 +1466,11 @@ updateState: function(state, statusMsg) {
RFB.ws.close();
}
// Make sure we transition to disconnected
setTimeout(function() {
if (RFB.stateinvalid)
return;
setTimeout(function() {
// here we do not invalidate the timer, or we can be stuck in 'normal' mode
RFB.updateState('disconnected');
}, 50);
break;
@@ -1551,13 +1548,13 @@ show_timings: function() {
init_ws: function () {
//Util.Debug(">> init_ws");
var uri = "", vars = [];
if (RFB.encrypt) {
uri = "wss://";
} else {
uri = "ws://";
}
uri += RFB.host + ":" + RFB.port + "/";
if (RFB.b64encode) {
vars.push("b64encode");
+9 -21
View File
@@ -8,7 +8,7 @@
"use strict";
/*jslint bitwise: false, white: false */
/*global window, console, document, navigator, ActiveXObject*/
/*global window, 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,14 +160,6 @@ 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
*/
@@ -275,18 +267,14 @@ 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) {
date = new Date();
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
}
else {
expires = "";
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
};
@@ -295,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) {
Util.createCookie(name,"",-1);
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) {