Skip to content

@tobie /example1.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
// Query current usage and availability in Temporary storage:
navigator.temporaryStorage.getInfo(
function (info) {
// Continue to initialize local cache using the obtained
// usage and quota (availability) information.
initializeCache(info);
}, function (error) { log("Got error: ", error);
});
function onError(error) {
// Handle an error.
log("Got error: ", error);
}
function setUpOfflineMode(availableSpace) {
// ...
}
// A function which is to be called when 'offline-mode' is enabled.
function onOfflineEnabled(amountOfSpaceNeeded) {
// First check how much we can use in the Persistent storage.
navigator.persistentStorage.getInfo(
function (info) {
var availableSpace = info.quota - info.usage;
if (availableSpace >= amountOfSpaceNeeded) {
// We're fine; just continue to set up offline mode.
setUpOfflineMode(availableSpace);
return;
}
var requestingQuota = amountOfSpaceNeeded + info.usage;
navigator.persistentStorage.requestQuota(
requestingQuota,
function (grantedQuota) {
setUpOfflineMode(grantedQuota - info.usage);
},
onError);
},
onError);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.