diff --git a/front/js/pialert_common.js b/front/js/pialert_common.js index 152ff569..81d0f3d4 100755 --- a/front/js/pialert_common.js +++ b/front/js/pialert_common.js @@ -20,13 +20,13 @@ var emptyArr = ['undefined', "", undefined, null, 'null']; // ----------------------------------------------------------------------------- // Simple session cache withe expiration managed via cookies // ----------------------------------------------------------------------------- -function getCache(key) +function getCache(key, noCookie = false) { // check cache if(sessionStorage.getItem(key)) { // check if not expired - if(getCookie(key + '_session_expiry') != "") + if(noCookie || getCookie(key + '_session_expiry') != "") { return sessionStorage.getItem(key); } @@ -38,8 +38,12 @@ function getCache(key) // ----------------------------------------------------------------------------- function setCache(key, data, expirationMinutes='') { - sessionStorage.setItem(key, data); - setCookie (key + '_session_expiry', 'OK', expirationMinutes='') + sessionStorage.setItem(key, data); + + if (expirationMinutes != '') + { + setCookie (key + '_session_expiry', 'OK', expirationMinutes='') + } } @@ -107,15 +111,29 @@ function cacheStrings() data.forEach((langString) => { // console.log(langString) - setCache(`pia_lang_${langString.String_Key}`, langString.String_Value, expirationMinutes='1440') // expire in a day + setCache(`pia_lang_${langString.String_Key}`, langString.String_Value) }); - }) } function getString (key) { - return getCache(`pia_lang_${key}`) + // todo + // php/server/utilDB.php?key=Gen_Okay + // need to initilaize session storage + + result = getCache(`pia_lang_${key}`, true); + + if (result == "") + { + getCache(`pia_lang_${key}`, true) + } + else + { + // this is async can't do that + } + + return result; } // ----------------------------------------------------------------------------- diff --git a/front/php/server/get b/front/php/server/get new file mode 100644 index 00000000..e69de29b diff --git a/front/php/server/utilDB.php b/front/php/server/utilDB.php new file mode 100644 index 00000000..4d88c4b8 --- /dev/null +++ b/front/php/server/utilDB.php @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/front/php/templates/language/lang.php b/front/php/templates/language/lang.php index f3dcd3a5..dcc552ad 100755 --- a/front/php/templates/language/lang.php +++ b/front/php/templates/language/lang.php @@ -37,6 +37,7 @@ require dirname(__FILE__).'/en_us.php'; require dirname(__FILE__).'/de_de.php'; require dirname(__FILE__).'/es_es.php'; + function lang($key) { global $pia_lang_selected, $lang, $defaultLang, $strings; @@ -72,4 +73,6 @@ function lang($key) } return $temp; -} +}; + +