Testing IndexedDB
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
window.rtcRoom = "telesec.tech.eus";
|
||||
var gun = Gun(RELAYS, {
|
||||
var opt = {
|
||||
axe: false,
|
||||
localStorage: true,
|
||||
localStorage: false,
|
||||
// radisk: true,
|
||||
});
|
||||
};
|
||||
|
||||
opt.store = RindexedDB(opt);
|
||||
|
||||
var gun = Gun(RELAYS, opt);
|
||||
var SEA = Gun.SEA;
|
||||
var user = gun.user();
|
||||
function removeCache() {
|
||||
|
||||
@@ -84,8 +84,8 @@
|
||||
<script src="static/sea.js"></script>
|
||||
<script src="static/yson.js"></script>
|
||||
<script src="static/radix.js"></script>
|
||||
<!-- <script src="static/radisk.js"></script> -->
|
||||
<!-- <script src="static/store.js"></script> -->
|
||||
<script src="static/radisk.js"></script>
|
||||
<script src="static/store.js"></script>
|
||||
<script src="static/rindexed.js"></script>
|
||||
<script src="static/path.js"></script>
|
||||
<script src="static/open.js"></script>
|
||||
@@ -95,22 +95,20 @@
|
||||
<script src="static/toastr.min.js"></script>
|
||||
<script src="static/doublescroll.js"></script>
|
||||
<!--<script src="static/simplemde.min.js"></script>-->
|
||||
<script async>
|
||||
async function getQuota(cb = () => {}) {
|
||||
if (navigator.storage && navigator.storage.estimate) {
|
||||
const quota = await navigator.storage.estimate();
|
||||
// quota.usage -> Number of bytes used.
|
||||
// quota.quota -> Maximum number of bytes available.
|
||||
const percentageUsed = (quota.usage / quota.quota) * 100;
|
||||
console.log(
|
||||
`You've used ${percentageUsed}% of the available storage.`
|
||||
);
|
||||
const remaining = quota.quota - quota.usage;
|
||||
cb(percentageUsed, remaining);
|
||||
console.log(`You can write up to ${remaining} more bytes.`);
|
||||
<script>
|
||||
let totalSize = 0;
|
||||
|
||||
for (let key in localStorage) {
|
||||
if (localStorage.hasOwnProperty(key)) {
|
||||
let keySize = new Blob([key]).size; // Size of the key
|
||||
let valueSize = new Blob([localStorage[key]]).size; // Size of the value
|
||||
totalSize += keySize + valueSize;
|
||||
}
|
||||
}
|
||||
getQuota();
|
||||
|
||||
console.log(`Total localStorage size: ${totalSize} bytes`);
|
||||
console.log(`Total size in KB: ${(totalSize / 1024).toFixed(2)} KB`);
|
||||
console.log(`Total size in MB: ${(totalSize / (1024 * 1024)).toFixed(2)} MB`);
|
||||
</script>
|
||||
<script src="pwa.js"></script>
|
||||
<script src="config.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user