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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
const markdown = require("marked").parse;
// Changes the main page
// This is the tabs in the sidebar
function page(page) {
let pages = document.querySelectorAll(".mainContainer .contentContainer")
let btns = document.querySelectorAll(".gamesContainer button")
for (let i = 0; i < pages.length; i++) {
pages[i].classList.add("hidden");
}
for (let i = 0; i < btns.length; i++) {
btns[i].classList.add("inactive");
}
pages[page].classList.remove("hidden");
btns[page].classList.remove("inactive");
bgHolder.setAttribute("bg", page);
}; page(1)
function formatRelease(notes) {
let content = "";
for (let release of notes) {
if (release.prerelease) {continue}
content += "# " + release.name + "\n\n" + release.body + "\n\n\n";
}
return markdown(content, {
breaks: true
});
}
// Updates the Viper release notes
ipcRenderer.on("vp-notes", (event, response) => {
vpReleaseNotes.innerHTML = formatRelease(response);
});
// Updates the Northstar release notes
ipcRenderer.on("ns-notes", (event, response) => {
nsRelease.innerHTML = formatRelease(response);
});
async function loadVpReleases() {
ipcRenderer.send("get-vp-notes");
}; loadVpReleases();
async function loadNsReleases() {
ipcRenderer.send("get-ns-notes");
}; loadNsReleases();
// TODO: We gotta make this more automatic instead of switch statements
// it's both not pretty, but adding more sections requires way too much
// effort, compared to how it should be.
function showVpSection(section) {
if (!["main", "release", "info", "credits"].includes(section)) throw new Error("unknown vp section");
vpMainBtn.removeAttribute("active");
vpReleaseBtn.removeAttribute("active");
vpInfoBtn.removeAttribute("active");
vpMain.classList.add("hidden");
vpReleaseNotes.classList.add("hidden");
vpInfo.classList.add("hidden");
switch(section) {
case "main":
vpMainBtn.setAttribute("active", "");
vpMain.classList.remove("hidden");
break;
case "release":
vpReleaseBtn.setAttribute("active", "");
vpReleaseNotes.classList.remove("hidden");
break;
case "info":
vpInfoBtn.setAttribute("active", "");
vpInfo.classList.remove("hidden");
break;
}
}
function showNsSection(section) {
if (!["main", "release", "mods"].includes(section)) throw new Error("unknown ns section");
nsMainBtn.removeAttribute("active");
nsModsBtn.removeAttribute("active");
nsReleaseBtn.removeAttribute("active");
nsMain.classList.add("hidden");
nsMods.classList.add("hidden");
nsRelease.classList.add("hidden");
switch(section) {
case "main":
nsMainBtn.setAttribute("active", "");
nsMain.classList.remove("hidden");
break;
case "mods":
nsModsBtn.setAttribute("active", "");
nsMods.style.display = "block";
nsMods.classList.remove("hidden");
break;
case "release":
nsReleaseBtn.setAttribute("active", "");
nsRelease.classList.remove("hidden");
break;
}
}
|