Moved functions from index.html to models.js

Moved function to check if the simulation is ended from index.html to
startup() in models.js
Added some functionality for the remote database to database.js