From bd574ef2619443a771be3ff043b6b19c683df785 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 5 Dec 2022 03:39:07 +0100 Subject: [PATCH] WebHost: save datatables state (#1145) * WebHost: save datatables state * WebHost: Fix DataTables local storage keys. Co-authored-by: recklesscoder <57289227+recklesscoder@users.noreply.github.com> --- WebHostLib/static/assets/autodatatable.js | 1 + WebHostLib/static/assets/tracker.js | 7 +++++++ WebHostLib/static/assets/userContent.js | 2 ++ WebHostLib/templates/checkResult.html | 2 +- WebHostLib/templates/genericTracker.html | 4 ++-- WebHostLib/templates/tracker.html | 6 +++--- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/WebHostLib/static/assets/autodatatable.js b/WebHostLib/static/assets/autodatatable.js index a1437514..d1cf9a6f 100644 --- a/WebHostLib/static/assets/autodatatable.js +++ b/WebHostLib/static/assets/autodatatable.js @@ -4,6 +4,7 @@ window.addEventListener('load', () => { "ordering": true, "info": false, "dom": "t", + "stateSave": true, }); console.log(tables); }); diff --git a/WebHostLib/static/assets/tracker.js b/WebHostLib/static/assets/tracker.js index c4b59958..0eeda35a 100644 --- a/WebHostLib/static/assets/tracker.js +++ b/WebHostLib/static/assets/tracker.js @@ -17,6 +17,13 @@ window.addEventListener('load', () => { paging: false, info: false, dom: "t", + stateSave: true, + stateSaveCallback: function(settings,data) { + localStorage.setItem(`DataTables_${settings.sInstance}_/tracker`, JSON.stringify(data)); + }, + stateLoadCallback: function(settings) { + return JSON.parse(localStorage.getItem(`DataTables_${settings.sInstance}_/tracker`)); + }, columnDefs: [ { targets: 'hours', diff --git a/WebHostLib/static/assets/userContent.js b/WebHostLib/static/assets/userContent.js index dcc8f565..18061733 100644 --- a/WebHostLib/static/assets/userContent.js +++ b/WebHostLib/static/assets/userContent.js @@ -6,6 +6,7 @@ window.addEventListener('load', () => { "order": [[ 3, "desc" ]], "info": false, "dom": "t", + "stateSave": true, }); $("#seeds-table").DataTable({ "paging": false, @@ -13,5 +14,6 @@ window.addEventListener('load', () => { "order": [[ 2, "desc" ]], "info": false, "dom": "t", + "stateSave": true, }); }); diff --git a/WebHostLib/templates/checkResult.html b/WebHostLib/templates/checkResult.html index 45a21ae7..c245d738 100644 --- a/WebHostLib/templates/checkResult.html +++ b/WebHostLib/templates/checkResult.html @@ -12,7 +12,7 @@

Verification Results

The results of your requested file check are below.

- +
diff --git a/WebHostLib/templates/genericTracker.html b/WebHostLib/templates/genericTracker.html index 2a48c66f..fa070ea6 100644 --- a/WebHostLib/templates/genericTracker.html +++ b/WebHostLib/templates/genericTracker.html @@ -15,7 +15,7 @@ This tracker will automatically update itself periodically.
-
File
+
@@ -37,7 +37,7 @@
Item
- +
diff --git a/WebHostLib/templates/tracker.html b/WebHostLib/templates/tracker.html index 889ed2b2..4b97d67e 100644 --- a/WebHostLib/templates/tracker.html +++ b/WebHostLib/templates/tracker.html @@ -25,7 +25,7 @@
{% for team, players in inventory.items() %}
-
Location
+
@@ -78,7 +78,7 @@ {% for team, players in checks_done.items() %}
-
#
+
@@ -153,7 +153,7 @@ {% endfor %} {% for team, hints in hints.items() %}
-
#
+
Finder