jivid/akobi — pull request #61 by jivid (2014-06-14 03:37:07+00:00)
Title: Refactor JS code to add structure

Lots of structural changes to our JS code.

- We now use backbone.js to separate out code into a MVC layout
- Require.js is used to load modules as needed
- There is an 'interview' variable accessible to all client-side code on a per-client basis. It has information regarding the interview and the client that is currently connected.
- Created a central 'EventBus' used to send events across modules. Modules can subscribe to specific events and register callbacks on them. This makes it very easy to call a method on another module without explicitly doing so
- Created a simple stats counter local to the client. Can be invoked using the countMe function. It will increment counters for a specific key
- Simple applications like heartbeat don't need to be in a model or view. Just a function that is registered as a callback on the heartbeat message event
- Enforced some basic code structure: all data should reside in a Backbone Model, anything interacting with the UI should be in a Backbone View
- Moved all external dependencies to an 'ext' folder
- Notes are now collected based on focus of the textbox as opposed to all the time. When in focus, the contents of the textarea are pulled every 50ms (this can be changed), and when the textarea loses focus, the collection is stopped and the current state sent up to the server

The entrypoint is 'static/js/main.js' so start from there if you want to sequentially run through the code

NOTE: Right now the scripts are being loaded from a fileserver running locally on my machine, and so the link is 127.0.0.1. This will be changed before merging.