remove function for checking for sessionStorage

This commit is contained in:
Fabian Franz 2017-12-02 19:32:47 +01:00
parent b2f0465cec
commit 062bdb294d
3 changed files with 9 additions and 23 deletions

View File

@ -39,21 +39,7 @@
function htmlDecode(value) {
return $("<textarea/>").html(value).text();
}
/**
* Check if sessionStorage is available
*
* @return boolean if sessionStorage is available.
*/
function checkSessionStorageExists() {
if ('sessionStorage' in window) {
if (window.sessionStorage != null) {
return true;
}
}
return false;
}
/**
*
@ -255,7 +241,7 @@ function watchScrollPosition() {
}
// link on scroll event handler
if (checkSessionStorageExists()) {
if (window.sessionStorage) {
$(window).scroll(function(){
sessionStorage.setItem('scrollpos', current_location()+"|"+$(window).scrollTop());
});

View File

@ -244,7 +244,7 @@ function initFormHelpUI() {
$('[id*="show_all_help"]').toggleClass("fa-toggle-on fa-toggle-off");
$('[id*="show_all_help"]').toggleClass("text-success text-danger");
if ($('[id*="show_all_help"]').hasClass("fa-toggle-on")) {
if (checkSessionStorageExists()) {
if (window.sessionStorage) {
sessionStorage.setItem('all_help_preset', 1);
}
$('[for*="help_for"]').addClass("show");
@ -252,13 +252,13 @@ function initFormHelpUI() {
} else {
$('[for*="help_for"]').addClass("hidden");
$('[for*="help_for"]').removeClass("show");
if (checkSessionStorageExists()) {
if (window.sessionStorage) {
sessionStorage.setItem('all_help_preset', 0);
}
}
event.preventDefault();
});
if (checkSessionStorageExists() && sessionStorage.getItem('all_help_preset') == 1) {
if (window.sessionStorage && sessionStorage.getItem('all_help_preset') == 1) {
// show all help messages when preset was stored
$('[id*="show_all_help"]').toggleClass("fa-toggle-on fa-toggle-off");
$('[id*="show_all_help"]').toggleClass("text-success text-danger");
@ -271,7 +271,7 @@ function initFormHelpUI() {
* handle advanced show/hide
*/
function initFormAdvancedUI() {
if (checkSessionStorageExists() && sessionStorage.getItem('show_advanced_preset') == 1) {
if (window.sessionStorage && sessionStorage.getItem('show_advanced_preset') == 1) {
// show advanced options when preset was stored
$('[id*="show_advanced"]').toggleClass("fa-toggle-on fa-toggle-off");
$('[id*="show_advanced"]').toggleClass("text-success text-danger");
@ -287,12 +287,12 @@ function initFormAdvancedUI() {
if ($('[id*="show_advanced"]').hasClass("fa-toggle-on")) {
$('[data-advanced*="true"]').show();
$('[data-advanced*="hidden_row"]').remove(); // the table row is deleted to keep correct table striping
if (checkSessionStorageExists()) {
if (window.sessionStorage) {
sessionStorage.setItem('show_advanced_preset', 1);
}
} else {
$('[data-advanced*="true"]').after("<tr data-advanced='hidden_row'></tr>").hide(); // the table row is added to keep correct table striping
if (checkSessionStorageExists()) {
if (window.sessionStorage) {
sessionStorage.setItem('show_advanced_preset', 0);
}
}

View File

@ -151,13 +151,13 @@ $pagetitle .= html_safe(sprintf(' | %s.%s', $config['system']['hostname'], $conf
$('[id*="show_all_help"]').toggleClass("fa-toggle-on fa-toggle-off");
$('[id*="show_all_help"]').toggleClass("text-success text-danger");
if ($('[id*="show_all_help"]').hasClass("fa-toggle-on")) {
if (checkSessionStorageExists()) {
if (window.sessionStorage) {
sessionStorage.setItem('all_help_preset', 1);
}
$('[for*="help_for"]').addClass("show");
$('[for*="help_for"]').removeClass("hidden");
} else {
if (checkSessionStorageExists()) {
if (window.sessionStorage) {
sessionStorage.setItem('all_help_preset', 0);
}
$('[for*="help_for"]').addClass("hidden");