Compare commits

...

18 Commits

Author SHA1 Message Date
primalmotion 11f3271a52 * take care of kanaka's suggestions 2010-08-04 18:10:36 +02:00
primalmotion 8ded53c1de * Adding a way to set the DOM document to use.
This is very usefull when you need to open a new window (with a new document) from javascript,
without having to reload the script.js.
2010-08-04 17:47:08 +02:00
primalmotion 434699bf23 * Port to be Cappuccino compatible (need to use GLOBAL() in fiture)
* Reverting to my zoom method
2010-08-03 13:52:56 +02:00
primalmotion 5e5d81dd86 Merge remote branch 'upstream/master'
Conflicts:
	include/canvas.js
	include/rfb.js
	include/util.js
	vnc.html
2010-08-03 10:11:03 +02:00
primalmotion f8f5c923dd * removing auto stylesheet loading 2010-07-29 18:04:24 +02:00
primalmotion 93c860e8e5 * removing the automatic init_logging based on page location 2010-07-29 17:59:56 +02:00
primalmotion 78223532ce * adding a 'none' logging level and setit by default 2010-07-29 17:55:33 +02:00
primalmotion 9fc59562a1 * removing use strict
* apply kanaka's patch for letting other events to have a chance to run when RFB is heavy loaded
2010-07-29 13:52:56 +02:00
primalmotion 045c117dbb Merge remote branch 'upstream/master' 2010-07-29 11:21:21 +02:00
primalmotion eb7b25ae17 Merge remote branch 'upstream/master' 2010-07-24 11:23:40 +02:00
primalmotion edd9a72c0e * adding customizable default size
* Removing useless test.
* Ready to merge upstream
2010-07-24 11:18:22 +02:00
primalmotion 9046dbf244 * add a method to invalidate all timers if necessary (usefull for Cappuccino dynamic loading of DOM object) 2010-07-22 23:53:57 +02:00
primalmotion 5c7418cf36 * Removing useless functions since last kanaka's update 2010-07-22 20:38:20 +02:00
primalmotion 61bddad2ea Merge remote branch 'upstream/master'
Conflicts:
	include/canvas.js
	include/default_controls.js
	include/vnc.js
2010-07-22 20:29:21 +02:00
primalmotion 30a532d38c * conflict resolution 2010-07-22 14:28:37 +02:00
primalmotion 212733afbf * check if Canvas still exists before resizing and dettaching events 2010-07-22 12:46:54 +02:00
Antoine Mercadal 33ebb52b56 * removing init.js and add loadExtras() to RFB namespace 2010-07-22 10:51:08 +02:00
Antoine Mercadal ed5573e806 * Use zoom if present to avoid layout problem with scale
* Create a init.js file that does initialization if wanted (with Cappuccino we do not want to)
* Update the demo files
2010-07-21 18:32:50 +02:00
6 changed files with 64 additions and 49 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.pyc
*.o
wsproxy
*.DS_Store

View File

@ -6,11 +6,11 @@
* See README.md for usage and integration instructions.
*/
"use strict";
//"use strict";
/*jslint browser: true, white: false, bitwise: false */
/*global window, Util, Base64 */
function Canvas(conf) {
Canvas = function(conf) {
conf = conf || {}; // Configuration
var that = {}, // Public API interface
@ -41,6 +41,7 @@ Util.conf_default(conf, that, 'true_color', true);
Util.conf_default(conf, that, 'focused', true);
Util.conf_default(conf, that, 'colourMap', []);
Util.conf_default(conf, that, 'scale', 1);
Util.conf_default(conf, that, 'focusContainer', document);
// Override some specific getters/setters
that.set_prefer_js = function(val) {
@ -76,8 +77,6 @@ that.get_height = function() {
return c_height;
};
//
// Private functions
//
@ -386,8 +385,8 @@ that.start = function(keyPressFunc, mouseButtonFunc, mouseMoveFunc) {
c_mouseButton = mouseButtonFunc || null;
c_mouseMove = mouseMoveFunc || null;
Util.addEvent(document, 'keydown', onKeyDown);
Util.addEvent(document, 'keyup', onKeyUp);
Util.addEvent(conf.focusContainer, 'keydown', onKeyDown);
Util.addEvent(conf.focusContainer, 'keyup', onKeyUp);
Util.addEvent(c, 'mousedown', onMouseDown);
Util.addEvent(c, 'mouseup', onMouseUp);
Util.addEvent(c, 'mousemove', onMouseMove);
@ -395,38 +394,52 @@ that.start = function(keyPressFunc, mouseButtonFunc, mouseMoveFunc) {
onMouseWheel);
/* Work around right and middle click browser behaviors */
Util.addEvent(document, 'click', onMouseDisable);
Util.addEvent(document.body, 'contextmenu', onMouseDisable);
Util.addEvent(conf.focusContainer, 'click', onMouseDisable);
Util.addEvent(conf.focusContainer.body, 'contextmenu', onMouseDisable);
Util.Debug("<< Canvas.start");
};
that.rescale = function(factor) {
var c, tp, x, y,
properties = ['transform', 'WebkitTransform', 'MozTransform', null];
properties = ['transform', 'WebkitTransform', 'MozTransform', 'oTransform', null],
origin = ['transformOrigin', 'WebkitTransformOrigin', 'MozTransformOrigin', 'oTransformOrigin', null];
if (conf.scale === factor) {
return;
}
c = conf.target;
tp = properties.shift();
while (tp) {
if (typeof c.style[tp] !== 'undefined') {
conf.scale = factor;
x = c.width - c.width * factor;
y = c.height - c.height * factor;
//tp = properties.shift();
if (typeof(c.style.zoom) != "undefined") {
c.style.zoom = conf.scale;
return
}
while (tp = properties.shift()) {
if (typeof c.style[tp] != 'undefined') {
break;
}
tp = properties.shift();
}
while (tpo = origin.shift()) {
if (typeof c.style[tpo] != 'undefined') {
break;
}
}
if (tp === null) {
Util.Debug("No scaling support");
return;
}
if (conf.scale === factor) {
//Util.Debug("Canvas already scaled to '" + factor + "'");
return;
}
conf.scale = factor;
x = c.width - c.width * factor;
y = c.height - c.height * factor;
c.style[tp] = "scale(" + conf.scale + ") translate(-" + x + "px, -" + y + "px)";
c.style[tpo] = "top left";
c.style[tp] = "scale(" + conf.scale + ")";
};
that.resize = function(width, height, true_color) {
@ -452,8 +465,8 @@ that.clear = function() {
that.stop = function() {
var c = conf.target;
Util.removeEvent(document, 'keydown', onKeyDown);
Util.removeEvent(document, 'keyup', onKeyUp);
Util.removeEvent(conf.focusContainer, 'keydown', onKeyDown);
Util.removeEvent(conf.focusContainer, 'keyup', onKeyUp);
Util.removeEvent(c, 'mousedown', onMouseDown);
Util.removeEvent(c, 'mouseup', onMouseUp);
Util.removeEvent(c, 'mousemove', onMouseMove);
@ -461,8 +474,8 @@ that.stop = function() {
onMouseWheel);
/* Work around right and middle click browser behaviors */
Util.removeEvent(document, 'click', onMouseDisable);
Util.removeEvent(document.body, 'contextmenu', onMouseDisable);
Util.removeEvent(conf.focusContainer, 'click', onMouseDisable);
Util.removeEvent(conf.focusContainer.body, 'contextmenu', onMouseDisable);
// Turn off cursor rendering
if (conf.cursor_uri) {

View File

@ -6,13 +6,12 @@
* See README.md for usage and integration instructions.
*/
"use strict";
//"use strict";
/*jslint white: false, browser: true, bitwise: false */
/*global window, WebSocket, Util, Canvas, VNC_native_ws, Base64, DES */
function RFB(conf) {
RFB = function(conf) {
conf = conf || {}; // Configuration
var that = {}, // Public API interface
@ -140,6 +139,8 @@ Util.conf_default(conf, that, 'true_color', true, true);
Util.conf_default(conf, that, 'b64encode', true, true);
Util.conf_default(conf, that, 'local_cursor', true, true);
Util.conf_default(conf, that, 'focusContainer', document);
// time to wait for connection
Util.conf_default(conf, that, 'connectTimeout', 2000);
// frequency to check for send/receive
@ -195,7 +196,7 @@ function constructor() {
}
// Initialize canvas
try {
canvas = new Canvas({'target': conf.target});
canvas = new Canvas({'target': conf.target, 'focusContainer': conf.focusContainer});
} catch (exc) {
Util.Error("Canvas exception: " + exc);
updateState('fatal', "No working Canvas");

View File

@ -8,10 +8,10 @@
"use strict";
/*jslint bitwise: false, white: false */
/*global window, console, document, navigator, ActiveXObject*/
/*global window, document, navigator, ActiveXObject*/
// Globals defined here
var Util = {}, $;
Util = {};
/*
@ -303,18 +303,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=/";
};
@ -329,7 +325,7 @@ Util.readCookie = function(name, defaultValue) {
};
Util.eraseCookie = function(name) {
Util.createCookie(name,"",-1);
createCookie(name,"",-1);
};
/*

View File

@ -13,16 +13,19 @@
var VNC_native_ws, WebSocket__swfLocation;
/*
* Load supporting scripts
* RFB namespace
*/
function get_VNC_uri_prefix() {
return (typeof VNC_uri_prefix !== "undefined") ? VNC_uri_prefix : "include/";
}
(function () {
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='" + get_VNC_uri_prefix();
start = "<script src='" + RFB.get_VNC_uri_prefix();
end = "'><\/script>";
// Uncomment to activate firebug lite
@ -47,5 +50,5 @@ function get_VNC_uri_prefix() {
extra += start + "web-socket-js/web_socket.js" + end;
}
document.write(extra);
}());
},

View File

@ -12,6 +12,7 @@ Connect parameters are provided in query string:
<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>
</head>