diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 75ec6bd79..748b8382a 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1076,7 +1076,6 @@ function handleClientReady(client, message) "historicalAuthorData": historicalAuthorData, "apool": apool, "rev": pad.getHeadRevisionNumber(), - "globalPadId": message.padId, "time": currentTime, }, "colorPalette": authorManager.getColorPalette(), @@ -1093,7 +1092,6 @@ function handleClientReady(client, message) "readOnlyId": padIds.readOnlyPadId, "readonly": padIds.readonly, "serverTimestamp": new Date().getTime(), - "globalPadId": message.padId, "userId": author, "abiwordAvailable": settings.abiwordAvailable(), "plugins": { diff --git a/src/node/utils/padDiff.js b/src/node/utils/padDiff.js index c53540417..88fa5cbad 100644 --- a/src/node/utils/padDiff.js +++ b/src/node/utils/padDiff.js @@ -331,14 +331,6 @@ PadDiff.prototype._createDeletionChangeset = function(cs, startAText, apool) { } } - function lines_length() { - if ((typeof lines.length) == "number") { - return lines.length; - } else { - return lines.length(); - } - } - function alines_get(idx) { if (alines.get) { return alines.get(idx); @@ -347,14 +339,6 @@ PadDiff.prototype._createDeletionChangeset = function(cs, startAText, apool) { } } - function alines_length() { - if ((typeof alines.length) == "number") { - return alines.length; - } else { - return alines.length(); - } - } - var curLine = 0; var curChar = 0; var curLineOpIter = null; diff --git a/src/node/utils/tar.json b/src/node/utils/tar.json index b010f851b..70001f8f2 100644 --- a/src/node/utils/tar.json +++ b/src/node/utils/tar.json @@ -46,7 +46,6 @@ , "Changeset.js" , "ChangesetUtils.js" , "skiplist.js" - , "virtual_lines.js" , "cssmanager.js" , "colorutils.js" , "undomodule.js" diff --git a/src/static/css/iframe_editor.css b/src/static/css/iframe_editor.css index ddb509f45..beec4971c 100644 --- a/src/static/css/iframe_editor.css +++ b/src/static/css/iframe_editor.css @@ -159,8 +159,6 @@ p { font-family: monospace; /* overridden by lineMetricsDiv.style */ } -#overlaysdiv { position: absolute; left: -1000px; top: -1000px; } - /* Stops super long lines without being spaces such as aaaaaaaaaaaaaa*100 breaking the editor Commented out because it stops IE from being able to render the document, crazy IE bug is crazy. */ /* diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index 77bd3a4c9..e47b30524 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -1841,14 +1841,6 @@ exports.inverse = function (cs, lines, alines, pool) { } } - function lines_length() { - if ((typeof lines.length) == "number") { - return lines.length; - } else { - return lines.length(); - } - } - function alines_get(idx) { if (alines.get) { return alines.get(idx); @@ -1857,14 +1849,6 @@ exports.inverse = function (cs, lines, alines, pool) { } } - function alines_length() { - if ((typeof alines.length) == "number") { - return alines.length; - } else { - return alines.length(); - } - } - var curLine = 0; var curChar = 0; var curLineOpIter = null; diff --git a/src/static/js/ace.js b/src/static/js/ace.js index db0d596b8..d2bbb4847 100644 --- a/src/static/js/ace.js +++ b/src/static/js/ace.js @@ -313,7 +313,7 @@ window.onload = function () {\n\ // bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly // (throbs busy while typing) - outerHTML.push('', '', scriptTag(outerScript), '
x
'); + outerHTML.push('', '', scriptTag(outerScript), '
x
'); var outerFrame = document.createElement("IFRAME"); outerFrame.name = "ace_outer"; diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 012d72f38..0aa9998ad 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -51,7 +51,6 @@ function Ace2Inner(){ var linestylefilter = require('./linestylefilter').linestylefilter; var SkipList = require('./skiplist'); var undoModule = require('./undomodule').undoModule; - var makeVirtualLineView = require('./virtual_lines').makeVirtualLineView; var AttributeManager = require('./AttributeManager'); var DEBUG = false; //$$ build script replaces the string "var DEBUG=true;//$$" with "var DEBUG=false;" @@ -79,7 +78,6 @@ function Ace2Inner(){ iframe.ace_outerWin = null; // prevent IE 6 memory leak var sideDiv = iframe.nextSibling; var lineMetricsDiv = sideDiv.nextSibling; - var overlaysdiv = lineMetricsDiv.nextSibling; initLineNumbers(); var outsideKeyDown = noop; @@ -102,13 +100,13 @@ function Ace2Inner(){ apool: new AttribPool() }; - // lines, alltext, alines, and DOM are set up in setup() + // lines, alltext, alines, and DOM are set up in init() if (undoModule.enabled) { undoModule.apool = rep.apool; } - var root, doc; // set in setup() + var root, doc; // set in init() var isEditable = true; var doesWrap = true; var hasLineNumbers = true; @@ -346,19 +344,6 @@ function Ace2Inner(){ } } - function boldColorFromColor(lightColorCSS) - { - var color = colorutils.css2triple(lightColorCSS); - - // amp up the saturation to full - color = colorutils.saturate(color); - - // normalize brightness based on luminosity - color = colorutils.scaleColor(color, 0, 0.5 / colorutils.luminosity(color)); - - return colorutils.triple2css(color); - } - function fadeColor(colorCSS, fadeFrac) { var color = colorutils.css2triple(colorCSS); @@ -551,22 +536,6 @@ function Ace2Inner(){ } editorInfo.ace_inCallStackIfNecessary = inCallStackIfNecessary; - function recolorLineByKey(key) - { - if (rep.lines.containsKey(key)) - { - var offset = rep.lines.offsetOfKey(key); - var width = rep.lines.atKey(key).width; - recolorLinesInRange(offset, offset + width); - } - } - - function getLineKeyForOffset(charOffset) - { - return rep.lines.atOffset(charOffset).key; - } - - function dispose() { disposed = true; @@ -1173,34 +1142,6 @@ function Ace2Inner(){ } editorInfo.ace_fastIncorp = fastIncorp; - function incorpIfQuick() - { - var me = incorpIfQuick; - var failures = (me.failures || 0); - if (failures < 5) - { - var isTimeUp = newTimeLimit(40); - var madeChanges = incorporateUserChanges(isTimeUp); - if (isTimeUp()) - { - me.failures = failures + 1; - } - return true; - } - else - { - var skipCount = (me.skipCount || 0); - skipCount++; - if (skipCount == 20) - { - skipCount = 0; - me.failures = 0; - } - me.skipCount = skipCount; - } - return false; - } - var idleWorkTimer = makeIdleAction(function() { @@ -1807,13 +1748,6 @@ function Ace2Inner(){ return domChanges; } - function htmlForRemovedChild(n) - { - var div = doc.createElement("DIV"); - div.appendChild(n); - return div.innerHTML; - } - var STYLE_ATTRIBS = { bold: true, italic: true, @@ -4900,54 +4834,6 @@ function Ace2Inner(){ else $(elem).removeClass(className); } - function setup() - { - doc = document; // defined as a var in scope outside - inCallStackIfNecessary("setup", function() - { - var body = doc.getElementById("innerdocbody"); - root = body; // defined as a var in scope outside - if (browser.mozilla) addClass(root, "mozilla"); - if (browser.safari) addClass(root, "safari"); - if (browser.msie) addClass(root, "msie"); - if (browser.msie) - { - // cache CSS background images - try - { - doc.execCommand("BackgroundImageCache", false, true); - } - catch (e) - { /* throws an error in some IE 6 but not others! */ - } - } - setClassPresence(root, "authorColors", true); - setClassPresence(root, "doesWrap", doesWrap); - - initDynamicCSS(); - - enforceEditability(); - - // set up dom and rep - while (root.firstChild) root.removeChild(root.firstChild); - var oneEntry = createDomLineEntry(""); - doRepLineSplice(0, rep.lines.length(), [oneEntry]); - insertDomLines(null, [oneEntry.domInfo], null); - rep.alines = Changeset.splitAttributionLines( - Changeset.makeAttribution("\n"), "\n"); - - bindTheEventHandlers(); - - }); - - scheduler.setTimeout(function() - { - parent.readyFunc(); // defined in code that sets up the inner iframe - }, 0); - - isSetUp = true; - } - function focus() { window.focus(); diff --git a/src/static/js/broadcast.js b/src/static/js/broadcast.js index 6bd135bd2..d4bda1110 100644 --- a/src/static/js/broadcast.js +++ b/src/static/js/broadcast.js @@ -77,7 +77,6 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro } - var socketId; //var socket; var channelState = "DISCONNECTED"; diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index ec56264f8..146ec51b5 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -40,11 +40,9 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) var rev = serverVars.rev; var padId = serverVars.padId; - var globalPadId = serverVars.globalPadId; var state = "IDLE"; var stateMessage; - var stateMessageSocketId; var channelState = "CONNECTING"; var appLevelDisconnectReason = null; @@ -52,12 +50,10 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) var initialStartConnectTime = 0; var userId = initialUserInfo.userId; - var socketId; //var socket; var userSet = {}; // userId -> userInfo userSet[userId] = initialUserInfo; - var reconnectTimes = []; var caughtErrors = []; var caughtErrorCatchers = []; var caughtErrorTimes = []; @@ -196,7 +192,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) changeset: userChangesData.changeset, apool: userChangesData.apool }; - stateMessageSocketId = socketId; sendMessage(stateMessage); sentMessage = true; callbacks.onInternalAction("commitPerformed"); @@ -209,17 +204,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) } } - function getStats() - { - var stats = {}; - - stats.screen = [$(window).width(), $(window).height(), window.screen.availWidth, window.screen.availHeight, window.screen.width, window.screen.height].join(','); - stats.ip = serverVars.clientIp; - stats.useragent = serverVars.clientAgent; - - return stats; - } - function setUpSocket() { hiccupCount = 0; @@ -505,16 +489,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) } } - function keys(obj) - { - var array = []; - $.each(obj, function(k, v) - { - array.push(k); - }); - return array; - } - function valuesArray(obj) { var array = []; @@ -593,7 +567,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) { obj.committedChangeset = stateMessage.changeset; obj.committedChangesetAPool = stateMessage.apool; - obj.committedChangesetSocketId = stateMessageSocketId; editor.applyPreparedChangesetToBase(); } var userChangesData = editor.prepareUserChangeset(); diff --git a/src/static/js/pad_connectionstatus.js b/src/static/js/pad_connectionstatus.js index 4cbf16425..76eedbc4d 100644 --- a/src/static/js/pad_connectionstatus.js +++ b/src/static/js/pad_connectionstatus.js @@ -21,7 +21,6 @@ */ var padmodals = require('./pad_modals').padmodals; -var padeditbar = require('./pad_editbar').padeditbar; var padconnectionstatus = (function() { diff --git a/src/static/js/pad_modals.js b/src/static/js/pad_modals.js index 39094a7ea..67b03662f 100644 --- a/src/static/js/pad_modals.js +++ b/src/static/js/pad_modals.js @@ -20,7 +20,6 @@ * limitations under the License. */ -var padutils = require('./pad_utils').padutils; var padeditbar = require('./pad_editbar').padeditbar; var padmodals = (function() @@ -39,10 +38,10 @@ var padmodals = (function() padeditbar.toggleDropDown("connectivity"); }); }, - showOverlay: function(duration) { + showOverlay: function() { $("#overlay").show(); }, - hideOverlay: function(duration) { + hideOverlay: function() { $("#overlay").hide(); } }; diff --git a/src/static/js/timeslider.js b/src/static/js/timeslider.js index 194899617..fd22c69a3 100644 --- a/src/static/js/timeslider.js +++ b/src/static/js/timeslider.js @@ -28,7 +28,6 @@ JSON = require('./json2'); var createCookie = require('./pad_utils').createCookie; var readCookie = require('./pad_utils').readCookie; var randomString = require('./pad_utils').randomString; -var _ = require('./underscore'); var hooks = require('./pluginfw/hooks'); var token, padId, export_links; diff --git a/src/static/js/virtual_lines.js b/src/static/js/virtual_lines.js deleted file mode 100644 index 2bcf5ed63..000000000 --- a/src/static/js/virtual_lines.js +++ /dev/null @@ -1,388 +0,0 @@ -/** - * This code is mostly from the old Etherpad. Please help us to comment this code. - * This helps other people to understand this code better and helps them to improve it. - * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED - */ - -/** - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -function makeVirtualLineView(lineNode) -{ - - // how much to jump forward or backward at once in a charSeeker before - // constructing a DOM node and checking the coordinates (which takes a - // significant fraction of a millisecond). From the - // coordinates and the approximate line height we can estimate how - // many lines we have moved. We risk being off if the number of lines - // we move is on the order of the line height in pixels. Fortunately, - // when the user boosts the font-size they increase both. - var maxCharIncrement = 20; - var seekerAtEnd = null; - - function getNumChars() - { - return lineNode.textContent.length; - } - - function getNumVirtualLines() - { - if (!seekerAtEnd) - { - var seeker = makeCharSeeker(); - seeker.forwardByWhile(maxCharIncrement); - seekerAtEnd = seeker; - } - return seekerAtEnd.getVirtualLine() + 1; - } - - function getVLineAndOffsetForChar(lineChar) - { - var seeker = makeCharSeeker(); - seeker.forwardByWhile(maxCharIncrement, null, lineChar); - var theLine = seeker.getVirtualLine(); - seeker.backwardByWhile(8, function() - { - return seeker.getVirtualLine() == theLine; - }); - seeker.forwardByWhile(1, function() - { - return seeker.getVirtualLine() != theLine; - }); - var lineStartChar = seeker.getOffset(); - return { - vline: theLine, - offset: (lineChar - lineStartChar) - }; - } - - function getCharForVLineAndOffset(vline, offset) - { - // returns revised vline and offset as well as absolute char index within line. - // if offset is beyond end of line, for example, will give new offset at end of line. - var seeker = makeCharSeeker(); - // go to start of line - seeker.binarySearch(function() - { - return seeker.getVirtualLine() >= vline; - }); - var lineStart = seeker.getOffset(); - var theLine = seeker.getVirtualLine(); - // go to offset, overshooting the virtual line only if offset is too large for it - seeker.forwardByWhile(maxCharIncrement, null, lineStart + offset); - // get back into line - seeker.backwardByWhile(1, function() - { - return seeker.getVirtualLine() != theLine; - }, lineStart); - var lineChar = seeker.getOffset(); - var theOffset = lineChar - lineStart; - // handle case of last virtual line; should be able to be at end of it - if (theOffset < offset && theLine == (getNumVirtualLines() - 1)) - { - var lineLen = getNumChars(); - theOffset += lineLen - lineChar; - lineChar = lineLen; - } - - return { - vline: theLine, - offset: theOffset, - lineChar: lineChar - }; - } - - return { - getNumVirtualLines: getNumVirtualLines, - getVLineAndOffsetForChar: getVLineAndOffsetForChar, - getCharForVLineAndOffset: getCharForVLineAndOffset, - makeCharSeeker: function() - { - return makeCharSeeker(); - } - }; - - function deepFirstChildTextNode(nd) - { - nd = nd.firstChild; - while (nd && nd.firstChild) nd = nd.firstChild; - if (nd.data) return nd; - return null; - } - - function makeCharSeeker( /*lineNode*/ ) - { - - function charCoords(tnode, i) - { - var container = tnode.parentNode; - - // treat space specially; a space at the end of a virtual line - // will have weird coordinates - var isSpace = (tnode.nodeValue.charAt(i) === " "); - if (isSpace) - { - if (i == 0) - { - if (container.previousSibling && deepFirstChildTextNode(container.previousSibling)) - { - tnode = deepFirstChildTextNode(container.previousSibling); - i = tnode.length - 1; - container = tnode.parentNode; - } - else - { - return { - top: container.offsetTop, - left: container.offsetLeft - }; - } - } - else - { - i--; // use previous char - } - } - - - var charWrapper = document.createElement("SPAN"); - - // wrap the character - var tnodeText = tnode.nodeValue; - var frag = document.createDocumentFragment(); - frag.appendChild(document.createTextNode(tnodeText.substring(0, i))); - charWrapper.appendChild(document.createTextNode(tnodeText.substr(i, 1))); - frag.appendChild(charWrapper); - frag.appendChild(document.createTextNode(tnodeText.substring(i + 1))); - container.replaceChild(frag, tnode); - - var result = { - top: charWrapper.offsetTop, - left: charWrapper.offsetLeft + (isSpace ? charWrapper.offsetWidth : 0), - height: charWrapper.offsetHeight - }; - - while (container.firstChild) container.removeChild(container.firstChild); - container.appendChild(tnode); - - return result; - } - - var lineText = lineNode.textContent; - var lineLength = lineText.length; - - var curNode = null; - var curChar = 0; - var curCharWithinNode = 0 - var curTop; - var curLeft; - var approxLineHeight; - var whichLine = 0; - - function nextNode() - { - var n = curNode; - if (!n) n = lineNode.firstChild; - else n = n.nextSibling; - while (n && !deepFirstChildTextNode(n)) - { - n = n.nextSibling; - } - return n; - } - - function prevNode() - { - var n = curNode; - if (!n) n = lineNode.lastChild; - else n = n.previousSibling; - while (n && !deepFirstChildTextNode(n)) - { - n = n.previousSibling; - } - return n; - } - - var seeker; - if (lineLength > 0) - { - curNode = nextNode(); - var firstCharData = charCoords(deepFirstChildTextNode(curNode), 0); - approxLineHeight = firstCharData.height; - curTop = firstCharData.top; - curLeft = firstCharData.left; - - function updateCharData(tnode, i) - { - var coords = charCoords(tnode, i); - whichLine += Math.round((coords.top - curTop) / approxLineHeight); - curTop = coords.top; - curLeft = coords.left; - } - - seeker = { - forward: function(numChars) - { - var oldChar = curChar; - var newChar = curChar + numChars; - if (newChar > (lineLength - 1)) newChar = lineLength - 1; - while (curChar < newChar) - { - var curNodeLength = deepFirstChildTextNode(curNode).length; - var toGo = curNodeLength - curCharWithinNode; - if (curChar + toGo > newChar || !nextNode()) - { - // going to next node would be too far - var n = newChar - curChar; - if (n >= toGo) n = toGo - 1; - curChar += n; - curCharWithinNode += n; - break; - } - else - { - // go to next node - curChar += toGo; - curCharWithinNode = 0; - curNode = nextNode(); - } - } - updateCharData(deepFirstChildTextNode(curNode), curCharWithinNode); - return curChar - oldChar; - }, - backward: function(numChars) - { - var oldChar = curChar; - var newChar = curChar - numChars; - if (newChar < 0) newChar = 0; - while (curChar > newChar) - { - if (curChar - curCharWithinNode <= newChar || !prevNode()) - { - // going to prev node would be too far - var n = curChar - newChar; - if (n > curCharWithinNode) n = curCharWithinNode; - curChar -= n; - curCharWithinNode -= n; - break; - } - else - { - // go to prev node - curChar -= curCharWithinNode + 1; - curNode = prevNode(); - curCharWithinNode = deepFirstChildTextNode(curNode).length - 1; - } - } - updateCharData(deepFirstChildTextNode(curNode), curCharWithinNode); - return oldChar - curChar; - }, - getVirtualLine: function() - { - return whichLine; - }, - getLeftCoord: function() - { - return curLeft; - } - }; - } - else - { - curLeft = lineNode.offsetLeft; - seeker = { - forward: function(numChars) - { - return 0; - }, - backward: function(numChars) - { - return 0; - }, - getVirtualLine: function() - { - return 0; - }, - getLeftCoord: function() - { - return curLeft; - } - }; - } - seeker.getOffset = function() - { - return curChar; - }; - seeker.getLineLength = function() - { - return lineLength; - }; - seeker.toString = function() - { - return "seeker[curChar: " + curChar + "(" + lineText.charAt(curChar) + "), left: " + seeker.getLeftCoord() + ", vline: " + seeker.getVirtualLine() + "]"; - }; - - function moveByWhile(isBackward, amount, optCondFunc, optCharLimit) - { - var charsMovedLast = null; - var hasCondFunc = ((typeof optCondFunc) == "function"); - var condFunc = optCondFunc; - var hasCharLimit = ((typeof optCharLimit) == "number"); - var charLimit = optCharLimit; - while (charsMovedLast !== 0 && ((!hasCondFunc) || condFunc())) - { - var toMove = amount; - if (hasCharLimit) - { - var untilLimit = (isBackward ? curChar - charLimit : charLimit - curChar); - if (untilLimit < toMove) toMove = untilLimit; - } - if (toMove < 0) break; - charsMovedLast = (isBackward ? seeker.backward(toMove) : seeker.forward(toMove)); - } - } - - seeker.forwardByWhile = function(amount, optCondFunc, optCharLimit) - { - moveByWhile(false, amount, optCondFunc, optCharLimit); - } - seeker.backwardByWhile = function(amount, optCondFunc, optCharLimit) - { - moveByWhile(true, amount, optCondFunc, optCharLimit); - } - seeker.binarySearch = function(condFunc) - { - // returns index of boundary between false chars and true chars; - // positions seeker at first true char, or else last char - var trueFunc = condFunc; - var falseFunc = function() - { - return !condFunc(); - }; - seeker.forwardByWhile(20, falseFunc); - seeker.backwardByWhile(20, trueFunc); - seeker.forwardByWhile(10, falseFunc); - seeker.backwardByWhile(5, trueFunc); - seeker.forwardByWhile(1, falseFunc); - return seeker.getOffset() + (condFunc() ? 0 : 1); - } - - return seeker; - } - -} - -exports.makeVirtualLineView = makeVirtualLineView; diff --git a/src/templates/pad.html b/src/templates/pad.html index bed281516..d03bcbe49 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -274,7 +274,6 @@
-