Update main.js

Replaced the alerts by text messages and added a little log-function