Update js/main.js

Add base function code