-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset.html
More file actions
66 lines (61 loc) · 2.29 KB
/
reset.html
File metadata and controls
66 lines (61 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title l10n="ResetConfig">Reset Configuration</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/default.css">
<script src="./lib/init.js"></script>
</head>
<body>
<h1 style="color:red" l10n="ResetConfig">Reset Configuration</h1>
<h2 l10n="IMPORTANT: this operation does not always remove data from the browser, you need to clear browser history and data for that.">IMPORTANT: this operation does not always remove data from the browser, you need to clear browser history and data for that.</h2>
<form id="reset_config">
<label for="confirm_reset" style="color:red" l10n="Drag all the way to the right to reset">Drag all the way to the right to reset</label>
<input type="range" id="confirm_reset" name="confirm_reset" min="0" max="4" value="0">
</form>
<div class="grid-container">
<button id="home" onclick="window.location.href='./index.html'">HOME</button>
</div>
<div id="outputdiv">
</div>
<script type="module">
import * as Earthstar from "./lib/earthstar.web.js";
const settings = new Earthstar.SharedSettings();
//clear cache and service workers
async function clearsw() {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for(let registration of registrations) {
registration.unregister().then(function(boolean) {
if (boolean) {
console.log('Service worker unregistered');
} else {
console.log('Service worker not found');
}
});
}
});
caches.keys().then(function(cacheNames) {
cacheNames.forEach(function(cacheName) {
caches.delete(cacheName);
});
});
}
const outputdiv=document.getElementById("outputdiv");
const slider=document.getElementById("confirm_reset");
slider.oninput = async function() {
if (this.value == 4) {
settings.clear();
sessionStorage.clear();
localStorage.clear();
clearsw();
// note, following two lines are not universally supported
const idxdb = await window.indexedDB.databases();
idxdb.forEach(d => { window.indexedDB.deleteDatabase(d.name) })
outputdiv.insertAdjacentHTML("beforeend", ('<p>' + t("Done") + '</p>'));
}
};
</script>
</body>
</html>