Move some duplicated code to utils.js

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner
2020-05-22 13:48:31 +01:00
committed by XhmikosR
parent eb05394b66
commit 3957e9eef1
13 changed files with 54 additions and 143 deletions

View File

@@ -5,7 +5,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
/* global moment:false */
/* global moment:false, utils:false */
var tableApi;
@@ -186,24 +186,10 @@ $(document).ready(function () {
],
stateSave: true,
stateSaveCallback: function (settings, data) {
// Store current state in client's local storage area
localStorage.setItem("network_table", JSON.stringify(data));
utils.stateSaveCallback("network_table", data);
},
stateLoadCallback: function () {
// Receive previous state from client's local storage area
var data = localStorage.getItem("network_table");
// Return if not available
if (data === null) {
return null;
}
data = JSON.parse(data);
// Always start on the first page
data.start = 0;
// Always start with empty search field
data.search.search = "";
// Apply loaded state to table
return data;
return utils.stateLoadCallback("network_table");
},
columnDefs: [
{