You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by hu...@apache.org on 2016/02/05 11:58:01 UTC

svn commit: r1728635 - /steve/trunk/pysteve/www/htdocs/js/steve_monitor.js

Author: humbedooh
Date: Fri Feb  5 10:58:01 2016
New Revision: 1728635

URL: http://svn.apache.org/viewvc?rev=1728635&view=rev
Log:
try to save state in localStorage so browsers can resume after window has been closed.

Modified:
    steve/trunk/pysteve/www/htdocs/js/steve_monitor.js

Modified: steve/trunk/pysteve/www/htdocs/js/steve_monitor.js
URL: http://svn.apache.org/viewvc/steve/trunk/pysteve/www/htdocs/js/steve_monitor.js?rev=1728635&r1=1728634&r2=1728635&view=diff
==============================================================================
--- steve/trunk/pysteve/www/htdocs/js/steve_monitor.js (original)
+++ steve/trunk/pysteve/www/htdocs/js/steve_monitor.js Fri Feb  5 10:58:01 2016
@@ -36,6 +36,7 @@ function getJSON(theUrl, xstate, callbac
 
 function getIssues() {
     election = document.location.search.substr(1)
+    fetchData(election)
     getJSON("/steve/admin/view/" + election, election, listIssues)
 }
 
@@ -50,6 +51,40 @@ var recasters = {}
 var rigged = false
 var riggedIssues = {}
 
+function saveData(election) {
+    if (typeof(window.localStorage) !== "undefined" ) {
+        var d = window.localStorage.getItem("monitor_" + election)
+        var js = {
+            issues: issues,
+            basedata: basedata,
+            votes: votes,
+            oldvotes: oldvotes,
+            recasts: recasts,
+            recasters: recasters,
+            rigged: rigger,
+            riggedIssues: riggedIssues
+        }
+        window.localStorage.SetItem("monitor_" + election, JSON.stringify(js))
+    }
+}
+
+function fetchData(election) {
+    if (typeof(window.localStorage) !== "undefined" ) {
+        var d = window.localStorage.getItem("monitor_" + election)
+        if (d) {
+            var js = JSON.parse(d)
+            issues = js.issues
+            basedata = js.basedata
+            votes = js.votes
+            oldvotes = js.oldvotes
+            recasts = js.recasts
+            recasters = js.recasters
+            rigged = js.rigged
+            riggedIssues = js.riggedIssues
+        }
+    }
+}
+
 function listIssues(code, response, election) {
     if (code == 200) {
         eid = election
@@ -197,10 +232,9 @@ function showChanges(issue) {
             header.innerHTML = "No votes cast yet..!"
         }
     }
+    saveData(election)
     getJSON("/steve/admin/monitor/" + eid + "/" + issue.id, issue.id, updateVotes)
     
-    
-    
 }