Added main function calcFields()

I add the main function to the external main.js file