Fix some conflicts with auto-embed and link title
Also, less `Function.call(this)`
This commit is contained in:
parent
463d6607f6
commit
1c4f4cea24
@ -4477,28 +4477,33 @@
|
|||||||
if (Conf['Auto-embed']) {
|
if (Conf['Auto-embed']) {
|
||||||
Linkify.cb.toggle.call(embed);
|
Linkify.cb.toggle.call(embed);
|
||||||
}
|
}
|
||||||
|
data.push(embed);
|
||||||
},
|
},
|
||||||
title: function(data) {
|
title: function(data) {
|
||||||
var err, key, link, options, service, title, titles, uid;
|
var embed, err, key, link, options, service, title, titles, uid;
|
||||||
|
|
||||||
key = data[0], uid = data[1], options = data[2], link = data[3];
|
key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4];
|
||||||
if (!(service = Linkify.types[key].title)) {
|
if (!(service = Linkify.types[key].title)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
titles = Conf['CachedTitles'];
|
titles = Conf['CachedTitles'];
|
||||||
if (title = titles[uid]) {
|
if (title = titles[uid]) {
|
||||||
link.textContent = title[0];
|
if (link) {
|
||||||
|
link.textContent = title[0];
|
||||||
|
}
|
||||||
if (Conf['Embedding']) {
|
if (Conf['Embedding']) {
|
||||||
return link.nextElementSibling.dataset.title = title[0];
|
return embed.dataset.title = title[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$.cache(service.api(uid), function() {
|
$.cache(service.api(uid), function() {
|
||||||
return title = Linkify.cb.title.apply(this, [data]);
|
return title = Linkify.cb.title(this, data);
|
||||||
});
|
});
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
link.innerHTML = "[" + key + "] <span class=warning>Title Link Blocked</span> (are you using NoScript?)</a>";
|
if (link) {
|
||||||
|
link.innerHTML = "[" + key + "] <span class=warning>Title Link Blocked</span> (are you using NoScript?)</a>";
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (title) {
|
if (title) {
|
||||||
@ -4521,7 +4526,7 @@
|
|||||||
embed: function(a) {
|
embed: function(a) {
|
||||||
var el, style, type;
|
var el, style, type;
|
||||||
|
|
||||||
el = (type = Linkify.types[a.dataset.key]).el.call(a);
|
el = (type = Linkify.types[a.dataset.key]).el(a);
|
||||||
el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
|
el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
@ -4538,58 +4543,61 @@
|
|||||||
$.addClass(el, a.dataset.key);
|
$.addClass(el, a.dataset.key);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
title: function(data) {
|
title: function(response, data) {
|
||||||
var key, link, options, service, text, uid;
|
var embed, key, link, options, service, text, uid;
|
||||||
|
|
||||||
key = data[0], uid = data[1], options = data[2], link = data[3];
|
key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4];
|
||||||
service = Linkify.types[key].title;
|
service = Linkify.types[key].title;
|
||||||
return link.textContent = (function() {
|
switch (response.status) {
|
||||||
switch (this.status) {
|
case 200:
|
||||||
case 200:
|
case 304:
|
||||||
case 304:
|
text = "" + (service.text(JSON.parse(response.responseText)));
|
||||||
text = "" + (service.text.call(this));
|
if (Conf['Embedding']) {
|
||||||
if (Conf['Embedding']) {
|
embed.dataset.title = text;
|
||||||
link.nextElementSibling.dataset.title = text;
|
}
|
||||||
}
|
break;
|
||||||
return text;
|
case 404:
|
||||||
case 404:
|
text = "[" + key + "] Not Found";
|
||||||
return "[" + key + "] Not Found";
|
break;
|
||||||
case 403:
|
case 403:
|
||||||
return "[" + key + "] Forbidden or Private";
|
text = "[" + key + "] Forbidden or Private";
|
||||||
default:
|
break;
|
||||||
return "[" + key + "] " + this.status + "'d";
|
default:
|
||||||
}
|
text = "[" + key + "] " + this.status + "'d";
|
||||||
}).call(this);
|
}
|
||||||
|
if (link) {
|
||||||
|
return link.textContent = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
types: {
|
types: {
|
||||||
audio: {
|
audio: {
|
||||||
regExp: /(.*\.(mp3|ogg|wav))$/,
|
regExp: /(.*\.(mp3|ogg|wav))$/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('audio', {
|
return $.el('audio', {
|
||||||
controls: 'controls',
|
controls: 'controls',
|
||||||
preload: 'auto',
|
preload: 'auto',
|
||||||
src: this.dataset.uid
|
src: a.dataset.uid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
gist: {
|
gist: {
|
||||||
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/,
|
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
var div;
|
var div;
|
||||||
|
|
||||||
return div = $.el('iframe', {
|
return div = $.el('iframe', {
|
||||||
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.dataset.uid + ".js"
|
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + a.dataset.uid + ".js"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
api: function(uid) {
|
api: function(uid) {
|
||||||
return "https://api.github.com/gists/" + uid;
|
return "https://api.github.com/gists/" + uid;
|
||||||
},
|
},
|
||||||
text: function() {
|
text: function(data) {
|
||||||
var file, response;
|
var file, response;
|
||||||
|
|
||||||
response = JSON.parse(this.responseText).files;
|
response = data.files;
|
||||||
for (file in response) {
|
for (file in response) {
|
||||||
if (response.hasOwnProperty(file)) {
|
if (response.hasOwnProperty(file)) {
|
||||||
return file;
|
return file;
|
||||||
@ -4601,49 +4609,49 @@
|
|||||||
image: {
|
image: {
|
||||||
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: function() {
|
el: function(a) {
|
||||||
return $.el('div', {
|
return $.el('div', {
|
||||||
innerHTML: "<a target=_blank href='" + this.dataset.href + "'><img src='" + this.dataset.href + "'></a>"
|
innerHTML: "<a target=_blank href='" + a.dataset.href + "'><img src='" + a.dataset.href + "'></a>"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
InstallGentoo: {
|
InstallGentoo: {
|
||||||
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/,
|
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('iframe', {
|
return $.el('iframe', {
|
||||||
src: "http://paste.installgentoo.com/view/embed/" + this.dataset.uid
|
src: "http://paste.installgentoo.com/view/embed/" + a.dataset.uid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LiveLeak: {
|
LiveLeak: {
|
||||||
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/,
|
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('object', {
|
return $.el('object', {
|
||||||
innerHTML: "<embed src='http://www.liveleak.com/e/" + this.dataset.uid + "?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
innerHTML: "<embed src='http://www.liveleak.com/e/" + a.dataset.uid + "?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pastebin: {
|
pastebin: {
|
||||||
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/,
|
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
var div;
|
var div;
|
||||||
|
|
||||||
return div = $.el('iframe', {
|
return div = $.el('iframe', {
|
||||||
src: "http://pastebin.com/embed_iframe.php?i=" + this.dataset.uid
|
src: "http://pastebin.com/embed_iframe.php?i=" + a.dataset.uid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SoundCloud: {
|
SoundCloud: {
|
||||||
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/,
|
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/,
|
||||||
style: 'height: auto; width: 500px; display: inline-block;',
|
style: 'height: auto; width: 500px; display: inline-block;',
|
||||||
el: function() {
|
el: function(a) {
|
||||||
var div;
|
var div;
|
||||||
|
|
||||||
div = $.el('div', {
|
div = $.el('div', {
|
||||||
className: "soundcloud",
|
className: "soundcloud",
|
||||||
name: "soundcloud"
|
name: "soundcloud"
|
||||||
});
|
});
|
||||||
$.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.dataset.uid, {
|
$.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + a.dataset.uid, {
|
||||||
div: div,
|
div: div,
|
||||||
onloadend: function() {
|
onloadend: function() {
|
||||||
return this.div.innerHTML = JSON.parse(this.responseText).html;
|
return this.div.innerHTML = JSON.parse(this.responseText).html;
|
||||||
@ -4655,25 +4663,25 @@
|
|||||||
api: function(uid) {
|
api: function(uid) {
|
||||||
return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid;
|
return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid;
|
||||||
},
|
},
|
||||||
text: function() {
|
text: function(data) {
|
||||||
return JSON.parse(this.responseText).title;
|
return data.title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TwitchTV: {
|
TwitchTV: {
|
||||||
regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/,
|
regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/,
|
||||||
style: "border: none; width: 640px; height: 360px;",
|
style: "border: none; width: 640px; height: 360px;",
|
||||||
el: function() {
|
el: function(a) {
|
||||||
var channel, chapter, result, _;
|
var channel, chapter, result, _;
|
||||||
|
|
||||||
if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(this.dataset.uid)) {
|
if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(a.dataset.uid)) {
|
||||||
_ = result[0], channel = result[1], chapter = result[2];
|
_ = result[0], channel = result[1], chapter = result[2];
|
||||||
return $.el('object', {
|
return $.el('object', {
|
||||||
data: 'http://www.twitch.tv/widgets/archive_embed_player.swf',
|
data: 'http://www.twitch.tv/widgets/archive_embed_player.swf',
|
||||||
innerHTML: "<param name='allowFullScreen' value='true' />\n<param name='flashvars' value='channel=" + channel + "&start_volume=25&auto_play=false" + (chapter ? "&chapter_id=" + chapter : "") + "' />"
|
innerHTML: "<param name='allowFullScreen' value='true' />\n<param name='flashvars' value='channel=" + channel + "&start_volume=25&auto_play=false" + (chapter ? "&chapter_id=" + chapter : "") + "' />"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
channel = (/(\w+)/.exec(this.dataset.uid))[0];
|
channel = (/(\w+)/.exec(a.dataset.uid))[0];
|
||||||
return $.el('object', {
|
return $.el('object', {
|
||||||
data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=" + channel,
|
data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=" + channel,
|
||||||
innerHTML: "<param name=\"allowFullScreen\" value=\"true\" />\n<param name=\"movie\" value=\"http://www.twitch.tv/widgets/live_embed_player.swf\" />\n<param name=\"flashvars\" value=\"hostname=www.twitch.tv&channel=" + channel + "&auto_play=true&start_volume=25\" />"
|
innerHTML: "<param name=\"allowFullScreen\" value=\"true\" />\n<param name=\"movie\" value=\"http://www.twitch.tv/widgets/live_embed_player.swf\" />\n<param name=\"flashvars\" value=\"hostname=www.twitch.tv&channel=" + channel + "&auto_play=true&start_volume=25\" />"
|
||||||
@ -4684,50 +4692,50 @@
|
|||||||
Vocaroo: {
|
Vocaroo: {
|
||||||
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/,
|
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/,
|
||||||
style: 'border: 0; width: 150px; height: 45px;',
|
style: 'border: 0; width: 150px; height: 45px;',
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('object', {
|
return $.el('object', {
|
||||||
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=" + (this.dataset.uid.replace(/^i\//, '')) + "&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=" + (a.dataset.uid.replace(/^i\//, '')) + "&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Vimeo: {
|
Vimeo: {
|
||||||
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/,
|
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('iframe', {
|
return $.el('iframe', {
|
||||||
src: "//player.vimeo.com/video/" + this.dataset.uid + "?wmode=opaque"
|
src: "//player.vimeo.com/video/" + a.dataset.uid + "?wmode=opaque"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
api: function(uid) {
|
api: function(uid) {
|
||||||
return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid;
|
return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid;
|
||||||
},
|
},
|
||||||
text: function() {
|
text: function(data) {
|
||||||
return JSON.parse(this.responseText).title;
|
return data.title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Vine: {
|
Vine: {
|
||||||
regExp: /.*(?:vine.co\/)([^#\&\?]*).*/,
|
regExp: /.*(?:vine.co\/)([^#\&\?]*).*/,
|
||||||
style: 'border: none; width: 500px; height: 500px;',
|
style: 'border: none; width: 500px; height: 500px;',
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('iframe', {
|
return $.el('iframe', {
|
||||||
src: "https://vine.co/" + this.dataset.uid + "/card"
|
src: "https://vine.co/" + a.dataset.uid + "/card"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
YouTube: {
|
YouTube: {
|
||||||
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/,
|
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('iframe', {
|
return $.el('iframe', {
|
||||||
src: "//www.youtube.com/embed/" + this.dataset.uid + (this.dataset.option ? '#' + this.dataset.option : '') + "?wmode=opaque"
|
src: "//www.youtube.com/embed/" + a.dataset.uid + (a.dataset.option ? '#' + a.dataset.option : '') + "?wmode=opaque"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
api: function(uid) {
|
api: function(uid) {
|
||||||
return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode";
|
return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode";
|
||||||
},
|
},
|
||||||
text: function() {
|
text: function(data) {
|
||||||
return JSON.parse(this.responseText).entry.title.$t;
|
return data.entry.title.$t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4482,28 +4482,33 @@
|
|||||||
if (Conf['Auto-embed']) {
|
if (Conf['Auto-embed']) {
|
||||||
Linkify.cb.toggle.call(embed);
|
Linkify.cb.toggle.call(embed);
|
||||||
}
|
}
|
||||||
|
data.push(embed);
|
||||||
},
|
},
|
||||||
title: function(data) {
|
title: function(data) {
|
||||||
var err, key, link, options, service, title, titles, uid;
|
var embed, err, key, link, options, service, title, titles, uid;
|
||||||
|
|
||||||
key = data[0], uid = data[1], options = data[2], link = data[3];
|
key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4];
|
||||||
if (!(service = Linkify.types[key].title)) {
|
if (!(service = Linkify.types[key].title)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
titles = Conf['CachedTitles'];
|
titles = Conf['CachedTitles'];
|
||||||
if (title = titles[uid]) {
|
if (title = titles[uid]) {
|
||||||
link.textContent = title[0];
|
if (link) {
|
||||||
|
link.textContent = title[0];
|
||||||
|
}
|
||||||
if (Conf['Embedding']) {
|
if (Conf['Embedding']) {
|
||||||
return link.nextElementSibling.dataset.title = title[0];
|
return embed.dataset.title = title[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$.cache(service.api(uid), function() {
|
$.cache(service.api(uid), function() {
|
||||||
return title = Linkify.cb.title.apply(this, [data]);
|
return title = Linkify.cb.title(this, data);
|
||||||
});
|
});
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
link.innerHTML = "[" + key + "] <span class=warning>Title Link Blocked</span> (are you using NoScript?)</a>";
|
if (link) {
|
||||||
|
link.innerHTML = "[" + key + "] <span class=warning>Title Link Blocked</span> (are you using NoScript?)</a>";
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (title) {
|
if (title) {
|
||||||
@ -4526,7 +4531,7 @@
|
|||||||
embed: function(a) {
|
embed: function(a) {
|
||||||
var el, style, type;
|
var el, style, type;
|
||||||
|
|
||||||
el = (type = Linkify.types[a.dataset.key]).el.call(a);
|
el = (type = Linkify.types[a.dataset.key]).el(a);
|
||||||
el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
|
el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
@ -4543,58 +4548,61 @@
|
|||||||
$.addClass(el, a.dataset.key);
|
$.addClass(el, a.dataset.key);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
title: function(data) {
|
title: function(response, data) {
|
||||||
var key, link, options, service, text, uid;
|
var embed, key, link, options, service, text, uid;
|
||||||
|
|
||||||
key = data[0], uid = data[1], options = data[2], link = data[3];
|
key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4];
|
||||||
service = Linkify.types[key].title;
|
service = Linkify.types[key].title;
|
||||||
return link.textContent = (function() {
|
switch (response.status) {
|
||||||
switch (this.status) {
|
case 200:
|
||||||
case 200:
|
case 304:
|
||||||
case 304:
|
text = "" + (service.text(JSON.parse(response.responseText)));
|
||||||
text = "" + (service.text.call(this));
|
if (Conf['Embedding']) {
|
||||||
if (Conf['Embedding']) {
|
embed.dataset.title = text;
|
||||||
link.nextElementSibling.dataset.title = text;
|
}
|
||||||
}
|
break;
|
||||||
return text;
|
case 404:
|
||||||
case 404:
|
text = "[" + key + "] Not Found";
|
||||||
return "[" + key + "] Not Found";
|
break;
|
||||||
case 403:
|
case 403:
|
||||||
return "[" + key + "] Forbidden or Private";
|
text = "[" + key + "] Forbidden or Private";
|
||||||
default:
|
break;
|
||||||
return "[" + key + "] " + this.status + "'d";
|
default:
|
||||||
}
|
text = "[" + key + "] " + this.status + "'d";
|
||||||
}).call(this);
|
}
|
||||||
|
if (link) {
|
||||||
|
return link.textContent = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
types: {
|
types: {
|
||||||
audio: {
|
audio: {
|
||||||
regExp: /(.*\.(mp3|ogg|wav))$/,
|
regExp: /(.*\.(mp3|ogg|wav))$/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('audio', {
|
return $.el('audio', {
|
||||||
controls: 'controls',
|
controls: 'controls',
|
||||||
preload: 'auto',
|
preload: 'auto',
|
||||||
src: this.dataset.uid
|
src: a.dataset.uid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
gist: {
|
gist: {
|
||||||
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/,
|
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
var div;
|
var div;
|
||||||
|
|
||||||
return div = $.el('iframe', {
|
return div = $.el('iframe', {
|
||||||
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.dataset.uid + ".js"
|
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + a.dataset.uid + ".js"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
api: function(uid) {
|
api: function(uid) {
|
||||||
return "https://api.github.com/gists/" + uid;
|
return "https://api.github.com/gists/" + uid;
|
||||||
},
|
},
|
||||||
text: function() {
|
text: function(data) {
|
||||||
var file, response;
|
var file, response;
|
||||||
|
|
||||||
response = JSON.parse(this.responseText).files;
|
response = data.files;
|
||||||
for (file in response) {
|
for (file in response) {
|
||||||
if (response.hasOwnProperty(file)) {
|
if (response.hasOwnProperty(file)) {
|
||||||
return file;
|
return file;
|
||||||
@ -4606,49 +4614,49 @@
|
|||||||
image: {
|
image: {
|
||||||
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: function() {
|
el: function(a) {
|
||||||
return $.el('div', {
|
return $.el('div', {
|
||||||
innerHTML: "<a target=_blank href='" + this.dataset.href + "'><img src='" + this.dataset.href + "'></a>"
|
innerHTML: "<a target=_blank href='" + a.dataset.href + "'><img src='" + a.dataset.href + "'></a>"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
InstallGentoo: {
|
InstallGentoo: {
|
||||||
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/,
|
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('iframe', {
|
return $.el('iframe', {
|
||||||
src: "http://paste.installgentoo.com/view/embed/" + this.dataset.uid
|
src: "http://paste.installgentoo.com/view/embed/" + a.dataset.uid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LiveLeak: {
|
LiveLeak: {
|
||||||
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/,
|
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('object', {
|
return $.el('object', {
|
||||||
innerHTML: "<embed src='http://www.liveleak.com/e/" + this.dataset.uid + "?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
innerHTML: "<embed src='http://www.liveleak.com/e/" + a.dataset.uid + "?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pastebin: {
|
pastebin: {
|
||||||
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/,
|
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
var div;
|
var div;
|
||||||
|
|
||||||
return div = $.el('iframe', {
|
return div = $.el('iframe', {
|
||||||
src: "http://pastebin.com/embed_iframe.php?i=" + this.dataset.uid
|
src: "http://pastebin.com/embed_iframe.php?i=" + a.dataset.uid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SoundCloud: {
|
SoundCloud: {
|
||||||
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/,
|
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/,
|
||||||
style: 'height: auto; width: 500px; display: inline-block;',
|
style: 'height: auto; width: 500px; display: inline-block;',
|
||||||
el: function() {
|
el: function(a) {
|
||||||
var div;
|
var div;
|
||||||
|
|
||||||
div = $.el('div', {
|
div = $.el('div', {
|
||||||
className: "soundcloud",
|
className: "soundcloud",
|
||||||
name: "soundcloud"
|
name: "soundcloud"
|
||||||
});
|
});
|
||||||
$.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.dataset.uid, {
|
$.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + a.dataset.uid, {
|
||||||
div: div,
|
div: div,
|
||||||
onloadend: function() {
|
onloadend: function() {
|
||||||
return this.div.innerHTML = JSON.parse(this.responseText).html;
|
return this.div.innerHTML = JSON.parse(this.responseText).html;
|
||||||
@ -4660,25 +4668,25 @@
|
|||||||
api: function(uid) {
|
api: function(uid) {
|
||||||
return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid;
|
return "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + uid;
|
||||||
},
|
},
|
||||||
text: function() {
|
text: function(data) {
|
||||||
return JSON.parse(this.responseText).title;
|
return data.title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TwitchTV: {
|
TwitchTV: {
|
||||||
regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/,
|
regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/,
|
||||||
style: "border: none; width: 640px; height: 360px;",
|
style: "border: none; width: 640px; height: 360px;",
|
||||||
el: function() {
|
el: function(a) {
|
||||||
var channel, chapter, result, _;
|
var channel, chapter, result, _;
|
||||||
|
|
||||||
if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(this.dataset.uid)) {
|
if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(a.dataset.uid)) {
|
||||||
_ = result[0], channel = result[1], chapter = result[2];
|
_ = result[0], channel = result[1], chapter = result[2];
|
||||||
return $.el('object', {
|
return $.el('object', {
|
||||||
data: 'http://www.twitch.tv/widgets/archive_embed_player.swf',
|
data: 'http://www.twitch.tv/widgets/archive_embed_player.swf',
|
||||||
innerHTML: "<param name='allowFullScreen' value='true' />\n<param name='flashvars' value='channel=" + channel + "&start_volume=25&auto_play=false" + (chapter ? "&chapter_id=" + chapter : "") + "' />"
|
innerHTML: "<param name='allowFullScreen' value='true' />\n<param name='flashvars' value='channel=" + channel + "&start_volume=25&auto_play=false" + (chapter ? "&chapter_id=" + chapter : "") + "' />"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
channel = (/(\w+)/.exec(this.dataset.uid))[0];
|
channel = (/(\w+)/.exec(a.dataset.uid))[0];
|
||||||
return $.el('object', {
|
return $.el('object', {
|
||||||
data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=" + channel,
|
data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=" + channel,
|
||||||
innerHTML: "<param name=\"allowFullScreen\" value=\"true\" />\n<param name=\"movie\" value=\"http://www.twitch.tv/widgets/live_embed_player.swf\" />\n<param name=\"flashvars\" value=\"hostname=www.twitch.tv&channel=" + channel + "&auto_play=true&start_volume=25\" />"
|
innerHTML: "<param name=\"allowFullScreen\" value=\"true\" />\n<param name=\"movie\" value=\"http://www.twitch.tv/widgets/live_embed_player.swf\" />\n<param name=\"flashvars\" value=\"hostname=www.twitch.tv&channel=" + channel + "&auto_play=true&start_volume=25\" />"
|
||||||
@ -4689,50 +4697,50 @@
|
|||||||
Vocaroo: {
|
Vocaroo: {
|
||||||
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/,
|
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/,
|
||||||
style: 'border: 0; width: 150px; height: 45px;',
|
style: 'border: 0; width: 150px; height: 45px;',
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('object', {
|
return $.el('object', {
|
||||||
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=" + (this.dataset.uid.replace(/^i\//, '')) + "&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=" + (a.dataset.uid.replace(/^i\//, '')) + "&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Vimeo: {
|
Vimeo: {
|
||||||
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/,
|
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('iframe', {
|
return $.el('iframe', {
|
||||||
src: "//player.vimeo.com/video/" + this.dataset.uid + "?wmode=opaque"
|
src: "//player.vimeo.com/video/" + a.dataset.uid + "?wmode=opaque"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
api: function(uid) {
|
api: function(uid) {
|
||||||
return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid;
|
return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid;
|
||||||
},
|
},
|
||||||
text: function() {
|
text: function(data) {
|
||||||
return JSON.parse(this.responseText).title;
|
return data.title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Vine: {
|
Vine: {
|
||||||
regExp: /.*(?:vine.co\/)([^#\&\?]*).*/,
|
regExp: /.*(?:vine.co\/)([^#\&\?]*).*/,
|
||||||
style: 'border: none; width: 500px; height: 500px;',
|
style: 'border: none; width: 500px; height: 500px;',
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('iframe', {
|
return $.el('iframe', {
|
||||||
src: "https://vine.co/" + this.dataset.uid + "/card"
|
src: "https://vine.co/" + a.dataset.uid + "/card"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
YouTube: {
|
YouTube: {
|
||||||
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/,
|
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/,
|
||||||
el: function() {
|
el: function(a) {
|
||||||
return $.el('iframe', {
|
return $.el('iframe', {
|
||||||
src: "//www.youtube.com/embed/" + this.dataset.uid + (this.dataset.option ? '#' + this.dataset.option : '') + "?wmode=opaque"
|
src: "//www.youtube.com/embed/" + a.dataset.uid + (a.dataset.option ? '#' + a.dataset.option : '') + "?wmode=opaque"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
api: function(uid) {
|
api: function(uid) {
|
||||||
return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode";
|
return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode";
|
||||||
},
|
},
|
||||||
text: function() {
|
text: function(data) {
|
||||||
return JSON.parse(this.responseText).entry.title.$t;
|
return data.entry.title.$t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,7 +59,6 @@ Linkify =
|
|||||||
|
|
||||||
items = @nodes.links
|
items = @nodes.links
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
while range = items[i++]
|
while range = items[i++]
|
||||||
if data = Linkify.services range
|
if data = Linkify.services range
|
||||||
Linkify.embed data if Conf['Embedding']
|
Linkify.embed data if Conf['Embedding']
|
||||||
@ -162,22 +161,27 @@ Linkify =
|
|||||||
if Conf['Auto-embed']
|
if Conf['Auto-embed']
|
||||||
Linkify.cb.toggle.call embed
|
Linkify.cb.toggle.call embed
|
||||||
|
|
||||||
|
data.push embed
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
title: (data) ->
|
title: (data) ->
|
||||||
[key, uid, options, link] = data
|
[key, uid, options, link, embed] = data
|
||||||
return unless service = Linkify.types[key].title
|
return unless service = Linkify.types[key].title
|
||||||
titles = Conf['CachedTitles']
|
titles = Conf['CachedTitles']
|
||||||
if title = titles[uid]
|
if title = titles[uid]
|
||||||
link.textContent = title[0]
|
# Auto-embed may destroy our links.
|
||||||
|
if link
|
||||||
|
link.textContent = title[0]
|
||||||
if Conf['Embedding']
|
if Conf['Embedding']
|
||||||
link.nextElementSibling.dataset.title = title[0]
|
embed.dataset.title = title[0]
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
$.cache service.api(uid), ->
|
$.cache service.api(uid), ->
|
||||||
title = Linkify.cb.title.apply @, [data]
|
title = Linkify.cb.title @, data
|
||||||
catch err
|
catch err
|
||||||
link.innerHTML = "[#{key}] <span class=warning>Title Link Blocked</span> (are you using NoScript?)</a>"
|
if link
|
||||||
|
link.innerHTML = "[#{key}] <span class=warning>Title Link Blocked</span> (are you using NoScript?)</a>"
|
||||||
return
|
return
|
||||||
if title
|
if title
|
||||||
titles[uid] = [title, Date.now()]
|
titles[uid] = [title, Date.now()]
|
||||||
@ -197,7 +201,7 @@ Linkify =
|
|||||||
|
|
||||||
embed: (a) ->
|
embed: (a) ->
|
||||||
# We create an element to embed
|
# We create an element to embed
|
||||||
el = (type = Linkify.types[a.dataset.key]).el.call a
|
el = (type = Linkify.types[a.dataset.key]).el a
|
||||||
|
|
||||||
# Set style values.
|
# Set style values.
|
||||||
el.style.cssText = if style = type.style
|
el.style.cssText = if style = type.style
|
||||||
@ -220,77 +224,77 @@ Linkify =
|
|||||||
|
|
||||||
return el
|
return el
|
||||||
|
|
||||||
title: (data) ->
|
title: (response, data) ->
|
||||||
[key, uid, options, link] = data
|
[key, uid, options, link, embed] = data
|
||||||
service = Linkify.types[key].title
|
service = Linkify.types[key].title
|
||||||
link.textContent = switch @status
|
switch response.status
|
||||||
when 200, 304
|
when 200, 304
|
||||||
text = "#{service.text.call @}"
|
text = "#{service.text JSON.parse response.responseText}"
|
||||||
if Conf['Embedding']
|
if Conf['Embedding']
|
||||||
link.nextElementSibling.dataset.title = text
|
embed.dataset.title = text
|
||||||
text
|
|
||||||
when 404
|
when 404
|
||||||
"[#{key}] Not Found"
|
text = "[#{key}] Not Found"
|
||||||
when 403
|
when 403
|
||||||
"[#{key}] Forbidden or Private"
|
text = "[#{key}] Forbidden or Private"
|
||||||
else
|
else
|
||||||
"[#{key}] #{@status}'d"
|
text = "[#{key}] #{@status}'d"
|
||||||
|
link.textContent = text if link
|
||||||
|
|
||||||
types:
|
types:
|
||||||
audio:
|
audio:
|
||||||
regExp: /(.*\.(mp3|ogg|wav))$/
|
regExp: /(.*\.(mp3|ogg|wav))$/
|
||||||
el: ->
|
el: (a) ->
|
||||||
$.el 'audio',
|
$.el 'audio',
|
||||||
controls: 'controls'
|
controls: 'controls'
|
||||||
preload: 'auto'
|
preload: 'auto'
|
||||||
src: @dataset.uid
|
src: a.dataset.uid
|
||||||
|
|
||||||
gist:
|
gist:
|
||||||
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/
|
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/
|
||||||
el: ->
|
el: (a) ->
|
||||||
div = $.el 'iframe',
|
div = $.el 'iframe',
|
||||||
# Github doesn't allow embedding straight from the site, so we use an external site to bypass that.
|
# Github doesn't allow embedding straight from the site, so we use an external site to bypass that.
|
||||||
src: "http://www.purplegene.com/script?url=https://gist.github.com/#{@dataset.uid}.js"
|
src: "http://www.purplegene.com/script?url=https://gist.github.com/#{a.dataset.uid}.js"
|
||||||
title:
|
title:
|
||||||
api: (uid) -> "https://api.github.com/gists/#{uid}"
|
api: (uid) -> "https://api.github.com/gists/#{uid}"
|
||||||
text: ->
|
text: (data) ->
|
||||||
response = JSON.parse(@responseText).files
|
response = data.files
|
||||||
return file for file of response when response.hasOwnProperty file
|
return file for file of response when response.hasOwnProperty file
|
||||||
|
|
||||||
image:
|
image:
|
||||||
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: ->
|
el: (a) ->
|
||||||
$.el 'div',
|
$.el 'div',
|
||||||
innerHTML: "<a target=_blank href='#{@dataset.href}'><img src='#{@dataset.href}'></a>"
|
innerHTML: "<a target=_blank href='#{a.dataset.href}'><img src='#{a.dataset.href}'></a>"
|
||||||
|
|
||||||
InstallGentoo:
|
InstallGentoo:
|
||||||
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/
|
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/
|
||||||
el: ->
|
el: (a) ->
|
||||||
$.el 'iframe',
|
$.el 'iframe',
|
||||||
src: "http://paste.installgentoo.com/view/embed/#{@dataset.uid}"
|
src: "http://paste.installgentoo.com/view/embed/#{a.dataset.uid}"
|
||||||
|
|
||||||
LiveLeak:
|
LiveLeak:
|
||||||
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/
|
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/
|
||||||
el: ->
|
el: (a) ->
|
||||||
$.el 'object',
|
$.el 'object',
|
||||||
innerHTML: "<embed src='http://www.liveleak.com/e/#{@dataset.uid}?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
innerHTML: "<embed src='http://www.liveleak.com/e/#{a.dataset.uid}?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
||||||
|
|
||||||
pastebin:
|
pastebin:
|
||||||
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/
|
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/
|
||||||
el: ->
|
el: (a) ->
|
||||||
div = $.el 'iframe',
|
div = $.el 'iframe',
|
||||||
src: "http://pastebin.com/embed_iframe.php?i=#{@dataset.uid}"
|
src: "http://pastebin.com/embed_iframe.php?i=#{a.dataset.uid}"
|
||||||
|
|
||||||
SoundCloud:
|
SoundCloud:
|
||||||
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/
|
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/
|
||||||
style: 'height: auto; width: 500px; display: inline-block;'
|
style: 'height: auto; width: 500px; display: inline-block;'
|
||||||
el: ->
|
el: (a) ->
|
||||||
div = $.el 'div',
|
div = $.el 'div',
|
||||||
className: "soundcloud"
|
className: "soundcloud"
|
||||||
name: "soundcloud"
|
name: "soundcloud"
|
||||||
$.ajax(
|
$.ajax(
|
||||||
"//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{@dataset.uid}"
|
"//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{a.dataset.uid}"
|
||||||
div: div
|
div: div
|
||||||
onloadend: ->
|
onloadend: ->
|
||||||
@div.innerHTML = JSON.parse(@responseText).html
|
@div.innerHTML = JSON.parse(@responseText).html
|
||||||
@ -298,13 +302,13 @@ Linkify =
|
|||||||
div
|
div
|
||||||
title:
|
title:
|
||||||
api: (uid) -> "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{uid}"
|
api: (uid) -> "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{uid}"
|
||||||
text: -> JSON.parse(@responseText).title
|
text: (data) -> data.title
|
||||||
|
|
||||||
TwitchTV:
|
TwitchTV:
|
||||||
regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/
|
regExp: /.*(?:twitch.tv\/)([^#\&\?]*).*/
|
||||||
style: "border: none; width: 640px; height: 360px;"
|
style: "border: none; width: 640px; height: 360px;"
|
||||||
el: ->
|
el: (a) ->
|
||||||
if result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec @dataset.uid
|
if result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec a.dataset.uid
|
||||||
[_, channel, chapter] = result
|
[_, channel, chapter] = result
|
||||||
|
|
||||||
$.el 'object',
|
$.el 'object',
|
||||||
@ -315,7 +319,7 @@ Linkify =
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
else
|
else
|
||||||
channel = (/(\w+)/.exec @dataset.uid)[0]
|
channel = (/(\w+)/.exec a.dataset.uid)[0]
|
||||||
|
|
||||||
$.el 'object',
|
$.el 'object',
|
||||||
data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=#{channel}"
|
data: "http://www.twitch.tv/widgets/live_embed_player.swf?channel=#{channel}"
|
||||||
@ -328,31 +332,31 @@ Linkify =
|
|||||||
Vocaroo:
|
Vocaroo:
|
||||||
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/
|
regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/
|
||||||
style: 'border: 0; width: 150px; height: 45px;'
|
style: 'border: 0; width: 150px; height: 45px;'
|
||||||
el: ->
|
el: (a) ->
|
||||||
$.el 'object',
|
$.el 'object',
|
||||||
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=#{@dataset.uid.replace /^i\//, ''}&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=#{a.dataset.uid.replace /^i\//, ''}&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
|
||||||
|
|
||||||
Vimeo:
|
Vimeo:
|
||||||
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/
|
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/
|
||||||
el: ->
|
el: (a) ->
|
||||||
$.el 'iframe',
|
$.el 'iframe',
|
||||||
src: "//player.vimeo.com/video/#{@dataset.uid}?wmode=opaque"
|
src: "//player.vimeo.com/video/#{a.dataset.uid}?wmode=opaque"
|
||||||
title:
|
title:
|
||||||
api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}"
|
api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}"
|
||||||
text: -> JSON.parse(@responseText).title
|
text: (data) -> data.title
|
||||||
|
|
||||||
Vine:
|
Vine:
|
||||||
regExp: /.*(?:vine.co\/)([^#\&\?]*).*/
|
regExp: /.*(?:vine.co\/)([^#\&\?]*).*/
|
||||||
style: 'border: none; width: 500px; height: 500px;'
|
style: 'border: none; width: 500px; height: 500px;'
|
||||||
el: ->
|
el: (a) ->
|
||||||
$.el 'iframe',
|
$.el 'iframe',
|
||||||
src: "https://vine.co/#{@dataset.uid}/card"
|
src: "https://vine.co/#{a.dataset.uid}/card"
|
||||||
|
|
||||||
YouTube:
|
YouTube:
|
||||||
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/
|
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/
|
||||||
el: ->
|
el: (a) ->
|
||||||
$.el 'iframe',
|
$.el 'iframe',
|
||||||
src: "//www.youtube.com/embed/#{@dataset.uid}#{if @dataset.option then '#' + @dataset.option else ''}?wmode=opaque"
|
src: "//www.youtube.com/embed/#{a.dataset.uid}#{if a.dataset.option then '#' + a.dataset.option else ''}?wmode=opaque"
|
||||||
title:
|
title:
|
||||||
api: (uid) -> "https://gdata.youtube.com/feeds/api/videos/#{uid}?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"
|
api: (uid) -> "https://gdata.youtube.com/feeds/api/videos/#{uid}?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"
|
||||||
text: -> JSON.parse(@responseText).entry.title.$t
|
text: (data) -> data.entry.title.$t
|
||||||
Loading…
x
Reference in New Issue
Block a user