Commit b7376c79 authored by Cerdic's avatar Cerdic

Webkit/Safari ne supporte pas encore navigator.storage Fix #4

parent f4b72d06
......@@ -7,14 +7,16 @@ offline.showSWStatut = function() {
if (typeof c !== "undefined" && c) {
status = status + 'ON ' + c.state;
jQuery('#swstatus').html(status);
navigator.storage.estimate().then(info => {
var mb,s;
mb = Math.round(info.usage/1024/1024*10) / 10;
s = mb + 'Mb';
mb = Math.round(info.quota/1024/1024);
s = s + '/' + mb + 'Mb';
jQuery('#swstatus').append('' + s);
});
if (typeof navigator.storage !== "undefined" && navigator.storage) {
navigator.storage.estimate().then(info => {
var mb,s;
mb = Math.round(info.usage/1024/1024*10) / 10;
s = mb + 'Mb';
mb = Math.round(info.quota/1024/1024);
s = s + '/' + mb + 'Mb';
jQuery('#swstatus').append('' + s);
});
}
}
else {
status = status + '-';
......
......@@ -85,19 +85,21 @@ var offline = {
},
promptPersistent : function() {
// https://storage.spec.whatwg.org/
Promise.all([
if (typeof navigator.storage !== "undefined" && navigator.storage) {
Promise.all([
navigator.storage.persisted(),
navigator.permissions.query({name: "persistent-storage"})
]).then(([persisted, permission]) => {
if(permission.state == "granted") {
// nothing to do !
} else if(permission.state == "prompt") {
// ask once
navigator.storage.persist();
} else if(permission.state == "denied") {
// tant pis ?
}
//console.log(persisted,permission);
})
]).then(([persisted, permission]) => {
if(permission.state == "granted") {
// nothing to do !
} else if(permission.state == "prompt") {
// ask once
navigator.storage.persist();
} else if(permission.state == "denied") {
// tant pis ?
}
//console.log(persisted,permission);
})
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment