summaryrefslogtreecommitdiff
path: root/imdb-lookup/js/app.js
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2014-12-20 04:59:41 +0100
committerYves Fischer <yvesf-git@xapek.org>2014-12-20 04:59:41 +0100
commit9089d2eb4bc34994abaf6ed173e95c97243789cd (patch)
tree97b092f159c73a10f88dc62bb3fb086ec85ac5ed /imdb-lookup/js/app.js
parenta9e676eb8af8f9881c152dacbea450610e8002fa (diff)
downloadscripts-9089d2eb4bc34994abaf6ed173e95c97243789cd.tar.gz
scripts-9089d2eb4bc34994abaf6ed173e95c97243789cd.zip
search and sort
Diffstat (limited to 'imdb-lookup/js/app.js')
-rw-r--r--imdb-lookup/js/app.js45
1 files changed, 34 insertions, 11 deletions
diff --git a/imdb-lookup/js/app.js b/imdb-lookup/js/app.js
index b49d1c9..03819e6 100644
--- a/imdb-lookup/js/app.js
+++ b/imdb-lookup/js/app.js
@@ -5,19 +5,19 @@ App.Router.map(function() { // put your routes here
});
App.IndexRoute = Ember.Route.extend({
- model: function() {
- return this.store.find('movies')
- }
+ model: function() {
+ return this.store.findAll('movie');
+ }
});
-App.Movies = DS.Model.extend({
- FIXTURES : [],
+App.Movie = DS.Model.extend({
title: DS.attr('string'),
path: DS.attr('string'),
poster: DS.attr('string'),
tagline: DS.attr('string'),
plot: DS.attr('string'),
website: DS.attr('string'),
+ release: DS.attr('string'),
movieFiles: DS.attr(),
imdbRating: DS.attr('int'),
@@ -30,8 +30,10 @@ App.Movies = DS.Model.extend({
omdbTomatoUserRating: DS.attr(),
omdbTomatoFresh: DS.attr('int'),
- tmdbId: DS.attr('int'),
-
+ tmdbId: DS.attr('int')
+})
+
+App.MovieController = Ember.ObjectController.extend({
linkTmdb: function() {
return "http://www.themoviedb.org/movie/" + this.get('tmdbId');
}.property('tmdbId'),
@@ -44,7 +46,30 @@ App.Movies = DS.Model.extend({
linkOfdb: function() {
return "http://www.ofdb.de/view.php?page=suchergebnis&Kat=IMDb&SText=" + this.get('id');
}.property('id')
-})
+});
+
+App.IndexController = Ember.ArrayController.extend({
+ itemController: 'movie',
+ filter: '',
+ filteredContent: function(){
+ var filter = this.get('filter');
+ var content = this.get('arrangedContent');
+ if (filter.length > 2) {
+ var rx = new RegExp(filter, 'gi');
+ return content.filter(function(movie) {
+ return movie && movie.get('title').match(rx);
+ });
+ } else {
+ return content;
+ }
+ }.property('arrangedContent', 'filter'),
+ actions: {
+ sortBy: function(property) {
+ this.set('sortProperties', [property]);
+ this.set('sortAscending', !this.get('sortAscending'));
+ }
+ }
+});
Ember.Handlebars.helper('filelink', function(value, options) {
var escaped = encodeURIComponent(value);
@@ -52,9 +77,7 @@ Ember.Handlebars.helper('filelink', function(value, options) {
});
function dataCb(data) {
- App.Movies.reopenClass({
- FIXTURES : data
- });
+ App.Movie.FIXTURES = data;
}
window['dataCb'] = dataCb;