var loggedIn = false; // true after swiping the cards
var timeToLogout = undefined; // defined during logout countdown
var logoutTimer;
+var reloadTimer = undefined;
console.log("hello from flask");
//sendJSON("{\"type\":\"empty\"}");
if (updateRemote === undefined) {
update("remote", "<center>Server offline...</center>");
document.getElementById("local").style.display = "block";
+ loadRemote();
} else {
document.getElementById("local").style.display = "none";
function loadRemote(string) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- update("remote", this.responseText);
- updateRemote = hiddenUpdateRemote;
- loadLocalStorage();
- updateUI();
+ if (this.readyState == 4) {
+ if (this.status == 200) {
+ update("remote", this.responseText);
+ updateRemote = hiddenUpdateRemote;
+ loadLocalStorage();
+ updateUI();
+ clearTimeout(reloadTimer);
+ } else {
+ reloadTimer = setTimeout(loadRemote, 1000);
+ }
}
};
xhr.open("GET", flask, true);