Timeslider is working
This commit is contained in:
parent
44aa476ec0
commit
867525945d
|
@ -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 = {
|
||||
|
|
|
@ -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",
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
// ]]>
|
||||
|
|
Loading…
Reference in New Issue