-
Notifications
You must be signed in to change notification settings - Fork 11
/
aaaaxy.html
66 lines (59 loc) · 1.77 KB
/
aaaaxy.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
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.6.0">
<script src="wasm_exec.js"></script>
<script>
// Polyfill
if (!WebAssembly.instantiateStreaming) {
WebAssembly.instantiateStreaming = async (resp, importObject) => {
const source = await (await resp).arrayBuffer();
return await WebAssembly.instantiate(source, importObject);
};
}
const go = new Go();
WebAssembly.instantiateStreaming(fetch("aaaaxy-js-wasm.wasm"), go.importObject).then(result => {
go.run(result.instance);
});
// Utility functions for the JS console.
function help() {
console.info('Functions by AAAAXY:');
console.info(' get()["key"]; // views config settings');
console.info(' set({key: value, ...}); // changes config settings and restarts');
console.info(' getSave(n); // views a save game');
console.info(' setSave(n, saveStr); // writes a save game');
}
console.info('Welcome to AAAAXY console. Type help(); for more info.');
function get() {
const confStr = localStorage['0/config.json'] || '{}';
return JSON.parse(confStr);
}
function set(obj) {
const conf = get();
for (const [k, v] of Object.entries(obj)) {
if (v == null) {
delete conf[k];
} else {
conf[k] = v.toString();
}
}
const confStr = JSON.stringify(conf);
localStorage['0/config.json'] = confStr;
location.reload(false);
}
function getSave(i) {
return localStorage[`1/save-${i}.json`];
}
function setSave(i, save) {
if (save == null) {
delete localStorage[`1/save-${i}.json`];
} else {
localStorage[`1/save-${i}.json`] = save;
}
}
</script>
<title>AAAAXY</title>
</head>
<body>
</body>
</html>