Thesis is a project mainly written in JAVASCRIPT and RUBY, it's free.
Master degree thesis
Read the code, it's simple...