-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_dump.html
More file actions
56 lines (52 loc) · 2 KB
/
settings_dump.html
File metadata and controls
56 lines (52 loc) · 2 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title l10n="Settings">Settings</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">
<style>
#ta_settings { width: 100%}
</style>
<script src="./lib/init.js"></script>
</head>
<body>
<h1 l10n="Settings">Settings</h1>
<form id="settings" width="100%">
<textarea id="ta_settings" readonly rows="4"></textarea>
<div class="grid-container">
<button type="submit" id="btn_pref_dump" l10n="Dump">Dump</button>
<button id="btn_pref_rest" l10n="Restore">Restore</button>
<button id="home" onclick="window.location.href='./index.html';return false" l10n="Home">HOME</button>
</div>
</form>
<p l10n="SavedPrefsList">What gets saved: current ID, channels list, channel write permissions, server list. Not saved: the choice of current channel and server, passwords, all other settings.</p>
<div id="outputdiv">
</div>
<script type="module">
const outputdiv=document.getElementById("outputdiv");
import * as Earthstar from "./lib/earthstar.web.js";
const settings = new Earthstar.SharedSettings();
const settings_str = JSON.stringify(settings);
document.getElementById("ta_settings").innerHTML = settings_str;
function generate_download(text, filename) {
// Create a Blob object from the text
var blob = new Blob([text], {type: "text/plain"});
// Create a link with the download attribute and click it
var link = document.createElement("a");
link.download = filename;
link.href = URL.createObjectURL(blob);
link.click();
}
document.getElementById("settings").addEventListener("submit", async function(event) {
event.preventDefault();
generate_download(settings_str,`settings.json.txt`);
});
document.getElementById("btn_pref_rest").addEventListener("click", function(event) {
event.preventDefault();
window.location.href = "./settings_restore.html";
});
</script>
</body>
</html>