Moved javascript objects from template.js to main class