aboutsummaryrefslogtreecommitdiffstats
path: root/addon/oembed/oembed.js
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-01-26 17:17:02 +0100
committerFabio Comuni <fabrix.xm@gmail.com>2011-01-26 17:17:02 +0100
commit43be72297a281b41e7b77ba6078aeb48ee007299 (patch)
treec7b4d7ab43ad51a84933146326f50d425ab85b3b /addon/oembed/oembed.js
parent6ca1e2ddfe649d2ffeb6bd157b1b04533fa835ff (diff)
downloadvolse-hubzilla-43be72297a281b41e7b77ba6078aeb48ee007299.tar.gz
volse-hubzilla-43be72297a281b41e7b77ba6078aeb48ee007299.tar.bz2
volse-hubzilla-43be72297a281b41e7b77ba6078aeb48ee007299.zip
Rewrite oembed plugin to use new bbcode tag [embed] and make discovery server-side
Diffstat (limited to 'addon/oembed/oembed.js')
-rw-r--r--addon/oembed/oembed.js47
1 files changed, 3 insertions, 44 deletions
diff --git a/addon/oembed/oembed.js b/addon/oembed/oembed.js
index 26541490b..54547a86e 100644
--- a/addon/oembed/oembed.js
+++ b/addon/oembed/oembed.js
@@ -3,49 +3,8 @@ function oembed(){
}
function oembed_do(){
- embedurl = $('#oembed_url').attr('value');
- var url = 'http://oohembed.com/oohembed/?url='+escape( embedurl )+"&callback=?";
-
- $.getJSON(url, function(data) {
- var ret="";
- switch(data.type){
- case "video": {
- if (data.thumbnail_url){
- tw = 200; if (data.thumbnail_width) tw=data.thumbnail_width;
- th = 180; if (data.thumbnail_height) tw=data.thumbnail_height;
- ret = "<a href='"+embedurl+"'>";
- // tiny mce bbcode plugin not support image size......
- ret += "<img width='"+tw+"' height='"+th+"' src='"+data.thumbnail_url+"'></a>";
- } else {
- ret = data.html;
- }
- }; break;
- case "photo": {
- // tiny mce bbcode plugin not support image size......
- ret = "<img width='"+data.width+"' height='"+data.height+"' src='"+data.url+"'>";
- }; break;
- case "link": {
- ret = "<a href='"+embedurl+"'>"+data.title+"</a>";
- }; break;
- case "rich": {
- ret = data.html; // not so safe... http://www.oembed.com/ : "Consumers may wish to load the HTML in an off-domain iframe to avoid XSS"
- }; break;
- default: {
- alert("Error retriving data!");
- return;
- }
- }
- var embedlink = embedurl;
- if (data.title) embedlink = data.title
- ret+="<br><a href='"+embedurl+"'>"+embedlink+"</a>";
- if (data.author_name) {
- ret+=" by "+data.author_name;
- }
- if (data.provider_name) {
- ret+=" on "+data.provider_name;
- }
- tinyMCE.execCommand('mceInsertRawHTML',false,ret);
- oembed();
- });
+ embed = "[embed]"+$('#oembed_url').attr('value')+"[/embed]";
+ tinyMCE.execCommand('mceInsertRawHTML',false,embed);
+ oembed();
}