From bcd5328b80504ac3e93494ab70fc21fee4ea6aab Mon Sep 17 00:00:00 2001 From: silas Date: Wed, 31 Oct 2018 11:18:06 +0100 Subject: [PATCH] updated settings storage --- .../js/Fragment/WordRotatorSettingFragment.js | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js b/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js index 9bc76e9..fa0ba4b 100644 --- a/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js +++ b/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js @@ -82,39 +82,39 @@ export class WordRotatorSettingFragment extends LocalStorageSettingsFragment { installButton.classList.remove("hidden"); }); - // let storageManager = MyStorageManager.getInstance(); - // if (storageManager.canEstimateStorage()) { - // console.log("can estimate storage!"); - // Promise.all([storageManager.estimate(), storageManager.isPersistent()]).then(res => { - // let storage = res[0]; - // let isPersisted = res[1]; - // let storageObject = this.findBy("#storage-info"); - // console.log(isPersisted); - // storageObject.appendChild(Translator.makePersistentTranslation("storage-info", [ - // Math.round(storage.usage / (1024 * 1024) * 100) / 100, - // Math.round(storage.quota / (1024 * 1024) * 100) / 100, - // Math.round(storage.usage / storage.quota * 10000) / 100, - // ((isPersisted) ? "" : "nicht")])); - // storageObject.parentElement.classList.remove("hidden"); - // storageObject.parentElement.addEventListener("click", () => { - // storageManager.persist().then(isPersisted => { - // storageObject.removeAllChildren().appendChild(Translator.makePersistentTranslation("storage-info", [ - // Math.round(storage.usage / (1024 * 1024) * 100) / 100, - // Math.round(storage.quota / (1024 * 1024) * 100) / 100, - // Math.round(storage.usage / storage.quota * 10000) / 100, - // ((isPersisted) ? "" : "nicht")])); - // - // console.log("p", isPersisted); - // if (!isPersisted){ - // FlashMessenger.addMessage("storage-permission-not-get"); - // } - // else { - // FlashMessenger.addMessage("storage-permission-get"); - // } - // }); - // }) - // }); - // } + let storageManager = MyStorageManager.getInstance(); + if (storageManager.canEstimateStorage()) { + console.log("can estimate storage!"); + Promise.all([storageManager.estimate(), storageManager.isPersistent()]).then(res => { + let storage = res[0]; + let isPersisted = res[1]; + let storageObject = this.findBy("#storage-info"); + console.log(isPersisted); + storageObject.appendChild(Translator.makePersistentTranslation("storage-info", [ + Math.round(storage.usage / (1024 * 1024) * 100) / 100, + Math.round(storage.quota / (1024 * 1024) * 100) / 100, + Math.round(storage.usage / storage.quota * 10000) / 100, + ((isPersisted) ? "" : "nicht")])); + storageObject.parentElement.classList.remove("hidden"); + storageObject.parentElement.addEventListener("click", () => { + storageManager.persist().then(isPersisted => { + storageObject.removeAllChildren().appendChild(Translator.makePersistentTranslation("storage-info", [ + Math.round(storage.usage / (1024 * 1024) * 100) / 100, + Math.round(storage.quota / (1024 * 1024) * 100) / 100, + Math.round(storage.usage / storage.quota * 10000) / 100, + ((isPersisted) ? "" : "nicht")])); + + console.log("p", isPersisted); + if (!isPersisted){ + FlashMessenger.addMessage("storage-permission-not-get"); + } + else { + FlashMessenger.addMessage("storage-permission-get"); + } + }); + }) + }); + } return super.onFirstStart(); }