diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2014-12-24 15:33:29 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2014-12-24 15:33:29 +0100 |
commit | 79ba03a5a84a4ac5c526cb69f1337b2fdc876c54 (patch) | |
tree | 739c607acb07086bbbd4225c8c03472544e18830 /imdb-lookup/html/index-files | |
parent | 3324414ec1299d5bedcb18314360eb242db2b69d (diff) | |
download | scripts-79ba03a5a84a4ac5c526cb69f1337b2fdc876c54.tar.gz scripts-79ba03a5a84a4ac5c526cb69f1337b2fdc876c54.zip |
filtering
Diffstat (limited to 'imdb-lookup/html/index-files')
-rw-r--r-- | imdb-lookup/html/index-files/css/style.css | 7 | ||||
-rw-r--r-- | imdb-lookup/html/index-files/js/app.js | 58 |
2 files changed, 48 insertions, 17 deletions
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<filter.length; i++) { + if (title.toUpperCase().indexOf(filter[i]) == -1) { + return false; + } + } + } + return true; + }); + }.property('arrangedContent.[]', 'page', 'perPage', 'filter'), pagesCount: function() { - return Math.ceil(this.get("content.length") / parseInt(this.get("perPage"))) - }.property('content.[]', 'perPage'), + var contentLength = this.get("filteredContent.length") ; + if (contentLength == 0) { + return 0; + } else { + return Math.ceil(contentLength / parseInt(this.get("perPage"))); + } + }.property('filteredContent.[]', 'perPage'), _getPaginatedContent: function(page) { var perPage = parseInt(this.get('perPage')); var start = (page - 1 ) * perPage; var end = page * perPage; - return this.get('arrangedContent').slice(start, end) + return this.get('filteredContent').slice(start, end) }, actions: { setPage: function(property) { @@ -118,6 +143,9 @@ App.IndexController = Ember.ArrayController.extend({ if (current > 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: |