Attach button event handlers in Javascript
Restructure Javascript code and allow choosing renderer