Update main.js

Greatly reduced the amount of Javascript necessary through the use of backend Python and some jQuery.