Created
July 25, 2014 14:47
-
-
Save imsickofmaps/93bb08c5d0143883fa60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Show questions in topic x | |
self.states.add('states_questions', function(name, opts) { | |
return go.utils.get_snappy_questions(self.im, | |
self.im.config.snappy.default_faq, self.im.user.answers.states_start) | |
.then(function(response) { | |
if (typeof response.data.error !== 'undefined') { | |
// TODO Throw proper error | |
return error; | |
} else { | |
var choices = response.data.map(function(d) { | |
return new Choice(d.id, d.question); | |
}); | |
return { | |
choices: choices, | |
api_response: response | |
}; | |
} | |
}) | |
.then(function(choices, api_response) { | |
return new ChoiceState(name, { | |
question: $('Please choose a question:'), | |
choices: choices, | |
next: function(){ | |
return { | |
name: 'states_answers', | |
creator_opts: api_response | |
}; | |
} | |
}); | |
}); | |
}); | |
// Show answer in question x | |
self.states.add('states_answers', function(name, opts) { | |
pages = opts.data; | |
return new BookletState(name, { | |
pages: pages.length, | |
page_text: function(n) {return pages[n];}, | |
buttons: {"1": -1, "2": +1, "3": "exit"}, | |
footer_text:$([ | |
"1. Prev", | |
"2. Next", | |
"3. Exit" | |
].join("\n")), | |
next: 'states_end' | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment