Added listener to refresh when player logs in.
Moved common functions to shared js file.