From 79ba03a5a84a4ac5c526cb69f1337b2fdc876c54 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Wed, 24 Dec 2014 15:33:29 +0100 Subject: filtering --- imdb-lookup/html/index-files/css/style.css | 7 ++-- imdb-lookup/html/index-files/js/app.js | 58 ++++++++++++++++++++++-------- imdb-lookup/html/index.html | 57 +++++++++-------------------- imdb-lookup/imdbinfo.py | 15 ++++++-- 4 files changed, 77 insertions(+), 60 deletions(-) (limited to 'imdb-lookup') diff --git a/imdb-lookup/html/index-files/css/style.css b/imdb-lookup/html/index-files/css/style.css index 483d8bb..aa3d234 100644 --- a/imdb-lookup/html/index-files/css/style.css +++ b/imdb-lookup/html/index-files/css/style.css @@ -1,5 +1,5 @@ .box { - margin: 20px 50px auto; + margin: 10px 20px auto; border-radius: 5px; box-shadow: 0px 0px 15px 0px gray; background-color: #fafafa; @@ -55,7 +55,10 @@ font-size: 8pt; vertical-align: center; } -.headline { font-size: 0.9em; color: 3e3e3e; } +.headline { + font-size: 10pt; + color: 3e3e3e; +} .plot { margin-top: 10px; } .consensus { margin-top: 10px; font-style: italic;} .box-footer { diff --git a/imdb-lookup/html/index-files/js/app.js b/imdb-lookup/html/index-files/js/app.js index 3bba2a1..a3a9632 100644 --- a/imdb-lookup/html/index-files/js/app.js +++ b/imdb-lookup/html/index-files/js/app.js @@ -1,8 +1,6 @@ var App = Ember.Application.create(); App.ApplicationAdapter = DS.FixtureAdapter.extend(); - -App.Router.map(function() { // put your routes here -}); +App.Router.map(function() { }); App.IndexRoute = Ember.Route.extend({ model: function() { @@ -12,6 +10,7 @@ App.IndexRoute = Ember.Route.extend({ App.Movie = DS.Model.extend({ title: DS.attr('string'), + summary: DS.attr('string'), path: DS.attr('string'), poster: DS.attr('string'), tagline: DS.attr('string'), @@ -21,16 +20,14 @@ App.Movie = DS.Model.extend({ path: DS.attr(), tags: DS.attr(), - imdbRating: DS.attr('int'), - imdbVotes: DS.attr('int'), + imdbRating: DS.attr('number'), + imdbVotes: DS.attr('number'), omdbTomatoConsensus: DS.attr('string'), - omdbTomato: DS.attr('int'), - omdbUserTomato: DS.attr('int'), + omdbTomatoMeter: DS.attr('number'), omdbTomatoRating: DS.attr(), - omdbTomatoUserRating: DS.attr(), - tmdbId: DS.attr('int'), + tmdbId: DS.attr('number'), linkTmdb: function() { return "http://www.themoviedb.org/movie/" + this.get('tmdbId'); @@ -52,11 +49,19 @@ App.Movie = DS.Model.extend({ App.IndexController = Ember.ArrayController.extend({ page: 1, perPage: "10", + filterTextEntry: "", + filter: "", sortAscending: "false", sortProperties: function() { return [this.get("firstSortProperty")]; }.property("firstSortProperty"), firstSortProperty: "title", + possibleSortProperties: [ {value:"title",label:"Title"}, + {value:"imdbRating", label:"IMDB Rating"}, + {value:"imdbVotes", label:"IMDB Votes"}, + {value:"release", label:"Release Year"}, + {value:"omdbTomatoMeter", label:"RottenTomatoes Meter %"}, + {value:"omdbTomatoRating", label:"RottenTomatoes Rating"}], visiblePerPage: ["10", "20", "25", "50", "100", "250", "500"], pages: function() { var list = []; @@ -89,19 +94,39 @@ App.IndexController = Ember.ArrayController.extend({ list.push({number: i, runningLabel: runningLabel, style: style}); } return list; - }.property('page','perPage','sortProperties','sortAscending'), + }.property('page','perPage','sortProperties','sortAscending','pagesCount'), paginatedContent: function() { var page = this.get('page'); return this._getPaginatedContent(page); - }.property('arrangedContent.[]', 'page', 'perPage'), + }.property('filteredContent.[]', 'page', 'perPage'), + filteredContent: function() { + var filter = this.get("filter").toUpperCase().split(" "); + var content = this.get("arrangedContent"); + return content.filter(function(movie) { + if (movie) { + var title = movie.get("title"); + for (var i = 0; i 1) { this.set('page', current-1); } + }, + applyFilter: function() { + this.set("filter", this.get("filterTextEntry")); } } }); @@ -141,5 +169,5 @@ App.RadioView = Ember.Checkbox.extend({ function dataCb(data) { App.Movie.reopenClass({FIXTURES:data}) } -window['dataCb'] = dataCb; +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4: diff --git a/imdb-lookup/html/index.html b/imdb-lookup/html/index.html index fbce633..deff8b2 100644 --- a/imdb-lookup/html/index.html +++ b/imdb-lookup/html/index.html @@ -12,32 +12,18 @@