Add an unload check to scouting page.

Preferably, we'd save the data locally. For now, this will generally
work to prevent the user losing data due to accidental refresh.

Change-Id: Icecdc18b12948941278d3511a55649b2ccc8cd79
Signed-off-by: Alex Perry <alex.perry96@gmail.com>
diff --git a/scouting/www/app.ts b/scouting/www/app.ts
index e22fad0..79c1094 100644
--- a/scouting/www/app.ts
+++ b/scouting/www/app.ts
@@ -10,6 +10,15 @@
 export class App {
   tab: Tab = 'Entry';
 
+  constructor() {
+    window.addEventListener('beforeunload', (e) => {
+      // Based on https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#example
+      // This combination ensures a dialog will be shown on most browsers.
+      e.preventDefault();
+      e.returnValue = '';
+    });
+  }
+
   tabIs(tab: Tab) {
     return this.tab == tab;
   }