Skip to content

Commit

Permalink
1119 Privacy - Query Page and Dom.storage
Browse files Browse the repository at this point in the history
implement memory storage for functionality in case of no storage

Signed-off-by: Chris Miceli <chrismiceli@outlook.com>
  • Loading branch information
chrismiceli committed Feb 6, 2022
1 parent 99c7182 commit bb2934e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/pi-hole/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,20 @@ function setBsSelectDefaults() {
};
}

var backupStorage = {};
function stateSaveCallback(itemName, data) {
localStorage.setItem(itemName, JSON.stringify(data));
if (localStorage === null) {
backupStorage[itemName] = JSON.stringify(data);
} else {
localStorage.setItem(itemName, JSON.stringify(data));
}
}

function stateLoadCallback(itemName) {
// Receive previous state from client's local storage area
var data = localStorage ? localStorage.getItem(itemName) : null;
var data =
localStorage === null ? backupStorage[itemName] || null : localStorage.getItem(itemName);

// Return if not available
if (data === null) {
return null;
Expand Down

0 comments on commit bb2934e

Please sign in to comment.