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>
This commit is contained in:
Fabian Dill 2022-12-05 03:39:07 +01:00 committed by GitHub
parent 45719eb7e0
commit bd574ef261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 6 deletions

View File

@ -4,6 +4,7 @@ window.addEventListener('load', () => {
"ordering": true, "ordering": true,
"info": false, "info": false,
"dom": "t", "dom": "t",
"stateSave": true,
}); });
console.log(tables); console.log(tables);
}); });

View File

@ -17,6 +17,13 @@ window.addEventListener('load', () => {
paging: false, paging: false,
info: false, info: false,
dom: "t", 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: [ columnDefs: [
{ {
targets: 'hours', targets: 'hours',

View File

@ -6,6 +6,7 @@ window.addEventListener('load', () => {
"order": [[ 3, "desc" ]], "order": [[ 3, "desc" ]],
"info": false, "info": false,
"dom": "t", "dom": "t",
"stateSave": true,
}); });
$("#seeds-table").DataTable({ $("#seeds-table").DataTable({
"paging": false, "paging": false,
@ -13,5 +14,6 @@ window.addEventListener('load', () => {
"order": [[ 2, "desc" ]], "order": [[ 2, "desc" ]],
"info": false, "info": false,
"dom": "t", "dom": "t",
"stateSave": true,
}); });
}); });

View File

@ -12,7 +12,7 @@
<div id="check-result" class="grass-island"> <div id="check-result" class="grass-island">
<h1>Verification Results</h1> <h1>Verification Results</h1>
<p>The results of your requested file check are below.</p> <p>The results of your requested file check are below.</p>
<table class="table autodatatable"> <table id="results-table" class="table autodatatable">
<thead> <thead>
<tr> <tr>
<th>File</th> <th>File</th>

View File

@ -15,7 +15,7 @@
<span class="info">This tracker will automatically update itself periodically.</span> <span class="info">This tracker will automatically update itself periodically.</span>
</div> </div>
<div class="table-wrapper"> <div class="table-wrapper">
<table class="table non-unique-item-table"> <table id="received-table" class="table non-unique-item-table">
<thead> <thead>
<tr> <tr>
<th>Item</th> <th>Item</th>
@ -37,7 +37,7 @@
</table> </table>
</div> </div>
<div class="table-wrapper"> <div class="table-wrapper">
<table class="table non-unique-item-table"> <table id="locations-table" class="table non-unique-item-table">
<thead> <thead>
<tr> <tr>
<th>Location</th> <th>Location</th>

View File

@ -25,7 +25,7 @@
<div id="tables-container"> <div id="tables-container">
{% for team, players in inventory.items() %} {% for team, players in inventory.items() %}
<div class="table-wrapper"> <div class="table-wrapper">
<table class="table unique-item-table"> <table id="inventory-table" class="table unique-item-table">
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
@ -78,7 +78,7 @@
{% for team, players in checks_done.items() %} {% for team, players in checks_done.items() %}
<div class="table-wrapper"> <div class="table-wrapper">
<table class="table non-unique-item-table"> <table id="checks-table" class="table non-unique-item-table">
<thead> <thead>
<tr> <tr>
<th rowspan="2">#</th> <th rowspan="2">#</th>
@ -153,7 +153,7 @@
{% endfor %} {% endfor %}
{% for team, hints in hints.items() %} {% for team, hints in hints.items() %}
<div class="table-wrapper"> <div class="table-wrapper">
<table class="table non-unique-item-table" data-order='[[5, "asc"], [0, "asc"]]'> <table id="hints-table" class="table non-unique-item-table" data-order='[[5, "asc"], [0, "asc"]]'>
<thead> <thead>
<tr> <tr>
<th>Finder</th> <th>Finder</th>