|
|
@ -93,22 +93,37 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var createSpinner = function ($container, config) {
|
|
|
|
var createSpinner = function ($container, config) {
|
|
|
|
if (config.displayed.indexOf('spinner') !== -1) {
|
|
|
|
if (config.displayed.indexOf('spinner') !== -1) {
|
|
|
|
|
|
|
|
var $spin = $('<span>');
|
|
|
|
var $spinner = $('<span>', {
|
|
|
|
var $spinner = $('<span>', {
|
|
|
|
id: uid(),
|
|
|
|
id: uid(),
|
|
|
|
'class': SPINNER_CLS + ' fa fa-spinner fa-pulse',
|
|
|
|
'class': SPINNER_CLS + ' spin fa fa-spinner fa-pulse',
|
|
|
|
}).hide();
|
|
|
|
}).appendTo($spin).hide();
|
|
|
|
$container.prepend($spinner);
|
|
|
|
var $spinner = $('<span>', {
|
|
|
|
return $spinner[0];
|
|
|
|
id: uid(),
|
|
|
|
|
|
|
|
'class': SPINNER_CLS + ' synced fa fa-check',
|
|
|
|
|
|
|
|
title: Messages.synced
|
|
|
|
|
|
|
|
}).appendTo($spin);
|
|
|
|
|
|
|
|
$container.prepend($spin);
|
|
|
|
|
|
|
|
return $spin[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var kickSpinner = function (spinnerElement) {
|
|
|
|
var kickSpinner = function (Cryptpad, realtime, local, spinnerElement) {
|
|
|
|
if (!spinnerElement) { return; }
|
|
|
|
if (!spinnerElement) { return; }
|
|
|
|
$(spinnerElement).show();
|
|
|
|
$(spinnerElement).find('.spin').show();
|
|
|
|
if (spinnerElement.timeout) { clearTimeout(spinnerElement.timeout); }
|
|
|
|
$(spinnerElement).find('.synced').hide();
|
|
|
|
spinnerElement.timeout = setTimeout(function () {
|
|
|
|
var onSynced = function () {
|
|
|
|
$(spinnerElement).hide();
|
|
|
|
if (spinnerElement.timeout) { clearTimeout(spinnerElement.timeout); }
|
|
|
|
}, SPINNER_DISAPPEAR_TIME);
|
|
|
|
spinnerElement.timeout = setTimeout(function () {
|
|
|
|
|
|
|
|
$(spinnerElement).find('.spin').hide();
|
|
|
|
|
|
|
|
$(spinnerElement).find('.synced').show();
|
|
|
|
|
|
|
|
}, local ? 0 : SPINNER_DISAPPEAR_TIME);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if (Cryptpad) {
|
|
|
|
|
|
|
|
Cryptpad.whenRealtimeSyncs(realtime, onSynced);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onSynced();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var createUserButtons = function ($userlistElement, config, readOnly, Cryptpad) {
|
|
|
|
var createUserButtons = function ($userlistElement, config, readOnly, Cryptpad) {
|
|
|
@ -749,13 +764,14 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var ks = function () {
|
|
|
|
var ks = function (local) {
|
|
|
|
if (connected) { kickSpinner(spinner); }
|
|
|
|
return function () {
|
|
|
|
|
|
|
|
if (connected) { kickSpinner(Cryptpad, realtime, local, spinner); }
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
realtime.onPatch(ks);
|
|
|
|
realtime.onPatch(ks());
|
|
|
|
// Try to filter out non-patch messages, doesn't have to be perfect this is just the spinner
|
|
|
|
realtime.onMessage(ks(true));
|
|
|
|
realtime.onMessage(function (msg) { if (msg.indexOf(':[2,') > -1) { ks(); } });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkLag(getLag, lagElement);
|
|
|
|
checkLag(getLag, lagElement);
|
|
|
|
setInterval(function () {
|
|
|
|
setInterval(function () {
|
|
|
|