﻿(function(c) { c.fn.oembed = function(f, e, g) { e = c.extend({}, c.fn.oembed.defaults, e); return this.each(function() { var h = c(this); var i = (f != null) ? f : h.attr("href"); var j; if (!g) { g = function(l, k) { c.fn.oembed.insertCode(l, e.embedMethod, k) } } if (i != null) { j = d(i); if (j != null) { j.maxWidth = e.maxWidth; j.maxHeight = e.maxHeight; j.embedCode(h, i, g); return } } g(h, null) }) }; c.fn.oembed.defaults = { maxWidth: 500, maxHeight: 400, embedMethod: "replace" }; c.fn.oembed.insertCode = function(f, g, e) { switch (g) { case "auto": if (f.attr("href") != null) { insertCode(f, "append", e) } else { insertCode(f, "replace", e) } break; case "replace": f.replaceWith(e.code); break; case "fill": f.html(e.code); break; case "append": var h = f.next(); if (h == null || !h.hasClass("oembed-container")) { h = f.after('<div class="oembed-container"></div>').next(".oembed-container") } h.html(e.code); break } }; c.fn.oembed.getPhotoCode = function(e, g) { var f = '<div><a href="' + e + '" target="_blank"><img src="' + g.url + '"/></a></div>'; if (g.html) { f += "<div>" + g.html + "</div>" } return f }; c.fn.oembed.getVideoCode = function(e, g) { var f = g.html; return f }; c.fn.oembed.getRichCode = function(e, g) { var f = g.html; return f }; c.fn.oembed.getGenericCode = function(e, g) { var h = (g.title != null) ? g.title : e, f = '<a href="' + e + '">' + h + "</a>"; if (g.html) { f += "<div>" + g.html + "</div>" } return f }; c.fn.oembed.isAvailable = function(e) { var f = d(e); return (f != null) }; function d(e) { for (var f = 0; f < b.length; f++) { if (b[f].matches(e)) { return b[f] } } return null } var b = [new a("fivemin", "5min.com"), new a("amazon", "amazon.com"), new a("flickr", "flickr", "http://flickr.com/services/oembed", "jsoncallback"), new a("googlevideo", "video.google."), new a("hulu", "hulu.com"), new a("imdb", "imdb.com"), new a("metacafe", "metacafe.com"), new a("qik", "qik.com"), new a("revision3", "slideshare"), new a("slideshare", "5min.com"), new a("twitpic", "twitpic.com"), new a("viddler", "viddler.com"), new a("vimeo", "vimeo.com", "http://vimeo.com/api/oembed.json"), new a("wikipedia", "wikipedia.org"), new a("wordpress", "wordpress.com"), new a("youtube", "youtube.com")]; function a(e, f, h, g) { this.name = e; this.urlPattern = f; this.oEmbedUrl = (h != null) ? h : "http://oohembed.com/oohembed/"; this.callbackparameter = (g != null) ? g : "callback"; this.maxWidth = 500; this.maxHeight = 400; this.matches = function(i) { return i.indexOf(this.urlPattern) >= 0 }; this.getRequestUrl = function(j) { var i = this.oEmbedUrl; if (i.indexOf("?") <= 0) { i = i + "?" } i += "maxwidth=" + this.maxWidth + "&maxHeight=" + this.maxHeight + "&format=json&url=" + escape(j) + "&" + this.callbackparameter + "=?"; return i }; this.embedCode = function(i, k, l) { var j = this.getRequestUrl(k); c.getJSON(j, function(p) { var m = c.extend(p); var o, n = p.type; switch (n) { case "photo": m.code = c.fn.oembed.getPhotoCode(k, p); break; case "video": m.code = c.fn.oembed.getVideoCode(k, p); break; case "rich": m.code = c.fn.oembed.getRichCode(k, p); break; default: m.code = c.fn.oembed.getGenericCode(k, p); break } l(i, m) }) } } })(jQuery);

