jquery-oembed-rails 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/assets/javascripts/jquery.oembed.js +821 -658
- data/lib/jquery/oembed/rails/version.rb +1 -1
- metadata +2 -2
@@ -5,92 +5,103 @@
|
|
5
5
|
* Licensed under the MIT license
|
6
6
|
*
|
7
7
|
* Orignal Author: Richard Chamorro
|
8
|
-
* Forked by Andrew Mee to Provide a slightly diffent kind of embedding
|
9
|
-
* experience
|
8
|
+
* Forked by Andrew Mee to Provide a slightly diffent kind of embedding experience
|
10
9
|
*/
|
11
|
-
(function($) {
|
12
|
-
$.fn.oembed = function(url, options, embedAction) {
|
10
|
+
(function ($) {
|
11
|
+
$.fn.oembed = function (url, options, embedAction) {
|
13
12
|
|
14
13
|
settings = $.extend(true, $.fn.oembed.defaults, options);
|
15
|
-
var shortURLList = ["0rz.tw","1link.in","1url.com","2.gp","2big.at","2tu.us","3.ly","307.to","4ms.me","4sq.com","4url.cc","6url.com","7.ly","a.gg","a.nf","aa.cx","abcurl.net",
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
14
|
+
var shortURLList = ["0rz.tw", "1link.in", "1url.com", "2.gp", "2big.at", "2tu.us", "3.ly", "307.to", "4ms.me", "4sq.com", "4url.cc", "6url.com", "7.ly", "a.gg", "a.nf", "aa.cx", "abcurl.net",
|
15
|
+
"ad.vu", "adf.ly", "adjix.com", "afx.cc", "all.fuseurl.com", "alturl.com", "amzn.to", "ar.gy", "arst.ch", "atu.ca", "azc.cc", "b23.ru", "b2l.me", "bacn.me", "bcool.bz", "binged.it",
|
16
|
+
"bit.ly", "bizj.us", "bloat.me", "bravo.ly", "bsa.ly", "budurl.com", "canurl.com", "chilp.it", "chzb.gr", "cl.lk", "cl.ly", "clck.ru", "cli.gs", "cliccami.info",
|
17
|
+
"clickthru.ca", "clop.in", "conta.cc", "cort.as", "cot.ag", "crks.me", "ctvr.us", "cutt.us", "dai.ly", "decenturl.com", "dfl8.me", "digbig.com",
|
18
|
+
"http:\/\/digg\.com\/[^\/]+$", "disq.us", "dld.bz", "dlvr.it", "do.my", "doiop.com", "dopen.us", "easyuri.com", "easyurl.net", "eepurl.com", "eweri.com",
|
19
|
+
"fa.by", "fav.me", "fb.me", "fbshare.me", "ff.im", "fff.to", "fire.to", "firsturl.de", "firsturl.net", "flic.kr", "flq.us", "fly2.ws", "fon.gs", "freak.to",
|
20
|
+
"fuseurl.com", "fuzzy.to", "fwd4.me", "fwib.net", "g.ro.lt", "gizmo.do", "gl.am", "go.9nl.com", "go.ign.com", "go.usa.gov", "goo.gl", "goshrink.com", "gurl.es",
|
21
|
+
"hex.io", "hiderefer.com", "hmm.ph", "href.in", "hsblinks.com", "htxt.it", "huff.to", "hulu.com", "hurl.me", "hurl.ws", "icanhaz.com", "idek.net", "ilix.in", "is.gd",
|
22
|
+
"its.my", "ix.lt", "j.mp", "jijr.com", "kl.am", "klck.me", "korta.nu", "krunchd.com", "l9k.net", "lat.ms", "liip.to", "liltext.com", "linkbee.com", "linkbun.ch",
|
23
|
+
"liurl.cn", "ln-s.net", "ln-s.ru", "lnk.gd", "lnk.ms", "lnkd.in", "lnkurl.com", "lru.jp", "lt.tl", "lurl.no", "macte.ch", "mash.to", "merky.de", "migre.me", "miniurl.com",
|
24
|
+
"minurl.fr", "mke.me", "moby.to", "moourl.com", "mrte.ch", "myloc.me", "myurl.in", "n.pr", "nbc.co", "nblo.gs", "nn.nf", "not.my", "notlong.com", "nsfw.in",
|
25
|
+
"nutshellurl.com", "nxy.in", "nyti.ms", "o-x.fr", "oc1.us", "om.ly", "omf.gd", "omoikane.net", "on.cnn.com", "on.mktw.net", "onforb.es", "orz.se", "ow.ly", "ping.fm",
|
26
|
+
"pli.gs", "pnt.me", "politi.co", "post.ly", "pp.gg", "profile.to", "ptiturl.com", "pub.vitrue.com", "qlnk.net", "qte.me", "qu.tc", "qy.fi", "r.ebay.com", "r.im", "rb6.me", "read.bi",
|
27
|
+
"readthis.ca", "reallytinyurl.com", "redir.ec", "redirects.ca", "redirx.com", "retwt.me", "ri.ms", "rickroll.it", "riz.gd", "rt.nu", "ru.ly", "rubyurl.com", "rurl.org",
|
28
|
+
"rww.tw", "s4c.in", "s7y.us", "safe.mn", "sameurl.com", "sdut.us", "shar.es", "shink.de", "shorl.com", "short.ie", "short.to", "shortlinks.co.uk", "shorturl.com",
|
29
|
+
"shout.to", "show.my", "shrinkify.com", "shrinkr.com", "shrt.fr", "shrt.st", "shrten.com", "shrunkin.com", "simurl.com", "slate.me", "smallr.com", "smsh.me", "smurl.name",
|
30
|
+
"sn.im", "snipr.com", "snipurl.com", "snurl.com", "sp2.ro", "spedr.com", "srnk.net", "srs.li", "starturl.com", "stks.co", "su.pr", "surl.co.uk", "surl.hu", "t.cn", "t.co", "t.lh.com",
|
31
|
+
"ta.gd", "tbd.ly", "tcrn.ch", "tgr.me", "tgr.ph", "tighturl.com", "tiniuri.com", "tiny.cc", "tiny.ly", "tiny.pl", "tinylink.in", "tinyuri.ca", "tinyurl.com", "tk.", "tl.gd",
|
32
|
+
"tmi.me", "tnij.org", "tnw.to", "tny.com", "to.ly", "togoto.us", "totc.us", "toysr.us", "tpm.ly", "tr.im", "tra.kz", "trunc.it", "twhub.com", "twirl.at",
|
33
|
+
"twitclicks.com", "twitterurl.net", "twitterurl.org", "twiturl.de", "twurl.cc", "twurl.nl", "u.mavrev.com", "u.nu", "u76.org", "ub0.cc", "ulu.lu", "updating.me", "ur1.ca",
|
34
|
+
"url.az", "url.co.uk", "url.ie", "url360.me", "url4.eu", "urlborg.com", "urlbrief.com", "urlcover.com", "urlcut.com", "urlenco.de", "urli.nl", "urls.im",
|
35
|
+
"urlshorteningservicefortwitter.com", "urlx.ie", "urlzen.com", "usat.ly", "use.my", "vb.ly", "vevo.ly", "vgn.am", "vl.am", "vm.lc", "w55.de", "wapo.st", "wapurl.co.uk", "wipi.es",
|
36
|
+
"wp.me", "x.vu", "xr.com", "xrl.in", "xrl.us", "xurl.es", "xurl.jp", "y.ahoo.it", "yatuc.com", "ye.pe", "yep.it", "yfrog.com", "yhoo.it", "yiyd.com", "youtu.be", "yuarel.com",
|
37
|
+
"z0p.de", "zi.ma", "zi.mu", "zipmyurl.com", "zud.me", "zurl.ws", "zz.gd", "zzang.kr", "›.ws", "✩.ws", "✿.ws", "❥.ws", "➔.ws", "➞.ws", "➡.ws", "➨.ws", "➯.ws", "➹.ws", "➽.ws"];
|
39
38
|
|
40
39
|
if ($('#jqoembeddata').length === 0) $('<span id="jqoembeddata"></span>').appendTo('body');
|
41
40
|
|
42
|
-
return this.each(function() {
|
43
|
-
|
41
|
+
return this.each(function () {
|
44
42
|
var container = $(this),
|
45
|
-
resourceURL =
|
43
|
+
resourceURL = (url && (!url.indexOf('http://') || !url.indexOf('https://'))) ? url : container.attr("href"),
|
46
44
|
provider;
|
47
45
|
|
48
46
|
if (embedAction) {
|
49
47
|
settings.onEmbed = embedAction;
|
50
48
|
}
|
51
|
-
else if (!settings.onEmbed){
|
52
|
-
settings.onEmbed = function(oembedData) {
|
49
|
+
else if (!settings.onEmbed) {
|
50
|
+
settings.onEmbed = function (oembedData) {
|
53
51
|
$.fn.oembed.insertCode(this, settings.embedMethod, oembedData);
|
54
52
|
};
|
55
53
|
}
|
56
54
|
|
57
55
|
if (resourceURL !== null && resourceURL !== undefined) {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
56
|
+
//Check if shorten URL
|
57
|
+
for (var j = 0, l = shortURLList.length; j < l; j++) {
|
58
|
+
var regExp = new RegExp('://' + shortURLList[j] + '/', "i");
|
59
|
+
|
60
|
+
if (resourceURL.match(regExp) !== null) {
|
61
|
+
//AJAX to http://api.longurl.org/v2/expand?url=http://bit.ly/JATvIs&format=json&callback=hhh
|
62
|
+
var ajaxopts = $.extend({
|
63
|
+
url: "http://api.longurl.org/v2/expand",
|
64
|
+
dataType: 'jsonp',
|
65
|
+
data: {
|
66
|
+
url: resourceURL,
|
67
|
+
format: "json"
|
68
|
+
//callback: "?"
|
69
|
+
},
|
70
|
+
success: function (data) {
|
71
|
+
//this = $.fn.oembed;
|
72
|
+
resourceURL = data['long-url'];
|
73
|
+
provider = $.fn.oembed.getOEmbedProvider(data['long-url']);
|
74
|
+
|
75
|
+
//remove fallback
|
76
|
+
if (!!settings.fallback === false) {
|
77
|
+
provider = provider.name.toLowerCase() === 'opengraph' ? null : provider;
|
78
|
+
}
|
79
|
+
|
80
|
+
if (provider !== null) {
|
81
|
+
provider.params = getNormalizedParams(settings[provider.name]) || {};
|
82
|
+
provider.maxWidth = settings.maxWidth;
|
83
|
+
provider.maxHeight = settings.maxHeight;
|
84
|
+
embedCode(container, resourceURL, provider);
|
85
|
+
} else {
|
86
|
+
settings.onProviderNotFound.call(container, resourceURL);
|
87
|
+
}
|
88
|
+
},
|
89
|
+
error: function () {
|
90
|
+
settings.onError.call(container, resourceURL)
|
91
|
+
}
|
92
|
+
}, settings.ajaxOptions || {});
|
93
|
+
|
94
|
+
$.ajax(ajaxopts);
|
95
|
+
|
96
|
+
return container;
|
97
|
+
}
|
98
|
+
}
|
92
99
|
provider = $.fn.oembed.getOEmbedProvider(resourceURL);
|
93
100
|
|
101
|
+
//remove fallback
|
102
|
+
if (!!settings.fallback === false) {
|
103
|
+
provider = provider.name.toLowerCase() === 'opengraph' ? null : provider;
|
104
|
+
}
|
94
105
|
if (provider !== null) {
|
95
106
|
provider.params = getNormalizedParams(settings[provider.name]) || {};
|
96
107
|
provider.maxWidth = settings.maxWidth;
|
@@ -100,42 +111,45 @@
|
|
100
111
|
settings.onProviderNotFound.call(container, resourceURL);
|
101
112
|
}
|
102
113
|
}
|
103
|
-
|
104
114
|
return container;
|
105
115
|
});
|
106
|
-
|
107
|
-
|
108
116
|
};
|
109
117
|
|
110
118
|
var settings;
|
111
119
|
|
112
120
|
// Plugin defaults
|
113
121
|
$.fn.oembed.defaults = {
|
122
|
+
fallback: true,
|
114
123
|
maxWidth: null,
|
115
124
|
maxHeight: null,
|
116
|
-
|
125
|
+
includeHandle: true,
|
117
126
|
embedMethod: 'auto',
|
118
|
-
// "auto", "append", "fill"
|
119
|
-
onProviderNotFound: function() {
|
120
|
-
|
121
|
-
|
127
|
+
// "auto", "append", "fill"
|
128
|
+
onProviderNotFound: function () {
|
129
|
+
},
|
130
|
+
beforeEmbed: function () {
|
131
|
+
},
|
132
|
+
afterEmbed: function () {
|
133
|
+
},
|
122
134
|
onEmbed: false,
|
123
|
-
onError: function() {
|
135
|
+
onError: function (a, b, c, d) {
|
136
|
+
console.log('err:', a, b, c, d)
|
137
|
+
},
|
124
138
|
ajaxOptions: {}
|
125
139
|
};
|
126
140
|
|
127
141
|
/* Private functions */
|
128
|
-
function rand(length,current){ //Found on http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
|
129
|
-
|
130
|
-
|
142
|
+
function rand(length, current) { //Found on http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
|
143
|
+
current = current ? current : '';
|
144
|
+
return length ? rand(--length, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt(Math.floor(Math.random() * 60)) + current) : current;
|
131
145
|
}
|
132
|
-
|
146
|
+
|
133
147
|
function getRequestUrl(provider, externalUrl) {
|
134
148
|
var url = provider.apiendpoint,
|
135
149
|
qs = "",
|
136
150
|
i;
|
137
151
|
url += (url.indexOf("?") <= 0) ? "?" : "&";
|
138
|
-
url = url.replace('#','%23');
|
152
|
+
url = url.replace('#', '%23');
|
139
153
|
|
140
154
|
if (provider.maxWidth !== null && (typeof provider.params.maxwidth === 'undefined' || provider.params.maxwidth === null)) {
|
141
155
|
provider.params.maxwidth = provider.maxWidth;
|
@@ -147,17 +161,21 @@
|
|
147
161
|
|
148
162
|
for (i in provider.params) {
|
149
163
|
// We don't want them to jack everything up by changing the callback parameter
|
150
|
-
if (i == provider.callbackparameter)
|
164
|
+
if (i == provider.callbackparameter)
|
165
|
+
continue;
|
151
166
|
|
152
167
|
// allows the options to be set to null, don't send null values to the server as parameters
|
153
|
-
if (provider.params[i] !== null)
|
168
|
+
if (provider.params[i] !== null)
|
169
|
+
qs += "&" + escape(i) + "=" + provider.params[i];
|
154
170
|
}
|
155
171
|
|
156
172
|
url += "format=" + provider.format + "&url=" + escape(externalUrl) + qs;
|
157
|
-
if(provider.dataType!='json')
|
173
|
+
if (provider.dataType != 'json')
|
174
|
+
url += "&" + provider.callbackparameter + "=?";
|
158
175
|
|
159
176
|
return url;
|
160
177
|
}
|
178
|
+
|
161
179
|
function success(oembedData, externalUrl, container) {
|
162
180
|
$('#jqoembeddata').data(externalUrl, oembedData.code);
|
163
181
|
settings.beforeEmbed.call(container, oembedData);
|
@@ -166,149 +184,155 @@
|
|
166
184
|
}
|
167
185
|
|
168
186
|
function embedCode(container, externalUrl, embedProvider) {
|
169
|
-
|
170
|
-
|
171
|
-
success(oembedData, externalUrl, container);
|
172
|
-
}else if (embedProvider.yql) {
|
173
|
-
var from = embedProvider.yql.from || 'htmlstring';
|
174
|
-
var url = embedProvider.yql.url ? embedProvider.yql.url(externalUrl) : externalUrl;
|
175
|
-
var query = 'SELECT * FROM '
|
176
|
-
+ from
|
177
|
-
+ ' WHERE url="' + (url) + '"'
|
178
|
-
+ " and " + (/html/.test(from) ? 'xpath' : 'itemPath') + "='" + (embedProvider.yql.xpath || '/')+"'" ;
|
179
|
-
if(from=='html') query += " and compat='html5'";
|
180
|
-
var ajaxopts = $.extend({
|
181
|
-
url: "http://query.yahooapis.com/v1/public/yql",
|
182
|
-
dataType: 'jsonp',
|
183
|
-
data: {
|
184
|
-
q: query,
|
185
|
-
format: "json",
|
186
|
-
env: 'store://datatables.org/alltableswithkeys',
|
187
|
-
callback: "?"
|
188
|
-
},
|
189
|
-
success: function(data) {
|
190
|
-
var result;
|
191
|
-
if(embedProvider.yql.xpath && embedProvider.yql.xpath=='//meta|//title|//link'){
|
192
|
-
var meta={};
|
193
|
-
if (data.query.results == null) {
|
194
|
-
data.query.results = {"meta": []};
|
195
|
-
}
|
196
|
-
for(var i=0, l=data.query.results.meta.length; i<l; i++){
|
197
|
-
var name = data.query.results.meta[i].name||data.query.results.meta[i].property||null;
|
198
|
-
if(name==null)continue;
|
199
|
-
meta[name.toLowerCase()]=data.query.results.meta[i].content;
|
200
|
-
}
|
201
|
-
if (!meta.hasOwnProperty("title") || !meta.hasOwnProperty("og:title") ) {
|
202
|
-
if ( data.query.results.title != null ) {
|
203
|
-
meta.title = data.query.results.title;
|
204
|
-
}
|
205
|
-
}
|
206
|
-
if (!meta.hasOwnProperty("og:image") && data.query.results.hasOwnProperty("link")) {
|
207
|
-
for ( var i=0, l=data.query.results.link.length; i<l; i++){
|
208
|
-
if ( data.query.results.link[i].hasOwnProperty("rel") ) {
|
209
|
-
if (data.query.results.link[i].rel == "apple-touch-icon") {
|
210
|
-
if ( data.query.results.link[i].href.charAt(0) == "/" ) {
|
211
|
-
meta["og:image"] = url.match(/^(([a-z]+:)?(\/\/)?[^\/]+\/).*$/)[1] + data.query.results.link[i].href;
|
212
|
-
} else {
|
213
|
-
meta["og:image"] = data.query.results.link[i].href;
|
214
|
-
}
|
215
|
-
}
|
216
|
-
}
|
217
|
-
}
|
218
|
-
}
|
219
|
-
result = embedProvider.yql.datareturn(meta);
|
220
|
-
}else{
|
221
|
-
result = embedProvider.yql.datareturn ? embedProvider.yql.datareturn(data.query.results) : data.query.results.result;
|
222
|
-
}
|
223
|
-
if(result===false)return;
|
224
|
-
var oembedData = $.extend({}, result);
|
225
|
-
oembedData.code = result;
|
187
|
+
if ($('#jqoembeddata').data(externalUrl) != undefined && embedProvider.embedtag.tag != 'iframe') {
|
188
|
+
var oembedData = {code: $('#jqoembeddata').data(externalUrl)};
|
226
189
|
success(oembedData, externalUrl, container);
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
190
|
+
} else if (embedProvider.yql) {
|
191
|
+
var from = embedProvider.yql.from || 'htmlstring';
|
192
|
+
var url = embedProvider.yql.url ? embedProvider.yql.url(externalUrl) : externalUrl;
|
193
|
+
var query = 'SELECT * FROM ' + from
|
194
|
+
+ ' WHERE url="' + (url) + '"'
|
195
|
+
+ " and " + (/html/.test(from) ? 'xpath' : 'itemPath') + "='" + (embedProvider.yql.xpath || '/') + "'";
|
196
|
+
if (from == 'html')
|
197
|
+
query += " and compat='html5'";
|
198
|
+
var ajaxopts = $.extend({
|
199
|
+
url: "//query.yahooapis.com/v1/public/yql",
|
200
|
+
dataType: 'jsonp',
|
201
|
+
data: {
|
202
|
+
q: query,
|
203
|
+
format: "json",
|
204
|
+
env: 'store://datatables.org/alltableswithkeys',
|
205
|
+
callback: "?"
|
206
|
+
},
|
207
|
+
success: function (data) {
|
208
|
+
var result;
|
209
|
+
|
210
|
+
if (embedProvider.yql.xpath && embedProvider.yql.xpath == '//meta|//title|//link') {
|
211
|
+
var meta = {};
|
212
|
+
|
213
|
+
if (data.query == null) {
|
214
|
+
data.query = {};
|
215
|
+
}
|
216
|
+
if (data.query.results == null) {
|
217
|
+
data.query.results = {"meta": []};
|
218
|
+
}
|
219
|
+
for (var i = 0, l = data.query.results.meta.length; i < l; i++) {
|
220
|
+
var name = data.query.results.meta[i].name || data.query.results.meta[i].property || null;
|
221
|
+
if (name == null)continue;
|
222
|
+
meta[name.toLowerCase()] = data.query.results.meta[i].content;
|
223
|
+
}
|
224
|
+
if (!meta.hasOwnProperty("title") || !meta.hasOwnProperty("og:title")) {
|
225
|
+
if (data.query.results.title != null) {
|
226
|
+
meta.title = data.query.results.title;
|
227
|
+
}
|
228
|
+
}
|
229
|
+
if (!meta.hasOwnProperty("og:image") && data.query.results.hasOwnProperty("link")) {
|
230
|
+
for (var i = 0, l = data.query.results.link.length; i < l; i++) {
|
231
|
+
if (data.query.results.link[i].hasOwnProperty("rel")) {
|
232
|
+
if (data.query.results.link[i].rel == "apple-touch-icon") {
|
233
|
+
if (data.query.results.link[i].href.charAt(0) == "/") {
|
234
|
+
meta["og:image"] = url.match(/^(([a-z]+:)?(\/\/)?[^\/]+\/).*$/)[1] + data.query.results.link[i].href;
|
235
|
+
} else {
|
236
|
+
meta["og:image"] = data.query.results.link[i].href;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
result = embedProvider.yql.datareturn(meta);
|
243
|
+
} else {
|
244
|
+
result = embedProvider.yql.datareturn ? embedProvider.yql.datareturn(data.query.results) : data.query.results.result;
|
245
|
+
}
|
246
|
+
if (result === false)return;
|
247
|
+
var oembedData = $.extend({}, result);
|
248
|
+
oembedData.code = result;
|
249
|
+
success(oembedData, externalUrl, container);
|
250
|
+
},
|
251
|
+
error: settings.onError.call(container, externalUrl, embedProvider)
|
276
252
|
}, settings.ajaxOptions || {});
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
253
|
+
$.ajax(ajaxopts);
|
254
|
+
} else if (embedProvider.templateRegex) {
|
255
|
+
if (embedProvider.embedtag.tag !== '') {
|
256
|
+
var flashvars = embedProvider.embedtag.flashvars || '';
|
257
|
+
var tag = embedProvider.embedtag.tag || 'embed';
|
258
|
+
var width = embedProvider.embedtag.width || 'auto';
|
259
|
+
var height = embedProvider.embedtag.height || 'auto';
|
260
|
+
var src = externalUrl.replace(embedProvider.templateRegex, embedProvider.apiendpoint);
|
261
|
+
|
262
|
+
if (!embedProvider.nocache) {
|
263
|
+
src += '&jqoemcache=' + rand(5);
|
264
|
+
}
|
265
|
+
|
266
|
+
if (embedProvider.apikey) {
|
267
|
+
src = src.replace('_APIKEY_', settings.apikeys[embedProvider.name]);
|
268
|
+
}
|
269
|
+
|
270
|
+
var code = $('<' + tag + '/>').attr('src', src).attr('width', width)
|
271
|
+
.attr('height', height)
|
272
|
+
.attr('allowfullscreen', embedProvider.embedtag.allowfullscreen || 'true')
|
273
|
+
.attr('allowscriptaccess', embedProvider.embedtag.allowfullscreen || 'always')
|
274
|
+
.css('max-height', settings.maxHeight || 'auto')
|
275
|
+
.css('max-width', settings.maxWidth || 'auto');
|
276
|
+
|
277
|
+
if (tag == 'embed') {
|
278
|
+
code.attr('type', embedProvider.embedtag.type || "application/x-shockwave-flash")
|
279
|
+
.attr('flashvars', externalUrl.replace(embedProvider.templateRegex, flashvars));
|
280
|
+
}
|
284
281
|
|
285
|
-
|
282
|
+
if (tag == 'iframe') {
|
283
|
+
code.attr('scrolling', embedProvider.embedtag.scrolling || "no")
|
284
|
+
.attr('frameborder', embedProvider.embedtag.frameborder || "0");
|
285
|
+
|
286
|
+
}
|
287
|
+
|
288
|
+
success({code: code}, externalUrl, container);
|
289
|
+
} else if (embedProvider.apiendpoint) {
|
290
|
+
//Add APIkey if true
|
291
|
+
if (embedProvider.apikey)
|
292
|
+
embedProvider.apiendpoint = embedProvider.apiendpoint.replace('_APIKEY_', settings.apikeys[embedProvider.name]);
|
293
|
+
|
294
|
+
ajaxopts = $.extend({
|
295
|
+
url: externalUrl.replace(embedProvider.templateRegex, embedProvider.apiendpoint),
|
296
|
+
dataType: 'jsonp',
|
297
|
+
success: function (data) {
|
298
|
+
var oembedData = $.extend({}, data);
|
299
|
+
oembedData.code = embedProvider.templateData(data);
|
300
|
+
success(oembedData, externalUrl, container);
|
301
|
+
},
|
302
|
+
error: settings.onError.call(container, externalUrl, embedProvider)
|
303
|
+
}, settings.ajaxOptions || {});
|
304
|
+
$.ajax(ajaxopts);
|
305
|
+
} else {
|
306
|
+
success({code: externalUrl.replace(embedProvider.templateRegex, embedProvider.template)}, externalUrl, container);
|
307
|
+
}
|
308
|
+
} else {
|
309
|
+
|
310
|
+
var requestUrl = getRequestUrl(embedProvider, externalUrl);
|
286
311
|
ajaxopts = $.extend({
|
287
312
|
url: requestUrl,
|
288
313
|
dataType: embedProvider.dataType || 'jsonp',
|
289
|
-
success: function(data) {
|
314
|
+
success: function (data) {
|
290
315
|
var oembedData = $.extend({}, data);
|
291
316
|
switch (oembedData.type) {
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
317
|
+
case "file": //Deviant Art has this
|
318
|
+
case "photo":
|
319
|
+
oembedData.code = $.fn.oembed.getPhotoCode(externalUrl, oembedData);
|
320
|
+
break;
|
321
|
+
case "video":
|
322
|
+
case "rich":
|
323
|
+
oembedData.code = $.fn.oembed.getRichCode(externalUrl, oembedData);
|
324
|
+
break;
|
325
|
+
default:
|
326
|
+
oembedData.code = $.fn.oembed.getGenericCode(externalUrl, oembedData);
|
327
|
+
break;
|
303
328
|
}
|
304
329
|
success(oembedData, externalUrl, container);
|
305
330
|
},
|
306
331
|
error: settings.onError.call(container, externalUrl, embedProvider)
|
307
332
|
}, settings.ajaxOptions || {});
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
};
|
333
|
+
$.ajax(ajaxopts);
|
334
|
+
}
|
335
|
+
}
|
312
336
|
|
313
337
|
function getNormalizedParams(params) {
|
314
338
|
if (params === null) return null;
|
@@ -320,140 +344,166 @@
|
|
320
344
|
}
|
321
345
|
|
322
346
|
/* Public functions */
|
323
|
-
$.fn.oembed.insertCode = function(container, embedMethod, oembedData) {
|
324
|
-
if (oembedData === null)
|
325
|
-
|
326
|
-
|
347
|
+
$.fn.oembed.insertCode = function (container, embedMethod, oembedData) {
|
348
|
+
if (oembedData === null)
|
349
|
+
return;
|
350
|
+
|
351
|
+
if (embedMethod === 'auto' && container.attr('href') !== null) {
|
352
|
+
embedMethod = 'append';
|
353
|
+
} else if (embedMethod == 'auto') {
|
354
|
+
embedMethod = 'replace';
|
355
|
+
}
|
356
|
+
|
327
357
|
switch (embedMethod) {
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
break;
|
358
|
+
case "replace":
|
359
|
+
container.replaceWith(oembedData.code);
|
360
|
+
break;
|
361
|
+
case "fill":
|
362
|
+
container.html(oembedData.code);
|
363
|
+
break;
|
364
|
+
case "append":
|
365
|
+
container.wrap('<div class="oembedall-container"></div>');
|
366
|
+
var oembedContainer = container.parent();
|
367
|
+
if (settings.includeHandle) {
|
368
|
+
$('<span class="oembedall-closehide">↓</span>').insertBefore(container).click(function () {
|
369
|
+
var encodedString = encodeURIComponent($(this).text());
|
370
|
+
$(this).html((encodedString == '%E2%86%91') ? '↓' : '↑');
|
371
|
+
$(this).parent().children().last().toggle();
|
372
|
+
});
|
373
|
+
}
|
374
|
+
oembedContainer.append('<br/>');
|
375
|
+
try {
|
376
|
+
oembedData.code.clone().appendTo(oembedContainer);
|
377
|
+
} catch (e) {
|
378
|
+
oembedContainer.append(oembedData.code);
|
379
|
+
}
|
380
|
+
/* Make videos semi-responsive
|
381
|
+
* If parent div width less than embeded iframe video then iframe gets shrunk to fit smaller width
|
382
|
+
* If parent div width greater thans embed iframe use the max widht
|
383
|
+
* - works on youtubes and vimeo
|
384
|
+
*/
|
385
|
+
if (settings.maxWidth) {
|
386
|
+
var post_width = oembedContainer.parent().width();
|
387
|
+
if (post_width < settings.maxWidth) {
|
388
|
+
var iframe_width_orig = $('iframe', oembedContainer).width();
|
389
|
+
var iframe_height_orig = $('iframe', oembedContainer).height();
|
390
|
+
var ratio = iframe_width_orig / post_width;
|
391
|
+
$('iframe', oembedContainer).width(iframe_width_orig / ratio);
|
392
|
+
$('iframe', oembedContainer).height(iframe_height_orig / ratio);
|
393
|
+
} else {
|
394
|
+
if (settings.maxWidth) {
|
395
|
+
$('iframe', oembedContainer).width(settings.maxWidth);
|
396
|
+
}
|
397
|
+
if (settings.maxHeight) {
|
398
|
+
$('iframe', oembedContainer).height(settings.maxHeight);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
}
|
402
|
+
break;
|
374
403
|
}
|
375
404
|
};
|
376
405
|
|
377
|
-
$.fn.oembed.getPhotoCode = function(url, oembedData) {
|
378
|
-
var code
|
406
|
+
$.fn.oembed.getPhotoCode = function (url, oembedData) {
|
407
|
+
var code;
|
408
|
+
var alt = oembedData.title ? oembedData.title : '';
|
379
409
|
alt += oembedData.author_name ? ' - ' + oembedData.author_name : '';
|
380
410
|
alt += oembedData.provider_name ? ' - ' + oembedData.provider_name : '';
|
381
|
-
|
411
|
+
|
412
|
+
if (oembedData.url) {
|
382
413
|
code = '<div><a href="' + url + '" target=\'_blank\'><img src="' + oembedData.url + '" alt="' + alt + '"/></a></div>';
|
383
|
-
} else if (oembedData.thumbnail_url){
|
384
|
-
var newURL = oembedData.thumbnail_url.replace('_s','_b');
|
414
|
+
} else if (oembedData.thumbnail_url) {
|
415
|
+
var newURL = oembedData.thumbnail_url.replace('_s', '_b');
|
385
416
|
code = '<div><a href="' + url + '" target=\'_blank\'><img src="' + newURL + '" alt="' + alt + '"/></a></div>';
|
386
417
|
} else {
|
387
418
|
code = '<div>Error loading this picture</div>';
|
388
419
|
}
|
389
|
-
|
420
|
+
|
421
|
+
if (oembedData.html) {
|
422
|
+
code += "<div>" + oembedData.html + "</div>";
|
423
|
+
}
|
424
|
+
|
390
425
|
return code;
|
391
426
|
};
|
392
427
|
|
393
|
-
$.fn.oembed.getRichCode = function(url, oembedData) {
|
394
|
-
|
395
|
-
return code;
|
428
|
+
$.fn.oembed.getRichCode = function (url, oembedData) {
|
429
|
+
return oembedData.html;
|
396
430
|
};
|
397
431
|
|
398
|
-
$.fn.oembed.getGenericCode = function(url, oembedData) {
|
399
|
-
var title = (oembedData.title !== null) ? oembedData.title : url
|
400
|
-
|
401
|
-
|
432
|
+
$.fn.oembed.getGenericCode = function (url, oembedData) {
|
433
|
+
var title = ((oembedData.title) && (oembedData.title !== null)) ? oembedData.title : url;
|
434
|
+
var code = '<a href="' + url + '">' + title + '</a>';
|
435
|
+
|
436
|
+
if (oembedData.html) {
|
437
|
+
code += "<div>" + oembedData.html + "</div>";
|
438
|
+
}
|
439
|
+
|
402
440
|
return code;
|
403
441
|
};
|
404
442
|
|
405
|
-
$.fn.oembed.getOEmbedProvider = function(url) {
|
443
|
+
$.fn.oembed.getOEmbedProvider = function (url) {
|
406
444
|
for (var i = 0; i < $.fn.oembed.providers.length; i++) {
|
407
|
-
for (var j = 0, l
|
445
|
+
for (var j = 0, l = $.fn.oembed.providers[i].urlschemes.length; j < l; j++) {
|
408
446
|
var regExp = new RegExp($.fn.oembed.providers[i].urlschemes[j], "i");
|
409
|
-
|
447
|
+
|
448
|
+
if (url.match(regExp) !== null)
|
449
|
+
return $.fn.oembed.providers[i];
|
410
450
|
}
|
411
451
|
}
|
412
452
|
return null;
|
413
453
|
};
|
414
454
|
|
415
|
-
|
455
|
+
// Constructor Function for OEmbedProvider Class.
|
456
|
+
$.fn.oembed.OEmbedProvider = function (name, type, urlschemesarray, apiendpoint, extraSettings) {
|
416
457
|
this.name = name;
|
417
458
|
this.type = type; // "photo", "video", "link", "rich", null
|
418
459
|
this.urlschemes = urlschemesarray;
|
419
460
|
this.apiendpoint = apiendpoint;
|
420
461
|
this.maxWidth = 500;
|
421
462
|
this.maxHeight = 400;
|
422
|
-
extraSettings =extraSettings ||{};
|
423
|
-
|
424
|
-
if(extraSettings.useYQL){
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
463
|
+
extraSettings = extraSettings || {};
|
464
|
+
|
465
|
+
if (extraSettings.useYQL) {
|
466
|
+
|
467
|
+
if (extraSettings.useYQL == 'xml') {
|
468
|
+
extraSettings.yql = {
|
469
|
+
xpath: "//oembed/html",
|
470
|
+
from: 'xml',
|
471
|
+
apiendpoint: this.apiendpoint,
|
472
|
+
url: function (externalurl) {
|
473
|
+
return this.apiendpoint + '?format=xml&url=' + externalurl
|
474
|
+
},
|
475
|
+
datareturn: function (results) {
|
476
|
+
return results.html.replace(/.*\[CDATA\[(.*)\]\]>$/, '$1') || ''
|
477
|
+
}
|
478
|
+
};
|
479
|
+
} else {
|
480
|
+
extraSettings.yql = {
|
481
|
+
from: 'json',
|
482
|
+
apiendpoint: this.apiendpoint,
|
483
|
+
url: function (externalurl) {
|
484
|
+
return this.apiendpoint + '?format=json&url=' + externalurl
|
485
|
+
},
|
486
|
+
datareturn: function (results) {
|
487
|
+
if (results.json.type != 'video' && (results.json.url || results.json.thumbnail_url)) {
|
488
|
+
return '<img src="' + (results.json.url || results.json.thumbnail_url) + '" />';
|
489
|
+
}
|
490
|
+
return results.json.html || ''
|
491
|
+
}
|
492
|
+
};
|
493
|
+
}
|
494
|
+
this.apiendpoint = null;
|
445
495
|
}
|
446
|
-
|
447
|
-
|
496
|
+
|
497
|
+
|
448
498
|
for (var property in extraSettings) {
|
449
|
-
|
499
|
+
this[property] = extraSettings[property];
|
450
500
|
}
|
451
|
-
|
501
|
+
|
452
502
|
this.format = this.format || 'json';
|
453
503
|
this.callbackparameter = this.callbackparameter || "callback";
|
454
|
-
this.embedtag = this.embedtag || {tag:""};
|
504
|
+
this.embedtag = this.embedtag || {tag: ""};
|
505
|
+
|
455
506
|
|
456
|
-
|
457
507
|
};
|
458
508
|
|
459
509
|
/*
|
@@ -465,7 +515,7 @@
|
|
465
515
|
* @param {String} apiendpoint The endpoint of the provider
|
466
516
|
* @param {String} extraSettings Extra settings of the provider
|
467
517
|
*/
|
468
|
-
$.fn.updateOEmbedProvider = function(name, type, urlschemesarray, apiendpoint, extraSettings) {
|
518
|
+
$.fn.updateOEmbedProvider = function (name, type, urlschemesarray, apiendpoint, extraSettings) {
|
469
519
|
for (var i = 0; i < $.fn.oembed.providers.length; i++) {
|
470
520
|
if ($.fn.oembed.providers[i].name === name) {
|
471
521
|
if (type !== null) {
|
@@ -491,355 +541,468 @@
|
|
491
541
|
|
492
542
|
/* Native & common providers */
|
493
543
|
$.fn.oembed.providers = [
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
}
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
}),
|
721
|
-
|
722
|
-
new $.fn.oembed.OEmbedProvider("facebook", "rich", ["facebook.com/(people/[^\\/]+/\\d+|[^\\/]+$)"], "https://graph.facebook.com/$2$3/?callback=?"
|
723
|
-
,{templateRegex:/.*facebook.com\/(people\/[^\/]+\/(\d+).*|([^\/]+$))/,
|
724
|
-
templateData : function(data){ if(!data.id)return false;
|
725
|
-
var out = '<div class="oembedall-facebook1"><div class="oembedall-facebook2"><a href="http://www.facebook.com/">facebook</a> ';
|
726
|
-
if(data.from) out += '<a href="http://www.facebook.com/'+data.from.id+'">'+data.from.name+'</a>';
|
727
|
-
else if(data.link) out += '<a href="'+data.link+'">'+data.name+'</a>';
|
728
|
-
else if(data.username) out += '<a href="http://www.facebook.com/'+data.username+'">'+data.name+'</a>';
|
729
|
-
else out += '<a href="http://www.facebook.com/'+data.id+'">'+data.name+'</a>';
|
730
|
-
out += '</div><div class="oembedall-facebookBody"><div class="contents">';
|
731
|
-
if(data.picture) out += '<a href="'+data.link+'"><img src="'+data.picture+'"></a>';
|
732
|
-
else out += '<img src="https://graph.facebook.com/'+data.id+'/picture">';
|
733
|
-
if(data.from) out += '<a href="'+data.link+'">'+data.name+'</a>';
|
734
|
-
if(data.founded) out += 'Founded: <strong>'+data.founded+'</strong><br>'
|
735
|
-
if(data.category) out += 'Category: <strong>'+data.category+'</strong><br>';
|
736
|
-
if(data.website) out += 'Website: <strong><a href="'+data.website+'">'+data.website+'</a></strong><br>';
|
737
|
-
if(data.gender) out += 'Gender: <strong>'+data.gender+'</strong><br>';
|
738
|
-
if(data.description) out += data.description + '<br>';
|
739
|
-
out += '</div></div>';
|
740
|
-
return out;
|
741
|
-
}
|
742
|
-
}),
|
743
|
-
new $.fn.oembed.OEmbedProvider("stackoverflow", "rich", ["stackoverflow.com/questions/[\\d]+"], "http://api.stackoverflow.com/1.1/questions/$1?body=true&jsonp=?"
|
744
|
-
,{templateRegex:/.*questions\/([\d]+).*/,
|
745
|
-
templateData : function(data){
|
746
|
-
if(!data.questions)return false;
|
747
|
-
var q = data.questions[0];
|
748
|
-
var body = $(q.body).text();
|
749
|
-
var out = '<div class="oembedall-stoqembed"><div class="oembedall-statscontainer"><div class="oembedall-statsarrow"></div><div class="oembedall-stats"><div class="oembedall-vote"><div class="oembedall-votes">'
|
750
|
-
+'<span class="oembedall-vote-count-post"><strong>'+ (q.up_vote_count - q.down_vote_count)+ '</strong></span><div class="oembedall-viewcount">vote(s)</div></div>'
|
751
|
-
+'</div><div class="oembedall-status"><strong>'+q.answer_count+'</strong>answer</div></div><div class="oembedall-views">'+q.view_count+' view(s)</div></div>'
|
752
|
-
+'<div class="oembedall-summary"><h3><a class="oembedall-question-hyperlink" href="http://stackoverflow.com/questions/'+q.question_id+'/">'+q.title+'</a></h3>'
|
753
|
-
+'<div class="oembedall-excerpt">'+ body.substring(0,100)+'...</div><div class="oembedall-tags">';
|
754
|
-
for(i in q.tags)
|
755
|
-
out += '<a title="" class="oembedall-post-tag" href="http://stackoverflow.com/questions/tagged/'+q.tags[i]+'">'+q.tags[i]+'</a>';
|
756
|
-
out += '</div><div class="oembedall-fr"><div class="oembedall-user-info"><div class="oembedall-user-gravatar32"><a href="http://stackoverflow.com/users/'+q.owner.user_id+'/'+q.owner.display_name+'">'
|
757
|
-
+'<img width="32" height="32" alt="" src="http://www.gravatar.com/avatar/'+q.owner.email_hash+'?s=32&d=identicon&r=PG"></a></div><div class="oembedall-user-details">'
|
758
|
-
+'<a href="http://stackoverflow.com/users/'+q.owner.user_id+'/'+q.owner.display_name+'">'+q.owner.display_name+'</a><br><span title="reputation score" class="oembedall-reputation-score">'
|
759
|
-
+q.owner.reputation+'</span></div></div></div></div></div>';
|
760
|
-
return out;
|
761
|
-
}
|
762
|
-
}),
|
763
|
-
new $.fn.oembed.OEmbedProvider("wordpress", "rich", ["wordpress\\.com/.+","blogs\\.cnn\\.com/.+","techcrunch\\.com/.+","wp\\.me/.+"], "http://public-api.wordpress.com/oembed/1.0/?for=jquery-oembed-all"),
|
764
|
-
new $.fn.oembed.OEmbedProvider("screenr", "rich", ["screenr\.com"], "http://www.screenr.com/embed/$1",
|
765
|
-
{templateRegex:/.*\/([^\/]+).*/
|
766
|
-
,embedtag : {tag: 'iframe', width:'650',height: 396}
|
767
|
-
}) ,
|
768
|
-
new $.fn.oembed.OEmbedProvider("gigpans", "rich", ["gigapan\\.org/[-.\\w@]+/\\d+"],"http://gigapan.org/gigapans/$1/options/nosnapshots/iframe/flash.html",
|
769
|
-
{templateRegex:/.*\/(\d+)\/?.*/,
|
770
|
-
embedtag : {tag: 'iframe', width:'100%',height: 400 }
|
771
|
-
}),
|
772
|
-
new $.fn.oembed.OEmbedProvider("scribd", "rich", ["scribd\\.com/.+"],"http://www.scribd.com/embeds/$1/content?start_page=1&view_mode=list",
|
773
|
-
{templateRegex:/.*doc\/([^\/]+).*/ ,
|
774
|
-
embedtag : {tag: 'iframe', width:'100%',height: 600}
|
775
|
-
}),
|
776
|
-
new $.fn.oembed.OEmbedProvider("kickstarter", "rich", ["kickstarter\\.com/projects/.+"], "$1/widget/card.html",
|
777
|
-
{templateRegex:/([^\?]+).*/ ,
|
778
|
-
embedtag : {tag: 'iframe', width:'220',height: 380}
|
779
|
-
}),
|
780
|
-
|
781
|
-
new $.fn.oembed.OEmbedProvider("amazon", "rich", ["amzn.com/B+","amazon.com.*/(B\\S+)($|\\/.*)"], "http://rcm.amazon.com/e/cm?t=_APIKEY_&o=1&p=8&l=as1&asins=$1&ref=qf_br_asin_til&fc1=000000&IS2=1<1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr"
|
782
|
-
,{apikey: true,templateRegex:/.*\/(B[0-9A-Z]+)($|\/.*)/,
|
783
|
-
embedtag : {tag: 'iframe', width:'120px',height: '240px'}
|
784
|
-
}),
|
785
|
-
|
786
|
-
new $.fn.oembed.OEmbedProvider("slideshare", "rich", ["slideshare\.net"], "http://www.slideshare.net/api/oembed/2",{format:'jsonp'}),
|
787
|
-
new $.fn.oembed.OEmbedProvider("roomsharejp", "rich", ["roomshare\\.jp/(en/)?post/.*"], "http://roomshare.jp/oembed.json"),
|
788
|
-
|
789
|
-
new $.fn.oembed.OEmbedProvider("lanyard", "rich", ["lanyrd.com/\\d+/.+"], null,
|
790
|
-
{yql:{xpath:'(//div[@class="primary"])[1]', from: 'htmlstring'
|
791
|
-
, datareturn:function(results){
|
792
|
-
if(!results.result) return false;
|
793
|
-
return '<div class="oembedall-lanyard">'+results.result+'</div>';
|
794
|
-
}
|
795
|
-
}
|
796
|
-
}),
|
797
|
-
new $.fn.oembed.OEmbedProvider("asciiartfarts", "rich", ["asciiartfarts.com/\\d+.html"], null,
|
798
|
-
{yql:{xpath:'//pre/font', from: 'htmlstring'
|
799
|
-
, datareturn:function(results){
|
800
|
-
if(!results.result) return false;
|
801
|
-
return '<pre style="background-color:000;">'+results.result+'</div>';
|
802
|
-
}
|
803
|
-
}
|
804
|
-
}),
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
//Use Open Graph Where applicable
|
809
|
-
new $.fn.oembed.OEmbedProvider("opengraph", "rich", [".*"], null,
|
810
|
-
{yql:{xpath:"//meta|//title|//link", from:'html'
|
811
|
-
, datareturn:function(results){
|
812
|
-
if(!results['og:title'] && results['title'] &&results['description'])results['og:title']=results['title'];
|
813
|
-
if(!results['og:title'] && !results['title'])return false;
|
814
|
-
var code = $('<p/>');
|
815
|
-
if(results['og:video']) {
|
816
|
-
var embed = $('<embed src="'+results['og:video']+'"/>');
|
817
|
-
embed
|
818
|
-
.attr('type',results['og:video:type'] || "application/x-shockwave-flash")
|
819
|
-
.css('max-height', settings.maxHeight || 'auto' )
|
820
|
-
.css('max-width', settings.maxWidth || 'auto' );
|
821
|
-
if(results['og:video:width']) embed.attr('width',results['og:video:width']);
|
822
|
-
if(results['og:video:height']) embed.attr('height',results['og:video:height']);
|
823
|
-
code.append(embed);
|
824
|
-
}else if(results['og:image']) {
|
825
|
-
var img = $('<img src="'+results['og:image']+'">');
|
826
|
-
img.css('max-height', settings.maxHeight || 'auto' ).css('max-width', settings.maxWidth || 'auto' );
|
827
|
-
if(results['og:image:width']) img.attr('width',results['og:image:width']);
|
828
|
-
if(results['og:image:height']) img.attr('height',results['og:image:height']);
|
829
|
-
code.append(img);
|
544
|
+
|
545
|
+
//Video
|
546
|
+
new $.fn.oembed.OEmbedProvider("youtube", "video", ["youtube\\.com/watch.+v=[\\w-]+&?", "youtu\\.be/[\\w-]+", "youtube.com/embed"], 'http://www.youtube.com/embed/$1?wmode=transparent', {
|
547
|
+
templateRegex: /.*(?:v\=|be\/|embed\/)([\w\-]+)&?.*/, embedtag: {tag: 'iframe', width: '425', height: '349'}
|
548
|
+
}),
|
549
|
+
|
550
|
+
//new $.fn.oembed.OEmbedProvider("youtube", "video", ["youtube\\.com/watch.+v=[\\w-]+&?", "youtu\\.be/[\\w-]+"], 'http://www.youtube.com/oembed', {useYQL:'json'}),
|
551
|
+
//new $.fn.oembed.OEmbedProvider("youtubeiframe", "video", ["youtube.com/embed"], "$1?wmode=transparent",
|
552
|
+
// {templateRegex:/(.*)/,embedtag : {tag: 'iframe', width:'425',height: '349'}}),
|
553
|
+
new $.fn.oembed.OEmbedProvider("wistia", "video", ["wistia.com/m/.+", "wistia.com/embed/.+", "wi.st/m/.+", "wi.st/embed/.+"], 'http://fast.wistia.com/oembed', {useYQL: 'json'}),
|
554
|
+
new $.fn.oembed.OEmbedProvider("xtranormal", "video", ["xtranormal\\.com/watch/.+"], "http://www.xtranormal.com/xtraplayr/$1/$2", {
|
555
|
+
templateRegex: /.*com\/watch\/([\w\-]+)\/([\w\-]+).*/, embedtag: {tag: 'iframe', width: '320', height: '269'}}),
|
556
|
+
new $.fn.oembed.OEmbedProvider("scivee", "video", ["scivee.tv/node/.+"], "http://www.scivee.tv/flash/embedCast.swf?", {
|
557
|
+
templateRegex: /.*tv\/node\/(.+)/, embedtag: {width: '480', height: '400', flashvars: "id=$1&type=3"}}),
|
558
|
+
new $.fn.oembed.OEmbedProvider("veoh", "video", ["veoh.com/watch/.+"], "http://www.veoh.com/swf/webplayer/WebPlayer.swf?version=AFrontend.5.7.0.1337&permalinkId=$1&player=videodetailsembedded&videoAutoPlay=0&id=anonymous", {
|
559
|
+
templateRegex: /.*watch\/([^\?]+).*/, embedtag: {width: '410', height: '341'}}),
|
560
|
+
new $.fn.oembed.OEmbedProvider("gametrailers", "video", ["gametrailers\\.com/video/.+"], "http://media.mtvnservices.com/mgid:moses:video:gametrailers.com:$2", {
|
561
|
+
templateRegex: /.*com\/video\/([\w\-]+)\/([\w\-]+).*/, embedtag: {width: '512', height: '288' }}),
|
562
|
+
new $.fn.oembed.OEmbedProvider("funnyordie", "video", ["funnyordie\\.com/videos/.+"], "http://player.ordienetworks.com/flash/fodplayer.swf?", {
|
563
|
+
templateRegex: /.*videos\/([^\/]+)\/([^\/]+)?/, embedtag: {width: 512, height: 328, flashvars: "key=$1"}}),
|
564
|
+
new $.fn.oembed.OEmbedProvider("colledgehumour", "video", ["collegehumor\\.com/video/.+"], "http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=$1&use_node_id=true&fullscreen=1",
|
565
|
+
{templateRegex: /.*video\/([^\/]+).*/, embedtag: {width: 600, height: 338}}),
|
566
|
+
new $.fn.oembed.OEmbedProvider("metacafe", "video", ["metacafe\\.com/watch/.+"], "http://www.metacafe.com/fplayer/$1/$2.swf",
|
567
|
+
{templateRegex: /.*watch\/(\d+)\/(\w+)\/.*/, embedtag: {width: 400, height: 345}}),
|
568
|
+
new $.fn.oembed.OEmbedProvider("bambuser", "video", ["bambuser\\.com\/channel\/.*\/broadcast\/.*"], "http://static.bambuser.com/r/player.swf?vid=$1",
|
569
|
+
{templateRegex: /.*bambuser\.com\/channel\/.*\/broadcast\/(\w+).*/, embedtag: {width: 512, height: 339 }}),
|
570
|
+
new $.fn.oembed.OEmbedProvider("twitvid", "video", ["twitvid\\.com/.+"], "http://www.twitvid.com/embed.php?guid=$1&autoplay=0",
|
571
|
+
{templateRegex: /.*twitvid\.com\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }}),
|
572
|
+
new $.fn.oembed.OEmbedProvider("aniboom", "video", ["aniboom\\.com/animation-video/.+"], "http://api.aniboom.com/e/$1",
|
573
|
+
{templateRegex: /.*animation-video\/(\d+).*/, embedtag: {width: 594, height: 334}}),
|
574
|
+
new $.fn.oembed.OEmbedProvider("vzaar", "video", ["vzaar\\.com/videos/.+", "vzaar.tv/.+"], "http://view.vzaar.com/$1/player?",
|
575
|
+
{templateRegex: /.*\/(\d+).*/, embedtag: {tag: 'iframe', width: 576, height: 324 }}),
|
576
|
+
new $.fn.oembed.OEmbedProvider("snotr", "video", ["snotr\\.com/video/.+"], "http://www.snotr.com/embed/$1",
|
577
|
+
{templateRegex: /.*\/(\d+).*/, embedtag: {tag: 'iframe', width: 400, height: 330}, nocache: 1 }),
|
578
|
+
new $.fn.oembed.OEmbedProvider("youku", "video", ["v.youku.com/v_show/id_.+"], "http://player.youku.com/player.php/sid/$1/v.swf",
|
579
|
+
{templateRegex: /.*id_(.+)\.html.*/, embedtag: {width: 480, height: 400}, nocache: 1 }),
|
580
|
+
new $.fn.oembed.OEmbedProvider("tudou", "video", ["tudou.com/programs/view/.+\/"], "http://www.tudou.com/v/$1/v.swf",
|
581
|
+
{templateRegex: /.*view\/(.+)\//, embedtag: {width: 480, height: 400}, nocache: 1 }),
|
582
|
+
new $.fn.oembed.OEmbedProvider("embedr", "video", ["embedr\\.com/playlist/.+"], "http://embedr.com/swf/slider/$1/425/520/default/false/std?",
|
583
|
+
{templateRegex: /.*playlist\/([^\/]+).*/, embedtag: {width: 425, height: 520}}),
|
584
|
+
new $.fn.oembed.OEmbedProvider("blip", "video", ["blip\\.tv/.+"], "//blip.tv/oembed/"),
|
585
|
+
new $.fn.oembed.OEmbedProvider("minoto-video", "video", ["http://api.minoto-video.com/publishers/.+/videos/.+", "http://dashboard.minoto-video.com/main/video/details/.+", "http://embed.minoto-video.com/.+"], "http://api.minoto-video.com/services/oembed.json", {useYQL: 'json'}),
|
586
|
+
new $.fn.oembed.OEmbedProvider("animoto", "video", ["animoto.com/play/.+"], "http://animoto.com/services/oembed"),
|
587
|
+
new $.fn.oembed.OEmbedProvider("hulu", "video", ["hulu\\.com/watch/.*"], "//www.hulu.com/api/oembed.json"),
|
588
|
+
new $.fn.oembed.OEmbedProvider("ustream", "video", ["ustream\\.tv/recorded/.*"], "http://www.ustream.tv/oembed", {useYQL: 'json'}),
|
589
|
+
new $.fn.oembed.OEmbedProvider("videojug", "video", ["videojug\\.com/(film|payer|interview).*"], "http://www.videojug.com/oembed.json", {useYQL: 'json'}),
|
590
|
+
new $.fn.oembed.OEmbedProvider("sapo", "video", ["videos\\.sapo\\.pt/.*"], "http://videos.sapo.pt/oembed", {useYQL: 'json'}),
|
591
|
+
new $.fn.oembed.OEmbedProvider("vodpod", "video", ["vodpod.com/watch/.*"], "http://vodpod.com/oembed.js", {useYQL: 'json'}),
|
592
|
+
new $.fn.oembed.OEmbedProvider("vimeo", "video", ["www\.vimeo\.com\/groups\/.*\/videos\/.*", "www\.vimeo\.com\/.*", "vimeo\.com\/groups\/.*\/videos\/.*", "vimeo\.com\/.*"], "//vimeo.com/api/oembed.json"),
|
593
|
+
new $.fn.oembed.OEmbedProvider("dailymotion", "video", ["dailymotion\\.com/.+"], '//www.dailymotion.com/services/oembed'),
|
594
|
+
new $.fn.oembed.OEmbedProvider("5min", "video", ["www\\.5min\\.com/.+"], 'http://api.5min.com/oembed.xml', {useYQL: 'xml'}),
|
595
|
+
new $.fn.oembed.OEmbedProvider("National Film Board of Canada", "video", ["nfb\\.ca/film/.+"], 'http://www.nfb.ca/remote/services/oembed/', {useYQL: 'json'}),
|
596
|
+
new $.fn.oembed.OEmbedProvider("qik", "video", ["qik\\.com/\\w+"], 'http://qik.com/api/oembed.json', {useYQL: 'json'}),
|
597
|
+
new $.fn.oembed.OEmbedProvider("revision3", "video", ["revision3\\.com"], "http://revision3.com/api/oembed/"),
|
598
|
+
new $.fn.oembed.OEmbedProvider("dotsub", "video", ["dotsub\\.com/view/.+"], "http://dotsub.com/services/oembed", {useYQL: 'json'}),
|
599
|
+
new $.fn.oembed.OEmbedProvider("clikthrough", "video", ["clikthrough\\.com/theater/video/\\d+"], "http://clikthrough.com/services/oembed"),
|
600
|
+
new $.fn.oembed.OEmbedProvider("Kinomap", "video", ["kinomap\\.com/.+"], "http://www.kinomap.com/oembed"),
|
601
|
+
new $.fn.oembed.OEmbedProvider("VHX", "video", ["vhx.tv/.+"], "http://vhx.tv/services/oembed.json"),
|
602
|
+
new $.fn.oembed.OEmbedProvider("bambuser", "video", ["bambuser.com/.+"], "http://api.bambuser.com/oembed/iframe.json"),
|
603
|
+
new $.fn.oembed.OEmbedProvider("justin.tv", "video", ["justin.tv/.+"], 'http://api.justin.tv/api/embed/from_url.json', {useYQL: 'json'}),
|
604
|
+
new $.fn.oembed.OEmbedProvider("vine", "video", ["vine.co/v/.*"], null,
|
605
|
+
{
|
606
|
+
templateRegex: /https?:\/\/w?w?w?.?vine\.co\/v\/([a-zA-Z0-9]*).*/,
|
607
|
+
template: '<iframe src="https://vine.co/v/$1/embed/postcard" width="600" height="600" allowfullscreen="true" allowscriptaccess="always" scrolling="no" frameborder="0"></iframe>' +
|
608
|
+
'<script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>',
|
609
|
+
nocache: 1
|
610
|
+
}),
|
611
|
+
new $.fn.oembed.OEmbedProvider("boxofficebuz", "video", ["boxofficebuz\\.com\\/embed/.+"], "http://boxofficebuz.com/embed/$1/$2", {templateRegex: [/.*boxofficebuz\.com\/embed\/(\w+)\/([\w*\-*]+)/], embedtag: {tag: 'iframe', width: 480, height: 360 }}),
|
612
|
+
new $.fn.oembed.OEmbedProvider("clipsyndicate", "video", ["clipsyndicate\\.com/video/play/.+", "clipsyndicate\\.com/embed/iframe\?.+"], "http://eplayer.clipsyndicate.com/embed/iframe?pf_id=1&show_title=0&va_id=$1&windows=1", {templateRegex: [/.*www\.clipsyndicate\.com\/video\/play\/(\w+)\/.*/, /.*eplayer\.clipsyndicate\.com\/embed\/iframe\?.*va_id=(\w+).*.*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
613
|
+
new $.fn.oembed.OEmbedProvider("coub", "video", ["coub\\.com/.+"], "http://www.coub.com/embed/$1?muted=false&autostart=false&originalSize=false&hideTopBar=false&noSiteButtons=false&startWithHD=false", {templateRegex: [/.*coub\.com\/embed\/(\w+)\?*.*/, /.*coub\.com\/view\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
614
|
+
new $.fn.oembed.OEmbedProvider("discoverychannel", "video", ["snagplayer\\.video\\.dp\\.discovery\\.com/.+"], "http://snagplayer.video.dp.discovery.com/$1/snag-it-player.htm?auto=no", {templateRegex: [/.*snagplayer\.video\.dp\.discovery\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }}),
|
615
|
+
new $.fn.oembed.OEmbedProvider("telly", "video", ["telly\\.com/.+"], "http://www.telly.com/embed.php?guid=$1&autoplay=0", {templateRegex: [/.*telly\.com\/embed\.php\?guid=(\w+).*/, /.*telly\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }}),
|
616
|
+
new $.fn.oembed.OEmbedProvider("minilogs", "video", ["minilogs\\.com/.+"], "http://www.minilogs.com/e/$1", {templateRegex: [/.*minilogs\.com\/e\/(\w+).*/, /.*minilogs\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
617
|
+
new $.fn.oembed.OEmbedProvider("viddy", "video", ["viddy\\.com/.+"], "http://www.viddy.com/embed/video/$1", {templateRegex: [/.*viddy\.com\/embed\/video\/(\.*)/, /.*viddy\.com\/video\/(\.*)/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
618
|
+
new $.fn.oembed.OEmbedProvider("worldstarhiphop", "video", ["worldstarhiphop\\.com\/embed/.+"], "http://www.worldstarhiphop.com/embed/$1", {templateRegex: /.*worldstarhiphop\.com\/embed\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
619
|
+
new $.fn.oembed.OEmbedProvider("zapiks", "video", ["zapiks\\.fr\/.+"], "http://www.zapiks.fr/index.php?action=playerIframe&media_id=$1&autoStart=fals", {templateRegex: /.*zapiks\.fr\/index.php\?[\w\=\&]*media_id=(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
620
|
+
|
621
|
+
//Audio
|
622
|
+
new $.fn.oembed.OEmbedProvider("official.fm", "rich", ["official.fm/.+"], 'http://official.fm/services/oembed', {useYQL: 'json'}),
|
623
|
+
new $.fn.oembed.OEmbedProvider("chirbit", "rich", ["chirb.it/.+"], 'http://chirb.it/oembed.json', {useYQL: 'json'}),
|
624
|
+
new $.fn.oembed.OEmbedProvider("chirbit", "audio", ["chirb\\.it/.+"], "http://chirb.it/wp/$1", {templateRegex: [/.*chirb\.it\/wp\/(\w+).*/, /.*chirb\.it\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
625
|
+
new $.fn.oembed.OEmbedProvider("Huffduffer", "rich", ["huffduffer.com/[-.\\w@]+/\\d+"], "http://huffduffer.com/oembed"),
|
626
|
+
new $.fn.oembed.OEmbedProvider("Spotify", "rich", ["open.spotify.com/(track|album|user)/"], "https://embed.spotify.com/oembed/"),
|
627
|
+
new $.fn.oembed.OEmbedProvider("shoudio", "rich", ["shoudio.com/.+", "shoud.io/.+"], "http://shoudio.com/api/oembed"),
|
628
|
+
new $.fn.oembed.OEmbedProvider("mixcloud", "rich", ["mixcloud.com/.+"], 'http://www.mixcloud.com/oembed/', {useYQL: 'json'}),
|
629
|
+
new $.fn.oembed.OEmbedProvider("rdio.com", "rich", ["rd.io/.+", "rdio.com"], "http://www.rdio.com/api/oembed/"),
|
630
|
+
new $.fn.oembed.OEmbedProvider("Soundcloud", "rich", ["soundcloud.com/.+", "snd.sc/.+"], "//soundcloud.com/oembed", {format: 'js'}),
|
631
|
+
new $.fn.oembed.OEmbedProvider("bandcamp", "rich", ["bandcamp\\.com/album/.+"], null,
|
632
|
+
{
|
633
|
+
yql: {
|
634
|
+
xpath: "//meta[contains(@content, \\'EmbeddedPlayer\\')]",
|
635
|
+
from: 'html',
|
636
|
+
datareturn: function (results) {
|
637
|
+
return results.meta ? '<iframe width="400" height="100" src="' + results.meta.content + '" allowtransparency="true" frameborder="0"></iframe>' : false;
|
638
|
+
}
|
639
|
+
}
|
640
|
+
}),
|
641
|
+
|
642
|
+
//Photo
|
643
|
+
new $.fn.oembed.OEmbedProvider("deviantart", "photo", ["deviantart.com/.+", "fav.me/.+", "deviantart.com/.+"], "//backend.deviantart.com/oembed", {format: 'jsonp'}),
|
644
|
+
new $.fn.oembed.OEmbedProvider("skitch", "photo", ["skitch.com/.+"], null,
|
645
|
+
{
|
646
|
+
yql: {
|
647
|
+
xpath: "json",
|
648
|
+
from: 'json',
|
649
|
+
url: function (externalurl) {
|
650
|
+
return 'http://skitch.com/oembed/?format=json&url=' + externalurl
|
651
|
+
},
|
652
|
+
datareturn: function (data) {
|
653
|
+
return $.fn.oembed.getPhotoCode(data.json.url, data.json);
|
654
|
+
}
|
655
|
+
}
|
656
|
+
}),
|
657
|
+
new $.fn.oembed.OEmbedProvider("mobypicture", "photo", ["mobypicture.com/user/.+/view/.+", "moby.to/.+"], "http://api.mobypicture.com/oEmbed"),
|
658
|
+
new $.fn.oembed.OEmbedProvider("flickr", "photo", ["flickr\\.com/photos/.+"], "//flickr.com/services/oembed", {callbackparameter: 'jsoncallback'}),
|
659
|
+
new $.fn.oembed.OEmbedProvider("photobucket", "photo", ["photobucket\\.com/(albums|groups)/.+"], "http://photobucket.com/oembed/"),
|
660
|
+
new $.fn.oembed.OEmbedProvider("instagram", "photo", ["instagr\\.?am(\\.com)?/.+"], "//api.instagram.com/oembed"),
|
661
|
+
//new $.fn.oembed.OEmbedProvider("yfrog", "photo", ["yfrog\\.(com|ru|com\\.tr|it|fr|co\\.il|co\\.uk|com\\.pl|pl|eu|us)/.+"], "http://www.yfrog.com/api/oembed",{useYQL:"json"}),
|
662
|
+
new $.fn.oembed.OEmbedProvider("SmugMug", "photo", ["smugmug.com/[-.\\w@]+/.+"], "http://api.smugmug.com/services/oembed/"),
|
663
|
+
new $.fn.oembed.OEmbedProvider("dribbble", "photo", ["dribbble.com/shots/.+"], "http://api.dribbble.com/shots/$1?callback=?",
|
664
|
+
{
|
665
|
+
templateRegex: /.*shots\/([\d]+).*/,
|
666
|
+
templateData: function (data) {
|
667
|
+
if (!data.image_teaser_url) {
|
668
|
+
return false;
|
669
|
+
}
|
670
|
+
return '<img src="' + data.image_teaser_url + '"/>';
|
671
|
+
}
|
672
|
+
}),
|
673
|
+
new $.fn.oembed.OEmbedProvider("chart.ly", "photo", ["chart\\.ly/[a-z0-9]{6,8}"], "http://chart.ly/uploads/large_$1.png",
|
674
|
+
{templateRegex: /.*ly\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
|
675
|
+
//new $.fn.oembed.OEmbedProvider("stocktwits.com", "photo", ["stocktwits\\.com/message/.+"], "http://charts.stocktwits.com/production/original_$1.png?",
|
676
|
+
// { templateRegex: /.*message\/([^\/]+).*/, embedtag: { tag: 'img'},nocache:1 }),
|
677
|
+
new $.fn.oembed.OEmbedProvider("circuitlab", "photo", ["circuitlab.com/circuit/.+"], "https://www.circuitlab.com/circuit/$1/screenshot/540x405/",
|
678
|
+
{templateRegex: /.*circuit\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
|
679
|
+
new $.fn.oembed.OEmbedProvider("23hq", "photo", ["23hq.com/[-.\\w@]+/photo/.+"], "http://www.23hq.com/23/oembed", {useYQL: "json"}),
|
680
|
+
new $.fn.oembed.OEmbedProvider("img.ly", "photo", ["img\\.ly/.+"], "//img.ly/show/thumb/$1",
|
681
|
+
{templateRegex: /.*ly\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
|
682
|
+
new $.fn.oembed.OEmbedProvider("twitgoo.com", "photo", ["twitgoo\\.com/.+"], "http://twitgoo.com/show/thumb/$1",
|
683
|
+
{templateRegex: /.*com\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
|
684
|
+
new $.fn.oembed.OEmbedProvider("imgur.com", "photo", ["imgur\\.com/gallery/.+"], "http://imgur.com/$1l.jpg",
|
685
|
+
{templateRegex: /.*gallery\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
|
686
|
+
new $.fn.oembed.OEmbedProvider("visual.ly", "rich", ["visual\\.ly/.+"], null,
|
687
|
+
{
|
688
|
+
yql: {
|
689
|
+
xpath: "//a[@id=\\'gc_article_graphic_image\\']/img",
|
690
|
+
from: 'htmlstring'
|
691
|
+
}
|
692
|
+
}),
|
693
|
+
new $.fn.oembed.OEmbedProvider("gravtar", "photo", ["mailto:.+"], null,
|
694
|
+
{
|
695
|
+
templateRegex: /mailto:([^\/]+).*/,
|
696
|
+
template: function (wm, email) {
|
697
|
+
return '<img src="http://gravatar.com/avatar/' + email.md5() + '.jpg" alt="on Gravtar" class="jqoaImg">';
|
698
|
+
}
|
699
|
+
}),
|
700
|
+
new $.fn.oembed.OEmbedProvider("achewood", "photo", ["achewood\\.com\\/index.php\\?date=.+"], "http://www.achewood.com/comic.php?date=$1", {templateRegex: /.*achewood\.com\/index.php\?date=(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
701
|
+
new $.fn.oembed.OEmbedProvider("fotokritik", "photo", ["fotokritik\\.com/.+"], "http://www.fotokritik.com/embed/$1", {templateRegex: [/.*fotokritik\.com\/embed\/(\w+).*/, /.*fotokritik\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
702
|
+
new $.fn.oembed.OEmbedProvider("giflike", "photo", ["giflike\\.com/.+"], "http://www.giflike.com/embed/$1", {templateRegex: [/.*giflike\.com\/embed\/(\w+).*/, /.*giflike\.com\/a\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
703
|
+
|
704
|
+
//Rich
|
705
|
+
new $.fn.oembed.OEmbedProvider("twitter", "rich", ["twitter.com/.+"], "https://api.twitter.com/1/statuses/oembed.json"),
|
706
|
+
new $.fn.oembed.OEmbedProvider("gmep", "rich", ["gmep.imeducate.com/.*", "gmep.org/.*"], "http://gmep.org/oembed.json"),
|
707
|
+
new $.fn.oembed.OEmbedProvider("urtak", "rich", ["urtak.com/(u|clr)/.+"], "http://oembed.urtak.com/1/oembed"),
|
708
|
+
new $.fn.oembed.OEmbedProvider("cacoo", "rich", ["cacoo.com/.+"], "http://cacoo.com/oembed.json"),
|
709
|
+
new $.fn.oembed.OEmbedProvider("dailymile", "rich", ["dailymile.com/people/.*/entries/.*"], "http://api.dailymile.com/oembed"),
|
710
|
+
new $.fn.oembed.OEmbedProvider("dipity", "rich", ["dipity.com/timeline/.+"], 'http://www.dipity.com/oembed/timeline/', {useYQL: 'json'}),
|
711
|
+
new $.fn.oembed.OEmbedProvider("sketchfab", "rich", ["sketchfab.com/show/.+"], 'http://sketchfab.com/oembed', {useYQL: 'json'}),
|
712
|
+
new $.fn.oembed.OEmbedProvider("speakerdeck", "rich", ["speakerdeck.com/.+"], 'http://speakerdeck.com/oembed.json', {useYQL: 'json'}),
|
713
|
+
new $.fn.oembed.OEmbedProvider("popplet", "rich", ["popplet.com/app/.*"], "http://popplet.com/app/Popplet_Alpha.swf?page_id=$1&em=1",
|
714
|
+
{
|
715
|
+
templateRegex: /.*#\/([^\/]+).*/,
|
716
|
+
embedtag: {
|
717
|
+
width: 460,
|
718
|
+
height: 460
|
719
|
+
}
|
720
|
+
}),
|
721
|
+
|
722
|
+
new $.fn.oembed.OEmbedProvider("pearltrees", "rich", ["pearltrees.com/.*"], "http://cdn.pearltrees.com/s/embed/getApp?",
|
723
|
+
{
|
724
|
+
templateRegex: /.*N-f=1_(\d+).*N-p=(\d+).*/,
|
725
|
+
embedtag: {
|
726
|
+
width: 460,
|
727
|
+
height: 460,
|
728
|
+
flashvars: "lang=en_US&embedId=pt-embed-$1-693&treeId=$1&pearlId=$2&treeTitle=Diagrams%2FVisualization&site=www.pearltrees.com%2FF"
|
729
|
+
}
|
730
|
+
}),
|
731
|
+
|
732
|
+
new $.fn.oembed.OEmbedProvider("prezi", "rich", ["prezi.com/.*"], "//prezi.com/bin/preziloader.swf?",
|
733
|
+
{
|
734
|
+
templateRegex: /.*com\/([^\/]+)\/.*/,
|
735
|
+
embedtag: {
|
736
|
+
width: 550,
|
737
|
+
height: 400,
|
738
|
+
flashvars: "prezi_id=$1&lock_to_path=0&color=ffffff&autoplay=no&autohide_ctrls=0"
|
739
|
+
}
|
740
|
+
}),
|
741
|
+
|
742
|
+
new $.fn.oembed.OEmbedProvider("tourwrist", "rich", ["tourwrist.com/tours/.+"], null,
|
743
|
+
{
|
744
|
+
templateRegex: /.*tours.([\d]+).*/,
|
745
|
+
template: function (wm, tourid) {
|
746
|
+
setTimeout(function () {
|
747
|
+
if (loadEmbeds)loadEmbeds();
|
748
|
+
}, 2000);
|
749
|
+
return "<div id='" + tourid + "' class='tourwrist-tour-embed direct'></div> <script type='text/javascript' src='http://tourwrist.com/tour_embed.js'></script>";
|
750
|
+
}
|
751
|
+
}),
|
752
|
+
|
753
|
+
new $.fn.oembed.OEmbedProvider("meetup", "rich", ["meetup\\.(com|ps)/.+"], "http://api.meetup.com/oembed"),
|
754
|
+
new $.fn.oembed.OEmbedProvider("ebay", "rich", ["ebay\\.*"], "http://togo.ebay.com/togo/togo.swf?2008013100",
|
755
|
+
{
|
756
|
+
templateRegex: /.*\/([^\/]+)\/(\d{10,13}).*/,
|
757
|
+
embedtag: {
|
758
|
+
width: 355,
|
759
|
+
height: 300,
|
760
|
+
flashvars: "base=http://togo.ebay.com/togo/&lang=en-us&mode=normal&itemid=$2&query=$1"
|
761
|
+
}
|
762
|
+
}),
|
763
|
+
new $.fn.oembed.OEmbedProvider("wikipedia", "rich", ["wikipedia.org/wiki/.+"], "http://$1.wikipedia.org/w/api.php?action=parse&page=$2&format=json§ion=0&callback=?", {
|
764
|
+
templateRegex: /.*\/\/([\w]+).*\/wiki\/([^\/]+).*/,
|
765
|
+
templateData: function (data) {
|
766
|
+
if (!data.parse)
|
767
|
+
return false;
|
768
|
+
var text = data.parse['text']['*'].replace(/href="\/wiki/g, 'href="http://en.wikipedia.org/wiki');
|
769
|
+
return '<div id="content"><h3><a class="nav-link" href="http://en.wikipedia.org/wiki/' + data.parse['displaytitle'] + '">' + data.parse['displaytitle'] + '</a></h3>' + text + '</div>';
|
830
770
|
}
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
771
|
+
}),
|
772
|
+
new $.fn.oembed.OEmbedProvider("imdb", "rich", ["imdb.com/title/.+"], "http://www.imdbapi.com/?i=$1&callback=?",
|
773
|
+
{
|
774
|
+
templateRegex: /.*\/title\/([^\/]+).*/,
|
775
|
+
templateData: function (data) {
|
776
|
+
if (!data.Title)
|
777
|
+
return false;
|
778
|
+
return '<div id="content"><h3><a class="nav-link" href="http://imdb.com/title/' + data.imdbID + '/">' + data.Title + '</a> (' + data.Year + ')</h3><p>Rating: ' + data.imdbRating + '<br/>Genre: ' + data.Genre + '<br/>Starring: ' + data.Actors + '</p></div> <div id="view-photo-caption">' + data.Plot + '</div></div>';
|
779
|
+
}
|
780
|
+
}),
|
781
|
+
new $.fn.oembed.OEmbedProvider("livejournal", "rich", ["livejournal.com/"], "http://ljpic.seacrow.com/json/$2$4?jsonp=?"
|
782
|
+
, {
|
783
|
+
templateRegex: /(http:\/\/(((?!users).)+)\.livejournal\.com|.*users\.livejournal\.com\/([^\/]+)).*/,
|
784
|
+
templateData: function (data) {
|
785
|
+
if (!data.username)
|
786
|
+
return false;
|
787
|
+
return '<div><img src="' + data.image + '" align="left" style="margin-right: 1em;" /><span class="oembedall-ljuser"><a href="http://' + data.username + '.livejournal.com/profile"><img src="http://www.livejournal.com/img/userinfo.gif" alt="[info]" width="17" height="17" /></a><a href="http://' + data.username + '.livejournal.com/">' + data.username + '</a></span><br />' + data.name + '</div>';
|
788
|
+
}
|
789
|
+
}),
|
790
|
+
new $.fn.oembed.OEmbedProvider("circuitbee", "rich", ["circuitbee\\.com/circuit/view/.+"], "http://c.circuitbee.com/build/r/schematic-embed.html?id=$1",
|
791
|
+
{
|
792
|
+
templateRegex: /.*circuit\/view\/(\d+).*/,
|
793
|
+
embedtag: {
|
794
|
+
tag: 'iframe',
|
795
|
+
width: '500',
|
796
|
+
height: '350'
|
797
|
+
}
|
798
|
+
}),
|
799
|
+
|
800
|
+
new $.fn.oembed.OEmbedProvider("googlecalendar", "rich", ["www.google.com/calendar/embed?.+"], "$1",
|
801
|
+
{templateRegex: /(.*)/, embedtag: {tag: 'iframe', width: '800', height: '600' }}),
|
802
|
+
new $.fn.oembed.OEmbedProvider("jsfiddle", "rich", ["jsfiddle.net/[^/]+/?"], "http://jsfiddle.net/$1/embedded/result,js,resources,html,css/?",
|
803
|
+
{templateRegex: /.*net\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '100%', height: '300' }}),
|
804
|
+
new $.fn.oembed.OEmbedProvider("jsbin", "rich", ["jsbin.com/.+"], "http://jsbin.com/$1/?",
|
805
|
+
{templateRegex: /.*com\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '100%', height: '300' }}),
|
806
|
+
new $.fn.oembed.OEmbedProvider("jotform", "rich", ["form.jotform.co/form/.+"], "$1?",
|
807
|
+
{templateRegex: /(.*)/, embedtag: {tag: 'iframe', width: '100%', height: '507' }}),
|
808
|
+
new $.fn.oembed.OEmbedProvider("reelapp", "rich", ["reelapp\\.com/.+"], "http://www.reelapp.com/$1/embed",
|
809
|
+
{templateRegex: /.*com\/(\S{6}).*/, embedtag: {tag: 'iframe', width: '400', height: '338'}}),
|
810
|
+
new $.fn.oembed.OEmbedProvider("linkedin", "rich", ["linkedin.com/pub/.+"], "https://www.linkedin.com/cws/member/public_profile?public_profile_url=$1&format=inline&isFramed=true",
|
811
|
+
{templateRegex: /(.*)/, embedtag: {tag: 'iframe', width: '368px', height: 'auto'}}),
|
812
|
+
new $.fn.oembed.OEmbedProvider("timetoast", "rich", ["timetoast.com/timelines/[0-9]+"], "http://www.timetoast.com/flash/TimelineViewer.swf?passedTimelines=$1",
|
813
|
+
{templateRegex: /.*timelines\/([0-9]*)/, embedtag: { width: 550, height: 400}, nocache: 1}),
|
814
|
+
new $.fn.oembed.OEmbedProvider("pastebin", "rich", ["pastebin\\.com/[\\S]{8}"], "http://pastebin.com/embed_iframe.php?i=$1",
|
815
|
+
{templateRegex: /.*\/(\S{8}).*/, embedtag: {tag: 'iframe', width: '100%', height: 'auto'}}),
|
816
|
+
new $.fn.oembed.OEmbedProvider("mixlr", "rich", ["mixlr.com/.+"], "http://mixlr.com/embed/$1?autoplay=ae",
|
817
|
+
{templateRegex: /.*com\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '100%', height: 'auto' }}),
|
818
|
+
new $.fn.oembed.OEmbedProvider("pastie", "rich", ["pastie\\.org/pastes/.+"], null, {yql: {xpath: '//pre[@class="textmate-source"]'}}),
|
819
|
+
new $.fn.oembed.OEmbedProvider("github", "rich", ["gist.github.com/.+"], "https://github.com/api/oembed"),
|
820
|
+
new $.fn.oembed.OEmbedProvider("github", "rich", ["github.com/[-.\\w@]+/[-.\\w@]+"], "https://api.github.com/repos/$1/$2?callback=?"
|
821
|
+
, {templateRegex: /.*\/([^\/]+)\/([^\/]+).*/,
|
822
|
+
templateData: function (data) {
|
823
|
+
if (!data.data.html_url)return false;
|
824
|
+
return '<div class="oembedall-githubrepos"><ul class="oembedall-repo-stats"><li>' + data.data.language + '</li><li class="oembedall-watchers"><a title="Watchers" href="' + data.data.html_url + '/watchers">◉ ' + data.data.watchers + '</a></li>'
|
825
|
+
+ '<li class="oembedall-forks"><a title="Forks" href="' + data.data.html_url + '/network">ɥ ' + data.data.forks + '</a></li></ul><h3><a href="' + data.data.html_url + '">' + data.data.name + '</a></h3><div class="oembedall-body"><p class="oembedall-description">' + data.data.description + '</p>'
|
826
|
+
+ '<p class="oembedall-updated-at">Last updated: ' + data.data.pushed_at + '</p></div></div>';
|
827
|
+
}
|
828
|
+
}),
|
829
|
+
new $.fn.oembed.OEmbedProvider("facebook", "rich", ["facebook.com"], null
|
830
|
+
, {templateRegex: /.*\/([^\/]+)\/([^\/]+).*/,
|
831
|
+
template: function (url) {
|
832
|
+
// adding script directly to DOM to make sure that it is loaded correctly.
|
833
|
+
if (!$.fn.oembed.facebokScriptHasBeenAdded) {
|
834
|
+
$('<div id="fb-root"></div>').appendTo('body');
|
835
|
+
var script = document.createElement('script');
|
836
|
+
script.type = 'text/javascript';
|
837
|
+
script.text = '(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";fjs.parentNode.insertBefore(js, fjs);}(document, "script", "facebook-jssdk"));';
|
838
|
+
document.body.appendChild(script);
|
839
|
+
$.fn.oembed.facebokScriptHasBeenAdded = true;
|
840
|
+
}
|
841
|
+
|
842
|
+
// returning template with url of facebook post.
|
843
|
+
return '<div class="fb-post" data-href="' + url + '" data-width="520"><div class="fb-xfbml-parse-ignore"><a href="' + url + '"></div></div>';
|
844
|
+
|
845
|
+
}
|
846
|
+
}),
|
847
|
+
/*
|
848
|
+
// Saving old implementation of Facebook in case we will need it as example in the future.
|
849
|
+
new $.fn.oembed.OEmbedProvider("facebook", "rich", ["facebook.com/(people/[^\\/]+/\\d+|[^\\/]+$)"], "https://graph.facebook.com/$2$3/?callback=?"
|
850
|
+
,{templateRegex:/.*facebook.com\/(people\/[^\/]+\/(\d+).*|([^\/]+$))/,
|
851
|
+
templateData : function(data){ if(!data.id)return false;
|
852
|
+
var out = '<div class="oembedall-facebook1"><div class="oembedall-facebook2"><a href="http://www.facebook.com/">facebook</a> ';
|
853
|
+
if(data.from) out += '<a href="http://www.facebook.com/'+data.from.id+'">'+data.from.name+'</a>';
|
854
|
+
else if(data.link) out += '<a href="'+data.link+'">'+data.name+'</a>';
|
855
|
+
else if(data.username) out += '<a href="http://www.facebook.com/'+data.username+'">'+data.name+'</a>';
|
856
|
+
else out += '<a href="http://www.facebook.com/'+data.id+'">'+data.name+'</a>';
|
857
|
+
out += '</div><div class="oembedall-facebookBody"><div class="contents">';
|
858
|
+
if(data.picture) out += '<a href="'+data.link+'"><img src="'+data.picture+'"></a>';
|
859
|
+
else out += '<img src="https://graph.facebook.com/'+data.id+'/picture">';
|
860
|
+
if(data.from) out += '<a href="'+data.link+'">'+data.name+'</a>';
|
861
|
+
if(data.founded) out += 'Founded: <strong>'+data.founded+'</strong><br>';
|
862
|
+
if(data.category) out += 'Category: <strong>'+data.category+'</strong><br>';
|
863
|
+
if(data.website) out += 'Website: <strong><a href="'+data.website+'">'+data.website+'</a></strong><br>';
|
864
|
+
if(data.gender) out += 'Gender: <strong>'+data.gender+'</strong><br>';
|
865
|
+
if(data.description) out += data.description + '<br>';
|
866
|
+
out += '</div></div>';
|
867
|
+
return out;
|
868
|
+
}
|
869
|
+
}),
|
870
|
+
*/
|
871
|
+
new $.fn.oembed.OEmbedProvider("stackoverflow", "rich", ["stackoverflow.com/questions/[\\d]+"], "http://api.stackoverflow.com/1.1/questions/$1?body=true&jsonp=?"
|
872
|
+
, {templateRegex: /.*questions\/([\d]+).*/,
|
873
|
+
templateData: function (data) {
|
874
|
+
if (!data.questions)
|
875
|
+
return false;
|
876
|
+
var q = data.questions[0];
|
877
|
+
var body = $(q.body).text();
|
878
|
+
var out = '<div class="oembedall-stoqembed"><div class="oembedall-statscontainer"><div class="oembedall-statsarrow"></div><div class="oembedall-stats"><div class="oembedall-vote"><div class="oembedall-votes">'
|
879
|
+
+ '<span class="oembedall-vote-count-post"><strong>' + (q.up_vote_count - q.down_vote_count) + '</strong></span><div class="oembedall-viewcount">vote(s)</div></div>'
|
880
|
+
+ '</div><div class="oembedall-status"><strong>' + q.answer_count + '</strong>answer</div></div><div class="oembedall-views">' + q.view_count + ' view(s)</div></div>'
|
881
|
+
+ '<div class="oembedall-summary"><h3><a class="oembedall-question-hyperlink" href="http://stackoverflow.com/questions/' + q.question_id + '/">' + q.title + '</a></h3>'
|
882
|
+
+ '<div class="oembedall-excerpt">' + body.substring(0, 100) + '...</div><div class="oembedall-tags">';
|
883
|
+
for (i in q.tags) {
|
884
|
+
out += '<a title="" class="oembedall-post-tag" href="http://stackoverflow.com/questions/tagged/' + q.tags[i] + '">' + q.tags[i] + '</a>';
|
885
|
+
}
|
886
|
+
|
887
|
+
out += '</div><div class="oembedall-fr"><div class="oembedall-user-info"><div class="oembedall-user-gravatar32"><a href="http://stackoverflow.com/users/' + q.owner.user_id + '/' + q.owner.display_name + '">'
|
888
|
+
+ '<img width="32" height="32" alt="" src="http://www.gravatar.com/avatar/' + q.owner.email_hash + '?s=32&d=identicon&r=PG"></a></div><div class="oembedall-user-details">'
|
889
|
+
+ '<a href="http://stackoverflow.com/users/' + q.owner.user_id + '/' + q.owner.display_name + '">' + q.owner.display_name + '</a><br><span title="reputation score" class="oembedall-reputation-score">'
|
890
|
+
+ q.owner.reputation + '</span></div></div></div></div></div>';
|
891
|
+
return out;
|
892
|
+
}
|
893
|
+
}),
|
894
|
+
new $.fn.oembed.OEmbedProvider("wordpress", "rich", ["wordpress\\.com/.+", "blogs\\.cnn\\.com/.+", "techcrunch\\.com/.+", "wp\\.me/.+"], "http://public-api.wordpress.com/oembed/1.0/?for=jquery-oembed-all"),
|
895
|
+
new $.fn.oembed.OEmbedProvider("screenr", "rich", ["screenr\.com"], "http://www.screenr.com/embed/$1",
|
896
|
+
{templateRegex: /.*\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '650', height: 396}}) ,
|
897
|
+
new $.fn.oembed.OEmbedProvider("gigpans", "rich", ["gigapan\\.org/[-.\\w@]+/\\d+"], "http://gigapan.org/gigapans/$1/options/nosnapshots/iframe/flash.html",
|
898
|
+
{templateRegex: /.*\/(\d+)\/?.*/, embedtag: {tag: 'iframe', width: '100%', height: 400 }}),
|
899
|
+
new $.fn.oembed.OEmbedProvider("scribd", "rich", ["scribd\\.com/.+"], "http://www.scribd.com/embeds/$1/content?start_page=1&view_mode=list",
|
900
|
+
{templateRegex: /.*doc\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '100%', height: 600}}),
|
901
|
+
new $.fn.oembed.OEmbedProvider("kickstarter", "rich", ["kickstarter\\.com/projects/.+"], "$1/widget/card.html",
|
902
|
+
{templateRegex: /([^\?]+).*/, embedtag: {tag: 'iframe', width: '220', height: 380}}),
|
903
|
+
new $.fn.oembed.OEmbedProvider("amazon", "rich", ["amzn.com/B+", "amazon.com.*/(B\\S+)($|\\/.*)"], "http://rcm.amazon.com/e/cm?t=_APIKEY_&o=1&p=8&l=as1&asins=$1&ref=qf_br_asin_til&fc1=000000&IS2=1<1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr",
|
904
|
+
{
|
905
|
+
apikey: true,
|
906
|
+
templateRegex: /.*\/(B[0-9A-Z]+)($|\/.*)/,
|
907
|
+
embedtag: {
|
908
|
+
tag: 'iframe',
|
909
|
+
width: '120px',
|
910
|
+
height: '240px'}
|
911
|
+
}),
|
912
|
+
new $.fn.oembed.OEmbedProvider("slideshare", "rich", ["slideshare\.net"], "//www.slideshare.net/api/oembed/2", {format: 'jsonp'}),
|
913
|
+
new $.fn.oembed.OEmbedProvider("roomsharejp", "rich", ["roomshare\\.jp/(en/)?post/.*"], "http://roomshare.jp/oembed.json"),
|
914
|
+
new $.fn.oembed.OEmbedProvider("lanyard", "rich", ["lanyrd.com/\\d+/.+"], null,
|
915
|
+
{
|
916
|
+
yql: {
|
917
|
+
xpath: '(//div[@class="primary"])[1]',
|
918
|
+
from: 'htmlstring',
|
919
|
+
datareturn: function (results) {
|
920
|
+
if (!results.result)
|
921
|
+
return false;
|
922
|
+
return '<div class="oembedall-lanyard">' + results.result + '</div>';
|
923
|
+
}
|
924
|
+
}
|
925
|
+
}),
|
926
|
+
new $.fn.oembed.OEmbedProvider("asciiartfarts", "rich", ["asciiartfarts.com/\\d+.html"], null,
|
927
|
+
{
|
928
|
+
yql: {
|
929
|
+
xpath: '//pre/font',
|
930
|
+
from: 'htmlstring',
|
931
|
+
datareturn: function (results) {
|
932
|
+
if (!results.result)
|
933
|
+
return false;
|
934
|
+
return '<pre style="background-color:#000;">' + results.result + '</div>';
|
935
|
+
}
|
936
|
+
}
|
937
|
+
}),
|
938
|
+
new $.fn.oembed.OEmbedProvider("coveritlive", "rich", ["coveritlive.com/"], null, {
|
939
|
+
templateRegex: /(.*)/,
|
940
|
+
template: '<iframe src="$1" allowtransparency="true" scrolling="no" width="615px" frameborder="0" height="625px"></iframe>'}),
|
941
|
+
new $.fn.oembed.OEmbedProvider("polldaddy", "rich", ["polldaddy.com/"], null, {
|
942
|
+
templateRegex: /(?:https?:\/\/w?w?w?.?polldaddy.com\/poll\/)([0-9]*)\//,
|
943
|
+
template: '<script async type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/$1.js"></script>',
|
944
|
+
nocache: 1
|
945
|
+
}),
|
946
|
+
new $.fn.oembed.OEmbedProvider("360io", "rich", ["360\\.io/.+"], "http://360.io/$1", {templateRegex: /.*360\.io\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
947
|
+
new $.fn.oembed.OEmbedProvider("bubbli", "rich", ["on\\.bubb\\.li/.+"], "http://on.bubb.li/$1", {templateRegex: /.*on\.bubb\.li\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360}, nocache: 1 }),
|
948
|
+
new $.fn.oembed.OEmbedProvider("cloudup", "rich", ["cloudup\\.com/.+"], "http://cloudup.com/$1?chromeless", {templateRegex: [/.*cloudup\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }}),
|
949
|
+
new $.fn.oembed.OEmbedProvider("codepen", "rich", ["codepen.io/.+"], "http://codepen.io/$1/embed/$2", {templateRegex: [/.*io\/(\w+)\/pen\/(\w+).*/, /.*io\/(\w+)\/full\/(\w+).*/], embedtag: {tag: 'iframe', width: '100%', height: '300'}, nocache: 1 }),
|
950
|
+
new $.fn.oembed.OEmbedProvider("googleviews", "rich", ["(.*maps\\.google\\.com\\/maps\\?).+(output=svembed).+(cbp=(.*)).*"], "https://maps.google.com/maps?layer=c&panoid=$3&ie=UTF8&source=embed&output=svembed&cbp=$5", {templateRegex: /(.*maps\.google\.com\/maps\?).+(panoid=(\w+)&).*(cbp=(.*)).*/, embedtag: {tag: 'iframe', width: 480, height: 360}, nocache: 1 }),
|
951
|
+
new $.fn.oembed.OEmbedProvider("googlemaps", "rich", ["google\\.com\/maps\/place/.+"], "http://maps.google.com/maps?t=m&q=$1&output=embed", {templateRegex: /.*google\.com\/maps\/place\/([\w\+]*)\/.*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
952
|
+
new $.fn.oembed.OEmbedProvider("imajize", "rich", ["embed\\.imajize\\.com/.+"], "http://embed.imajize.com/$1", {templateRegex: /.*embed\.imajize\.com\/(.*)/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
953
|
+
new $.fn.oembed.OEmbedProvider("mapjam", "rich", ["mapjam\\.com/.+"], "http://www.mapjam.com/$1", {templateRegex: /.*mapjam\.com\/(.*)/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
954
|
+
new $.fn.oembed.OEmbedProvider("polar", "rich", ["polarb\\.com/.+"], "http://assets-polarb-com.a.ssl.fastly.net/api/v4/publishers/unknown/embedded_polls/iframe?poll_id=$1", {templateRegex: /.*polarb\.com\/polls\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
955
|
+
new $.fn.oembed.OEmbedProvider("ponga", "rich", ["ponga\\.com/.+"], "https://www.ponga.com/embedded?id=$1", {templateRegex: [/.*ponga\.com\/embedded\?id=(\w+).*/, /.*ponga\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
|
956
|
+
|
957
|
+
//Use Open Graph Where applicable
|
958
|
+
new $.fn.oembed.OEmbedProvider("opengraph", "rich", [".*"], null,
|
959
|
+
{
|
960
|
+
yql: {
|
961
|
+
xpath: "//meta|//title|//link",
|
962
|
+
from: 'html',
|
963
|
+
datareturn: function (results) {
|
964
|
+
if (!results['og:title'] && results['title'] && results['description'])
|
965
|
+
results['og:title'] = results['title'];
|
966
|
+
|
967
|
+
if (!results['og:title'] && !results['title'])
|
968
|
+
return false;
|
969
|
+
|
970
|
+
var code = $('<p/>');
|
971
|
+
if (results['og:video']) {
|
972
|
+
var embed = $('<embed src="' + results['og:video'] + '"/>');
|
973
|
+
embed.attr('type', results['og:video:type'] || "application/x-shockwave-flash")
|
974
|
+
.css('max-height', settings.maxHeight || 'auto')
|
975
|
+
.css('max-width', settings.maxWidth || 'auto');
|
976
|
+
if (results['og:video:width'])
|
977
|
+
embed.attr('width', results['og:video:width']);
|
978
|
+
if (results['og:video:height'])
|
979
|
+
embed.attr('height', results['og:video:height']);
|
980
|
+
code.append(embed);
|
981
|
+
} else if (results['og:image']) {
|
982
|
+
var img = $('<img src="' + results['og:image'] + '">');
|
983
|
+
img.css('max-height', settings.maxHeight || 'auto').css('max-width', settings.maxWidth || 'auto');
|
984
|
+
if (results['og:image:width'])
|
985
|
+
img.attr('width', results['og:image:width']);
|
986
|
+
if (results['og:image:height'])
|
987
|
+
img.attr('height', results['og:image:height']);
|
988
|
+
code.append(img);
|
989
|
+
}
|
990
|
+
|
991
|
+
if (results['og:title'])
|
992
|
+
code.append('<b>' + results['og:title'] + '</b><br/>');
|
993
|
+
|
994
|
+
if (results['og:description'])
|
995
|
+
code.append(results['og:description'] + '<br/>');
|
996
|
+
else if (results['description'])
|
997
|
+
code.append(results['description'] + '<br/>');
|
998
|
+
|
999
|
+
return code;
|
1000
|
+
}
|
1001
|
+
}
|
1002
|
+
}
|
1003
|
+
)
|
840
1004
|
|
841
1005
|
];
|
842
1006
|
})(jQuery);
|
843
|
-
|
844
1007
|
//This is needed for gravatar :(
|
845
|
-
String.prototype.md5=function(){var a=function(a,b){var c=(a&65535)+(b&65535);var d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535};var b=function(a,b){return a<<b|a>>>32-b};var c=function(c,d,e,f,g,h){return a(b(a(a(d,c),a(f,h)),g),e)};var d=function(a,b,d,e,f,g,h){return c(b&d|~b&e,a,b,f,g,h)};var e=function(a,b,d,e,f,g,h){return c(b&e|d&~e,a,b,f,g,h)};var f=function(a,b,d,e,f,g,h){return c(b^d^e,a,b,f,g,h)};var g=function(a,b,d,e,f,g,h){return c(d^(b|~e),a,b,f,g,h)};var h=function(b){var c,h,i,j,k,l=b.length;var m=1732584193;var n=-271733879;var o=-1732584194;var p=271733878;for(k=0;k<l;k+=16){c=m;h=n;i=o;j=p;m=d(m,n,o,p,b[k+0],7,-680876936);p=d(p,m,n,o,b[k+1],12,-389564586);o=d(o,p,m,n,b[k+2],17,606105819);n=d(n,o,p,m,b[k+3],22,-1044525330);m=d(m,n,o,p,b[k+4],7,-176418897);p=d(p,m,n,o,b[k+5],12,1200080426);o=d(o,p,m,n,b[k+6],17,-1473231341);n=d(n,o,p,m,b[k+7],22,-45705983);m=d(m,n,o,p,b[k+8],7,1770035416);p=d(p,m,n,o,b[k+9],12,-1958414417);o=d(o,p,m,n,b[k+10],17,-42063);n=d(n,o,p,m,b[k+11],22,-1990404162);m=d(m,n,o,p,b[k+12],7,1804603682);p=d(p,m,n,o,b[k+13],12,-40341101);o=d(o,p,m,n,b[k+14],17,-1502002290);n=d(n,o,p,m,b[k+15],22,1236535329);m=e(m,n,o,p,b[k+1],5,-165796510);p=e(p,m,n,o,b[k+6],9,-1069501632);o=e(o,p,m,n,b[k+11],14,643717713);n=e(n,o,p,m,b[k+0],20,-373897302);m=e(m,n,o,p,b[k+5],5,-701558691);p=e(p,m,n,o,b[k+10],9,38016083);o=e(o,p,m,n,b[k+15],14,-660478335);n=e(n,o,p,m,b[k+4],20,-405537848);m=e(m,n,o,p,b[k+9],5,568446438);p=e(p,m,n,o,b[k+14],9,-1019803690);o=e(o,p,m,n,b[k+3],14,-187363961);n=e(n,o,p,m,b[k+8],20,1163531501);m=e(m,n,o,p,b[k+13],5,-1444681467);p=e(p,m,n,o,b[k+2],9,-51403784);o=e(o,p,m,n,b[k+7],14,1735328473);n=e(n,o,p,m,b[k+12],20,-1926607734);m=f(m,n,o,p,b[k+5],4,-378558);p=f(p,m,n,o,b[k+8],11,-2022574463);o=f(o,p,m,n,b[k+11],16,1839030562);n=f(n,o,p,m,b[k+14],23,-35309556);m=f(m,n,o,p,b[k+1],4,-1530992060);p=f(p,m,n,o,b[k+4],11,1272893353);o=f(o,p,m,n,b[k+7],16,-155497632);n=f(n,o,p,m,b[k+10],23,-1094730640);m=f(m,n,o,p,b[k+13],4,681279174);p=f(p,m,n,o,b[k+0],11,-358537222);o=f(o,p,m,n,b[k+3],16,-722521979);n=f(n,o,p,m,b[k+6],23,76029189);m=f(m,n,o,p,b[k+9],4,-640364487);p=f(p,m,n,o,b[k+12],11,-421815835);o=f(o,p,m,n,b[k+15],16,530742520);n=f(n,o,p,m,b[k+2],23,-995338651);m=g(m,n,o,p,b[k+0],6,-198630844);p=g(p,m,n,o,b[k+7],10,1126891415);o=g(o,p,m,n,b[k+14],15,-1416354905);n=g(n,o,p,m,b[k+5],21,-57434055);m=g(m,n,o,p,b[k+12],6,1700485571);p=g(p,m,n,o,b[k+3],10,-1894986606);o=g(o,p,m,n,b[k+10],15,-1051523);n=g(n,o,p,m,b[k+1],21,-2054922799);m=g(m,n,o,p,b[k+8],6,1873313359);p=g(p,m,n,o,b[k+15],10,-30611744);o=g(o,p,m,n,b[k+6],15,-1560198380);n=g(n,o,p,m,b[k+13],21,1309151649);m=g(m,n,o,p,b[k+4],6,-145523070);p=g(p,m,n,o,b[k+11],10,-1120210379);o=g(o,p,m,n,b[k+2],15,718787259);n=g(n,o,p,m,b[k+9],21,-343485551);m=a(m,c);n=a(n,h);o=a(o,i);p=a(p,j)}return[m,n,o,p]};var i=function(a){var b="0123456789abcdef",c="",d,e=a.length*4;for(d=0;d<e;d++){c+=b.charAt(a[d>>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15)}return c};var j=function(a){var b=(a.length+8>>6)+1;var c=[],d,e=b*16,f,g=a.length;for(d=0;d<e;d++){c.push(0)}for(f=0;f<g;f++){c[f>>2]|=(a.charCodeAt(f)&255)<<f%4*8}c[f>>2]|=128<<f%4*8;c[b*16-2]=g*8;return c};return i(h(j(this)))}
|
1008
|
+
String.prototype.md5=function(){var a=function(a,b){var c=(a&65535)+(b&65535);var d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535};var b=function(a,b){return a<<b|a>>>32-b};var c=function(c,d,e,f,g,h){return a(b(a(a(d,c),a(f,h)),g),e)};var d=function(a,b,d,e,f,g,h){return c(b&d|~b&e,a,b,f,g,h)};var e=function(a,b,d,e,f,g,h){return c(b&e|d&~e,a,b,f,g,h)};var f=function(a,b,d,e,f,g,h){return c(b^d^e,a,b,f,g,h)};var g=function(a,b,d,e,f,g,h){return c(d^(b|~e),a,b,f,g,h)};var h=function(b){var c,h,i,j,k,l=b.length;var m=1732584193;var n=-271733879;var o=-1732584194;var p=271733878;for(k=0;k<l;k+=16){c=m;h=n;i=o;j=p;m=d(m,n,o,p,b[k+0],7,-680876936);p=d(p,m,n,o,b[k+1],12,-389564586);o=d(o,p,m,n,b[k+2],17,606105819);n=d(n,o,p,m,b[k+3],22,-1044525330);m=d(m,n,o,p,b[k+4],7,-176418897);p=d(p,m,n,o,b[k+5],12,1200080426);o=d(o,p,m,n,b[k+6],17,-1473231341);n=d(n,o,p,m,b[k+7],22,-45705983);m=d(m,n,o,p,b[k+8],7,1770035416);p=d(p,m,n,o,b[k+9],12,-1958414417);o=d(o,p,m,n,b[k+10],17,-42063);n=d(n,o,p,m,b[k+11],22,-1990404162);m=d(m,n,o,p,b[k+12],7,1804603682);p=d(p,m,n,o,b[k+13],12,-40341101);o=d(o,p,m,n,b[k+14],17,-1502002290);n=d(n,o,p,m,b[k+15],22,1236535329);m=e(m,n,o,p,b[k+1],5,-165796510);p=e(p,m,n,o,b[k+6],9,-1069501632);o=e(o,p,m,n,b[k+11],14,643717713);n=e(n,o,p,m,b[k+0],20,-373897302);m=e(m,n,o,p,b[k+5],5,-701558691);p=e(p,m,n,o,b[k+10],9,38016083);o=e(o,p,m,n,b[k+15],14,-660478335);n=e(n,o,p,m,b[k+4],20,-405537848);m=e(m,n,o,p,b[k+9],5,568446438);p=e(p,m,n,o,b[k+14],9,-1019803690);o=e(o,p,m,n,b[k+3],14,-187363961);n=e(n,o,p,m,b[k+8],20,1163531501);m=e(m,n,o,p,b[k+13],5,-1444681467);p=e(p,m,n,o,b[k+2],9,-51403784);o=e(o,p,m,n,b[k+7],14,1735328473);n=e(n,o,p,m,b[k+12],20,-1926607734);m=f(m,n,o,p,b[k+5],4,-378558);p=f(p,m,n,o,b[k+8],11,-2022574463);o=f(o,p,m,n,b[k+11],16,1839030562);n=f(n,o,p,m,b[k+14],23,-35309556);m=f(m,n,o,p,b[k+1],4,-1530992060);p=f(p,m,n,o,b[k+4],11,1272893353);o=f(o,p,m,n,b[k+7],16,-155497632);n=f(n,o,p,m,b[k+10],23,-1094730640);m=f(m,n,o,p,b[k+13],4,681279174);p=f(p,m,n,o,b[k+0],11,-358537222);o=f(o,p,m,n,b[k+3],16,-722521979);n=f(n,o,p,m,b[k+6],23,76029189);m=f(m,n,o,p,b[k+9],4,-640364487);p=f(p,m,n,o,b[k+12],11,-421815835);o=f(o,p,m,n,b[k+15],16,530742520);n=f(n,o,p,m,b[k+2],23,-995338651);m=g(m,n,o,p,b[k+0],6,-198630844);p=g(p,m,n,o,b[k+7],10,1126891415);o=g(o,p,m,n,b[k+14],15,-1416354905);n=g(n,o,p,m,b[k+5],21,-57434055);m=g(m,n,o,p,b[k+12],6,1700485571);p=g(p,m,n,o,b[k+3],10,-1894986606);o=g(o,p,m,n,b[k+10],15,-1051523);n=g(n,o,p,m,b[k+1],21,-2054922799);m=g(m,n,o,p,b[k+8],6,1873313359);p=g(p,m,n,o,b[k+15],10,-30611744);o=g(o,p,m,n,b[k+6],15,-1560198380);n=g(n,o,p,m,b[k+13],21,1309151649);m=g(m,n,o,p,b[k+4],6,-145523070);p=g(p,m,n,o,b[k+11],10,-1120210379);o=g(o,p,m,n,b[k+2],15,718787259);n=g(n,o,p,m,b[k+9],21,-343485551);m=a(m,c);n=a(n,h);o=a(o,i);p=a(p,j)}return[m,n,o,p]};var i=function(a){var b="0123456789abcdef",c="",d,e=a.length*4;for(d=0;d<e;d++){c+=b.charAt(a[d>>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15)}return c};var j=function(a){var b=(a.length+8>>6)+1;var c=[],d,e=b*16,f,g=a.length;for(d=0;d<e;d++){c.push(0)}for(f=0;f<g;f++){c[f>>2]|=(a.charCodeAt(f)&255)<<f%4*8}c[f>>2]|=128<<f%4*8;c[b*16-2]=g*8;return c};return i(h(j(this)))};
|