diff options
| author | Teddy Wing | 2013-04-28 12:33:33 -0400 |
|---|---|---|
| committer | Teddy Wing | 2013-04-28 12:35:05 -0400 |
| commit | 9abf6afec1beaaa137090aec42c6a133b2e47b6e (patch) | |
| tree | aef565cd667e200ccea2daaad51c8d99aa466726 | |
| parent | e345c618b1c9b2f9301c794defdf36b0f7d6d676 (diff) | |
| download | Who-am-I-9abf6afec1beaaa137090aec42c6a133b2e47b6e.tar.bz2 | |
Enable way to respond on correct answer
| -rw-r--r-- | public/javascripts/app.js | 26 | ||||
| -rw-r--r-- | public/javascripts/parse-interface.js | 4 |
2 files changed, 21 insertions, 9 deletions
diff --git a/public/javascripts/app.js b/public/javascripts/app.js index f78b204..9bd769b 100644 --- a/public/javascripts/app.js +++ b/public/javascripts/app.js @@ -4,11 +4,12 @@ var App = App || null; var cApp = function() { this.characters = []; this.answer = null; + this.answer_name = ''; this.playlist = [] // CoverFlow - var initialise_js_cover_flow = function(playlist) { + this.initialise_js_cover_flow = function(playlist) { var that = this; coverflow('character-select-container').setup({ width: '100%', @@ -18,10 +19,10 @@ var App = App || null; }).on('ready', function() { var the_other = that; this.on('click', function(e) { -// if (the_other.answer == - console.log(e); - var selection = this.playlist[e]; -// alert('chosen'); + if (the_other.playlist[e].title == the_other.answer_name) { + // Answered correctly + the_other.correct_answer(); + } }); }); }; @@ -30,9 +31,12 @@ var App = App || null; console.log(url); }; - this.get_characters = function(series_id) { + this.get_characters = function(series_id, params) { // Populate characters var that = this; + var params = params || { + answer_id: -1 + }; var $character_container = $('#character-select .flow'); $.get( '/character-images/' + series_id, @@ -51,12 +55,20 @@ var App = App || null; personId: r.characters[i].tms_personId, name: r.characters[i].name }); + + if (params.answer_id == r.characters[i].tms_personId) { + that.answer_name = r.characters[i].name; + } } - initialise_js_cover_flow(that.playlist); + that.initialise_js_cover_flow(that.playlist); } ); }; + this.correct_answer = function() { + alert('chosen'); + }; + return this; }; diff --git a/public/javascripts/parse-interface.js b/public/javascripts/parse-interface.js index e58b243..717f059 100644 --- a/public/javascripts/parse-interface.js +++ b/public/javascripts/parse-interface.js @@ -24,9 +24,9 @@ var ParseInterface = ParseInterface || null; var video_url = contest_instance.get('video_url'); var series_id = contest_instance.get('series_id'); - App.answer = contest_instance.get('personId'); + App.answer = contest_instance.get('person_id'); App.initialize_video(video_url); - App.get_characters(series_id); + App.get_characters(series_id, { answer_id: App.answer }); }; |
