Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Merge branch 'in_theater_update' of https://github.com/killerfish/zer…
Browse files Browse the repository at this point in the history
…oclickinfo-spice into test

Conflicts:
	share/spice/in_theaters/in_theaters.js
  • Loading branch information
jagtalon committed Jul 29, 2014
2 parents b6a8bd8 + 79239fb commit 4dca80e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
18 changes: 17 additions & 1 deletion lib/DDG/Spice/InTheaters.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ my %movies = (
'pg movies opening' => 0,
'pg-13 movies opening' => 0,
'g movies opening' => 0,
'pg13 movies opening' => 0,
'unrated movies opening' => 0,
'see an r movie' => 1,
'see a pg movie' => 1,
'see a pg-13 movie' => 1,
'see a g movie' =>1,
'see a pg13 movie' =>1,
'see an unrated movie' =>1,
'pg13 movies opening soon' => 0,
'unrated movies opening soon' => 0,
'r movies opening soon' => 0,
'pg movies opening soon' => 0,
'pg-13 movies opening soon' => 0,
Expand All @@ -51,29 +57,39 @@ my %movies = (
'i want to watch an r movie' => 1,
'i want to watch a pg movie' => 1,
'i want to watch a pg-13 movie' =>1,
'i want to watch a pg13 movie' =>1,
'i want to watch an unrated movie' =>1,
'i want to watch something' => 1,
'watch something' => 1,
'need to watch a movie' => 1,
'need to watch an r movie' => 1,
'need to watch a pg movie' => 1,
'need to watch a pg-13 movie' => 1,
'need to watch a g movie' => 1,
'need to watch a pg13 movie' => 1,
'need to watch an unrated movie' => 1,
'watch an r movie' => 1,
'watch a pg movie' => 1,
'watch an pg-13 movie' => 1,
'watch a pg-13 movie' => 1,
'watch a g movie' => 1,
'watch a pg13 movie' => 1,
'watch an unrated movie' => 1,
'theaters' => 0,
'theatres' => 0,
'movies' => 1,
'r movies' => 1,
'pg movies' => 1,
'pg-13 movies' => 1,
'g movies' => 1,
'pg13 movies' => 1,
'unrated movies' => 1,
'movies in theaters' => 1,
'r movies in theaters' => 1,
'pg movies in theaters' => 1,
'pg-13 movies in theaters' => 1,
'g movies in theaters' => 1,
'pg13 movies in theaters' => 1,
'unrated movies in theaters' => 1,
'movies currently in theaters' => 1,
'movies currently in theatres' => 1,
'currently in theaters' => 1,
Expand Down
36 changes: 33 additions & 3 deletions share/spice/in_theaters/in_theaters.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,23 @@
if(!api_result || api_result.error) {
return Spice.failed('in_theaters');
}


var mod_api_result = [];
var filter_rating;
var query_array = DDG.get_query().toLowerCase().split(" ");
var ratings = ["r","pg-13","pg","g","pg13","unrated"];

// Check whether our query contains any rating
$.each(ratings, function(index, value) {
if(($.inArray(value, query_array)) !== -1) {
if(value === "pg13") {
filter_rating = "pg-13";
} else {
filter_rating = value;
}
}
});

Spice.add({
id: 'in_theaters',
name: 'Movies',
Expand All @@ -35,6 +51,18 @@
itemType: 'Movies'
},
normalize: function(item) {
if (filter_rating && item.mpaa_rating.toLowerCase() !== filter_rating) {
return null;
}

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)
Expand Down Expand Up @@ -62,7 +90,9 @@
});

// Hide the bottom text so that the poster occupies the whole tile.
Spice.getDOM('in_theaters').find('.tile__body').addClass('is-hidden');
if(typeof Spice.getDOM('in_theaters') !== 'undefined') {
Spice.getDOM('in_theaters').find('.tile__body').addClass('is-hidden');
}
}

// Convert minutes to hr. min. format.
Expand All @@ -76,4 +106,4 @@
}
return hours + (minutes > 0 ? minutes + ' min.' : '');
});
}(this));
}(this));

0 comments on commit 4dca80e

Please sign in to comment.