diff --git a/js/app.js b/js/app.js index c7f7df3..3f479e6 100755 --- a/js/app.js +++ b/js/app.js @@ -21,20 +21,9 @@ var groups = [ {id: "1", name: "sf"}, {id: "2", name: "major"} ]; -var theaters = [ - {id: "1", name: 'Sf Emporium', code: "9909"}, - {id: "2", name: 'Sf NgamWongWan', code: "9934"} -]; - -var showtimes = [ - {id: "1", name: "The Cove (1999)", showtimes: ['10:30', '13:30']}, - {id: "2", name: "The Notebook (2004)", showtimes: ['15:30', '17:30']}, -]; - var restUrl = 'http://showtimes.everyday.in.th/api'; var today = new Date(); - App.Router.map(function() { this.resource('about'); this.resource('api'); @@ -53,11 +42,14 @@ App.GroupsRoute = Ember.Route.extend({ App.TheatersRoute = Ember.Route.extend({ model: function(params) { - return $.getJSON(restUrl+'/theaters/'+params.name+'/'); + return $.getJSON(restUrl+'/theaters/'+params.name+'/').then(function(data) { + return data.objects.map(function(theater) { + return theater; + }); + }); } }); - App.ShowtimesRoute = Ember.Route.extend({ model: function(params) { var theatersObjs = this.modelFor('theaters'); @@ -65,7 +57,11 @@ App.ShowtimesRoute = Ember.Route.extend({ restUrl, '/showtimes/', theatersObjs[0].group, '/', params.code, '/?d=', moment(today).format('YYYY-MM-DD') ]; - return $.getJSON(url.join('')); + return $.getJSON(url.join('')).then(function(data) { + return data.objects.map(function(showtimesItem) { + return showtimesItem; + }); + }); } });