From 256e20aea5147a7a20ed1b1d5ec367a2c1b31836 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 11 Aug 2013 23:33:44 -0700 Subject: [PATCH] Since we're adding recursion, we should probably move our variable declaration outside of the potential recursive function --- builds/4chan-X.user.js | 16 ++++++++-------- builds/crx/script.js | 16 ++++++++-------- src/Linkification/Linkify.coffee | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 4b80565ec..a9f20840c 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4388,7 +4388,7 @@ }); }, node: function() { - var data, el, i, items, node, range, snapshot; + var data, el, i, items, links, node, range, snapshot, _i, _len, _ref; if (this.isClone) { if (Conf['Embedding']) { @@ -4409,10 +4409,16 @@ if (node.parentElement.nodeName === "A") { continue; } + links = []; if (Linkify.regString.test(node.data)) { Linkify.regString.lastIndex = 0; Linkify.gatherLinks(snapshot, this, node, i); } + _ref = links.reverse(); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + range = _ref[_i]; + Linkify.makeLink(range, post); + } } if (!(Conf['Embedding'] || Conf['Link Title'])) { return; @@ -4431,11 +4437,10 @@ } }, gatherLinks: function(snapshot, post, node, i) { - var data, index, len, len2, link, links, match, range, _i, _len, _ref; + var data, index, len, len2, link, match, range; data = node.data; len = data.length; - links = []; while ((match = Linkify.regString.exec(data))) { index = match.index; link = match[0]; @@ -4452,11 +4457,6 @@ if (match) { links.push(Linkify.seek(snapshot, post, node, match, i)); } - _ref = links.reverse(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - range = _ref[_i]; - Linkify.makeLink(range, post); - } }, seek: function(snapshot, post, node, match, i) { var data, index, link, next, range, result; diff --git a/builds/crx/script.js b/builds/crx/script.js index 60987bcda..567de0215 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4393,7 +4393,7 @@ }); }, node: function() { - var data, el, i, items, node, range, snapshot; + var data, el, i, items, links, node, range, snapshot, _i, _len, _ref; if (this.isClone) { if (Conf['Embedding']) { @@ -4414,10 +4414,16 @@ if (node.parentElement.nodeName === "A") { continue; } + links = []; if (Linkify.regString.test(node.data)) { Linkify.regString.lastIndex = 0; Linkify.gatherLinks(snapshot, this, node, i); } + _ref = links.reverse(); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + range = _ref[_i]; + Linkify.makeLink(range, post); + } } if (!(Conf['Embedding'] || Conf['Link Title'])) { return; @@ -4436,11 +4442,10 @@ } }, gatherLinks: function(snapshot, post, node, i) { - var data, index, len, len2, link, links, match, range, _i, _len, _ref; + var data, index, len, len2, link, match, range; data = node.data; len = data.length; - links = []; while ((match = Linkify.regString.exec(data))) { index = match.index; link = match[0]; @@ -4457,11 +4462,6 @@ if (match) { links.push(Linkify.seek(snapshot, post, node, match, i)); } - _ref = links.reverse(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - range = _ref[_i]; - Linkify.makeLink(range, post); - } }, seek: function(snapshot, post, node, match, i) { var data, index, link, next, range, result; diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 8996da4bd..9ab8209a5 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -48,11 +48,15 @@ Linkify = while node = snapshot.snapshotItem i++ continue if node.parentElement.nodeName is "A" + links = [] if Linkify.regString.test node.data Linkify.regString.lastIndex = 0 Linkify.gatherLinks snapshot, @, node, i + for range in links.reverse() + Linkify.makeLink range, post + return unless Conf['Embedding'] or Conf['Link Title'] items = @nodes.links @@ -67,7 +71,6 @@ Linkify = gatherLinks: (snapshot, post, node, i) -> {data} = node len = data.length - links = [] while (match = Linkify.regString.exec data) {index} = match @@ -86,9 +89,6 @@ Linkify = if match links.push Linkify.seek snapshot, post, node, match, i - for range in links.reverse() - Linkify.makeLink range, post - return seek: (snapshot, post, node, match, i) ->