utils/ExportHtml: nearly jshint compatible

This commit is contained in:
booo 2011-12-22 14:06:30 +01:00
parent ef1baf9510
commit 325ab65055

View file

@ -55,7 +55,7 @@ function getPadHTML(pad, revNum, callback)
function (callback) function (callback)
{ {
if (revNum != undefined) if (revNum)
{ {
pad.getInternalRevisionAText(revNum, function (err, revisionAtext) pad.getInternalRevisionAText(revNum, function (err, revisionAtext)
{ {
@ -171,6 +171,8 @@ function getHTMLFromAtext(pad, atext)
var iter = Changeset.opIterator(Changeset.subattribution(attribs, idx, idx + numChars)); var iter = Changeset.opIterator(Changeset.subattribution(attribs, idx, idx + numChars));
idx += numChars; idx += numChars;
var tags2close;
while (iter.hasNext()) while (iter.hasNext())
{ {
var o = iter.next(); var o = iter.next();
@ -191,7 +193,9 @@ function getHTMLFromAtext(pad, atext)
} }
} }
}); });
for (var i = 0; i < propVals.length; i++)
var i;
for (i = 0; i < propVals.length; i++)
{ {
if (propVals[i] === true) if (propVals[i] === true)
{ {
@ -209,7 +213,7 @@ function getHTMLFromAtext(pad, atext)
{ {
// leaving bold (e.g.) also leaves italics, etc. // leaving bold (e.g.) also leaves italics, etc.
var left = false; var left = false;
for (var i = 0; i < propVals.length; i++) for (i = 0; i < propVals.length; i++)
{ {
var v = propVals[i]; var v = propVals[i];
if (!left) if (!left)
@ -228,9 +232,9 @@ function getHTMLFromAtext(pad, atext)
} }
} }
var tags2close = []; tags2close = [];
for (var i = propVals.length - 1; i >= 0; i--) for (i = propVals.length - 1; i >= 0; i--)
{ {
if (propVals[i] === LEAVE) if (propVals[i] === LEAVE)
{ {
@ -247,7 +251,7 @@ function getHTMLFromAtext(pad, atext)
orderdCloseTags(tags2close); orderdCloseTags(tags2close);
for (var i = 0; i < propVals.length; i++) for (i = 0; i < propVals.length; i++)
{ {
if (propVals[i] === ENTER || propVals[i] === STAY) if (propVals[i] === ENTER || propVals[i] === STAY)
{ {
@ -272,13 +276,13 @@ function getHTMLFromAtext(pad, atext)
assem.append(_escapeHTML(s)); assem.append(_escapeHTML(s));
} // end iteration over spans in line } // end iteration over spans in line
var tags2close = []; tags2close = [];
for (var i = propVals.length - 1; i >= 0; i--) for (var x = propVals.length - 1; x >= 0; x--)
{ {
if (propVals[i]) if (propVals[x])
{ {
tags2close.push(i); tags2close.push(x);
propVals[i] = false; propVals[x] = false;
} }
} }
@ -425,7 +429,7 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback)
callback(null, head + html + foot); callback(null, head + html + foot);
}); });
}); });
} };
function _escapeHTML(s) function _escapeHTML(s)
{ {
@ -436,7 +440,7 @@ function _escapeHTML(s)
re.MAP = { re.MAP = {
'&': '&amp;', '&': '&amp;',
'<': '&lt;', '<': '&lt;',
'>': '&gt;', '>': '&gt;'
}; };
} }
@ -447,7 +451,7 @@ function _escapeHTML(s)
return s.replace(/[^\x21-\x7E\s\t\n\r]/g, function(c) return s.replace(/[^\x21-\x7E\s\t\n\r]/g, function(c)
{ {
return "&#" +c.charCodeAt(0) + ";" return "&#" +c.charCodeAt(0) + ";";
}); });
} }
@ -467,15 +471,19 @@ function _processSpaces(s)
{ {
parts.push(m); parts.push(m);
}); });
var i;
var p;
if (doesWrap) if (doesWrap)
{ {
var endOfLine = true; var endOfLine = true;
var beforeSpace = false; var beforeSpace = false;
// last space in a run is normal, others are nbsp, // last space in a run is normal, others are nbsp,
// end of line is nbsp // end of line is nbsp
for (var i = parts.length - 1; i >= 0; i--) for (i = parts.length - 1; i >= 0; i--)
{ {
var p = parts[i]; p = parts[i];
if (p == " ") if (p == " ")
{ {
if (endOfLine || beforeSpace) parts[i] = '&nbsp;'; if (endOfLine || beforeSpace) parts[i] = '&nbsp;';
@ -489,9 +497,9 @@ function _processSpaces(s)
} }
} }
// beginning of line is nbsp // beginning of line is nbsp
for (var i = 0; i < parts.length; i++) for (i = 0; i < parts.length; i++)
{ {
var p = parts[i]; p = parts[i];
if (p == " ") if (p == " ")
{ {
parts[i] = '&nbsp;'; parts[i] = '&nbsp;';
@ -505,9 +513,9 @@ function _processSpaces(s)
} }
else else
{ {
for (var i = 0; i < parts.length; i++) for (i = 0; i < parts.length; i++)
{ {
var p = parts[i]; p = parts[i];
if (p == " ") if (p == " ")
{ {
parts[i] = '&nbsp;'; parts[i] = '&nbsp;';
@ -521,7 +529,7 @@ function _processSpaces(s)
// copied from ACE // copied from ACE
var _REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/; var _REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/;
var _REGEX_SPACE = /\s/; var _REGEX_SPACE = /\s/;
var _REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#;()$]/.source + '|' + _REGEX_WORDCHAR.source + ')'); var _REGEX_URLCHAR = new RegExp('(' + (/[\-:@a-zA-Z0-9_.,~%+\/\\?=&#;()$]/).source + '|' + _REGEX_WORDCHAR.source + ')');
var _REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|gopher|txmt):\/\/|mailto:)/.source + _REGEX_URLCHAR.source + '*(?![:.,;])' + _REGEX_URLCHAR.source, 'g'); var _REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|gopher|txmt):\/\/|mailto:)/.source + _REGEX_URLCHAR.source + '*(?![:.,;])' + _REGEX_URLCHAR.source, 'g');
// returns null if no URLs, or [[startIndex1, url1], [startIndex2, url2], ...] // returns null if no URLs, or [[startIndex1, url1], [startIndex2, url2], ...]