aboutsummaryrefslogtreecommitdiffstats
path: root/public/javascripts
diff options
context:
space:
mode:
authorTeddy Wing2013-04-28 14:36:03 -0400
committerTeddy Wing2013-04-28 14:36:03 -0400
commit1c57161d94906820b0dc9dce23d8b5d8e9b181d1 (patch)
tree5516464872e3e5d92ae97ba7395028c042f88694 /public/javascripts
parent5352d970ba2982ea0e525ffdc4b84b730f2afcf7 (diff)
downloadWho-am-I-1c57161d94906820b0dc9dce23d8b5d8e9b181d1.tar.bz2
When you pick a character, show a dialog
The dialog contains a message based on whether or not you had the correct answer.
Diffstat (limited to 'public/javascripts')
-rw-r--r--public/javascripts/app.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/public/javascripts/app.js b/public/javascripts/app.js
index c700880..759c5eb 100644
--- a/public/javascripts/app.js
+++ b/public/javascripts/app.js
@@ -5,6 +5,7 @@ var App = App || null;
this.characters = [];
this.answer = null;
this.answer_name = '';
+ this.answer_image_url = '';
this.playlist = []
@@ -21,7 +22,10 @@ var App = App || null;
this.on('click', function(e) {
if (the_other.playlist[e].title == the_other.answer_name) {
// Answered correctly
- the_other.correct_answer();
+ the_other.pick_character({ correct: true });
+ }
+ else {
+ the_other.pick_character({ correct: false });
}
});
});
@@ -61,6 +65,7 @@ var App = App || null;
if (params.answer_id == r.characters[i].tms_personId) {
that.answer_name = r.characters[i].name;
+ that.answer_image_url = r.characters[i].image
}
}
that.initialise_js_cover_flow(that.playlist);
@@ -68,8 +73,23 @@ var App = App || null;
);
};
- this.correct_answer = function() {
- alert('chosen');
+ this.pick_character = function(params) {
+ var params = params || {
+ correct: false
+ };
+
+ var $open_dialog_button = $('<a id="character-chosen-dialog-button" href="#" data-transition="slideup" style="display: none;"></a>');
+ $('body').append($open_dialog_button);
+ var $open_dialog_button_in_dom = $('#character-chosen-dialog-button');
+
+ if (params.correct) {
+ $open_dialog_button_in_dom.attr('href', '/character-chosen/true');
+ }
+ else {
+ $open_dialog_button_in_dom.attr('href', '/character-chosen/false/?character_name=' + this.answer_name + '&character_image_url=' + this.answer_image_url);
+ }
+
+ $open_dialog_button_in_dom.trigger('click');
};