Logging verbose by class

This commit is contained in:
s1341 2013-12-24 19:30:46 +02:00
parent 321aa05eab
commit 39dc8622e6
2 changed files with 81 additions and 54 deletions

View file

@ -137,6 +137,7 @@ $.Class("Revision",
$.Class("RevisionCache", $.Class("RevisionCache",
{ {
VERBOSE: false,
}, },
{//instance {//instance
/** /**
@ -146,6 +147,7 @@ $.Class("RevisionCache",
* @param {number} head_revnum - The current head revision number. TODO: we can probably do away with this now. * @param {number} head_revnum - The current head revision number. TODO: we can probably do away with this now.
*/ */
init: function (connection, head_revnum) { init: function (connection, head_revnum) {
this.log = RevisionCache.VERBOSE ? console.log : function () {};
this.connection = connection; this.connection = connection;
this.loader = new ChangesetLoader(connection); this.loader = new ChangesetLoader(connection);
this.revisions = {}; this.revisions = {};
@ -233,14 +235,14 @@ $.Class("RevisionCache",
var direction = (to.revnum - from.revnum) < 0; var direction = (to.revnum - from.revnum) < 0;
var granularity = 0; var granularity = 0;
//console.log("[findpath] from: %d, to: %d", from.revnum, to.revnum); //log("[findpath] from: %d, to: %d", from.revnum, to.revnum);
while (current.lt(to, direction) && !found_discontinuity) { while (current.lt(to, direction) && !found_discontinuity) {
//console.log("\t[findPath] while current: ", current.revnum); //log("\t[findPath] while current: ", current.revnum);
var delta_revnum = to.revnum - current.revnum; var delta_revnum = to.revnum - current.revnum;
var direction_edges = direction ? current.previous : current.next; var direction_edges = direction ? current.previous : current.next;
for (granularity in Revision.granularities) { for (granularity in Revision.granularities) {
if (Math.abs(delta_revnum) >= Revision.granularities[granularity]) { if (Math.abs(delta_revnum) >= Revision.granularities[granularity]) {
//console.log("\t\t[findPath] for delta: %d, granularity: %d", delta_revnum, Revision.granularities[granularity]); //log("\t\t[findPath] for delta: %d, granularity: %d", delta_revnum, Revision.granularities[granularity]);
/* /*
* the delta is larger than the granularity, let's use the granularity * the delta is larger than the granularity, let's use the granularity
*TODO: what happens if we DON'T have the edge? *TODO: what happens if we DON'T have the edge?
@ -250,7 +252,7 @@ $.Class("RevisionCache",
* from current to that Revision (at the largest possible granularity) * from current to that Revision (at the largest possible granularity)
*/ */
var edge = direction_edges[granularity]; var edge = direction_edges[granularity];
//console.log("\t\t[findpath] edge:", edge); //log("\t\t[findpath] edge:", edge);
if (edge) { if (edge) {
// add this edge to our path // add this edge to our path
path.push(edge); path.push(edge);
@ -270,7 +272,7 @@ $.Class("RevisionCache",
} }
} }
//console.log("[findpath] ------------------"); //log("[findpath] ------------------");
// return either a full path, or a path ending as close as we can get to // return either a full path, or a path ending as close as we can get to
// the target revision. // the target revision.
return {path: path, end_revision: current, granularity: granularity}; return {path: path, end_revision: current, granularity: granularity};
@ -293,25 +295,25 @@ $.Class("RevisionCache",
var _this = this; var _this = this;
function partialTransition (current_revnum) { function partialTransition (current_revnum) {
console.log("from: %d, to: %d, current: %d", from_revnum, to_revnum, current_revnum); //log("from: %d, to: %d, current: %d", from_revnum, to_revnum, current_revnum);
var res = _this.findPath(_this.getRevision(from_revnum), target_revision); var res = _this.findPath(_this.getRevision(from_revnum), target_revision);
console.log("find: ", print_path(res.path)); //log("find: ", print_path(res.path));
if (res.end_revision == target_revision) { if (res.end_revision == target_revision) {
console.log("found: ", print_path(res.path)); //log("found: ", print_path(res.path));
if(applyChangeset_callback) { if(applyChangeset_callback) {
applyChangeset_callback(res.path); applyChangeset_callback(res.path);
} }
return; return;
} }
else { else {
console.log("end: %d, target: %d", res.end_revision.revnum, target_revision.revnum); //log("end: %d, target: %d", res.end_revision.revnum, target_revision.revnum);
} }
// we don't yet have all the changesets we need. Let's try to // we don't yet have all the changesets we need. Let's try to
// build a path from the current revision (the start of the range // build a path from the current revision (the start of the range
// in the response) to the target. // in the response) to the target.
res = _this.findPath(_this.getRevision(current_revnum), target_revision); res = _this.findPath(_this.getRevision(current_revnum), target_revision);
console.log(print_path(res.path)); //log(print_path(res.path));
// we can now request changesets from the end of that partial path // we can now request changesets from the end of that partial path
// to the target: // to the target:
_this.requestChangesets(res.end_revision, target_revision, partialTransition); _this.requestChangesets(res.end_revision, target_revision, partialTransition);
@ -330,7 +332,7 @@ $.Class("RevisionCache",
* received and processed (added to the graph) * received and processed (added to the graph)
*/ */
requestChangesets: function (from, to, changesetsProcessed_callback) { requestChangesets: function (from, to, changesetsProcessed_callback) {
console.log("[revisioncache] requestChangesets: %d -> %d", from.revnum, to.revnum); this.log("[revisioncache] requestChangesets: %d -> %d", from.revnum, to.revnum);
var delta = to.revnum - from.revnum; var delta = to.revnum - from.revnum;
var sign = delta > 0 ? 1 : -1; var sign = delta > 0 ? 1 : -1;
var start = delta > 0 ? from.revnum : to.revnum; var start = delta > 0 ? from.revnum : to.revnum;
@ -339,7 +341,7 @@ $.Class("RevisionCache",
var _this = this; var _this = this;
function process_received_changesets (data) { function process_received_changesets (data) {
//console.log("[revisioncache] received changesets {from: %d, to: %d} @ granularity: %d", data.start, data.actualEndNum, data.granularity); //log("[revisioncache] received changesets {from: %d, to: %d} @ granularity: %d", data.start, data.actualEndNum, data.granularity);
var start = data.start; var start = data.start;
for (var i = 0; i < data.timeDeltas.length; i++, start += data.granularity) { for (var i = 0; i < data.timeDeltas.length; i++, start += data.granularity) {
_this.addChangesetPair(start, start + data.granularity, data.forwardsChangesets[i], data.backwardsChangesets[i], data.timeDeltas[i]); _this.addChangesetPair(start, start + data.granularity, data.forwardsChangesets[i], data.backwardsChangesets[i], data.timeDeltas[i]);
@ -354,22 +356,22 @@ $.Class("RevisionCache",
var roundup = function (a, b) { var roundup = function (a, b) {
return (Math.floor(a / b)+1) * b; return (Math.floor(a / b)+1) * b;
}; };
//console.log("[requestChangesets] start: %d, end: %d, delta: %d, adelta: %d", start, end, delta, adelta); //log("[requestChangesets] start: %d, end: %d, delta: %d, adelta: %d", start, end, delta, adelta);
for (var g in Revision.granularities) { for (var g in Revision.granularities) {
var granularity = Revision.granularities[g]; var granularity = Revision.granularities[g];
var remainder = Math.floor(adelta / granularity); var remainder = Math.floor(adelta / granularity);
//console.log("\t[requestChangesets] start: %d, granularity: %d, adelta: %d, //: %d", start, granularity, adelta, remainder); //log("\t[requestChangesets] start: %d, granularity: %d, adelta: %d, //: %d", start, granularity, adelta, remainder);
//console.log("\t rounddown delta: %d, start: %d", rounddown(adelta, granularity), rounddown(start, granularity)); //log("\t rounddown delta: %d, start: %d", rounddown(adelta, granularity), rounddown(start, granularity));
if (remainder) { if (remainder) {
//this.loader.enqueue(start, granularity, process_received_changesets); //this.loader.enqueue(start, granularity, process_received_changesets);
//console.log("\t[requestChangesets] REQUEST start: %d, end: %d, granularity: %d", rounddown(start, granularity), roundup(adelta, granularity), granularity); //log("\t[requestChangesets] REQUEST start: %d, end: %d, granularity: %d", rounddown(start, granularity), roundup(adelta, granularity), granularity);
this.loader.enqueue(rounddown(start, granularity), granularity, process_received_changesets); this.loader.enqueue(rounddown(start, granularity), granularity, process_received_changesets);
// for the next granularity, we assume that we have now successfully navigated // for the next granularity, we assume that we have now successfully navigated
// as far as required for this granularity. We should also make sure that only // as far as required for this granularity. We should also make sure that only
// the significant part of the adelta is used in the next granularity. // the significant part of the adelta is used in the next granularity.
start = rounddown(start, granularity) + rounddown(adelta, granularity); start = rounddown(start, granularity) + rounddown(adelta, granularity);
adelta = adelta - rounddown(adelta, granularity); adelta = adelta - rounddown(adelta, granularity);
//console.log("\t new start: %d, delta: %d", start, adelta); //log("\t new start: %d, delta: %d", start, adelta);
} }
} }
}, },
@ -378,6 +380,7 @@ $.Class("RevisionCache",
$.Class("Thread", $.Class("Thread",
{//statics {//statics
VERBOSE: true
}, },
{//instance {//instance
init: function (interval) { init: function (interval) {
@ -385,17 +388,18 @@ $.Class("Thread",
this._is_stopping = false; this._is_stopping = false;
this._interval_id = null; this._interval_id = null;
this._interval = interval ? interval : 1000; this._interval = interval ? interval : 1000;
this.log = Thread.VERBOSE ? console.log : function () {};
}, },
_run: function () { _run: function () {
console.log("[thread] tick"); this.log("[thread] tick");
}, },
// start the run loop // start the run loop
start: function () { start: function () {
var _this = this; var _this = this;
console.log("[thread] starting"); this.log("[thread] starting");
var wrapper = function () { var wrapper = function () {
if (_this._is_running && _this._is_stopping) { if (_this._is_running && _this._is_stopping) {
console.log("[thread] shutting down"); this.log("[thread] shutting down");
clearInterval(_this._interval_id); clearInterval(_this._interval_id);
_this._is_running = false; _this._is_running = false;
return; return;
@ -409,7 +413,7 @@ $.Class("Thread",
// stop the run loop // stop the run loop
stop: function () { stop: function () {
this._is_stopping = true; this._is_stopping = true;
console.log("[thread] request stop"); this.log("[thread] request stop");
// TODO: consider finding a way to make this block // TODO: consider finding a way to make this block
// or alternatively, having a callback which is called // or alternatively, having a callback which is called
// when the thread stops // when the thread stops
@ -422,6 +426,7 @@ $.Class("ChangesetRequest",
}, },
{//instance {//instance
init: function (start, granularity, callback) { init: function (start, granularity, callback) {
this.log = ChangesetLoader.VERBOSE ? console.log : function () {};
this.start = start; this.start = start;
this.granularity = granularity; this.granularity = granularity;
this.request_id = (this.granularity << 16) + this.start; this.request_id = (this.granularity << 16) + this.start;
@ -431,7 +436,7 @@ $.Class("ChangesetRequest",
return this.request_id; return this.request_id;
}, },
fulfill: function (data) { fulfill: function (data) {
console.log("[changesetrequest] Fulfilling request %d", this.getRequestID()); this.log("[changesetrequest] Fulfilling request %d", this.getRequestID());
if (this.fulfill_callback) if (this.fulfill_callback)
this.fulfill_callback(data); this.fulfill_callback(data);
} }
@ -441,6 +446,7 @@ $.Class("ChangesetRequest",
Thread("ChangesetLoader", Thread("ChangesetLoader",
{//statics {//statics
VERBOSE: false
}, },
{//instance {//instance
/** /**
@ -461,6 +467,7 @@ Thread("ChangesetLoader",
this.connection.on("CHANGESET_REQ", function () { this.connection.on("CHANGESET_REQ", function () {
_this.on_response.apply(_this, arguments); _this.on_response.apply(_this, arguments);
}); });
this.log = ChangesetLoader.VERBOSE ? console.log : function () {};
}, },
/** /**
* Enqueue a request for changesets. The changesets will be retrieved * Enqueue a request for changesets. The changesets will be retrieved
@ -489,7 +496,7 @@ Thread("ChangesetLoader",
* asked for. * asked for.
*/ */
enqueue: function (start, granularity, callback) { enqueue: function (start, granularity, callback) {
console.log("[changeset_loader] enqueue: %d, %d", start, granularity); this.log("[changeset_loader] enqueue: %d, %d", start, granularity);
//TODO: check cache to see if we really need to fetch this //TODO: check cache to see if we really need to fetch this
// maybe even do splices if we just need a smaller range // maybe even do splices if we just need a smaller range
// in the middle // in the middle
@ -506,7 +513,7 @@ Thread("ChangesetLoader",
queue.push(request); queue.push(request);
}, },
_run: function () { _run: function () {
console.log("[changesetloader] tick"); this.log("[changesetloader] tick");
var _this = this; var _this = this;
function addToPending () { function addToPending () {
_this.pending[request.getRequestID()] = request; _this.pending[request.getRequestID()] = request;
@ -520,7 +527,7 @@ Thread("ChangesetLoader",
if (request.getRequestID() in this.pending) { if (request.getRequestID() in this.pending) {
//this request is already pending! //this request is already pending!
var id = request.getRequestID(); var id = request.getRequestID();
console.log("ALREADY PENDING REQUEST: %d, start: %d, granularity: %d", id, id & 0xffff, id >> 16); this.log("ALREADY PENDING REQUEST: %d, start: %d, granularity: %d", id, id & 0xffff, id >> 16);
continue; continue;
} }
//TODO: test AGAIN to make sure that it hasn't been retrieved and cached by //TODO: test AGAIN to make sure that it hasn't been retrieved and cached by
@ -543,9 +550,9 @@ Thread("ChangesetLoader",
//this.stop(); //this.stop();
}, },
on_response: function (data) { on_response: function (data) {
console.log("[changesetloader] on_response: ", data); this.log("[changesetloader] on_response: ", data);
if (!(data.requestID in this.pending)) { if (!(data.requestID in this.pending)) {
console.log("[changesetloader] WTF? changeset not pending: ", data.requestID); this.log("[changesetloader] WTF? changeset not pending: ", data.requestID);
return; return;
} }
@ -614,6 +621,7 @@ var domline = require("./domline").domline;
$.Class("PadClient", $.Class("PadClient",
{//static {//static
USE_COMPOSE: false, USE_COMPOSE: false,
VERBOSE: false,
}, },
{//instance {//instance
/** /**
@ -632,6 +640,7 @@ $.Class("PadClient",
this.authors = {}; this.authors = {};
this.dynamicCSS = libcssmanager.makeCSSManager('dynamicsyntax'); this.dynamicCSS = libcssmanager.makeCSSManager('dynamicsyntax');
this.palette = options.palette; this.palette = options.palette;
this.log = PadClient.VERBOSE ? console.log : function () {};
this.updateAuthors(options.author_info); this.updateAuthors(options.author_info);
@ -658,7 +667,7 @@ $.Class("PadClient",
}; };
}, },
goToRevision: function (revnum, atRevision_callback) { goToRevision: function (revnum, atRevision_callback) {
console.log("[padclient > goToRevision] revnum: %d", revnum); this.log("[padclient > goToRevision] revnum: %d", revnum);
var _this = this; var _this = this;
if (this.revision.revnum == revnum) { if (this.revision.revnum == revnum) {
if (atRevision_callback) if (atRevision_callback)
@ -667,7 +676,7 @@ $.Class("PadClient",
} }
this.revisionCache.transition(this.revision.revnum, revnum, function (path) { this.revisionCache.transition(this.revision.revnum, revnum, function (path) {
console.log("[padclient > applyChangeset_callback] path:", path); _this.log("[padclient > applyChangeset_callback] path:", path);
var time = _this.timestamp; var time = _this.timestamp;
var p, changeset = null; //pre-declare, because they're used in both blocks. var p, changeset = null; //pre-declare, because they're used in both blocks.
if (PadClient.USE_COMPOSE) { if (PadClient.USE_COMPOSE) {
@ -683,15 +692,16 @@ $.Class("PadClient",
for (p in path) { for (p in path) {
changeset = path[p]; changeset = path[p];
time += changeset.deltatime * 1000; time += changeset.deltatime * 1000;
try { //try {
_this.log("[transition] %d -> %d, changeset: %s", changeset.from_revision.revnum, changeset.to_revision.revnum, changeset.value);
changeset.apply(_this); changeset.apply(_this);
} catch (err) { /*} catch (err) {
console.log("Error applying changeset: "); log("Error applying changeset: ");
console.log("\t", changeset.value); log("\t", changeset.value);
console.log("\t %d -> %d ", changeset.from_revision.revnum, changeset.to_revision.revnum); log("\t %d -> %d ", changeset.from_revision.revnum, changeset.to_revision.revnum);
console.log(err); log(err);
console.log("--------------"); log("--------------");
} }*/
} }
} }
@ -700,7 +710,7 @@ $.Class("PadClient",
_this.timestamp = time; _this.timestamp = time;
// fire the callback // fire the callback
if (atRevision_callback) { if (atRevision_callback) {
console.log("[padclient] about to call atRevision_callback", _this.revision, _this.timestamp); _this.log("[padclient] about to call atRevision_callback", _this.revision, _this.timestamp);
atRevision_callback.call(_this, _this.revision, _this.timestamp); atRevision_callback.call(_this, _this.revision, _this.timestamp);
} }
}); });
@ -711,7 +721,7 @@ $.Class("PadClient",
*/ */
updateAuthors: function (author_info) { updateAuthors: function (author_info) {
var authors = author_info; var authors = author_info;
console.log("[updateAuthors]: ", authors); this.log("[updateAuthors]: ", authors);
for (var authorid in authors) { for (var authorid in authors) {
if (authorid in this.authors) { if (authorid in this.authors) {
// just dispose of existing ones instead of trying to update existing // just dispose of existing ones instead of trying to update existing
@ -758,6 +768,7 @@ $.Class("PadClient",
* @return {jquery object} - The div element ready for insertion into the DOM. * @return {jquery object} - The div element ready for insertion into the DOM.
*/ */
_getDivForLine: function (text, atext) { _getDivForLine: function (text, atext) {
this.log("[_getDivsForLine] %s; %s", text, atext);
var dominfo = domline.createDomLine(text != '\n', true); var dominfo = domline.createDomLine(text != '\n', true);
// Here begins the magic invocation: // Here begins the magic invocation:
@ -785,6 +796,7 @@ $.Class("PadClient",
*/ */
_spliceDivs: function (index, howMany, elements) { _spliceDivs: function (index, howMany, elements) {
elements = Array.prototype.slice.call(arguments, 2); elements = Array.prototype.slice.call(arguments, 2);
this.log("[_spliceDivs]: ", index, howMany);
// remove howMany divs starting from index. We need to remove them from // remove howMany divs starting from index. We need to remove them from
// the DOM. // the DOM.
for (var i = index; i < index + howMany && i < this.divs.length; i++) for (var i = index; i < index + howMany && i < this.divs.length; i++)
@ -803,7 +815,13 @@ $.Class("PadClient",
else else
this.divs[index - 1].after(newdivs); this.divs[index - 1].after(newdivs);
// super primitive scrollIntoView // super primitive scrollIntoView
newdivs[0][0].scrollIntoView(false); if (newdivs.length) {
for(var x in newdivs){
var div = newdivs[x][0];
this.log("ND> ", div.id, div.className, div.innerHTML);
}
newdivs[0][0].scrollIntoView(false);
}
// perform the splice on our array itself // perform the splice on our array itself
// TODO: monkey patching divs.splice, so use divs.original_splice or something // TODO: monkey patching divs.splice, so use divs.original_splice or something

View file

@ -29,12 +29,14 @@ var token, padId, export_links;
$.Class("SocketClient", $.Class("SocketClient",
{ //statics { //statics
VERBOSE: false,
}, },
{ //instance { //instance
init: function (baseurl) { init: function (baseurl) {
this.baseurl = baseurl; this.baseurl = baseurl;
this.log = SocketClient.VERBOSE ? console.log : function () {};
// connect to the server // connect to the server
console.log("[socket_client] connecting to:", this.baseurl); this.log("[socket_client] connecting to:", this.baseurl);
this.socket = io.connect(this.baseurl, {resource: "socket.io"}); this.socket = io.connect(this.baseurl, {resource: "socket.io"});
// setup the socket callbacks: // setup the socket callbacks:
_this = this; _this = this;
@ -51,11 +53,11 @@ $.Class("SocketClient",
}, },
onConnect: function() { onConnect: function() {
console.log("[socket_client] > onConnect"); this.log("[socket_client] > onConnect");
}, },
onDisconnect: function() { onDisconnect: function() {
console.log("[socket_client] > onDisconnect"); this.log("[socket_client] > onDisconnect");
}, },
/** /**
@ -63,7 +65,7 @@ $.Class("SocketClient",
* @param {object} message - The message. * @param {object} message - The message.
*/ */
onMessage: function(message) { onMessage: function(message) {
console.log("[socket_client] > onMessage: ", message); this.log("[socket_client] > onMessage: ", message);
}, },
/** /**
@ -73,7 +75,7 @@ $.Class("SocketClient",
* the message has been sent to the socket. * the message has been sent to the socket.
*/ */
sendMessage: function(message, callback) { sendMessage: function(message, callback) {
console.log("[socket_client] > sendMessage: ", message); this.log("[socket_client] > sendMessage: ", message);
this.socket.json.send(message); this.socket.json.send(message);
if (callback) if (callback)
callback(); callback();
@ -83,9 +85,11 @@ $.Class("SocketClient",
SocketClient("AuthenticatedSocketClient", SocketClient("AuthenticatedSocketClient",
{ //statics { //statics
VERBOSE: false,
}, },
{ //instance { //instance
init: function (baseurl, padID) { init: function (baseurl, padID) {
this.log = AuthenticatedSocketClient.VERBOSE ? console.log : function () {};
//make sure we have a token //make sure we have a token
this.token = readCookie("token"); this.token = readCookie("token");
@ -126,11 +130,11 @@ SocketClient("AuthenticatedSocketClient",
}, },
onMessage: function (message) { onMessage: function (message) {
console.log("[authorized_client] > onMessage:", message); this.log("[authorized_client] > onMessage:", message);
if (message.accessStatus) if (message.accessStatus)
{ //access denied? { //access denied?
//TODO raise some kind of error? //TODO raise some kind of error?
console.log("ACCESS ERROR!"); this.log("ACCESS ERROR!");
} }
this.dispatchMessage(message.type, message.data); this.dispatchMessage(message.type, message.data);
}, },
@ -143,7 +147,7 @@ SocketClient("AuthenticatedSocketClient",
* @param {object} data - The message payload. * @param {object} data - The message payload.
*/ */
dispatchMessage: function(type, data) { dispatchMessage: function(type, data) {
console.log("[authorized_client] > dispatchMessage('%s', %s)", type, data); this.log("[authorized_client] > dispatchMessage('%s', %s)", type, data);
// first call local handlers // first call local handlers
if ("handle_" + type in this) if ("handle_" + type in this)
this["handle_" + type](data); this["handle_" + type](data);
@ -174,7 +178,7 @@ SocketClient("AuthenticatedSocketClient",
* @param {object} data - The data received from the server. * @param {object} data - The data received from the server.
*/ */
handle_COLLABROOM: function(data) { handle_COLLABROOM: function(data) {
//console.log("[authsocket_client] handle_COLLABROOM: ", data); //this.log("[authsocket_client] handle_COLLABROOM: ", data);
this.dispatchMessage(data.type, data); this.dispatchMessage(data.type, data);
}, },
@ -185,17 +189,21 @@ require('./revisioncache');
require('./revisionslider'); require('./revisionslider');
AuthenticatedSocketClient("TimesliderClient", AuthenticatedSocketClient("TimesliderClient",
{ //statics { //statics
VERBOSE: false,
}, },
{ //instance { //instance
init: function (baseurl, padID) { init: function (baseurl, padID) {
this.log = TimesliderClient.VERBOSE ? console.log : function () {};
this._super(baseurl, padID); this._super(baseurl, padID);
}, },
onConnect: function () { onConnect: function () {
this.sendMessage("CLIENT_READY", {}, function() { console.log("CLIENT_READY sent");}); this.sendMessage("CLIENT_READY", {});
}, },
initialize: function (clientVars) { initialize: function (clientVars) {
if (this.is_initialized)
return;
this.clientVars = clientVars; this.clientVars = clientVars;
var collabClientVars = this.clientVars.collab_client_vars; var collabClientVars = this.clientVars.collab_client_vars;
this.savedRevisions = this.clientVars.savedRevisions; this.savedRevisions = this.clientVars.savedRevisions;
@ -217,12 +225,13 @@ AuthenticatedSocketClient("TimesliderClient",
//TODO: not wild about the timeslider-top selector being hard-coded here. //TODO: not wild about the timeslider-top selector being hard-coded here.
this.ui = new RevisionSlider(this, $("#timeslider-top")); this.ui = new RevisionSlider(this, $("#timeslider-top"));
this.is_initialized = true;
}, },
// ------------------------------------------ // ------------------------------------------
// Handling events // Handling events
handle_CLIENT_VARS: function(data) { handle_CLIENT_VARS: function(data) {
console.log("[timeslider_client] handle_CLIENT_VARS: ", data); this.log("[timeslider_client] handle_CLIENT_VARS: ", data);
this.initialize(data); this.initialize(data);
}, },
@ -232,7 +241,7 @@ AuthenticatedSocketClient("TimesliderClient",
* @param {object} data - the data received from the server. * @param {object} data - the data received from the server.
*/ */
handle_USER_NEWINFO: function (data) { handle_USER_NEWINFO: function (data) {
console.log("[timeslider_client] handle_USER_NEWINFO: ", data.userInfo); this.log("[timeslider_client] handle_USER_NEWINFO: ", data.userInfo);
//TODO: we might not want to add EVERY new user to the users list, //TODO: we might not want to add EVERY new user to the users list,
//possibly only active users? //possibly only active users?
var authors = {}; var authors = {};
@ -247,7 +256,7 @@ AuthenticatedSocketClient("TimesliderClient",
* @param {object} data - The data received from the server. * @param {object} data - The data received from the server.
*/ */
handle_USER_LEAVE: function (data) { handle_USER_LEAVE: function (data) {
console.log("[timeslider_client] handle_USER_LEAVE ", data.userInfo); this.log("[timeslider_client] handle_USER_LEAVE ", data.userInfo);
}, },
/** /**
@ -256,7 +265,7 @@ AuthenticatedSocketClient("TimesliderClient",
* @param {object} data - The data received from the server. * @param {object} data - The data received from the server.
*/ */
handle_NEW_CHANGES: function (data) { handle_NEW_CHANGES: function (data) {
console.log("[timeslider_client] handle_NEW_CHANGES: ", data); this.log("[timeslider_client] handle_NEW_CHANGES: ", data);
var changesets = this.padClient.mergeForeignChangeset(data.changeset, data.apool); var changesets = this.padClient.mergeForeignChangeset(data.changeset, data.apool);
//TODO: handle calculation of real timedela based on currenttime //TODO: handle calculation of real timedela based on currenttime
//TODO: deal with author? //TODO: deal with author?