Skip to content

Commit c08c43c

Browse files
committed
Refine website
1 parent d23783e commit c08c43c

File tree

3 files changed

+64
-20
lines changed

3 files changed

+64
-20
lines changed

index.css

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ body {
3737
color: var(--color);
3838
}
3939

40+
main {
41+
opacity: 0;
42+
}
43+
4044
.markdown {
4145
box-sizing: border-box;
4246
min-width: 200px;
@@ -59,6 +63,7 @@ body {
5963
border-bottom: 2px solid var(--separator-color);
6064
padding-bottom: 1rem;
6165
margin-bottom: 2.5rem;
66+
cursor: pointer;
6267
}
6368

6469
#header img {
@@ -70,10 +75,29 @@ body {
7075
display: none;
7176
background-color: var(--changes-background-color);
7277
font-size: medium;
73-
padding: .1rem 1.5rem .5rem 1.5rem;
78+
padding: .05rem 1.5rem .5rem 1.5rem;
7479
border-radius: .5rem;
7580
}
7681

82+
#changes-header {
83+
height: 3.25rem;
84+
display: flex;
85+
justify-content: space-between;
86+
}
87+
88+
#changes-dismiss {
89+
font-size: 2rem;
90+
font-weight: 200;
91+
color: var(--button-background-color);
92+
transition: color .1s ease-in-out;
93+
padding: .6rem 0 0 0;
94+
cursor: pointer;
95+
}
96+
97+
#changes-dismiss:hover {
98+
color: var(--button-background-color-hover);
99+
}
100+
77101
#abstract {
78102
padding-top: 1rem;
79103
font-size: 1.5rem;
@@ -142,8 +166,8 @@ footer {
142166
text-align: center;
143167
font-size: 1rem;
144168
opacity: .25;
145-
padding-top: 3rem;
146-
padding-bottom: 3rem;
169+
padding-top: 5.8rem;
170+
padding-bottom: .2rem;
147171
}
148172

149173
footer a {

index.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@
1616
<noscript>
1717
This website requires JavaScript.
1818
</noscript>
19-
<main class="markdown">
19+
<main id="main" class="markdown">
2020

21-
<div id="header">
21+
<div id="header" onclick="window.location.href = location.pathname;">
2222
<img src="extension/img/icon128.png">
2323
<span>ADAMatic</span>
2424
</div>
2525

2626
<div id="changes">
27-
<h2>Changes in <span id="changes-version"></span></h2>
27+
<div id="changes-header">
28+
<h2 id="changes-title"></h2>
29+
<span id="changes-dismiss" onclick="document.getElementById('changes').style.display = 'none';">&times;</span>
30+
</div>
2831
<div id="changelog"></div>
29-
<a class="secondary" href="https://thechnet.github.io/adamatic">Dismiss</a>
3032
</div>
3133

3234
<div id="abstract"></div>
@@ -38,10 +40,11 @@ <h2>Changes in <span id="changes-version"></span></h2>
3840
</div>
3941

4042
<div id="highlights"></div>
43+
44+
<footer>
45+
&copy; <a href="http://chnet.bplaced.net/">chnet</a>
46+
</footer>
4147
</main>
42-
<footer>
43-
&copy; <a href="http://chnet.bplaced.net/">chnet</a>
44-
</footer>
4548
</body>
4649

4750
</html>

index.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ function parseReadme(text) {
3030

3131
function parseChangelog(text) {
3232
let versions = {
33-
latest: undefined
33+
latest: undefined,
34+
unreleased: {
35+
lines: []
36+
}
3437
};
3538

3639
let lines = text.split('\n');
@@ -41,16 +44,22 @@ function parseChangelog(text) {
4144
continue;
4245
}
4346

47+
let unreleasedDeclaration = lines[i].match(/^## \[Unreleased\]/i);
48+
if (unreleasedDeclaration) {
49+
currentVersion = 'unreleased';
50+
continue;
51+
}
52+
4453
let versionDeclaration = lines[i].match(/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})$/);
4554
if (versionDeclaration) {
46-
if (!currentVersion) {
47-
versions.latest = versionDeclaration[1];
48-
}
4955
currentVersion = versionDeclaration[1];
5056
versions[currentVersion] = {
5157
date: versionDeclaration[2],
5258
lines: []
5359
};
60+
if (!versions.latest) {
61+
versions.latest = currentVersion;
62+
}
5463
continue;
5564
}
5665

@@ -81,18 +90,26 @@ function renderChanges(text, requestedVersion) {
8190
console.error('Requested version not in parsed versions.');
8291
return;
8392
}
84-
85-
document.getElementById('changes-version').innerText = requestedVersion;
86-
87-
document.getElementById('changelog').innerHTML = marked.parse(versions[requestedVersion].lines.join('\n'));
88-
document.getElementById('changes').style.display = 'block';
93+
94+
if (versions[requestedVersion].lines.length) {
95+
document.getElementById('changes-title').textContent = requestedVersion === 'unreleased' ? 'Upcoming Changes' : 'What\'s New in ' + requestedVersion;
96+
document.getElementById('changelog').innerHTML = marked.parse(versions[requestedVersion].lines.join('\n'));
97+
98+
document.getElementById('changes').style.display = 'block';
99+
}
89100
}
90101

91102
let requestedVersion = new URLSearchParams(window.location.search).get('changes');
92103

93104
async function main() {
94105
renderReadme(await (await fetch(FETCH_README)).text());
95-
renderChanges(await (await fetch(FETCH_CHANGELOG)).text(), requestedVersion);
106+
if (requestedVersion) {
107+
renderChanges(await (await fetch(FETCH_CHANGELOG)).text(), requestedVersion);
108+
}
109+
110+
Promise.all(Array.from(document.images).filter(img => !img.complete).map(img => new Promise(resolve => { img.onload = img.onerror = resolve; }))).then(() => {
111+
document.getElementById('main').style.opacity = 1;
112+
});
96113
}
97114

98115
main();

0 commit comments

Comments
 (0)