-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.html
87 lines (78 loc) · 2.78 KB
/
reset.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>reset - aframe vr player</title>
<link rel="stylesheet" href="https://unpkg.com/simpledotcss/simple.min.css">
</head>
<body>
<h1>reset - aframe vr player</h1>
<h2>Stuff</h2>
<p>
<input type="checkbox" name="show hidden" id="showhidden" value="">Show Hidden keys</input>
</p>
<p>
<input type="button" name="factoryreset" id="factoryreset" value="Factory Reset"></input>
</p>
<h2>Configuration keys</h2>
<figure>
<table>
<thead>
<tr>
<th>Name</th>
<th>Action</th>
<th>Value</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</figure>
<script>
function loadTable(exclude = []) {
const el = document.querySelector('tbody');
el.replaceChildren();
let names = Object.keys(localStorage);
names = names.filter(name => {
for (var i = 0; i < exclude.length; i++) {
if (name.startsWith(exclude[i])) {
return false;
}
}
return true;
});
for (var i = 0; i < names.length; i++) {
let name = names[i];
let tr = document.createElement('tr');
let td1 = document.createElement('td');
let td2 = document.createElement('td');
let td3 = document.createElement('td');
td1.innerText = name;
let actionBtn = document.createElement('button');
actionBtn.innerText = 'delete';
actionBtn.addEventListener('click', () => {
confirm(`delete ${name}?`) && localStorage.removeItem(name) && location.reload()
});
td2.appendChild(actionBtn);
td3.innerText = localStorage.getItem(name);
tr.append(td1, td2, td3);
el.appendChild(tr);
}
}
const excludeKeys = ['VID_'];
const showHidden = document.querySelector('#showhidden');
loadTable(excludeKeys);
showHidden.addEventListener('change', () => {
showHidden.checked ? loadTable() : loadTable(excludeKeys);
});
const factoryResetBtn = document.querySelector('#factoryreset');
factoryResetBtn.addEventListener('click', () => {
if (confirm('This will delete all settings/data in aframe-vr-player')) {
localStorage.clear();
location.reload();
}
});
</script>
</body>
</html>