From 5a4ac4b0c27fe0d57d771414f19bc5ea67e16e58 Mon Sep 17 00:00:00 2001 From: Zach Wise Date: Tue, 15 May 2012 17:36:28 -0500 Subject: [PATCH] Enabling thumbnails in the timeline --- source/js/VMM.ExternalAPI.js | 47 ++++++++++++++++++++++++++++++++++- source/js/VMM.MediaElement.js | 10 ++++---- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/source/js/VMM.ExternalAPI.js b/source/js/VMM.ExternalAPI.js index 534a44e..d6b1f8c 100644 --- a/source/js/VMM.ExternalAPI.js +++ b/source/js/VMM.ExternalAPI.js @@ -21,6 +21,9 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { if (VMM.master_config.wikipedia.active) { VMM.ExternalAPI.wikipedia.pushQue(); } + if (VMM.master_config.vimeo.active) { + VMM.ExternalAPI.vimeo.pushQue(); + } }, @@ -534,7 +537,8 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { var flickr_img_thumb = d.sizes.size[0].source; VMM.Lib.attr("#"+flickr_large_id, "src", flickr_img_large); - VMM.Lib.attr("#"+flickr_thumb_id, "src", flickr_img_thumb); + VMM.attachElement("#"+flickr_thumb_id, ""); + //VMM.Lib.attr("#"+flickr_thumb_id, "src", flickr_img_thumb); } }, @@ -615,6 +619,8 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { youtube: { get: function(id) { + var url = "http://gdata.youtube.com/feeds/api/videos/" + id + "?v=2&alt=jsonc&callback=?"; + if (VMM.master_config.youtube.active) { VMM.master_config.youtube.que.push(id); } else { @@ -625,6 +631,9 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { }); } } + + // THUMBNAIL + VMM.getJSON(url, VMM.ExternalAPI.youtube.createThumb); }, create: function(id) { @@ -656,6 +665,13 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { VMM.master_config.youtube.array.push(p); }, + createThumb: function(d) { + trace(d.data.id); + trace(d.data.thumbnail.sqDefault); + var thumb_id = "youtube_" + d.data.id + "_thumb"; + VMM.attachElement("#" + thumb_id, ""); + }, + pushQue: function() { for(var i = 0; i < VMM.master_config.youtube.que.length; i++) { VMM.ExternalAPI.youtube.create(VMM.master_config.youtube.que[i]); @@ -693,6 +709,35 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { } + }, + + vimeo: { + + get: function(id) { + VMM.master_config.vimeo.que.push(id); + VMM.master_config.vimeo.active = true; + }, + + create: function(d) { + trace("VIMEO CREATE"); + // THUMBNAIL + var url = "http://vimeo.com/api/v2/video/" + d + ".json"; + VMM.getJSON(url, VMM.ExternalAPI.vimeo.createThumb); + }, + + createThumb: function(d) { + trace("VIMEO CREATE THUMB"); + var thumb_id = "vimeo_" + d[0].id + "_thumb"; + VMM.attachElement("#" + thumb_id, ""); + }, + + pushQue: function() { + for(var i = 0; i < VMM.master_config.vimeo.que.length; i++) { + VMM.ExternalAPI.vimeo.create(VMM.master_config.vimeo.que[i]); + } + VMM.master_config.vimeo.que = []; + } + } } diff --git a/source/js/VMM.MediaElement.js b/source/js/VMM.MediaElement.js index f792bf1..596d698 100644 --- a/source/js/VMM.MediaElement.js +++ b/source/js/VMM.MediaElement.js @@ -24,17 +24,16 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') { mediaElem = "
"; return mediaElem; } else if (m.type == "flickr") { - //mediaElem = "
"; - mediaElem = "
"; + mediaElem = "
"; return mediaElem; } else if (m.type == "youtube") { - mediaElem = "
"; + mediaElem = "
"; return mediaElem; } else if (m.type == "googledoc") { mediaElem = "
"; return mediaElem; } else if (m.type == "vimeo") { - mediaElem = "
"; + mediaElem = "
"; return mediaElem; } else if (m.type == "dailymotion") { mediaElem = "
"; @@ -113,6 +112,7 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') { // VIMEO } else if (m.type == "vimeo") { mediaElem = ""; + VMM.ExternalAPI.vimeo.get(m.id); // DAILYMOTION } else if (m.type == "dailymotion") { mediaElem = ""; @@ -142,7 +142,7 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') { // UNKNOWN } else if (m.type == "unknown") { trace("NO KNOWN MEDIA TYPE FOUND TRYING TO JUST PLACE THE HTML"); - mediaElem = "
" + VMM.Util.properQuotes(m.id) + "
"; + mediaElem = "
" + VMM.Util.properQuotes(m.id) + "
"; // WEBSITE } else if (m.type == "website") { mediaElem = "";