diff --git a/www/pad/realtime-wysiwyg.js b/www/pad/realtime-wysiwyg.js index 54b2d4bf9..13b24f0e3 100644 --- a/www/pad/realtime-wysiwyg.js +++ b/www/pad/realtime-wysiwyg.js @@ -22,6 +22,7 @@ define([ '/pad/rangy.js', '/common/chainpad.js', '/common/otaml.js', + '/common/toolbar.js', '/bower_components/jquery/dist/jquery.min.js', '/bower_components/tweetnacl/nacl-fast.min.js' ], function (HTMLPatcher, ErrorBox, Messages, ReconnectingWebSocket) { @@ -98,28 +99,6 @@ window.ErrorBox = ErrorBox; unbind); }; - var SPINNER = [ '-', '\\', '|', '/' ]; - var kickSpinner = function (spinnerElement, reversed) { - var txt = spinnerElement.textContent || '-'; - var inc = (reversed) ? -1 : 1; - spinnerElement.textContent = SPINNER[(SPINNER.indexOf(txt) + inc) % SPINNER.length]; - spinnerElement.timeout && clearTimeout(spinnerElement.timeout); - spinnerElement.timeout = setTimeout(function () { - spinnerElement.textContent = ''; - }, SPINNER_DISAPPEAR_TIME); - }; - - var checkLag = function (realtime, lagElement) { - var lag = realtime.getLag(); - var lagSec = lag.lag/1000; - lagElement.textContent = "Lag: "; - if (lag.waiting && lagSec > 1) { - lagElement.textContent += "?? " + Math.floor(lagSec); - } else { - lagElement.textContent += lagSec; - } - }; - var isSocketDisconnected = function (socket, realtime) { var sock = socket._socket; return sock.readyState === sock.CLOSING @@ -127,28 +106,6 @@ window.ErrorBox = ErrorBox; || (realtime.getLag().waiting && realtime.getLag().lag > MAX_LAG_BEFORE_DISCONNECT); }; - var updateUserList = function (myUserName, listElement, userList) { - var meIdx = userList.indexOf(myUserName); - if (meIdx === -1) { - listElement.textContent = Messages.synchronizing; - return; - } - if (userList.length === 1) { - listElement.textContent = Messages.editingAlone; - } else if (userList.length === 2) { - listElement.textContent = Messages.editingWithOneOtherPerson; - } else { - listElement.textContent = Messages.editingWith + ' ' + (userList.length - 1) + - Messages.otherPeople; - } - }; - - var createUserList = function (container) { - var id = uid(); - $(container).prepend('
'); - return $('#'+id)[0]; - }; - var abort = function (socket, realtime) { realtime.abort(); try { socket._socket.close(); } catch (e) { } @@ -284,89 +241,6 @@ window.ErrorBox = ErrorBox; return docText; }; - var uid = function () { - return 'rtwysiwyg-uid-' + String(Math.random()).substring(2); - }; - - var checkLag = function (realtime, lagElement) { - var lag = realtime.getLag(); - var lagSec = lag.lag/1000; - var lagMsg = Messages.lag + ' '; - if (lag.waiting && lagSec > 1) { - lagMsg += "?? " + Math.floor(lagSec); - } else { - lagMsg += lagSec; - } - lagElement.textContent = lagMsg; - }; - - var createLagElement = function (container) { - var id = uid(); - $(container).append(''); - return $('#'+id)[0]; - }; - - var createSpinner = function (container) { - var id = uid(); - $(container).append(''); - return $('#'+id)[0]; - }; - - var createRealtimeToolbar = function (container) { - var id = uid(); - $(container).prepend( - '