jquery-oembed-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +54 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/jquery.oembed.js +845 -0
- data/app/assets/stylesheets/jquery.oembed.css +422 -0
- data/jquery-oembed-rails.gemspec +25 -0
- data/lib/jquery/oembed/rails/version.rb +7 -0
- data/lib/jquery/oembed/rails.rb +10 -0
- metadata +96 -0
@@ -0,0 +1,845 @@
|
|
1
|
+
/*!
|
2
|
+
* jquery oembed plugin
|
3
|
+
*
|
4
|
+
* Copyright (c) 2009 Richard Chamorro
|
5
|
+
* Licensed under the MIT license
|
6
|
+
*
|
7
|
+
* Orignal Author: Richard Chamorro
|
8
|
+
* Forked by Andrew Mee to Provide a slightly diffent kind of embedding
|
9
|
+
* experience
|
10
|
+
*/
|
11
|
+
(function($) {
|
12
|
+
$.fn.oembed = function(url, options, embedAction) {
|
13
|
+
|
14
|
+
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
|
+
"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",
|
17
|
+
"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",
|
18
|
+
"clickthru.ca", "clop.in", "conta.cc", "cort.as", "cot.ag", "crks.me", "ctvr.us", "cutt.us", "dai.ly", "decenturl.com", "dfl8.me", "digbig.com",
|
19
|
+
"http:\/\/digg\.com\/[^\/]+$", "disq.us", "dld.bz", "dlvr.it", "do.my", "doiop.com", "dopen.us", "easyuri.com", "easyurl.net", "eepurl.com", "eweri.com",
|
20
|
+
"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",
|
21
|
+
"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",
|
22
|
+
"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",
|
23
|
+
"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",
|
24
|
+
"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",
|
25
|
+
"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",
|
26
|
+
"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",
|
27
|
+
"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",
|
28
|
+
"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",
|
29
|
+
"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",
|
30
|
+
"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",
|
31
|
+
"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",
|
32
|
+
"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",
|
33
|
+
"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",
|
34
|
+
"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",
|
35
|
+
"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",
|
36
|
+
"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",
|
37
|
+
"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",
|
38
|
+
"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
|
+
|
40
|
+
if ($('#jqoembeddata').length === 0) $('<span id="jqoembeddata"></span>').appendTo('body');
|
41
|
+
|
42
|
+
return this.each(function() {
|
43
|
+
|
44
|
+
var container = $(this),
|
45
|
+
resourceURL = (url && (!url.indexOf('http://') || !url.indexOf('https://'))) ? url : container.attr("href"),
|
46
|
+
provider;
|
47
|
+
|
48
|
+
if (embedAction) {
|
49
|
+
settings.onEmbed = embedAction;
|
50
|
+
}
|
51
|
+
else if (!settings.onEmbed){
|
52
|
+
settings.onEmbed = function(oembedData) {
|
53
|
+
$.fn.oembed.insertCode(this, settings.embedMethod, oembedData);
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
if (resourceURL !== null && resourceURL !== undefined) {
|
58
|
+
//Check if shorten URL
|
59
|
+
for (var j = 0, l =shortURLList.length; j < l; j++) {
|
60
|
+
var regExp = new RegExp('://'+shortURLList[j]+'/', "i");
|
61
|
+
if (resourceURL.match(regExp) !== null) {
|
62
|
+
//AJAX to http://api.longurl.org/v2/expand?url=http://bit.ly/JATvIs&format=json&callback=hhh
|
63
|
+
var ajaxopts = $.extend({
|
64
|
+
url: "http://api.longurl.org/v2/expand",
|
65
|
+
dataType: 'jsonp',
|
66
|
+
data: {
|
67
|
+
url: resourceURL,
|
68
|
+
format: "json"
|
69
|
+
//callback: "?"
|
70
|
+
},
|
71
|
+
success: function(data) {
|
72
|
+
//this = $.fn.oembed;
|
73
|
+
resourceURL = data['long-url'];
|
74
|
+
provider = $.fn.oembed.getOEmbedProvider(data['long-url']);
|
75
|
+
|
76
|
+
if (provider !== null) {
|
77
|
+
provider.params = getNormalizedParams(settings[provider.name]) || {};
|
78
|
+
provider.maxWidth = settings.maxWidth;
|
79
|
+
provider.maxHeight = settings.maxHeight;
|
80
|
+
embedCode(container, resourceURL, provider);
|
81
|
+
} else {
|
82
|
+
settings.onProviderNotFound.call(container, resourceURL);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}, settings.ajaxOptions || {});
|
86
|
+
|
87
|
+
$.ajax(ajaxopts);
|
88
|
+
|
89
|
+
return container;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
provider = $.fn.oembed.getOEmbedProvider(resourceURL);
|
93
|
+
|
94
|
+
if (provider !== null) {
|
95
|
+
provider.params = getNormalizedParams(settings[provider.name]) || {};
|
96
|
+
provider.maxWidth = settings.maxWidth;
|
97
|
+
provider.maxHeight = settings.maxHeight;
|
98
|
+
embedCode(container, resourceURL, provider);
|
99
|
+
} else {
|
100
|
+
settings.onProviderNotFound.call(container, resourceURL);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
return container;
|
105
|
+
});
|
106
|
+
|
107
|
+
|
108
|
+
};
|
109
|
+
|
110
|
+
var settings;
|
111
|
+
|
112
|
+
// Plugin defaults
|
113
|
+
$.fn.oembed.defaults = {
|
114
|
+
maxWidth: null,
|
115
|
+
maxHeight: null,
|
116
|
+
includeHandle: true,
|
117
|
+
embedMethod: 'auto',
|
118
|
+
// "auto", "append", "fill"
|
119
|
+
onProviderNotFound: function() {},
|
120
|
+
beforeEmbed: function() {},
|
121
|
+
afterEmbed: function() {},
|
122
|
+
onEmbed: false,
|
123
|
+
onError: function() {},
|
124
|
+
ajaxOptions: {}
|
125
|
+
};
|
126
|
+
|
127
|
+
/* Private functions */
|
128
|
+
function rand(length,current){ //Found on http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
|
129
|
+
current = current ? current : '';
|
130
|
+
return length ? rand( --length , "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt( Math.floor( Math.random() * 60 ) ) + current ) : current;
|
131
|
+
}
|
132
|
+
|
133
|
+
function getRequestUrl(provider, externalUrl) {
|
134
|
+
var url = provider.apiendpoint,
|
135
|
+
qs = "",
|
136
|
+
i;
|
137
|
+
url += (url.indexOf("?") <= 0) ? "?" : "&";
|
138
|
+
url = url.replace('#','%23');
|
139
|
+
|
140
|
+
if (provider.maxWidth !== null && (typeof provider.params.maxwidth === 'undefined' || provider.params.maxwidth === null)) {
|
141
|
+
provider.params.maxwidth = provider.maxWidth;
|
142
|
+
}
|
143
|
+
|
144
|
+
if (provider.maxHeight !== null && (typeof provider.params.maxheight === 'undefined' || provider.params.maxheight === null)) {
|
145
|
+
provider.params.maxheight = provider.maxHeight;
|
146
|
+
}
|
147
|
+
|
148
|
+
for (i in provider.params) {
|
149
|
+
// We don't want them to jack everything up by changing the callback parameter
|
150
|
+
if (i == provider.callbackparameter) continue;
|
151
|
+
|
152
|
+
// allows the options to be set to null, don't send null values to the server as parameters
|
153
|
+
if (provider.params[i] !== null) qs += "&" + escape(i) + "=" + provider.params[i];
|
154
|
+
}
|
155
|
+
|
156
|
+
url += "format=" + provider.format + "&url=" + escape(externalUrl) + qs;
|
157
|
+
if(provider.dataType!='json') url += "&" + provider.callbackparameter + "=?";
|
158
|
+
|
159
|
+
return url;
|
160
|
+
}
|
161
|
+
function success(oembedData, externalUrl, container) {
|
162
|
+
$('#jqoembeddata').data(externalUrl, oembedData.code);
|
163
|
+
settings.beforeEmbed.call(container, oembedData);
|
164
|
+
settings.onEmbed.call(container, oembedData);
|
165
|
+
settings.afterEmbed.call(container, oembedData);
|
166
|
+
}
|
167
|
+
|
168
|
+
function embedCode(container, externalUrl, embedProvider) {
|
169
|
+
if ($('#jqoembeddata').data(externalUrl)!=undefined && embedProvider.embedtag.tag!='iframe'){
|
170
|
+
var oembedData = {code: $('#jqoembeddata').data(externalUrl)};
|
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;
|
226
|
+
success(oembedData, externalUrl, container);
|
227
|
+
},
|
228
|
+
error: settings.onError.call(container, externalUrl, embedProvider)
|
229
|
+
}, settings.ajaxOptions || {});
|
230
|
+
|
231
|
+
$.ajax(ajaxopts);
|
232
|
+
}else if (embedProvider.templateRegex) {
|
233
|
+
if(embedProvider.embedtag.tag!==''){
|
234
|
+
var flashvars = embedProvider.embedtag.flashvars || '';
|
235
|
+
var tag = embedProvider.embedtag.tag || 'embed';
|
236
|
+
var width = embedProvider.embedtag.width || 'auto';
|
237
|
+
var nocache = embedProvider.embedtag.nocache || 0;
|
238
|
+
var height = embedProvider.embedtag.height || 'auto';
|
239
|
+
var src =externalUrl.replace(embedProvider.templateRegex,embedProvider.apiendpoint);
|
240
|
+
if(!embedProvider.nocache) src += '&jqoemcache='+rand(5);
|
241
|
+
if (embedProvider.apikey) src = src.replace('_APIKEY_', settings.apikeys[embedProvider.name]);
|
242
|
+
|
243
|
+
|
244
|
+
var code = $('<'+tag+'/>')
|
245
|
+
.attr('src',src)
|
246
|
+
.attr('width',width)
|
247
|
+
.attr('height',height)
|
248
|
+
.attr('allowfullscreen',embedProvider.embedtag.allowfullscreen || 'true')
|
249
|
+
.attr('allowscriptaccess',embedProvider.embedtag.allowfullscreen || 'always')
|
250
|
+
.css('max-height', settings.maxHeight || 'auto' )
|
251
|
+
.css('max-width', settings.maxWidth || 'auto' );
|
252
|
+
if(tag=='embed')
|
253
|
+
code
|
254
|
+
.attr('type',embedProvider.embedtag.type || "application/x-shockwave-flash")
|
255
|
+
.attr('flashvars',externalUrl.replace(embedProvider.templateRegex,flashvars));
|
256
|
+
if(tag=='iframe')
|
257
|
+
code
|
258
|
+
.attr('scrolling',embedProvider.embedtag.scrolling || "no")
|
259
|
+
.attr('frameborder',embedProvider.embedtag.frameborder || "0");
|
260
|
+
|
261
|
+
|
262
|
+
var oembedData = {code: code};
|
263
|
+
success(oembedData, externalUrl,container);
|
264
|
+
}else if (embedProvider.apiendpoint) {
|
265
|
+
//Add APIkey if true
|
266
|
+
if (embedProvider.apikey) embedProvider.apiendpoint = embedProvider.apiendpoint.replace('_APIKEY_', settings.apikeys[embedProvider.name]);
|
267
|
+
ajaxopts = $.extend({
|
268
|
+
url: externalUrl.replace(embedProvider.templateRegex, embedProvider.apiendpoint),
|
269
|
+
dataType: 'jsonp',
|
270
|
+
success: function(data) {
|
271
|
+
var oembedData = $.extend({}, data);
|
272
|
+
oembedData.code = embedProvider.templateData(data);
|
273
|
+
success(oembedData, externalUrl, container);
|
274
|
+
},
|
275
|
+
error: settings.onError.call(container, externalUrl, embedProvider)
|
276
|
+
}, settings.ajaxOptions || {});
|
277
|
+
|
278
|
+
$.ajax( ajaxopts );
|
279
|
+
}else {
|
280
|
+
var oembedData = {code: externalUrl.replace(embedProvider.templateRegex,embedProvider.template)};
|
281
|
+
success(oembedData, externalUrl,container);
|
282
|
+
}
|
283
|
+
} else {
|
284
|
+
|
285
|
+
var requestUrl = getRequestUrl(embedProvider, externalUrl),
|
286
|
+
ajaxopts = $.extend({
|
287
|
+
url: requestUrl,
|
288
|
+
dataType: embedProvider.dataType || 'jsonp',
|
289
|
+
success: function(data) {
|
290
|
+
var oembedData = $.extend({}, data);
|
291
|
+
switch (oembedData.type) {
|
292
|
+
case "file": //Deviant Art has this
|
293
|
+
case "photo":
|
294
|
+
oembedData.code = $.fn.oembed.getPhotoCode(externalUrl, oembedData);
|
295
|
+
break;
|
296
|
+
case "video":
|
297
|
+
case "rich":
|
298
|
+
oembedData.code = $.fn.oembed.getRichCode(externalUrl, oembedData);
|
299
|
+
break;
|
300
|
+
default:
|
301
|
+
oembedData.code = $.fn.oembed.getGenericCode(externalUrl, oembedData);
|
302
|
+
break;
|
303
|
+
}
|
304
|
+
success(oembedData, externalUrl, container);
|
305
|
+
},
|
306
|
+
error: settings.onError.call(container, externalUrl, embedProvider)
|
307
|
+
}, settings.ajaxOptions || {});
|
308
|
+
|
309
|
+
$.ajax(ajaxopts);
|
310
|
+
}
|
311
|
+
};
|
312
|
+
|
313
|
+
function getNormalizedParams(params) {
|
314
|
+
if (params === null) return null;
|
315
|
+
var key, normalizedParams = {};
|
316
|
+
for (key in params) {
|
317
|
+
if (key !== null) normalizedParams[key.toLowerCase()] = params[key];
|
318
|
+
}
|
319
|
+
return normalizedParams;
|
320
|
+
}
|
321
|
+
|
322
|
+
/* Public functions */
|
323
|
+
$.fn.oembed.insertCode = function(container, embedMethod, oembedData) {
|
324
|
+
if (oembedData === null) return;
|
325
|
+
if(embedMethod=='auto' && container.attr("href") !== null) embedMethod='append';
|
326
|
+
else if(embedMethod=='auto') embedMethod='replace';
|
327
|
+
switch (embedMethod) {
|
328
|
+
case "replace":
|
329
|
+
container.replaceWith(oembedData.code);
|
330
|
+
break;
|
331
|
+
case "fill":
|
332
|
+
container.html(oembedData.code);
|
333
|
+
break;
|
334
|
+
case "append":
|
335
|
+
container.wrap('<div class="oembedall-container"></div>');
|
336
|
+
var oembedContainer = container.parent();
|
337
|
+
if (settings.includeHandle) {
|
338
|
+
$('<span class="oembedall-closehide">↓</span>').insertBefore(container).click(function() {
|
339
|
+
var encodedString = encodeURIComponent($(this).text());
|
340
|
+
$(this).html((encodedString == '%E2%86%91') ? '↓' : '↑');
|
341
|
+
$(this).parent().children().last().toggle();
|
342
|
+
});
|
343
|
+
}
|
344
|
+
oembedContainer.append('<br/>');
|
345
|
+
try {
|
346
|
+
oembedData.code.clone().appendTo(oembedContainer);
|
347
|
+
} catch(e) {
|
348
|
+
oembedContainer.append(oembedData.code);
|
349
|
+
}
|
350
|
+
/* Make videos semi-responsive
|
351
|
+
* If parent div width less than embeded iframe video then iframe gets shrunk to fit smaller width
|
352
|
+
* If parent div width greater thans embed iframe use the max widht
|
353
|
+
* - works on youtubes and vimeo
|
354
|
+
*/
|
355
|
+
if(settings.maxWidth){
|
356
|
+
var post_width = oembedContainer.parent().width();
|
357
|
+
if(post_width < settings.maxWidth)
|
358
|
+
{
|
359
|
+
var iframe_width_orig = $('iframe',oembedContainer).width();
|
360
|
+
var iframe_height_orig = $('iframe',oembedContainer).height();
|
361
|
+
var ratio = iframe_width_orig / post_width;
|
362
|
+
$('iframe',oembedContainer).width(iframe_width_orig / ratio);
|
363
|
+
$('iframe',oembedContainer).height(iframe_height_orig / ratio);
|
364
|
+
} else {
|
365
|
+
if(settings.maxWidth){
|
366
|
+
$('iframe',oembedContainer).width(settings.maxWidth);
|
367
|
+
}
|
368
|
+
if(settings.maxHeight){
|
369
|
+
$('iframe',oembedContainer).height(settings.maxHeight);
|
370
|
+
}
|
371
|
+
}
|
372
|
+
}
|
373
|
+
break;
|
374
|
+
}
|
375
|
+
};
|
376
|
+
|
377
|
+
$.fn.oembed.getPhotoCode = function(url, oembedData) {
|
378
|
+
var code, alt = oembedData.title ? oembedData.title : '';
|
379
|
+
alt += oembedData.author_name ? ' - ' + oembedData.author_name : '';
|
380
|
+
alt += oembedData.provider_name ? ' - ' + oembedData.provider_name : '';
|
381
|
+
if (oembedData.url){
|
382
|
+
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');
|
385
|
+
code = '<div><a href="' + url + '" target=\'_blank\'><img src="' + newURL + '" alt="' + alt + '"/></a></div>';
|
386
|
+
} else {
|
387
|
+
code = '<div>Error loading this picture</div>';
|
388
|
+
}
|
389
|
+
if (oembedData.html) code += "<div>" + oembedData.html + "</div>";
|
390
|
+
return code;
|
391
|
+
};
|
392
|
+
|
393
|
+
$.fn.oembed.getRichCode = function(url, oembedData) {
|
394
|
+
var code = oembedData.html;
|
395
|
+
return code;
|
396
|
+
};
|
397
|
+
|
398
|
+
$.fn.oembed.getGenericCode = function(url, oembedData) {
|
399
|
+
var title = (oembedData.title !== null) ? oembedData.title : url,
|
400
|
+
code = '<a href="' + url + '">' + title + '</a>';
|
401
|
+
if (oembedData.html) code += "<div>" + oembedData.html + "</div>";
|
402
|
+
return code;
|
403
|
+
};
|
404
|
+
|
405
|
+
$.fn.oembed.getOEmbedProvider = function(url) {
|
406
|
+
for (var i = 0; i < $.fn.oembed.providers.length; i++) {
|
407
|
+
for (var j = 0, l =$.fn.oembed.providers[i].urlschemes.length; j < l; j++) {
|
408
|
+
var regExp = new RegExp($.fn.oembed.providers[i].urlschemes[j], "i");
|
409
|
+
if (url.match(regExp) !== null) return $.fn.oembed.providers[i];
|
410
|
+
}
|
411
|
+
}
|
412
|
+
return null;
|
413
|
+
};
|
414
|
+
|
415
|
+
$.fn.oembed.OEmbedProvider = function(name, type, urlschemesarray, apiendpoint, extraSettings) {
|
416
|
+
this.name = name;
|
417
|
+
this.type = type; // "photo", "video", "link", "rich", null
|
418
|
+
this.urlschemes = urlschemesarray;
|
419
|
+
this.apiendpoint = apiendpoint;
|
420
|
+
this.maxWidth = 500;
|
421
|
+
this.maxHeight = 400;
|
422
|
+
extraSettings =extraSettings ||{};
|
423
|
+
|
424
|
+
if(extraSettings.useYQL){
|
425
|
+
|
426
|
+
if(extraSettings.useYQL=='xml'){
|
427
|
+
extraSettings.yql = {xpath:"//oembed/html", from:'xml'
|
428
|
+
, apiendpoint: this.apiendpoint
|
429
|
+
, url: function(externalurl){return this.apiendpoint+'?format=xml&url='+externalurl}
|
430
|
+
, datareturn:function(results){return results.html.replace(/.*\[CDATA\[(.*)\]\]>$/,'$1') || ''}
|
431
|
+
};
|
432
|
+
}else{
|
433
|
+
extraSettings.yql = {from:'json'
|
434
|
+
, apiendpoint: this.apiendpoint
|
435
|
+
, url: function(externalurl){return this.apiendpoint+'?format=json&url='+externalurl}
|
436
|
+
, datareturn:function(results){
|
437
|
+
if (results.json.type != 'video' && (results.json.url || results.json.thumbnail_url)) {
|
438
|
+
return '<img src="' + (results.json.url || results.json.thumbnail_url) + '" />';
|
439
|
+
}
|
440
|
+
return results.json.html || ''
|
441
|
+
}
|
442
|
+
};
|
443
|
+
}
|
444
|
+
this.apiendpoint = null;
|
445
|
+
}
|
446
|
+
|
447
|
+
|
448
|
+
for (var property in extraSettings) {
|
449
|
+
this[property] = extraSettings[property];
|
450
|
+
}
|
451
|
+
|
452
|
+
this.format = this.format || 'json';
|
453
|
+
this.callbackparameter = this.callbackparameter || "callback";
|
454
|
+
this.embedtag = this.embedtag || {tag:""};
|
455
|
+
|
456
|
+
|
457
|
+
};
|
458
|
+
|
459
|
+
/*
|
460
|
+
* Function to update existing providers
|
461
|
+
*
|
462
|
+
* @param {String} name The name of the provider
|
463
|
+
* @param {String} type The type of the provider can be "file", "photo", "video", "rich"
|
464
|
+
* @param {String} urlshemesarray Array of url of the provider
|
465
|
+
* @param {String} apiendpoint The endpoint of the provider
|
466
|
+
* @param {String} extraSettings Extra settings of the provider
|
467
|
+
*/
|
468
|
+
$.fn.updateOEmbedProvider = function(name, type, urlschemesarray, apiendpoint, extraSettings) {
|
469
|
+
for (var i = 0; i < $.fn.oembed.providers.length; i++) {
|
470
|
+
if ($.fn.oembed.providers[i].name === name) {
|
471
|
+
if (type !== null) {
|
472
|
+
$.fn.oembed.providers[i].type = type;
|
473
|
+
}
|
474
|
+
if (urlschemesarray !== null) {
|
475
|
+
$.fn.oembed.providers[i].urlschemes = urlschemesarray;
|
476
|
+
}
|
477
|
+
if (apiendpoint !== null) {
|
478
|
+
$.fn.oembed.providers[i].apiendpoint = apiendpoint;
|
479
|
+
}
|
480
|
+
if (extraSettings !== null) {
|
481
|
+
$.fn.oembed.providers[i].extraSettings = extraSettings;
|
482
|
+
for (var property in extraSettings) {
|
483
|
+
if (property !== null && extraSettings[property] !== null) {
|
484
|
+
$.fn.oembed.providers[i][property] = extraSettings[property];
|
485
|
+
}
|
486
|
+
}
|
487
|
+
}
|
488
|
+
}
|
489
|
+
}
|
490
|
+
};
|
491
|
+
|
492
|
+
/* Native & common providers */
|
493
|
+
$.fn.oembed.providers = [
|
494
|
+
|
495
|
+
//Video
|
496
|
+
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', {
|
497
|
+
templateRegex: /.*(?:v\=|be\/|embed\/)([\w\-]+)&?.*/,embedtag: {tag: 'iframe',width: '425',height: '349'}
|
498
|
+
}),
|
499
|
+
|
500
|
+
//new $.fn.oembed.OEmbedProvider("youtube", "video", ["youtube\\.com/watch.+v=[\\w-]+&?", "youtu\\.be/[\\w-]+"], 'http://www.youtube.com/oembed', {useYQL:'json'}),
|
501
|
+
//new $.fn.oembed.OEmbedProvider("youtubeiframe", "video", ["youtube.com/embed"], "$1?wmode=transparent",
|
502
|
+
// {templateRegex:/(.*)/,embedtag : {tag: 'iframe', width:'425',height: '349'}}),
|
503
|
+
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'}),
|
504
|
+
new $.fn.oembed.OEmbedProvider("xtranormal", "video", ["xtranormal\\.com/watch/.+"], "http://www.xtranormal.com/xtraplayr/$1/$2", {
|
505
|
+
templateRegex: /.*com\/watch\/([\w\-]+)\/([\w\-]+).*/,embedtag: {tag: 'iframe',width: '320',height: '269'}}),
|
506
|
+
new $.fn.oembed.OEmbedProvider("scivee", "video", ["scivee.tv/node/.+"], "http://www.scivee.tv/flash/embedCast.swf?", {
|
507
|
+
templateRegex: /.*tv\/node\/(.+)/,embedtag: {width: '480',height: '400',flashvars:"id=$1&type=3"}}),
|
508
|
+
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", {
|
509
|
+
templateRegex: /.*watch\/([^\?]+).*/,embedtag: {width: '410',height: '341'}}),
|
510
|
+
new $.fn.oembed.OEmbedProvider("gametrailers", "video", ["gametrailers\\.com/video/.+"], "http://media.mtvnservices.com/mgid:moses:video:gametrailers.com:$2", {
|
511
|
+
templateRegex: /.*com\/video\/([\w\-]+)\/([\w\-]+).*/,embedtag: {width: '512',height: '288' }}),
|
512
|
+
new $.fn.oembed.OEmbedProvider("funnyordie", "video", ["funnyordie\\.com/videos/.+"], "http://player.ordienetworks.com/flash/fodplayer.swf?", {
|
513
|
+
templateRegex: /.*videos\/([^\/]+)\/([^\/]+)?/,embedtag: {width: 512,height: 328,flashvars: "key=$1"}}),
|
514
|
+
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",
|
515
|
+
{templateRegex:/.*video\/([^\/]+).*/ , embedtag : {width:600,height: 338}}),
|
516
|
+
new $.fn.oembed.OEmbedProvider("metacafe", "video", ["metacafe\\.com/watch/.+"],"http://www.metacafe.com/fplayer/$1/$2.swf",
|
517
|
+
{templateRegex:/.*watch\/(\d+)\/(\w+)\/.*/ , embedtag : {width:400,height: 345}}),
|
518
|
+
new $.fn.oembed.OEmbedProvider("bambuser", "video", ["bambuser\\.com\/channel\/.*\/broadcast\/.*"],"http://static.bambuser.com/r/player.swf?vid=$1",
|
519
|
+
{templateRegex:/.*bambuser\.com\/channel\/.*\/broadcast\/(\w+).*/ , embedtag : {width:512,height: 339 }}),
|
520
|
+
new $.fn.oembed.OEmbedProvider("twitvid", "video", ["twitvid\\.com/.+"],"http://www.twitvid.com/embed.php?guid=$1&autoplay=0",
|
521
|
+
{templateRegex:/.*twitvid\.com\/(\w+).*/ , embedtag : {tag:'iframe',width:480,height: 360 }}),
|
522
|
+
|
523
|
+
new $.fn.oembed.OEmbedProvider("aniboom", "video", ["aniboom\\.com/animation-video/.+"],"http://api.aniboom.com/e/$1",
|
524
|
+
{templateRegex:/.*animation-video\/(\d+).*/ , embedtag : {width:594,height: 334}}),
|
525
|
+
|
526
|
+
new $.fn.oembed.OEmbedProvider("vzaar", "video", ["vzaar\\.com/videos/.+","vzaar.tv/.+"],"http://view.vzaar.com/$1/player?",
|
527
|
+
{templateRegex:/.*\/(\d+).*/, embedtag : {tag:'iframe',width:576,height: 324 }}),
|
528
|
+
new $.fn.oembed.OEmbedProvider("snotr", "video", ["snotr\\.com/video/.+"],"http://www.snotr.com/embed/$1",
|
529
|
+
{templateRegex:/.*\/(\d+).*/, embedtag : {tag:'iframe',width:400,height: 330, nocache:1 }}),
|
530
|
+
|
531
|
+
new $.fn.oembed.OEmbedProvider("youku", "video", ["v.youku.com/v_show/id_.+"],"http://player.youku.com/player.php/sid/$1/v.swf",
|
532
|
+
{templateRegex:/.*id_(.+)\.html.*/, embedtag : {width:480,height:400, nocache:1 }}),
|
533
|
+
new $.fn.oembed.OEmbedProvider("tudou", "video", ["tudou.com/programs/view/.+\/"],"http://www.tudou.com/v/$1/v.swf",
|
534
|
+
{templateRegex:/.*view\/(.+)\//, embedtag : {width:480,height:400, nocache:1 }}),
|
535
|
+
|
536
|
+
new $.fn.oembed.OEmbedProvider("embedr", "video", ["embedr\\.com/playlist/.+"],"http://embedr.com/swf/slider/$1/425/520/default/false/std?",
|
537
|
+
{templateRegex:/.*playlist\/([^\/]+).*/, embedtag : {width:425,height: 520}}),
|
538
|
+
new $.fn.oembed.OEmbedProvider("blip", "video", ["blip\\.tv/.+"], "http://blip.tv/oembed/"),
|
539
|
+
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'}),
|
540
|
+
new $.fn.oembed.OEmbedProvider("animoto", "video", ["animoto.com/play/.+"], "http://animoto.com/services/oembed"),
|
541
|
+
new $.fn.oembed.OEmbedProvider("hulu", "video", ["hulu\\.com/watch/.*"], "http://www.hulu.com/api/oembed.json"),
|
542
|
+
new $.fn.oembed.OEmbedProvider("ustream", "video", ["ustream\\.tv/recorded/.*"], "http://www.ustream.tv/oembed",{useYQL:'json'}),
|
543
|
+
new $.fn.oembed.OEmbedProvider("videojug", "video", ["videojug\\.com/(film|payer|interview).*"], "http://www.videojug.com/oembed.json",{useYQL:'json'}),
|
544
|
+
new $.fn.oembed.OEmbedProvider("sapo", "video", ["videos\\.sapo\\.pt/.*"], "http://videos.sapo.pt/oembed",{useYQL:'json'}),
|
545
|
+
new $.fn.oembed.OEmbedProvider("vodpod", "video", ["vodpod.com/watch/.*"], "http://vodpod.com/oembed.js",{useYQL:'json'}),
|
546
|
+
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"),
|
547
|
+
new $.fn.oembed.OEmbedProvider("dailymotion", "video", ["dailymotion\\.com/.+"],'http://www.dailymotion.com/services/oembed'),
|
548
|
+
new $.fn.oembed.OEmbedProvider("5min", "video", ["www\\.5min\\.com/.+"], 'http://api.5min.com/oembed.xml',{useYQL:'xml'}),
|
549
|
+
new $.fn.oembed.OEmbedProvider("National Film Board of Canada", "video", ["nfb\\.ca/film/.+"],'http://www.nfb.ca/remote/services/oembed/',{useYQL:'json'}),
|
550
|
+
new $.fn.oembed.OEmbedProvider("qik", "video", ["qik\\.com/\\w+"], 'http://qik.com/api/oembed.json',{useYQL:'json'}),
|
551
|
+
new $.fn.oembed.OEmbedProvider("revision3", "video", ["revision3\\.com"], "http://revision3.com/api/oembed/"),
|
552
|
+
new $.fn.oembed.OEmbedProvider("dotsub", "video", ["dotsub\\.com/view/.+"], "http://dotsub.com/services/oembed",{useYQL:'json'}),
|
553
|
+
new $.fn.oembed.OEmbedProvider("clikthrough", "video", ["clikthrough\\.com/theater/video/\\d+"], "http://clikthrough.com/services/oembed"),
|
554
|
+
new $.fn.oembed.OEmbedProvider("Kinomap", "video", ["kinomap\\.com/.+"], "http://www.kinomap.com/oembed"),
|
555
|
+
new $.fn.oembed.OEmbedProvider("VHX", "video", ["vhx.tv/.+"], "http://vhx.tv/services/oembed.json"),
|
556
|
+
new $.fn.oembed.OEmbedProvider("bambuser", "video", ["bambuser.com/.+"], "http://api.bambuser.com/oembed/iframe.json"),
|
557
|
+
new $.fn.oembed.OEmbedProvider("justin.tv", "video", ["justin.tv/.+"], 'http://api.justin.tv/api/embed/from_url.json',{useYQL:'json'}),
|
558
|
+
|
559
|
+
|
560
|
+
//Audio
|
561
|
+
new $.fn.oembed.OEmbedProvider("official.fm", "rich", ["official.fm/.+"], 'http://official.fm/services/oembed',{useYQL:'json'}),
|
562
|
+
new $.fn.oembed.OEmbedProvider("chirbit", "rich", ["chirb.it/.+"], 'http://chirb.it/oembed.json',{useYQL:'json'}),
|
563
|
+
new $.fn.oembed.OEmbedProvider("Huffduffer", "rich", ["huffduffer.com/[-.\\w@]+/\\d+"], "http://huffduffer.com/oembed"),
|
564
|
+
new $.fn.oembed.OEmbedProvider("Spotify", "rich", ["open.spotify.com/(track|album|user)/"], "https://embed.spotify.com/oembed/"),
|
565
|
+
new $.fn.oembed.OEmbedProvider("shoudio", "rich", ["shoudio.com/.+","shoud.io/.+"], "http://shoudio.com/api/oembed"),
|
566
|
+
new $.fn.oembed.OEmbedProvider("mixcloud", "rich", ["mixcloud.com/.+"],'http://www.mixcloud.com/oembed/',{useYQL:'json'}),
|
567
|
+
new $.fn.oembed.OEmbedProvider("rdio.com", "rich", ["rd.io/.+","rdio.com"], "http://www.rdio.com/api/oembed/"),
|
568
|
+
new $.fn.oembed.OEmbedProvider("Soundcloud", "rich", ["soundcloud.com/.+","snd.sc/.+"], "http://soundcloud.com/oembed",{format:'js'}),
|
569
|
+
new $.fn.oembed.OEmbedProvider("bandcamp", "rich", ["bandcamp\\.com/album/.+"], null,
|
570
|
+
{yql:{xpath:"//meta[contains(@content, \\'EmbeddedPlayer\\')]", from:'html'
|
571
|
+
, datareturn:function(results){
|
572
|
+
return results.meta ?'<iframe width="400" height="100" src="'+results.meta.content+'" allowtransparency="true" frameborder="0"></iframe>':false;
|
573
|
+
}
|
574
|
+
}
|
575
|
+
}),
|
576
|
+
|
577
|
+
//Photo
|
578
|
+
new $.fn.oembed.OEmbedProvider("deviantart", "photo", ["deviantart.com/.+","fav.me/.+","deviantart.com/.+"], "http://backend.deviantart.com/oembed",{format:'jsonp'}),
|
579
|
+
new $.fn.oembed.OEmbedProvider("skitch", "photo", ["skitch.com/.+"], null,
|
580
|
+
{yql:{xpath:"json", from:'json'
|
581
|
+
, url: function(externalurl){return 'http://skitch.com/oembed/?format=json&url='+externalurl}
|
582
|
+
, datareturn:function(data){return $.fn.oembed.getPhotoCode( data.json.url, data.json);}
|
583
|
+
}
|
584
|
+
}),
|
585
|
+
new $.fn.oembed.OEmbedProvider("mobypicture", "photo", ["mobypicture.com/user/.+/view/.+","moby.to/.+"], "http://api.mobypicture.com/oEmbed"),
|
586
|
+
new $.fn.oembed.OEmbedProvider("flickr", "photo", ["flickr\\.com/photos/.+"], "http://flickr.com/services/oembed",{callbackparameter:'jsoncallback'}),
|
587
|
+
new $.fn.oembed.OEmbedProvider("photobucket", "photo", ["photobucket\\.com/(albums|groups)/.+"], "http://photobucket.com/oembed/"),
|
588
|
+
new $.fn.oembed.OEmbedProvider("instagram", "photo", ["instagr\\.?am(\\.com)?/.+"], "http://api.instagram.com/oembed"),
|
589
|
+
//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"}),
|
590
|
+
new $.fn.oembed.OEmbedProvider("SmugMug", "photo", ["smugmug.com/[-.\\w@]+/.+"], "http://api.smugmug.com/services/oembed/"),
|
591
|
+
|
592
|
+
new $.fn.oembed.OEmbedProvider("dribbble", "photo", ["dribbble.com/shots/.+"], "http://api.dribbble.com/shots/$1?callback=?",
|
593
|
+
{ templateRegex:/.*shots\/([\d]+).*/,
|
594
|
+
templateData : function(data){if(!data.image_teaser_url)return false;
|
595
|
+
return '<img src="'+data.image_teaser_url+'"/>';
|
596
|
+
}
|
597
|
+
}),
|
598
|
+
new $.fn.oembed.OEmbedProvider("chart.ly", "photo", ["chart\\.ly/[a-z0-9]{6,8}"],"http://chart.ly/uploads/large_$1.png",
|
599
|
+
{templateRegex:/.*ly\/([^\/]+).*/ , embedtag : {tag:'img'},nocache:1}),
|
600
|
+
//new $.fn.oembed.OEmbedProvider("stocktwits.com", "photo", ["stocktwits\\.com/message/.+"], "http://charts.stocktwits.com/production/original_$1.png?",
|
601
|
+
// { templateRegex: /.*message\/([^\/]+).*/, embedtag: { tag: 'img'},nocache:1 }),
|
602
|
+
new $.fn.oembed.OEmbedProvider("circuitlab", "photo", ["circuitlab.com/circuit/.+"],"https://www.circuitlab.com/circuit/$1/screenshot/540x405/",
|
603
|
+
{templateRegex:/.*circuit\/([^\/]+).*/ , embedtag : {tag:'img'},nocache:1}),
|
604
|
+
new $.fn.oembed.OEmbedProvider("23hq", "photo", ["23hq.com/[-.\\w@]+/photo/.+"],"http://www.23hq.com/23/oembed",{useYQL:"json"}),
|
605
|
+
new $.fn.oembed.OEmbedProvider("img.ly", "photo", ["img\\.ly/.+"],"http://img.ly/show/thumb/$1",
|
606
|
+
{templateRegex:/.*ly\/([^\/]+).*/ , embedtag : {tag:'img'},nocache:1
|
607
|
+
}),
|
608
|
+
new $.fn.oembed.OEmbedProvider("twitgoo.com", "photo", ["twitgoo\\.com/.+"],"http://twitgoo.com/show/thumb/$1",
|
609
|
+
{templateRegex:/.*com\/([^\/]+).*/ , embedtag : {tag:'img'},nocache:1}),
|
610
|
+
new $.fn.oembed.OEmbedProvider("imgur.com", "photo", ["imgur\\.com/gallery/.+"],"http://imgur.com/$1l.jpg",
|
611
|
+
{templateRegex:/.*gallery\/([^\/]+).*/ , embedtag : {tag:'img'},nocache:1}),
|
612
|
+
new $.fn.oembed.OEmbedProvider("visual.ly", "rich", ["visual\\.ly/.+"], null,
|
613
|
+
{yql:{xpath:"//a[@id=\\'gc_article_graphic_image\\']/img", from:'htmlstring'}
|
614
|
+
}),
|
615
|
+
new $.fn.oembed.OEmbedProvider("gravtar", "photo", ["mailto:.+"],null,
|
616
|
+
{templateRegex:/mailto:([^\/]+).*/
|
617
|
+
, template : function(wm,email){
|
618
|
+
return '<img src="http://gravatar.com/avatar/'+email.md5()+'.jpg" alt="on Gravtar" class="jqoaImg">';
|
619
|
+
}
|
620
|
+
}),
|
621
|
+
|
622
|
+
//Rich
|
623
|
+
new $.fn.oembed.OEmbedProvider("twitter", "rich", ["twitter.com/.+"], "https://api.twitter.com/1/statuses/oembed.json"),
|
624
|
+
new $.fn.oembed.OEmbedProvider("gmep", "rich", ["gmep.imeducate.com/.*","gmep.org/.*"], "http://gmep.org/oembed.json"),
|
625
|
+
new $.fn.oembed.OEmbedProvider("urtak", "rich", ["urtak.com/(u|clr)/.+"], "http://oembed.urtak.com/1/oembed"),
|
626
|
+
new $.fn.oembed.OEmbedProvider("cacoo", "rich", ["cacoo.com/.+"], "http://cacoo.com/oembed.json"),
|
627
|
+
new $.fn.oembed.OEmbedProvider("dailymile", "rich", ["dailymile.com/people/.*/entries/.*"], "http://api.dailymile.com/oembed"),
|
628
|
+
new $.fn.oembed.OEmbedProvider("dipity", "rich", ["dipity.com/timeline/.+"],'http://www.dipity.com/oembed/timeline/',{useYQL:'json'}),
|
629
|
+
new $.fn.oembed.OEmbedProvider("sketchfab", "rich", ["sketchfab.com/show/.+"],'http://sketchfab.com/oembed',{useYQL:'json'}),
|
630
|
+
new $.fn.oembed.OEmbedProvider("speakerdeck", "rich", ["speakerdeck.com/.+"],'http://speakerdeck.com/oembed.json',{useYQL:'json'}),
|
631
|
+
new $.fn.oembed.OEmbedProvider("popplet", "rich", ["popplet.com/app/.*"],"http://popplet.com/app/Popplet_Alpha.swf?page_id=$1&em=1",
|
632
|
+
{templateRegex:/.*#\/([^\/]+).*/,embedtag : {width:460,height: 460} }),
|
633
|
+
|
634
|
+
new $.fn.oembed.OEmbedProvider("pearltrees", "rich", ["pearltrees.com/.*"],"http://cdn.pearltrees.com/s/embed/getApp?",
|
635
|
+
{templateRegex:/.*N-f=1_(\d+).*N-p=(\d+).*/, embedtag : {width:460,height: 460,
|
636
|
+
flashvars : "lang=en_US&embedId=pt-embed-$1-693&treeId=$1&pearlId=$2&treeTitle=Diagrams%2FVisualization&site=www.pearltrees.com%2FF"}
|
637
|
+
}),
|
638
|
+
|
639
|
+
new $.fn.oembed.OEmbedProvider("prezi", "rich", ["prezi.com/.*"],"http://prezi.com/bin/preziloader.swf?",
|
640
|
+
{templateRegex:/.*com\/([^\/]+)\/.*/,embedtag : {width:550,height: 400,
|
641
|
+
flashvars : "prezi_id=$1&lock_to_path=0&color=ffffff&autoplay=no&autohide_ctrls=0"
|
642
|
+
}
|
643
|
+
}),
|
644
|
+
|
645
|
+
new $.fn.oembed.OEmbedProvider("tourwrist", "rich", ["tourwrist.com/tours/.+"], null,
|
646
|
+
{ templateRegex:/.*tours.([\d]+).*/,
|
647
|
+
template : function(wm,tourid){
|
648
|
+
setTimeout(function(){if(loadEmbeds)loadEmbeds();},2000);
|
649
|
+
return "<div id='"+tourid+"' class='tourwrist-tour-embed direct'></div> <script type='text/javascript' src='http://tourwrist.com/tour_embed.js'></script>";
|
650
|
+
}
|
651
|
+
}),
|
652
|
+
|
653
|
+
new $.fn.oembed.OEmbedProvider("meetup", "rich", ["meetup\\.(com|ps)/.+"], "http://api.meetup.com/oembed"),
|
654
|
+
new $.fn.oembed.OEmbedProvider("ebay", "rich", ["ebay\\.*"],"http://togo.ebay.com/togo/togo.swf?2008013100",
|
655
|
+
{templateRegex:/.*\/([^\/]+)\/(\d{10,13}).*/, embedtag : {width:355,height: 300,
|
656
|
+
flashvars : "base=http://togo.ebay.com/togo/&lang=en-us&mode=normal&itemid=$2&query=$1"
|
657
|
+
}
|
658
|
+
}),
|
659
|
+
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=?",{
|
660
|
+
templateRegex:/.*\/\/([\w]+).*\/wiki\/([^\/]+).*/,
|
661
|
+
templateData : function(data){if(!data.parse)return false;
|
662
|
+
var text = data.parse['text']['*'].replace(/href="\/wiki/g,'href="http://en.wikipedia.org/wiki');
|
663
|
+
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>';
|
664
|
+
}
|
665
|
+
}),
|
666
|
+
new $.fn.oembed.OEmbedProvider("imdb", "rich", ["imdb.com/title/.+"], "http://www.imdbapi.com/?i=$1&callback=?",
|
667
|
+
{templateRegex:/.*\/title\/([^\/]+).*/,
|
668
|
+
templateData : function(data){if(!data.Title)return false;
|
669
|
+
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>';
|
670
|
+
}
|
671
|
+
}),
|
672
|
+
new $.fn.oembed.OEmbedProvider("livejournal", "rich", ["livejournal.com/"], "http://ljpic.seacrow.com/json/$2$4?jsonp=?"
|
673
|
+
,{templateRegex:/(http:\/\/(((?!users).)+)\.livejournal\.com|.*users\.livejournal\.com\/([^\/]+)).*/,
|
674
|
+
templateData : function(data){if(!data.username)return false;
|
675
|
+
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>';
|
676
|
+
}
|
677
|
+
}),
|
678
|
+
new $.fn.oembed.OEmbedProvider("circuitbee", "rich", ["circuitbee\\.com/circuit/view/.+"],"http://c.circuitbee.com/build/r/schematic-embed.html?id=$1",
|
679
|
+
{templateRegex:/.*circuit\/view\/(\d+).*/ ,embedtag : {tag: 'iframe', width:'500',height: '350'}
|
680
|
+
}),
|
681
|
+
|
682
|
+
new $.fn.oembed.OEmbedProvider("googlecalendar", "rich", ["www.google.com/calendar/embed?.+"],"$1",
|
683
|
+
{templateRegex:/(.*)/ ,embedtag : {tag: 'iframe', width:'800',height: '600' }
|
684
|
+
}),
|
685
|
+
new $.fn.oembed.OEmbedProvider("jsfiddle", "rich", ["jsfiddle.net/[^/]+/?"],"http://jsfiddle.net/$1/embedded/result,js,resources,html,css/?",
|
686
|
+
{templateRegex:/.*net\/([^\/]+).*/ ,embedtag : {tag: 'iframe', width:'100%',height: '300' }
|
687
|
+
}),
|
688
|
+
new $.fn.oembed.OEmbedProvider("jsbin", "rich", ["jsbin.com/.+"],"http://jsbin.com/$1/?",
|
689
|
+
{templateRegex:/.*com\/([^\/]+).*/ ,embedtag : {tag: 'iframe', width:'100%',height: '300' }
|
690
|
+
}),
|
691
|
+
|
692
|
+
new $.fn.oembed.OEmbedProvider("jotform", "rich", ["form.jotform.co/form/.+"],"$1?",
|
693
|
+
{templateRegex:/(.*)/ ,embedtag : {tag: 'iframe', width:'100%',height: '507' }
|
694
|
+
}),
|
695
|
+
new $.fn.oembed.OEmbedProvider("reelapp", "rich", ["reelapp\\.com/.+"],"http://www.reelapp.com/$1/embed",
|
696
|
+
{templateRegex:/.*com\/(\S{6}).*/ ,embedtag : {tag: 'iframe', width:'400',height: '338'}
|
697
|
+
}),
|
698
|
+
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",
|
699
|
+
{templateRegex:/(.*)/ ,embedtag : {tag: 'iframe', width:'368px',height: 'auto'}
|
700
|
+
}),
|
701
|
+
|
702
|
+
new $.fn.oembed.OEmbedProvider("timetoast", "rich", ["timetoast.com/timelines/[0-9]+"],"http://www.timetoast.com/flash/TimelineViewer.swf?passedTimelines=$1",
|
703
|
+
{templateRegex:/.*timelines\/([0-9]*)/ ,embedtag : { width:550,height: 400,nocache:1}
|
704
|
+
}),
|
705
|
+
new $.fn.oembed.OEmbedProvider("pastebin", "rich", ["pastebin\\.com/[\\S]{8}"],"http://pastebin.com/embed_iframe.php?i=$1",
|
706
|
+
{templateRegex:/.*\/(\S{8}).*/ ,embedtag : {tag: 'iframe', width:'100%',height: 'auto'}
|
707
|
+
}),
|
708
|
+
new $.fn.oembed.OEmbedProvider("mixlr", "rich", ["mixlr.com/.+"],"http://mixlr.com/embed/$1?autoplay=ae",
|
709
|
+
{templateRegex:/.*com\/([^\/]+).*/ ,embedtag : {tag: 'iframe', width:'100%',height: 'auto' }
|
710
|
+
}),
|
711
|
+
new $.fn.oembed.OEmbedProvider("pastie", "rich", ["pastie\\.org/pastes/.+"],null,{yql:{xpath:'//pre[@class="textmate-source"]'}}),
|
712
|
+
new $.fn.oembed.OEmbedProvider("github", "rich", ["gist.github.com/.+"], "https://github.com/api/oembed"),
|
713
|
+
new $.fn.oembed.OEmbedProvider("github", "rich", ["github.com/[-.\\w@]+/[-.\\w@]+"], "https://api.github.com/repos/$1/$2?callback=?"
|
714
|
+
,{templateRegex:/.*\/([^\/]+)\/([^\/]+).*/,
|
715
|
+
templateData : function(data){ if(!data.data.html_url)return false;
|
716
|
+
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>'
|
717
|
+
+'<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>'
|
718
|
+
+'<p class="oembedall-updated-at">Last updated: '+data.data.pushed_at+'</p></div></div>';
|
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);
|
830
|
+
}
|
831
|
+
if(results['og:title']) code.append('<b>'+results['og:title']+'</b><br/>');
|
832
|
+
if(results['og:description'])
|
833
|
+
code.append(results['og:description']+'<br/>');
|
834
|
+
else if(results['description'])
|
835
|
+
code.append(results['description']+'<br/>');
|
836
|
+
return code;
|
837
|
+
}
|
838
|
+
}
|
839
|
+
})
|
840
|
+
|
841
|
+
];
|
842
|
+
})(jQuery);
|
843
|
+
|
844
|
+
//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)))}
|