Commit be5ca923 authored by Luc Renambot's avatar Luc Renambot

Added the file SAGE2_runtime for global client-side functions

Added 'log' method in application for message logging sent to server
Fix layer issue with resize corner element


Former-commit-id: 0b90a3b4e92fee90a64c5ac9d7ba6e4364ca5e6f
parent 0bb1b20a
{
"name": "webSAGE",
"version": "0.1.0",
"private": true,
"description": "A cluster-based html viewer used for displaying elements across multiple browser windows",
"keywords": [
"SAGE",
"browser",
"collaboration"
],
"author": "UIC EVL <evl.avatar@gmail.com>",
"contributors": [
{
"name": "Thomas Marrinan",
"email": "thomas.j.marrinan@gmail.com"
},
{
"name": "Jillian Aurisano",
"email": "jillian.aurisano@gmail.com"
},
{
"name": "Arthur Nishimoto",
"email": "arthur.nishimoto@gmail.com"
},
{
"name": "Victor Mateevitsi",
"email": "mvictoras@gmail.com"
},
{
"name": "Krishna Bharadwaj",
"email": "krishnaknbharadwaj@gmail.com"
},
{
"name": "Luc Renambot",
"email": "renambot@gmail.com"
}
],
"repository": {
"type": "git",
"url": "https://github.com/uic-evl/SAGE2"
},
"dependencies": {
"decompress-zip": "latest",
"gm": "latest",
"imageinfo": "latest",
"json5": "latest",
"mime": "latest",
"multiparty": "latest",
"node-ffprobe": "latest",
"request": "latest",
"ws": "latest",
"ytdl": "latest",
"jshint": "latest",
"jslint": "latest"
},
"bundledDependencies": [],
"devDependencies": {},
"engines": {
"node": ">=0.6.x"
},
"scripts": {
"start": "node server.js",
"lint": "./node_modules/jslint/bin/jslint.js server.js",
"hint": "./node_modules/jshint/bin/jshint --verbose server.js node_modules/node-*.js"
},
"license": "BSD-3-Clause"
"name": "webSAGE",
"version": "0.1.0",
"private": true,
"description": "A cluster-based html viewer used for displaying elements across multiple browser windows",
"keywords": [
"SAGE",
"browser",
"collaboration"
],
"author": "UIC EVL <evl.avatar@gmail.com>",
"contributors": [
{
"name": "Thomas Marrinan",
"email": "thomas.j.marrinan@gmail.com"
},
{
"name": "Jillian Aurisano",
"email": "jillian.aurisano@gmail.com"
},
{
"name": "Arthur Nishimoto",
"email": "arthur.nishimoto@gmail.com"
},
{
"name": "Victor Mateevitsi",
"email": "mvictoras@gmail.com"
},
{
"name": "Krishna Bharadwaj",
"email": "krishnaknbharadwaj@gmail.com"
},
{
"name": "Luc Renambot",
"email": "renambot@gmail.com"
}
],
"repository": {
"type": "git",
"url": "https://github.com/uic-evl/SAGE2"
},
"dependencies": {
"decompress-zip": "latest",
"gm": "latest",
"imageinfo": "latest",
"json5": "latest",
"mime": "latest",
"multiparty": "latest",
"node-ffprobe": "latest",
"request": "latest",
"ws": "latest",
"ytdl": "latest",
"jshint": "latest",
"jslint": "latest",
"sprint": "^0.3.1"
},
"bundledDependencies": [],
"devDependencies": {},
"engines": {
"node": ">=0.10.x"
},
"scripts": {
"start": "node server.js",
"lint": "./node_modules/jslint/bin/jslint.js server.js",
"hint": "./node_modules/jshint/bin/jshint --verbose server.js node_modules/node-*.js"
},
"license": "BSD-3-Clause"
}
......@@ -19,6 +19,7 @@
<script type="text/javascript" src="lib/websocket.io.js"></script>
<script type="text/javascript" src="lib/Class.js"></script>
<script type="text/javascript" src="lib/SAGE2_App.js"></script>
<script type="text/javascript" src="lib/SAGE2_runtime.js"></script>
<script type="text/javascript" src="lib/image_viewer.js"></script>
<script type="text/javascript" src="lib/movie_player.js"></script>
<script type="text/javascript" src="lib/pdf_viewer.js"></script>
......@@ -64,7 +65,7 @@
function init() {
hostname = window.location.hostname;
port = window.location.port;
if(window.location.protocol == "http:" && port == "") port = "80";
if(window.location.protocol == "http:" && port == "") port = "80";
if(window.location.protocol == "https:" && port == "") port = "443";
clientID = parseInt(getParameterByName("clientID"));
......@@ -116,13 +117,14 @@
});
wsio.on('initialize', function(data) {
var startTime = new Date(data.start);
var startTime = new Date(data.start);
var serverTime = new Date(data.time);
var clientTime = new Date();
dt = clientTime - serverTime;
Math.seed(startTime.getTime());
// Global initialization
SAGE2_initialize(startTime);
});
wsio.on('setupDisplayConfiguration', function(json_cfg) {
......@@ -347,7 +349,6 @@
var i;
function loadApplication() {
// load new app
console.log(window[data.application]);
if(window[data.application] === undefined) {
var js = document.createElement("script");
js.addEventListener('error', function(event) {
......@@ -414,6 +415,7 @@
dragCorner.style.left = (data.width-cornerSize).toString() + "px";
dragCorner.style.backgroundColor = "rgba(255,255,255,0.0)";
dragCorner.style.border = "none";
dragCorner.style.zIndex = "1";
windowItem.appendChild(dragCorner);
itemCount += 2;
......@@ -602,107 +604,6 @@
*/
});
}
function playPauseVideo(elemId) {
var videoElem = document.getElementById(elemId + "_video");
if(videoElem.paused == true){ videoElem.play(); console.log("play"); }
else{ videoElem.pause(); console.log("pause"); }
}
function moveItemToFront(elem) {
var last = elem.parentNode.lastChild;
if(elem != last){
elem.parentNode.replaceChild(elem, last);
elem.parentNode.insertBefore(last, elem);
}
}
function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? "pm" : "am";
hours = hours % 12;
if(hours == 0) hours = 12;
var hh = hours.toString();
var mm = minutes < 10 ? "0"+minutes.toString() : minutes.toString();
return (hh + ":" + mm + ampm);
}
function format24Hr(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var hh = hours.toString();
var mm = minutes < 10 ? "0"+minutes.toString() : minutes.toString();
return (hh + ":" + mm);
}
function base64ToString(base64) {
//return decodeURIComponent(escape(atob(base64)));
return atob(base64);
}
function stringToBase64(string) {
//return btoa(unescape(encodeURIComponent(string)));
return btoa(string);
}
function stringToUint8Array(string) {
var uint8Array = new Uint8Array(new ArrayBuffer(string.length));
for (var i = 0; i < string.length; i++) {
uint8Array[i] = string.charCodeAt(i);
}
return uint8Array;
}
function base64ToUint8Array(base64) {
var raw = atob(base64); //This is a native function that decodes a base64-encoded string.
var uint8Array = new Uint8Array(new ArrayBuffer(raw.length));
for (var i = 0; i < raw.length; i++) {
uint8Array[i] = raw.charCodeAt(i);
}
return uint8Array;
}
function average(arr) {
var l = arr.length;
if(l == 0) return 0;
var sum = 0;
for(var i=0; i<l; i++){
sum += arr[i];
}
return sum / l;
}
function allTrueDict(dict) {
var key;
for(key in dict){
if(dict[key] !== true) return false;
}
return true;
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
Math.seed = function(s) {
Math.random = function() {
// POSIX drand48 ==> Xn+1 = (a*Xn+c) % m
var a = 25214903917;
var c = 11;
var m = 281474976710656;
s = (a*s+c) % m;
return s / m;
//s = Math.sin(s) * 10000; return s - Math.floor(s);
}
};
</script>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
......
......@@ -10,42 +10,43 @@
var SAGE2_App = Class.extend( {
construct: function() {
this.div = null;
this.element = null;
this.resrcPath = null;
this.div = null;
this.element = null;
this.resrcPath = null;
this.resizeEvents = "never";
this.startDate = null;
this.prevDate = null;
this.prevDate = null;
this.t = null;
this.dt = null;
this.t = null;
this.dt = null;
this.frame = null;
},
init: function(id, elem, width, height, resrc, date) {
this.div = document.getElementById(id);
this.div = document.getElementById(id);
this.element = document.createElement(elem);
this.element.className = "sageItem";
if (elem === "div") {
this.element.style.width = width + "px";
this.element.style.height = height + "px";
} else {
this.element.width = width;
this.element.height = height;
}
this.element.style.zIndex = "0";
if (elem === "div") {
this.element.style.width = width + "px";
this.element.style.height = height + "px";
} else {
this.element.width = width;
this.element.height = height;
}
this.div.appendChild(this.element);
console.log("created " + elem);
console.log(this.element);
//console.log("created " + elem);
//console.log(this.element);
this.resrcPath = resrc + "/";
this.startDate = date;
this.prevDate = date;
this.frame = 0;
this.prevDate = date;
this.frame = 0;
},
preDraw: function(date) {
this.t = (date.getTime() - this.startDate.getTime()) / 1000; // total time since start of program (sec)
this.t = (date.getTime() - this.startDate.getTime()) / 1000; // total time since start of program (sec)
this.dt = (date.getTime() - this.prevDate.getTime()) / 1000; // delta time since last frame (sec)
},
......@@ -53,6 +54,12 @@ var SAGE2_App = Class.extend( {
this.prevDate = date;
this.frame++;
},
// Prints message to local browser console and send to server
// accept a string as parameter: this.log("my message")
log: function(msg) {
sage2Log({app: this.div.id, message: msg});
},
});
......@@ -38,6 +38,7 @@ var modest = SAGE2_App.extend( {
var london = new MM.Location(51.5001524, -0.1262362);
var sf = new MM.Location(37.7749295, -122.4194155);
this.map.setCenterZoom(sf, 14);
this.log("Modest map at " + JSON.stringify(sf));
},
load: function(state, date) {
......
......@@ -38,6 +38,7 @@ var multiparty = require('multiparty'); // parses POST forms
var os = require('os'); // operating system access
var path = require('path'); // file path extraction and creation
var request = require('request'); // external http requests
var sprint = require('sprint'); // pretty formating (sprintf)
// custom node modules
var httpserver = require('node-httpserver'); // creates web server
......@@ -248,6 +249,9 @@ function initializeWSClient(wsio) {
}
if(wsio.clientType == "webBrowser") webBrowserClient = wsio;
// Debug messages from applications
wsio.on('sage2Log', wsPrintDebugInfo);
}
function initializeExistingSagePointers(wsio) {
......@@ -550,6 +554,10 @@ function wsStopMediaStream(wsio, data) {
if(elem !== null) deleteApplication( elem );
}
// Print message from remote applications
function wsPrintDebugInfo(wsio, data) {
console.log(sprint("Node %2d> [%s] %s", data.node, data.app, data.message));
}
function wsReceivedMediaStreamFrame(wsio, data) {
var uniqueID = wsio.remoteAddress.address + ":" + wsio.remoteAddress.port;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment