Merge pull request #2028 from webzwo0i/remove-deadcode

Remove deadcode
This commit is contained in:
John McLear 2013-12-09 10:49:57 -08:00
commit 24e96c4f8b
14 changed files with 5 additions and 576 deletions

View file

@ -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": {

View file

@ -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;

View file

@ -46,7 +46,6 @@
, "Changeset.js"
, "ChangesetUtils.js"
, "skiplist.js"
, "virtual_lines.js"
, "cssmanager.js"
, "colorutils.js"
, "undomodule.js"

View file

@ -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. */
/*

View file

@ -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;

View file

@ -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('<style type="text/css" title="dynamicsyntax"></style>', '<link rel="stylesheet" type="text/css" href="data:text/css,"/>', scriptTag(outerScript), '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>');
outerHTML.push('<style type="text/css" title="dynamicsyntax"></style>', '<link rel="stylesheet" type="text/css" href="data:text/css,"/>', scriptTag(outerScript), '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div></body></html>');
var outerFrame = document.createElement("IFRAME");
outerFrame.name = "ace_outer";

View file

@ -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();

View file

@ -77,7 +77,6 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
}
var socketId;
//var socket;
var channelState = "DISCONNECTED";

View file

@ -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();

View file

@ -21,7 +21,6 @@
*/
var padmodals = require('./pad_modals').padmodals;
var padeditbar = require('./pad_editbar').padeditbar;
var padconnectionstatus = (function()
{

View file

@ -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();
}
};

View file

@ -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;

View file

@ -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;

View file

@ -274,7 +274,6 @@
<div id="import"></div>
<div class="importmessage" id="importmessagesuccess" data-l10n-id="pad.importExport.importSuccessful"></div>
<div class="importformdiv" id="importformsubmitdiv">
<input type="hidden" name="padId" value="blpmaXT35R">
<span class="nowrap">
<input type="submit" name="submit" value="Import Now" disabled="disabled" id="importsubmitinput">
<img alt="" id="importstatusball" src="../static/img/loading.gif" align="top">