From 2a9f2cc1960bc6b4366935e603ba54c54620e99f Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 9 May 2014 00:31:37 -0700 Subject: [PATCH] switch to template approach --- src/Linkification/Linkify.coffee | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 2582108f2..a00466fa3 100755 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -266,12 +266,10 @@ Linkify = regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/ style: 'border: 0; width: auto; height: auto;' el: (a) -> - img = $.el 'img', src: a.dataset.href - link = $.el 'a', {target: '_blank', href: a.dataset.href} - div = $.el 'div' - $.add link, img - $.add div, link - div + el = $.el 'div', + innerHTML: "" + el.firstChild.href = el.firstChild.firstChild.src = a.dataset.href + el , key: 'InstallGentoo' regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/ @@ -314,18 +312,16 @@ Linkify = return div.textContent = "ERROR: Not a valid filetype" unless embed switch embed.type when 'video/mp4', 'video/ogv' - el.innerHTML = """ -""" + el.innerHTML = '' + el.firstChild.children[0].src = "https://mediacru.sh/#{a.dataset.uid}.mp4" + el.firstChild.children[1].src = "https://mediacru.sh/#{a.dataset.uid}.ogv" when 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'image/svg+xml' - $.add el, $.el 'a', - target: '_blank' - href: a.dataset.href - innerHTML: "" + el.innerHTML = '' + el.firstChild.href = a.dataset.href + el.firstChild.firstChild.src = "https://mediacru.sh/#{file.file}" when 'audio/mpeg' - el.innerHTML = "" + el.innerHTML = '' + el.firstChild.firstChild.src = "https://mediacru.sh/#{file.file}" else el.textContent = "ERROR: No valid filetype." el