summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/templates
diff options
context:
space:
mode:
authorSimon Rettberg2017-12-19 12:35:22 +0100
committerSimon Rettberg2017-12-19 12:35:22 +0100
commitcf9cf089478d5713e83339e02d4164efaa30ed28 (patch)
tree7c869df19c48567b698ec8d655de3dc92fcb8ad2 /modules-available/locationinfo/templates
parent[locationinfo] Reload panels when opening times are changed (diff)
downloadslx-admin-cf9cf089478d5713e83339e02d4164efaa30ed28.tar.gz
slx-admin-cf9cf089478d5713e83339e02d4164efaa30ed28.tar.xz
slx-admin-cf9cf089478d5713e83339e02d4164efaa30ed28.zip
[locationinfo] Fix infinite reload loop
Diffstat (limited to 'modules-available/locationinfo/templates')
-rw-r--r--modules-available/locationinfo/templates/frontend-summary.html32
1 files changed, 29 insertions, 3 deletions
diff --git a/modules-available/locationinfo/templates/frontend-summary.html b/modules-available/locationinfo/templates/frontend-summary.html
index ec5d8aab..4105dd16 100644
--- a/modules-available/locationinfo/templates/frontend-summary.html
+++ b/modules-available/locationinfo/templates/frontend-summary.html
@@ -226,8 +226,8 @@
queryRooms();
nextUpdate = 1000;
}
- for (property in rooms) {
- upDateRoomState(rooms[property]);
+ if (nextUpdate !== 1000) {
+ queryPanelChange();
}
clearTimeout(timeout);
setTimeout(update, nextUpdate);
@@ -267,7 +267,9 @@
}
ComputeCurrentState(rooms[json[i].id]);
}
- update();
+ for (property in rooms) {
+ upDateRoomState(rooms[property]);
+ }
}
/**
@@ -765,6 +767,30 @@
});
}
+ /**
+ * Checks whether the panel has been edited and reloads
+ * the entire page if so.
+ */
+ function queryPanelChange() {
+ $.ajax({
+ url: "{{dirprefix}}api.php?do=locationinfo&get=timestamp&uuid={{uuid}}",
+ dataType: 'json',
+ cache: false,
+ timeout: 5000,
+ success: function (result) {
+ if (!result || !result.ts) {
+ console.log('Warning: get=timestamp didnt return json with ts field');
+ return;
+ }
+ if (config.ts && config.ts !== result.ts) {
+ // Change
+ window.location.reload(true);
+ }
+ config.ts = result.ts;
+ }
+ })
+ }
+
</script>
</head>
<body>