From 5d94f893d864787d6a6df8b00d1692c8f461ae27 Mon Sep 17 00:00:00 2001 From: jagtalon Date: Thu, 26 Jun 2014 19:49:06 +0000 Subject: [PATCH 1/2] in_theaters.js: Format the file to 4 spaces instead of tabs. --- share/spice/in_theaters/in_theaters.js | 57 +++++++++++++------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/share/spice/in_theaters/in_theaters.js b/share/spice/in_theaters/in_theaters.js index c14315149c..055023ab58 100644 --- a/share/spice/in_theaters/in_theaters.js +++ b/share/spice/in_theaters/in_theaters.js @@ -1,23 +1,22 @@ (function(env) { "use strict"; - // A change in the Rotten Tomatoes API returns images that end in _tmb. // This changes this to _det. + function toDetail(img) { return img.replace(/tmb\.jpg$/, "det.jpg"); } env.ddg_spice_in_theaters = function(api_result) { - - if (!api_result || api_result.error) { + if(!api_result || api_result.error) { return Spice.failed('in_theaters'); } - + Spice.add({ id: 'in_theaters', name: 'Movies', data: api_result.movies, - signal: 'high', + signal: 'high', meta: { sourceName: 'Rotten Tomatoes', sourceUrl: 'http://www.rottentomatoes.com/movie/in-theaters/', @@ -25,52 +24,54 @@ itemType: 'Movies' }, normalize: function(item) { - var position; - if(item.ratings.critics_rating === "Fresh" || item.ratings.critics_rating === "Certified Fresh") { - position = "-256px -144px"; - } else if(item.ratings.critics_rating === "Rotten") { - position = "-272px -144px"; - } + var position; + // We add these so that we can position the Rotten Tomatoes images. + if(item.ratings.critics_rating === "Fresh" || item.ratings.critics_rating === "Certified Fresh") { + position = "-256px -144px"; + } else if(item.ratings.critics_rating === "Rotten") { + position = "-272px -144px"; + } + + // Modify the image from _tmb.jpg to _det.jpg var image = toDetail(item.posters.detailed) - return { + return { rating: item.ratings.critics_score >= 0 ? item.ratings.critics_score / 20 : 0, image: image, - icon_url: DDG.get_asset_path('in_theaters','icons-v2.png'), - icon_image: position, - icon_class: position ? 'tomato--icon' : "", - abstract: Handlebars.helpers.ellipsis(item.synopsis, 200), - heading: item.title, - img_m: image, - url: item.links.alternate + icon_url: DDG.get_asset_path('in_theaters', 'icons-v2.png'), + icon_image: position, + icon_class: position ? 'tomato--icon' : "", + abstract: Handlebars.helpers.ellipsis(item.synopsis, 200), + heading: item.title, + img_m: image, + url: item.links.alternate }; }, templates: { - group: 'media', - detail: 'products_item_detail', + group: 'media', + detail: 'products_item_detail', options: { variant: 'poster', - subtitle_content: Spice.in_theaters.subtitle_content, - rating: false, - buy: Spice.in_theaters.buy + subtitle_content: Spice.in_theaters.subtitle_content, + rating: false, + buy: Spice.in_theaters.buy } } }); + // Hide the bottom text so that the poster occupies the whole tile. Spice.getDOM('in_theaters').find('.tile__body').addClass('is-hidden'); } - + // Convert minutes to hr. min. format. // e.g. {{time 90}} will return 1 hr. 30 min. Handlebars.registerHelper("InTheaters_time", function(runtime) { var hours = '', minutes = runtime; - if(runtime >= 60) { hours = Math.floor(runtime / 60) + ' hr. '; minutes = (runtime % 60); } - return hours + (minutes > 0 ? minutes + ' min.' : ''); }); -}(this)); +}(this)); \ No newline at end of file From eed687a2e2f2ce320feaee24716f9d2d336a3860 Mon Sep 17 00:00:00 2001 From: jagtalon Date: Fri, 27 Jun 2014 14:24:21 +0000 Subject: [PATCH 2/2] in_theaters.js: Remove the space between comment and function. --- share/spice/in_theaters/in_theaters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/spice/in_theaters/in_theaters.js b/share/spice/in_theaters/in_theaters.js index 055023ab58..72d6e586e5 100644 --- a/share/spice/in_theaters/in_theaters.js +++ b/share/spice/in_theaters/in_theaters.js @@ -1,8 +1,8 @@ (function(env) { "use strict"; + // A change in the Rotten Tomatoes API returns images that end in _tmb. // This changes this to _det. - function toDetail(img) { return img.replace(/tmb\.jpg$/, "det.jpg"); }