-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingsViewer.js
44 lines (44 loc) · 1.12 KB
/
settingsViewer.js
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
define(
["core/settings", "core/events", "core/ui/content", "core/ui/navigation"],
function (settings, events, content, navigation) {
var drawSettings = function () {
var output = document.querySelector("#settings-viewer");
while (output.hasChildNodes()) {
output.removeChild(output.firstChild);
}
output.insertAdjacentText("beforeEnd",
Object.keys(settings).map(function (key) {
return key === "session"
? ""
: (key + ": " + JSON.stringify(settings[key], null, 2));
}).join("\n")
);
};
new content({
path: /^settings/,
open: function (path, element) {
require(["core/template"], function (template) {
template({
css: "modules/settingsViewer",
source: "settingsViewer",
container: element
})
.then(function () {
drawSettings();
events.subscribe("settings.change", drawSettings);
});
});
},
close: function (path, element) {
events.unsubscribe("settings.change", drawSettings);
require(["core/css"], function (css) {
css.unload("core/settingsViewer");
});
}
});
new navigation({
title: "Settings",
path: "settings"
});
return {};
});