From a8ee9b39929320748ce69dd5b51f2a482c4941cf Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 11 Aug 2013 23:44:05 -0700 Subject: [PATCH] Oops, accidentally got tired. --- builds/4chan-X.user.js | 17 +++++++++-------- builds/crx/script.js | 17 +++++++++-------- src/Linkification/Linkify.coffee | 18 +++++++++--------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index a9f20840c..b7c190b1f 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4412,12 +4412,12 @@ links = []; if (Linkify.regString.test(node.data)) { Linkify.regString.lastIndex = 0; - Linkify.gatherLinks(snapshot, this, node, i); + Linkify.gatherLinks(snapshot, this, node, links, i); } _ref = links.reverse(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { range = _ref[_i]; - Linkify.makeLink(range, post); + this.nodes.links.push(Linkify.makeLink(range, this)); } } if (!(Conf['Embedding'] || Conf['Link Title'])) { @@ -4436,7 +4436,7 @@ } } }, - gatherLinks: function(snapshot, post, node, i) { + gatherLinks: function(snapshot, post, node, links, i) { var data, index, len, len2, link, match, range; data = node.data; @@ -4455,10 +4455,10 @@ } Linkify.regString.lastIndex = 0; if (match) { - links.push(Linkify.seek(snapshot, post, node, match, i)); + links.push(Linkify.seek(snapshot, post, node, links, match, i)); } }, - seek: function(snapshot, post, node, match, i) { + seek: function(snapshot, post, node, links, match, i) { var data, index, link, next, range, result; link = match[0]; @@ -4471,7 +4471,8 @@ index = result.index; range.setEnd(node, index); Linkify.regString.lastIndex = index; - Linkify.gatherLinks(snapshot, post, node, i); + Linkify.gatherLinks(snapshot, post, node, links, i); + return range; } } if (range.collapsed) { @@ -4479,7 +4480,7 @@ } return range; }, - makeLink: function(range, post) { + makeLink: function(range) { var a, link; link = range.toString(); @@ -4492,7 +4493,7 @@ }); $.add(a, range.extractContents()); range.insertNode(a); - post.nodes.links.push(a); + return a; }, services: function(link) { var href, key, match, type, _ref; diff --git a/builds/crx/script.js b/builds/crx/script.js index 567de0215..d7146a8ab 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4417,12 +4417,12 @@ links = []; if (Linkify.regString.test(node.data)) { Linkify.regString.lastIndex = 0; - Linkify.gatherLinks(snapshot, this, node, i); + Linkify.gatherLinks(snapshot, this, node, links, i); } _ref = links.reverse(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { range = _ref[_i]; - Linkify.makeLink(range, post); + this.nodes.links.push(Linkify.makeLink(range, this)); } } if (!(Conf['Embedding'] || Conf['Link Title'])) { @@ -4441,7 +4441,7 @@ } } }, - gatherLinks: function(snapshot, post, node, i) { + gatherLinks: function(snapshot, post, node, links, i) { var data, index, len, len2, link, match, range; data = node.data; @@ -4460,10 +4460,10 @@ } Linkify.regString.lastIndex = 0; if (match) { - links.push(Linkify.seek(snapshot, post, node, match, i)); + links.push(Linkify.seek(snapshot, post, node, links, match, i)); } }, - seek: function(snapshot, post, node, match, i) { + seek: function(snapshot, post, node, links, match, i) { var data, index, link, next, range, result; link = match[0]; @@ -4476,7 +4476,8 @@ index = result.index; range.setEnd(node, index); Linkify.regString.lastIndex = index; - Linkify.gatherLinks(snapshot, post, node, i); + Linkify.gatherLinks(snapshot, post, node, links, i); + return range; } } if (range.collapsed) { @@ -4484,7 +4485,7 @@ } return range; }, - makeLink: function(range, post) { + makeLink: function(range) { var a, link; link = range.toString(); @@ -4497,7 +4498,7 @@ }); $.add(a, range.extractContents()); range.insertNode(a); - post.nodes.links.push(a); + return a; }, services: function(link) { var href, key, match, type, _ref; diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 9ab8209a5..74dca4b22 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -52,10 +52,10 @@ Linkify = if Linkify.regString.test node.data Linkify.regString.lastIndex = 0 - Linkify.gatherLinks snapshot, @, node, i + Linkify.gatherLinks snapshot, @, node, links, i for range in links.reverse() - Linkify.makeLink range, post + @nodes.links.push Linkify.makeLink range, @ return unless Conf['Embedding'] or Conf['Link Title'] @@ -68,7 +68,7 @@ Linkify = return - gatherLinks: (snapshot, post, node, i) -> + gatherLinks: (snapshot, post, node, links, i) -> {data} = node len = data.length @@ -87,11 +87,11 @@ Linkify = Linkify.regString.lastIndex = 0 if match - links.push Linkify.seek snapshot, post, node, match, i + links.push Linkify.seek snapshot, post, node, links, match, i return - seek: (snapshot, post, node, match, i) -> + seek: (snapshot, post, node, links, match, i) -> link = match[0] range = document.createRange() range.setStart node, match.index @@ -103,14 +103,15 @@ Linkify = {index} = result range.setEnd node, index Linkify.regString.lastIndex = index - Linkify.gatherLinks snapshot, post, node, i + Linkify.gatherLinks snapshot, post, node, links, i + return range if range.collapsed range.setEndAfter node range - makeLink: (range, post) -> + makeLink: (range) -> link = range.toString() link = if link.contains ':' @@ -129,8 +130,7 @@ Linkify = href: link $.add a, range.extractContents() range.insertNode a - post.nodes.links.push a - return + a services: (link) -> href = link.href