Refactored view.html, fixes #213
Moved JS to fragments