﻿/*
 * jquery-oembed 1.0.5
 * http://code.google.com/p/jquery-oembed/
 */
(function (d) { d.fn.oembed = function (g, f, h) { f = d.extend(true, d.fn.oembed.defaults, f); return this.each(function () { var i = d(this), j = (g != null) ? g : i.attr("href"), k; if (!h) { h = function (m, l) { d.fn.oembed.insertCode(m, f.embedMethod, l) } } if (j != null) { k = e(j); if (k != null) { k.params = c(f[k.name]) || {}; k.maxWidth = f.maxWidth; k.maxHeight = f.maxHeight; k.embedCode(i, j, h); return } } h(i, null) }) }; d.fn.oembed.defaults = { maxWidth: null, maxHeight: null, embedMethod: "replace" }; d.fn.oembed.insertCode = function (g, h, f) { if (f == null) { return } switch (h) { case "auto": if (g.attr("href") != null) { d.fn.oembed.insertCode(g, "append", f) } else { d.fn.oembed.insertCode(g, "replace", f) } break; case "replace": g.replaceWith(f.code); break; case "fill": g.html(f.code); break; case "append": var i = g.next(); if (i == null || !i.hasClass("oembed-container")) { i = g.after('<div class="oembed-container"></div>').next(".oembed-container"); if (f != null && f.provider_name != null) { i.toggleClass("oembed-container-" + f.provider_name) } } i.html(f.code); break } }; d.fn.oembed.getPhotoCode = function (f, h) { var i = h.title ? h.title : ""; i += h.author_name ? " - " + h.author_name : ""; i += h.provider_name ? " - " + h.provider_name : ""; var g = '<div><a href="' + f + '" target="_blank"><img src="' + h.url + '" alt="' + i + '"/></a></div>'; if (h.html) { g += "<div>" + h.html + "</div>" } return g }; d.fn.oembed.getVideoCode = function (f, h) { var g = h.html; return g }; d.fn.oembed.getRichCode = function (f, h) { var g = h.html; return g }; d.fn.oembed.getGenericCode = function (f, h) { var i = (h.title != null) ? h.title : f, g = '<a href="' + f + '">' + i + "</a>"; if (h.html) { g += "<div>" + h.html + "</div>" } return g }; d.fn.oembed.isAvailable = function (f) { var g = e(f); return (g != null) }; function e(f) { for (var g = 0; g < b.length; g++) { if (b[g].matches(f)) { return b[g] } } return null } function c(h) { if (h == null) { return null } var g = {}; for (var f in h) { if (f != null) { g[f.toLowerCase()] = h[f] } } return g } 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", "revision3.com"), new a("slideshare", "slideshare.net"), 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"), new a("vids.myspace.com", "vids.myspace.com", "http://vids.myspace.com/index.cfm?fuseaction=oembed"), new a("screenr", "screenr.com", "http://screenr.com/api/oembed.json")]; function a(f, g, i, h) { this.name = f; this.urlPattern = g; this.oEmbedUrl = (i != null) ? i : "http://oohembed.com/oohembed/"; this.callbackparameter = (h != null) ? h : "callback"; this.maxWidth = 500; this.maxHeight = 400; this.matches = function (j) { return j.indexOf(this.urlPattern) >= 0 }; this.getRequestUrl = function (m) { var k = this.oEmbedUrl; if (k.indexOf("?") <= 0) { k = k + "?" } else { k = k + "&" } var j = ""; if (this.maxWidth != null && this.params.maxwidth == null) { this.params.maxwidth = this.maxWidth } if (this.maxHeight != null && this.params.maxheight == null) { this.params.maxheight = this.maxHeight } for (var l in this.params) { if (l == this.callbackparameter) { continue } if (this.params[l] != null) { j += "&" + escape(l) + "=" + this.params[l] } } k += "format=json&url=" + escape(m) + j + "&" + this.callbackparameter + "=?"; return k }; this.embedCode = function (j, l, m) { var k = this.getRequestUrl(l); d.getJSON(k, function (q) { var n = d.extend(q); var p, o = q.type; switch (o) { case "photo": n.code = d.fn.oembed.getPhotoCode(l, q); break; case "video": n.code = d.fn.oembed.getVideoCode(l, q); break; case "rich": n.code = d.fn.oembed.getRichCode(l, q); break; default: n.code = d.fn.oembed.getGenericCode(l, q); break } m(j, n) }) } } })(jQuery);

