diff options
| -rw-r--r-- | public/javascripts/app.js | 57 | ||||
| -rw-r--r-- | public/javascripts/main.js | 42 | ||||
| -rw-r--r-- | public/javascripts/parse-interface.js | 37 | ||||
| -rw-r--r-- | routes/character-images.js | 3 | ||||
| -rw-r--r-- | views/index.ejs | 3 |
5 files changed, 101 insertions, 41 deletions
diff --git a/public/javascripts/app.js b/public/javascripts/app.js new file mode 100644 index 0000000..c54651a --- /dev/null +++ b/public/javascripts/app.js @@ -0,0 +1,57 @@ +var App = App || null; + +(function() { + var cApp = function() { + this.characters = null; + this.answer = null; + + + // CoverFlow + var initialise_js_cover_flow = function(playlist) { + coverflow('character-select-container').setup({ + width: '100%', + playlist: playlist, + coverheight: 130, + textoffset: 68 + }).on('ready', function() { + this.on('click', function() { + alert('chosen'); + }); + }); + }; + + this.initialize_video = function(url) { + + }; + + this.get_characters = function(series_id) { + // Populate characters + var that = this; + var $character_container = $('#character-select .flow'); + $.get( + '/character-images/' + series_id, + function(response) { + var r = JSON.parse(response); + + $character_container.empty() + + var playlist = [] + for (var i = 0; i < r.characters.length; i++) { + playlist.push({ + image: r.characters[i].image, + title: r.characters[i].name + }); + } + initialise_js_cover_flow(playlist); + + that.characters = _.pluck(r.characters, 'tms_personId'); + } + ); + }; + + + return this; + }; + + App = new cApp(); +})();
\ No newline at end of file diff --git a/public/javascripts/main.js b/public/javascripts/main.js index b76912e..0c1ba4e 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -1,41 +1,3 @@ -// CoverFlow (function() { - var initialise_js_cover_flow = function(playlist) { - coverflow('character-select-container').setup({ - width: '100%', - playlist: playlist, - coverheight: 130, - textoffset: 68 - }).on('ready', function() { - this.on('click', function() { - alert('chosen'); - }); - }); - }; - - // Populate characters - - // Change template settings to use {{}} delimiters - _.templateSettings = { - interpolate: /\{\{(.+?)\}\}/g - }; - - var $character_container = $('#character-select .flow'); - $.get( - '/character-images/8680539', - function(response) { - var r = JSON.parse(response); - - $character_container.empty() - - var playlist = [] - for (var i = 0; i < r.characters.length; i++) { - playlist.push({ - image: r.characters[i].image, - title: r.characters[i].name - }); - } - initialise_js_cover_flow(playlist); - } - ); -})();
\ No newline at end of file + ParseInterface.get_last_charade(); +})(); diff --git a/public/javascripts/parse-interface.js b/public/javascripts/parse-interface.js new file mode 100644 index 0000000..e58b243 --- /dev/null +++ b/public/javascripts/parse-interface.js @@ -0,0 +1,37 @@ +var ParseInterface = ParseInterface || null; + +(function() { + var cParseInterface = function() { + var application_id = '6jaGjImHFtbJLkAWJRnnLTHfD01nmWHAIrAKNYge'; + var javascript_key = 'zA6og358R2Wg5NVAHWj81zeFz2WQZ5u2AhHFPCjN'; + Parse.initialize(application_id, javascript_key); + + var ContestObject = Parse.Object.extend('ContestObject'); + + this.get_last_charade = function() { + var that = this; + var query = new Parse.Query(ContestObject); + query.limit(1); + query.descending('createdAt'); + query.find({ + success: function(response) { + that._process_charade(response[0]); + } + }); + }; + + this._process_charade = function(contest_instance) { + var video_url = contest_instance.get('video_url'); + var series_id = contest_instance.get('series_id'); + + App.answer = contest_instance.get('personId'); + App.initialize_video(video_url); + App.get_characters(series_id); + }; + + + return this; + }; + + ParseInterface = new cParseInterface(); +})();
\ No newline at end of file diff --git a/routes/character-images.js b/routes/character-images.js index f4ef9b6..a30ee9c 100644 --- a/routes/character-images.js +++ b/routes/character-images.js @@ -42,7 +42,8 @@ module.exports = function(req, res) { that.data.character_images.characters.push({ image: 'http://developer.tmsimg.com/' + r.preferredImage.uri + '?api_key=' + config.tms.key + '&h=100', - name: r.preferredImage.caption.content + name: r.preferredImage.caption.content, + tms_personId: r.personId }); callback(); diff --git a/views/index.ejs b/views/index.ejs index 31d31f3..4b800e5 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -16,6 +16,7 @@ <script src="/javascripts/vendor/js-cover-flow/coverflow.js"></script> <script src="/javascripts/vendor/jquery-2.0.0.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> + <script src="http://www.parsecdn.com/js/parse-1.2.7.min.js"></script> <script src="/javascripts/vendor/underscore-min.js"></script> </head> <body> @@ -43,6 +44,8 @@ </div> </footer> + <script src="/javascripts/app.js"></script> + <script src="/javascripts/parse-interface.js"></script> <script src="/javascripts/main.js"></script> </body> </html> |
