mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-26 10:26:15 -04:00
Disconnect handling and cleanup of unused code
This commit is contained in:
parent
e5a22423bb
commit
ed7e254417
4 changed files with 71 additions and 118 deletions
|
@ -519,81 +519,6 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
}
|
||||
};
|
||||
|
||||
function handleSocketClosed(params)
|
||||
{
|
||||
debugLog("socket closed!", params);
|
||||
socket = null;
|
||||
|
||||
BroadcastSlider.showReconnectUI();
|
||||
// var reason = appLevelDisconnectReason || params.reason;
|
||||
// var shouldReconnect = params.reconnect;
|
||||
// if (shouldReconnect) {
|
||||
// // determine if this is a tight reconnect loop due to weird connectivity problems
|
||||
// // reconnectTimes.push(+new Date());
|
||||
// var TOO_MANY_RECONNECTS = 8;
|
||||
// var TOO_SHORT_A_TIME_MS = 10000;
|
||||
// if (reconnectTimes.length >= TOO_MANY_RECONNECTS &&
|
||||
// ((+new Date()) - reconnectTimes[reconnectTimes.length-TOO_MANY_RECONNECTS]) <
|
||||
// TOO_SHORT_A_TIME_MS) {
|
||||
// setChannelState("DISCONNECTED", "looping");
|
||||
// }
|
||||
// else {
|
||||
// setChannelState("RECONNECTING", reason);
|
||||
// setUpSocket();
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// BroadcastSlider.showReconnectUI();
|
||||
// setChannelState("DISCONNECTED", reason);
|
||||
// }
|
||||
}
|
||||
|
||||
function sendMessage(msg)
|
||||
{
|
||||
socket.postMessage(JSON.stringify(
|
||||
{
|
||||
type: "COLLABROOM",
|
||||
data: msg
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
function setChannelState(newChannelState, moreInfo)
|
||||
{
|
||||
if (newChannelState != channelState)
|
||||
{
|
||||
channelState = newChannelState;
|
||||
// callbacks.onChannelStateChange(channelState, moreInfo);
|
||||
}
|
||||
}
|
||||
|
||||
function abandonConnection(reason)
|
||||
{
|
||||
if (socket)
|
||||
{
|
||||
socket.onclosed = function()
|
||||
{};
|
||||
socket.onhiccup = function()
|
||||
{};
|
||||
socket.disconnect();
|
||||
}
|
||||
socket = null;
|
||||
setChannelState("DISCONNECTED", reason);
|
||||
}
|
||||
|
||||
/// Since its not used, import 'forEach' has been dropped
|
||||
/*window['onloadFuncts'] = [];
|
||||
window.onload = function ()
|
||||
{
|
||||
window['isloaded'] = true;
|
||||
|
||||
|
||||
forEach(window['onloadFuncts'],function (funct)
|
||||
{
|
||||
funct();
|
||||
});
|
||||
};*/
|
||||
|
||||
// to start upon window load, just push a function onto this array
|
||||
//window['onloadFuncts'].push(setUpSocket);
|
||||
//window['onloadFuncts'].push(function ()
|
||||
|
@ -614,36 +539,19 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
// this is necessary to keep infinite loops of events firing,
|
||||
// since goToRevision changes the slider position
|
||||
var goToRevisionIfEnabledCount = 0;
|
||||
var goToRevisionIfEnabled = function()
|
||||
var goToRevisionIfEnabled = function() {
|
||||
if (goToRevisionIfEnabledCount > 0)
|
||||
{
|
||||
if (goToRevisionIfEnabledCount > 0)
|
||||
{
|
||||
goToRevisionIfEnabledCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
goToRevision.apply(goToRevision, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
goToRevisionIfEnabledCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
goToRevision.apply(goToRevision, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
BroadcastSlider.onSlider(goToRevisionIfEnabled);
|
||||
|
||||
(function()
|
||||
{
|
||||
for (var i = 0; i < clientVars.initialChangesets.length; i++)
|
||||
{
|
||||
var csgroup = clientVars.initialChangesets[i];
|
||||
var start = clientVars.initialChangesets[i].start;
|
||||
var granularity = clientVars.initialChangesets[i].granularity;
|
||||
debugLog("loading changest on startup: ", start, granularity, csgroup);
|
||||
changesetLoader.handleResponse(csgroup, start, granularity, null);
|
||||
}
|
||||
})();
|
||||
|
||||
var dynamicCSS = makeCSSManager('dynamicsyntax');
|
||||
var authorData = {};
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
// These parameters were global, now they are injected. A reference to the
|
||||
// Timeslider controller would probably be more appropriate.
|
||||
var _ = require('./underscore');
|
||||
var padmodals = require('./pad_modals').padmodals;
|
||||
|
||||
function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
||||
{
|
||||
|
@ -54,11 +55,7 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
|||
{
|
||||
slidercallbacks[i](newval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
var updateSliderElements = function()
|
||||
{
|
||||
|
@ -68,12 +65,8 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
|||
savedRevisions[i].css('left', (position * ($("#ui-slider-bar").width() - 2) / (sliderLength * 1.0)) - 1);
|
||||
}
|
||||
$("#ui-slider-handle").css('left', sliderPos * ($("#ui-slider-bar").width() - 2) / (sliderLength * 1.0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
var addSavedRevision = function(position, info)
|
||||
{
|
||||
var newSavedRevision = $('<div></div>');
|
||||
|
@ -88,7 +81,7 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
|||
BroadcastSlider.setSliderPosition(position);
|
||||
});
|
||||
savedRevisions.push(newSavedRevision);
|
||||
};
|
||||
};
|
||||
|
||||
var removeSavedRevision = function(position)
|
||||
{
|
||||
|
@ -96,7 +89,7 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
|||
savedRevisions.remove(element);
|
||||
element.remove();
|
||||
return element;
|
||||
};
|
||||
};
|
||||
|
||||
/* Begin small 'API' */
|
||||
|
||||
|
@ -162,9 +155,9 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
|||
|
||||
function showReconnectUI()
|
||||
{
|
||||
$("#padmain, #rightbars").css('top', "130px");
|
||||
$("#timeslider").show();
|
||||
$('#error').show();
|
||||
var cls = 'modaldialog cboxdisconnected cboxdisconnected_unknown';
|
||||
$("#connectionbox").get(0).className = cls;
|
||||
padmodals.showModal("#connectionbox", 500);
|
||||
}
|
||||
|
||||
var fixPadHeight = _.throttle(function(){
|
||||
|
|
|
@ -71,6 +71,11 @@ function init() {
|
|||
sendSocketMsg("CLIENT_READY", {});
|
||||
});
|
||||
|
||||
socket.on('disconnect', function()
|
||||
{
|
||||
BroadcastSlider.showReconnectUI();
|
||||
});
|
||||
|
||||
//route the incoming messages
|
||||
socket.on('message', function(message)
|
||||
{
|
||||
|
@ -96,6 +101,12 @@ function init() {
|
|||
} else {
|
||||
$("#returnbutton").attr("href", document.location.href.substring(0,document.location.href.lastIndexOf("/")));
|
||||
}
|
||||
|
||||
$('button#forcereconnect').click(function()
|
||||
{
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue