CharlieTruong/sinatra_flash_card — pull request #17 by CharlieTruong (2014-02-01 22:44:38+00:00)
Title: Flash Card Game Logic Updated with Javascript 

This is a pretty big change, and I'm okay if you don't want to use it. I may just create a new repo so you can download and see it running more easily.

I modified the guts of the game logic to mostly use jQuery/Javascript. It's technically not Ajax since the user does need to initially wait at the beginning and end for data to be sent from and to the server.

Basically, now, the server sends a JSON file with all the questions and answers. Once that happens, the game logic just uses Javascript and JQuery, recording within the browser the user's progress. After the final question, it then sends via Ajax the user's performance and the stats page is loaded.

Some nice UI features are that the user now sees the feedback with the associated question after submitting it. They then need to hit a 'next' button (or press enter) to move on. I bound the enter button to react as the button click for the on screen button (whether "guess","next", or "submit").

Also, once a user submits the guess, the input box is disabled, preventing them from changing their answer. They can only read the feedback and move forward.

If the user tries to go to a different site or close the window, then a warning is given, notifying them that all progress will be lost. The exception, of course, is on the final submission and redirect to the /stats page.

A progress bar has also been added for a user to know where they are in the round.