change onbeforeunload to onunload for wider compatibility
move tempo value to localStorage instead of page unload for max compatibility (eg. iOS home screen)
Merge branch 'master' into gh-pages