switch to template approach

This commit is contained in:
ccd0 2014-05-09 00:31:37 -07:00
parent 6002d118d6
commit 2a9f2cc196

View File

@ -266,12 +266,10 @@ Linkify =
regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/ regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/
style: 'border: 0; width: auto; height: auto;' style: 'border: 0; width: auto; height: auto;'
el: (a) -> el: (a) ->
img = $.el 'img', src: a.dataset.href el = $.el 'div',
link = $.el 'a', {target: '_blank', href: a.dataset.href} innerHTML: "<a target=_blank><img'></a>"
div = $.el 'div' el.firstChild.href = el.firstChild.firstChild.src = a.dataset.href
$.add link, img el
$.add div, link
div
, ,
key: 'InstallGentoo' key: 'InstallGentoo'
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/ regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/
@ -314,18 +312,16 @@ Linkify =
return div.textContent = "ERROR: Not a valid filetype" unless embed return div.textContent = "ERROR: Not a valid filetype" unless embed
switch embed.type switch embed.type
when 'video/mp4', 'video/ogv' when 'video/mp4', 'video/ogv'
el.innerHTML = """ el.innerHTML = '<video autoplay loop><source type="video/mp4"><source type="video/ogg; codecs=\'theora, vorbis\'"></video>'
<video autoplay loop> el.firstChild.children[0].src = "https://mediacru.sh/#{a.dataset.uid}.mp4"
<source src="https://mediacru.sh/#{a.dataset.uid}.mp4" type="video/mp4;"> el.firstChild.children[1].src = "https://mediacru.sh/#{a.dataset.uid}.ogv"
<source src="https://mediacru.sh/#{a.dataset.uid}.ogv" type="video/ogg; codecs='theora, vorbis'">
</video>"""
when 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'image/svg+xml' when 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'image/svg+xml'
$.add el, $.el 'a', el.innerHTML = '<a target="_blank"><img></a>'
target: '_blank' el.firstChild.href = a.dataset.href
href: a.dataset.href el.firstChild.firstChild.src = "https://mediacru.sh/#{file.file}"
innerHTML: "<img src='https://mediacru.sh/#{file.file}'>"
when 'audio/mpeg' when 'audio/mpeg'
el.innerHTML = "<audio controls><source src='https://mediacru.sh/#{file.file}'></audio>" el.innerHTML = '<audio controls><source></audio>'
el.firstChild.firstChild.src = "https://mediacru.sh/#{file.file}"
else else
el.textContent = "ERROR: No valid filetype." el.textContent = "ERROR: No valid filetype."
el el