summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter 'Pita' Martischka <petermartischka@googlemail.com>2011-06-20 15:37:41 +0100
committerPeter 'Pita' Martischka <petermartischka@googlemail.com>2011-06-20 15:37:41 +0100
commit867525945d2439ae0cd0ed4907da62f9c6d00419 (patch)
treea827ff9d0996bca43727179f6caa99515609234b
parent44aa476ec07ec35c78a4ad01c8116786102b56a6 (diff)
downloadetherpad-lite-867525945d2439ae0cd0ed4907da62f9c6d00419.zip
Timeslider is working
-rw-r--r--node/TimesliderMessageHandler.js22
-rw-r--r--package.json2
-rw-r--r--static/img/crushed_button_depressed.pngbin0 -> 4134 bytes
-rw-r--r--static/img/pause.pngbin0 -> 2883 bytes
-rw-r--r--static/js/broadcast.js44
-rw-r--r--static/js/broadcast_slider.js6
-rw-r--r--static/timeslider.html98
7 files changed, 84 insertions, 88 deletions
diff --git a/node/TimesliderMessageHandler.js b/node/TimesliderMessageHandler.js
index 8e589443..2212c110 100644
--- a/node/TimesliderMessageHandler.js
+++ b/node/TimesliderMessageHandler.js
@@ -68,6 +68,10 @@ exports.handleMessage = function(client, message)
{
handleClientReady(client, message);
}
+ else if(message.type == "CHANGESET_REQ")
+ {
+ handleChangesetRequest(client, message);
+ }
//if the message type is unkown, throw an exception
else
{
@@ -85,6 +89,24 @@ function handleClientReady(client, message)
})
}
+function handleChangesetRequest(client, message)
+{
+ var granularity = message.data.granularity;
+ var start = message.data.start;
+ var end = start + (100 * granularity);
+ var padId = message.padId;
+
+ getChangesetInfo(padId, start, end, granularity, function(err, changesetInfo)
+ {
+ if(err) throw err;
+
+ var data = changesetInfo;
+ data.requestID = message.data.requestID;
+
+ client.send({type: "CHANGESET_REQ", data: data});
+ });
+}
+
function createTimesliderClientVars (padId, callback)
{
var clientVars = {
diff --git a/package.json b/package.json
index 9663efe2..3bf789ec 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
],
"dependencies" : {
"socket.io" : "0.6.18",
- "ueberDB" : "0.0.7",
+ "ueberDB" : "0.0.8",
"async" : "0.1.9",
"joose" : "3.18.0",
"express" : "2.3.10",
diff --git a/static/img/crushed_button_depressed.png b/static/img/crushed_button_depressed.png
new file mode 100644
index 00000000..d75dcce2
--- /dev/null
+++ b/static/img/crushed_button_depressed.png
Binary files differ
diff --git a/static/img/pause.png b/static/img/pause.png
new file mode 100644
index 00000000..657782c0
--- /dev/null
+++ b/static/img/pause.png
Binary files differ
diff --git a/static/js/broadcast.js b/static/js/broadcast.js
index c150ebb6..9b25e3b8 100644
--- a/static/js/broadcast.js
+++ b/static/js/broadcast.js
@@ -103,7 +103,7 @@ function loadBroadcastJS()
var userId = "hiddenUser" + randomString();
var socketId;
- var socket;
+ //var socket;
var channelState = "DISCONNECTED";
@@ -406,12 +406,13 @@ function loadBroadcastJS()
}));
}
- var changesetLoader = {
+ global.changesetLoader = {
running: false,
resolved: [],
requestQueue1: [],
requestQueue2: [],
requestQueue3: [],
+ reqCallbacks: [],
queueUp: function (revision, width, callback)
{
if (revision < 0) revision = 0;
@@ -448,7 +449,26 @@ function loadBroadcastJS()
var granularity = request.res;
var callback = request.callback;
var start = request.rev;
- debugLog("loadinging revision", start, "through ajax");
+ var requestID = Math.floor(Math.random()*100000);
+
+ /*var msg = { "component" : "timeslider",
+ "type":"CHANGESET_REQ",
+ "padId": padId,
+ "token": token,
+ "protocolVersion": 2,
+ "data"
+ {
+ "start": start,
+ "granularity": granularity
+ }};
+
+ socket.send(msg);*/
+
+ sendSocketMsg("CHANGESET_REQ",{ "start": start, "granularity": granularity, "requestID": requestID});
+
+ self.reqCallbacks[requestID] = callback;
+
+ /*debugLog("loadinging revision", start, "through ajax");
$.getJSON("/ep/pad/changes/" + clientVars.padIdForUrl + "?s=" + start + "&g=" + granularity, function (data, textStatus)
{
if (textStatus !== "success")
@@ -459,7 +479,19 @@ function loadBroadcastJS()
self.handleResponse(data, start, granularity, callback);
setTimeout(self.loadFromQueue, 10); // load the next ajax function
- });
+ });*/
+ },
+ handleSocketResponse: function (message)
+ {
+ var self = changesetLoader;
+
+ var start = message.data.start;
+ var granularity = message.data.granularity;
+ var callback = self.reqCallbacks[message.data.requestID];
+ delete self.reqCallbacks[message.data.requestID];
+
+ self.handleResponse(message.data, start, granularity, callback);
+ setTimeout(self.loadFromQueue, 10);
},
handleResponse: function (data, start, granularity, callback)
{
@@ -561,7 +593,7 @@ function loadBroadcastJS()
}));
}
- function setUpSocket()
+ /*function setUpSocket()
{
// required for Comet
if ((!$.browser.msie) && (!($.browser.mozilla && $.browser.version.indexOf("1.8.") == 0)))
@@ -607,7 +639,7 @@ function loadBroadcastJS()
{
abandonConnection("initsocketfail");
}
- }
+ }*/
function setChannelState(newChannelState, moreInfo)
{
diff --git a/static/js/broadcast_slider.js b/static/js/broadcast_slider.js
index 20966770..3a645c9d 100644
--- a/static/js/broadcast_slider.js
+++ b/static/js/broadcast_slider.js
@@ -346,16 +346,16 @@ function loadBroadcastSliderJS()
{
var self = this;
- $(self).css('background-image', 'url(/static/img/pad/timeslider/crushed_button_depressed.png)');
+ $(self).css('background-image', 'url(/static/img/crushed_button_depressed.png)');
$(self).mouseup(function (evt2)
{
- $(self).css('background-image', 'url(/static/img/pad/timeslider/crushed_button_undepressed.png)');
+ $(self).css('background-image', 'url(/static/img/crushed_button_undepressed.png)');
$(self).unbind('mouseup');
BroadcastSlider.playpause();
});
$(document).mouseup(function (evt2)
{
- $(self).css('background-image', 'url(/static/img/pad/timeslider/crushed_button_undepressed.png)');
+ $(self).css('background-image', 'url(/static/img/crushed_button_undepressed.png)');
$(document).unbind('mouseup');
});
});
diff --git a/static/timeslider.html b/static/timeslider.html
index 88cdb84f..791bd496 100644
--- a/static/timeslider.html
+++ b/static/timeslider.html
@@ -51,11 +51,10 @@
return "t." + randomstring;
}
- /*var padId, token;
+ var socket, token, padId;
- $(document).ready(function()
+ $(window).load(function ()
{
- //find out the padId
var urlParts= document.URL.split("/");
padId = urlParts[urlParts.length-2];
@@ -74,53 +73,9 @@
socket = new io.Socket();
socket.connect();
- socket.on('connect', function(){
- var msg = { "component" : "timeslider",
- "type":"CLIENT_READY",
- "padId": padId,
- "token": token,
- "protocolVersion": 2};
-
- socket.send(msg);
- });
-
- socket.on('message', function(message)
- {
- console.log(message);
- clientVars = message.data;
- initalizeWithClientVars();
- })
- });*/
-
- $(window).load(function ()
- {
- var urlParts= document.URL.split("/");
- var padId = urlParts[urlParts.length-2];
-
- //set the title
- document.title = document.title + " | " + padId;
-
- //ensure we have a token
- var token = readCookie("token");
- if(token == null)
- {
- token = randomString();
- createCookie("token", token, 60);
- }
-
- //build up the socket io connection
- var socket = new io.Socket();
- socket.connect();
-
socket.on('connect', function()
{
- var msg = { "component" : "timeslider",
- "type":"CLIENT_READY",
- "padId": padId,
- "token": token,
- "protocolVersion": 2};
-
- socket.send(msg);
+ sendSocketMsg("CLIENT_READY", {});
});
socket.on('message', function(message)
@@ -131,11 +86,26 @@
{
handleClientVars(message);
}
+ else if(message.type == "CHANGESET_REQ")
+ {
+ changesetLoader.handleSocketResponse(message);
+ //alert("answer!")
+ }
});
-
- //handleClientVars({data: clientVars});
});
+ function sendSocketMsg(type, data)
+ {
+ var msg = { "component" : "timeslider",
+ "type": type,
+ "data": data,
+ "padId": padId,
+ "token": token,
+ "protocolVersion": 2};
+
+ socket.send(msg);
+ }
+
var fireWhenAllScriptsAreLoaded = [];
function handleClientVars(message)
@@ -151,34 +121,6 @@
{
fireWhenAllScriptsAreLoaded[i]();
}
-
- /*var scriptsToLoad = 3;
-
- var loadCallback = function(info)
- {
- scriptsToLoad--;
-
- console.log(scriptsToLoad);
-
- if(scriptsToLoad == 1)
- {
- $.getScript('/static/js/broadcast.js', loadCallback);
- }
-
- //if all scripts are loaded
- if(scriptsToLoad == 0)
- {
- console.log("execute!");
-
- for(var i=0;i < fireWhenAllScriptsAreLoaded.length;i++)
- {
- fireWhenAllScriptsAreLoaded[i]();
- }
- }
- }*/
-
- //$.getScript('/static/js/broadcast_slider.js', loadCallback);
- //$.getScript('/static/js/broadcast_revisions.js', loadCallback);
}
// ]]>