Oops, accidentally got tired.

This commit is contained in:
Zixaphir 2013-08-11 23:44:05 -07:00
parent 256e20aea5
commit a8ee9b3992
3 changed files with 27 additions and 25 deletions

View File

@ -4412,12 +4412,12 @@
links = []; links = [];
if (Linkify.regString.test(node.data)) { if (Linkify.regString.test(node.data)) {
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
Linkify.gatherLinks(snapshot, this, node, i); Linkify.gatherLinks(snapshot, this, node, links, i);
} }
_ref = links.reverse(); _ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i]; range = _ref[_i];
Linkify.makeLink(range, post); this.nodes.links.push(Linkify.makeLink(range, this));
} }
} }
if (!(Conf['Embedding'] || Conf['Link Title'])) { 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; var data, index, len, len2, link, match, range;
data = node.data; data = node.data;
@ -4455,10 +4455,10 @@
} }
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
if (match) { 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; var data, index, link, next, range, result;
link = match[0]; link = match[0];
@ -4471,7 +4471,8 @@
index = result.index; index = result.index;
range.setEnd(node, index); range.setEnd(node, index);
Linkify.regString.lastIndex = index; Linkify.regString.lastIndex = index;
Linkify.gatherLinks(snapshot, post, node, i); Linkify.gatherLinks(snapshot, post, node, links, i);
return range;
} }
} }
if (range.collapsed) { if (range.collapsed) {
@ -4479,7 +4480,7 @@
} }
return range; return range;
}, },
makeLink: function(range, post) { makeLink: function(range) {
var a, link; var a, link;
link = range.toString(); link = range.toString();
@ -4492,7 +4493,7 @@
}); });
$.add(a, range.extractContents()); $.add(a, range.extractContents());
range.insertNode(a); range.insertNode(a);
post.nodes.links.push(a); return a;
}, },
services: function(link) { services: function(link) {
var href, key, match, type, _ref; var href, key, match, type, _ref;

View File

@ -4417,12 +4417,12 @@
links = []; links = [];
if (Linkify.regString.test(node.data)) { if (Linkify.regString.test(node.data)) {
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
Linkify.gatherLinks(snapshot, this, node, i); Linkify.gatherLinks(snapshot, this, node, links, i);
} }
_ref = links.reverse(); _ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i]; range = _ref[_i];
Linkify.makeLink(range, post); this.nodes.links.push(Linkify.makeLink(range, this));
} }
} }
if (!(Conf['Embedding'] || Conf['Link Title'])) { 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; var data, index, len, len2, link, match, range;
data = node.data; data = node.data;
@ -4460,10 +4460,10 @@
} }
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
if (match) { 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; var data, index, link, next, range, result;
link = match[0]; link = match[0];
@ -4476,7 +4476,8 @@
index = result.index; index = result.index;
range.setEnd(node, index); range.setEnd(node, index);
Linkify.regString.lastIndex = index; Linkify.regString.lastIndex = index;
Linkify.gatherLinks(snapshot, post, node, i); Linkify.gatherLinks(snapshot, post, node, links, i);
return range;
} }
} }
if (range.collapsed) { if (range.collapsed) {
@ -4484,7 +4485,7 @@
} }
return range; return range;
}, },
makeLink: function(range, post) { makeLink: function(range) {
var a, link; var a, link;
link = range.toString(); link = range.toString();
@ -4497,7 +4498,7 @@
}); });
$.add(a, range.extractContents()); $.add(a, range.extractContents());
range.insertNode(a); range.insertNode(a);
post.nodes.links.push(a); return a;
}, },
services: function(link) { services: function(link) {
var href, key, match, type, _ref; var href, key, match, type, _ref;

View File

@ -52,10 +52,10 @@ Linkify =
if Linkify.regString.test node.data if Linkify.regString.test node.data
Linkify.regString.lastIndex = 0 Linkify.regString.lastIndex = 0
Linkify.gatherLinks snapshot, @, node, i Linkify.gatherLinks snapshot, @, node, links, i
for range in links.reverse() for range in links.reverse()
Linkify.makeLink range, post @nodes.links.push Linkify.makeLink range, @
return unless Conf['Embedding'] or Conf['Link Title'] return unless Conf['Embedding'] or Conf['Link Title']
@ -68,7 +68,7 @@ Linkify =
return return
gatherLinks: (snapshot, post, node, i) -> gatherLinks: (snapshot, post, node, links, i) ->
{data} = node {data} = node
len = data.length len = data.length
@ -87,11 +87,11 @@ Linkify =
Linkify.regString.lastIndex = 0 Linkify.regString.lastIndex = 0
if match if match
links.push Linkify.seek snapshot, post, node, match, i links.push Linkify.seek snapshot, post, node, links, match, i
return return
seek: (snapshot, post, node, match, i) -> seek: (snapshot, post, node, links, match, i) ->
link = match[0] link = match[0]
range = document.createRange() range = document.createRange()
range.setStart node, match.index range.setStart node, match.index
@ -103,14 +103,15 @@ Linkify =
{index} = result {index} = result
range.setEnd node, index range.setEnd node, index
Linkify.regString.lastIndex = index Linkify.regString.lastIndex = index
Linkify.gatherLinks snapshot, post, node, i Linkify.gatherLinks snapshot, post, node, links, i
return range
if range.collapsed if range.collapsed
range.setEndAfter node range.setEndAfter node
range range
makeLink: (range, post) -> makeLink: (range) ->
link = range.toString() link = range.toString()
link = link =
if link.contains ':' if link.contains ':'
@ -129,8 +130,7 @@ Linkify =
href: link href: link
$.add a, range.extractContents() $.add a, range.extractContents()
range.insertNode a range.insertNode a
post.nodes.links.push a a
return
services: (link) -> services: (link) ->
href = link.href href = link.href