refactored JS for web interface into a file shared by multiple HTML interfaces