Congratulations you're right! You just won 1 million Viggle points!
+ <% } else { %> +Sorry, that wasn't the right character. Keep watching and you'll get it next time.
+ ++ The right one was: +
+ ++ <%= character_name %> +
+ +
+
+
From 1c57161d94906820b0dc9dce23d8b5d8e9b181d1 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 28 Apr 2013 14:36:03 -0400 Subject: When you pick a character, show a dialog The dialog contains a message based on whether or not you had the correct answer. --- TODO | 1 + public/javascripts/app.js | 26 +++++++++++++++-- public/stylesheets/style.css | 32 ++++++++++++++++++++ routes/character-chosen-dialog.js | 11 +++++++ routes/index.js | 4 ++- views/character-chosen-dialog.ejs | 61 +++++++++++++++++++++++++++++++++++++++ views/index.ejs | 4 +-- 7 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 routes/character-chosen-dialog.js create mode 100644 views/character-chosen-dialog.ejs diff --git a/TODO b/TODO index 88040af..331e12f 100644 --- a/TODO +++ b/TODO @@ -11,3 +11,4 @@ v Push to Heroku v Change Coverflow library - Make Leaderboard page - Make Rules page +- Spinner until everything loads 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 = $(''); + $('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'); }; diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index b9d84e1..1c3215e 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -1,6 +1,11 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0} +b { + font-weight: bold; +} + + section.video { position: relative; padding-bottom: 56.25%; @@ -36,6 +41,33 @@ footer { } +/* Character Chosen dialog */ +/* +body.character-chosen-dialog .ui-body-c { + background-color: #ddd; +} +*/ + +#character-chosen-content { + width: 95%; + margin: 0 auto; + position: relative; + top: 2em; +} + +#character-chosen-content h1 { + font-size: 2em; + font-weight: bold; + line-height: 1.2em; + text-align: center; +} + +#character-chosen-content p { + margin-top: 1em; + text-align: center; +} + + /* jQuery Mobile overrides */ .ui-body-c { diff --git a/routes/character-chosen-dialog.js b/routes/character-chosen-dialog.js new file mode 100644 index 0000000..db5a6c0 --- /dev/null +++ b/routes/character-chosen-dialog.js @@ -0,0 +1,11 @@ +module.exports = function(req, res) { + this.success = req.params.success; + + this.data = { + success: this.success, + character_name: req.query.character_name, + character_image_url: req.query.character_image_url + }; + + res.render('character-chosen-dialog', this.data); +}; \ No newline at end of file diff --git a/routes/index.js b/routes/index.js index f0d7c86..20333b5 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,7 +1,9 @@ module.exports = function(app) { var index = require('./home') - , character_images = require('./character-images'); + , character_images = require('./character-images') + , character_chosen_dialog = require('./character-chosen-dialog'); app.get('/', index); app.get('/character-images/:series_id', character_images); + app.get('/character-chosen/:success', character_chosen_dialog); }; \ No newline at end of file diff --git a/views/character-chosen-dialog.ejs b/views/character-chosen-dialog.ejs new file mode 100644 index 0000000..2d37ea4 --- /dev/null +++ b/views/character-chosen-dialog.ejs @@ -0,0 +1,61 @@ + + +
+ + + ++ The right one was: +
+ ++ <%= character_name %> +
+ +
+
+