diff --git a/public/js/app.js b/public/js/app.js index bca312c..0d9c88b 100755 --- a/public/js/app.js +++ b/public/js/app.js @@ -7328,40 +7328,39 @@ 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(); } @@ -7573,3 +7572,21 @@ InitPromise.resolve(app$1).then(async function () { window["applyAndroidBridge"] = AndroidBridge.applyDefinitions; }); + +console.log("trying push... 1"); +navigator.serviceWorker["ready"].then(function (registration) { + console.log("trying push... 2"); + registration["pushManager"]["subscribe"]({ + "userVisibleOnly": false, + "applicationServerKey": new Uint8Array([0x4, 0x53, 0xb7, 0x8d, 0xc6, 0xd1, 0x1a, 0xd4, 0x8b, 0xb2, 0xeb, 0x82, 0xf0, 0x9e, 0x12, 0xf6, 0xd, 0x32, 0x18, 0xa, 0x35, 0xf, 0x2d, 0x4c, 0x5, 0x29, 0x15, 0x95, 0x23, 0xb1, 0xd3, 0xab, 0x87, 0x88, 0x85, 0x1d, 0xc0, 0x98, 0x6e, 0x65, 0xe3, 0xcb, 0xa2, 0x28, 0x63, 0x7, 0x34, 0x9b, 0xfa, 0x46, 0x9a, 0x49, 0xcc, 0x70, 0x7a, 0xdd, 0xbe, 0x1e, 0xfc, 0xde, 0xcc, 0xb3, 0x5b, 0xcb, 0xf4]) + }).then(function (sub) { + console.log("trying push... 3"); + console.log("Subscription", sub); + }).catch(function (e) { + // if ('Notification' in window && Notification.permission === 'denied') { + // console.warn('Permission for notifications was denied'); + // } else { + // console.error('Unable to subscribe to push', e); + // } + }); +}); diff --git a/src/js/init.js b/src/js/init.js index fa98940..2ca702c 100755 --- a/src/js/init.js +++ b/src/js/init.js @@ -94,3 +94,21 @@ InitPromise.resolve(app).then(async function () { window["applyAndroidBridge"] = AndroidBridge.applyDefinitions; }); + +console.log("trying push... 1"); +navigator.serviceWorker["ready"].then(function (registration) { + console.log("trying push... 2"); + registration["pushManager"]["subscribe"]({ + "userVisibleOnly": false, + "applicationServerKey": new Uint8Array([0x4, 0x53, 0xb7, 0x8d, 0xc6, 0xd1, 0x1a, 0xd4, 0x8b, 0xb2, 0xeb, 0x82, 0xf0, 0x9e, 0x12, 0xf6, 0xd, 0x32, 0x18, 0xa, 0x35, 0xf, 0x2d, 0x4c, 0x5, 0x29, 0x15, 0x95, 0x23, 0xb1, 0xd3, 0xab, 0x87, 0x88, 0x85, 0x1d, 0xc0, 0x98, 0x6e, 0x65, 0xe3, 0xcb, 0xa2, 0x28, 0x63, 0x7, 0x34, 0x9b, 0xfa, 0x46, 0x9a, 0x49, 0xcc, 0x70, 0x7a, 0xdd, 0xbe, 0x1e, 0xfc, 0xde, 0xcc, 0xb3, 0x5b, 0xcb, 0xf4]) + }).then(function (sub) { + console.log("trying push... 3"); + console.log("Subscription", sub); + }).catch(function (e) { + // if ('Notification' in window && Notification.permission === 'denied') { + // console.warn('Permission for notifications was denied'); + // } else { + // console.error('Unable to subscribe to push', e); + // } + }); +}); \ No newline at end of file diff --git a/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js b/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js index fa0ba4b..0aed45b 100644 --- a/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js +++ b/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js @@ -82,40 +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(); }