Added a main method to the JS code so that it can interact with the simple web page. Note this is very rudimentary so far, and it does not do error handling.