Storage-Info hinzugefügt

This commit is contained in:
silas
2018-10-30 11:20:58 +01:00
parent dc13bc019d
commit 068f72c447
8 changed files with 129 additions and 7 deletions

View File

@@ -535,6 +535,44 @@ InitPromise.addPromise(() => {
// window["soundManagerInstance"]["resumeAllIfNotMuted"] = window["soundManagerInstance"].resumeAllIfNotMuted;
// });
class StorageManager {
static getInstance() {
if (Helper.isNull(StorageManager.instance)) {
StorageManager.instance = new StorageManager();
}
return StorageManager.instance;
}
async estimate() {
if ('storage' in navigator && 'estimate' in navigator.storage) {
// We've got the real thing! Return its response.
return navigator.storage.estimate();
}
if ('webkitTemporaryStorage' in navigator &&
'queryUsageAndQuota' in navigator.webkitTemporaryStorage) {
// Return a promise-based wrapper that will follow the expected interface.
return new Promise(function (resolve, reject) {
navigator.webkitTemporaryStorage.queryUsageAndQuota(
function (usage, quota) {
resolve({usage: usage, quota: quota});
},
reject
);
});
}
// If we can't estimate the values, return a Promise that resolves with NaN.
return Promise.resolve({usage: NaN, quota: NaN});
}
canEstimateStorage() {
return ('storage' in navigator && 'estimate' in navigator.storage || 'webkitTemporaryStorage' in navigator &&
'queryUsageAndQuota' in navigator.webkitTemporaryStorage);
}
}
StorageManager.instance = null;
class TabbedFragment extends Fragment {
constructor(site) {
super(site, 'pwaAssets/html/fragment/tabbedFragment.html');
@@ -600,4 +638,4 @@ class TabbedFragment extends Fragment {
}
}
export { DelayPromise, InstallManager, Matomo, MatomoShareButton, RotateHelper, ScaleHelper, AudioChain, SoundManager, TabbedFragment };
export { DelayPromise, InstallManager, Matomo, MatomoShareButton, RotateHelper, ScaleHelper, AudioChain, SoundManager, StorageManager, TabbedFragment };