moved js-code from html to js file