Skip to content

Commit 4205425

Browse files
committed
Add jsdoc
1 parent aa86428 commit 4205425

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

static/main.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* @typedef {Object} GitHubAsset
3+
* @property {string} name
4+
* @property {string} browser_download_url
5+
* @property {number} download_count
6+
*/
7+
8+
/**
9+
* @typedef {Object} GitHubRelease
10+
* @property {string} tag_name
11+
* @property {string} html_url
12+
* @property {string} published_at
13+
* @property {string} body_html
14+
* @property {GitHubAsset[]} assets
15+
*/
16+
117
const releasesPerPage = 5;
218
const releaseNotesContainer = document.getElementById('changelog');
319
const downloadFormatter = new Intl.NumberFormat('en', {
@@ -26,7 +42,7 @@ function LoadReleases() {
2642

2743
return response.json();
2844
})
29-
.then((releases) => {
45+
.then((/** @type {GitHubRelease[]} */ releases) => {
3046
if (existingBtn) {
3147
existingBtn.remove();
3248
}
@@ -84,6 +100,10 @@ function LoadReleases() {
84100
});
85101
}
86102

103+
/**
104+
* @param {GitHubRelease[]} releases
105+
* @param {boolean} isFirstPage
106+
*/
87107
function RenderReleases(releases, isFirstPage) {
88108
for (const release of releases) {
89109
const releaseSection = document.createElement('div');
@@ -178,7 +198,12 @@ function RenderReleases(releases, isFirstPage) {
178198
}
179199
}
180200

201+
/** @param {HTMLElement} changelogContainer */
181202
function AdjustChangelog(changelogContainer) {
203+
/**
204+
* @param {HTMLElement} element
205+
* @param {HTMLElement|null} [unwrapParent]
206+
*/
182207
const wrapMedia = (element, unwrapParent) => {
183208
if (unwrapParent) {
184209
const wrapper = document.createElement('div');
@@ -214,7 +239,12 @@ function AdjustChangelog(changelogContainer) {
214239
}
215240
}
216241

242+
/**
243+
* @param {string} src
244+
* @param {"image"|"video"} type
245+
*/
217246
function OpenMediaModal(src, type) {
247+
/** @type {HTMLDialogElement} */
218248
let modal = document.getElementById('changelog-media-modal');
219249
if (!modal) {
220250
modal = document.createElement('dialog');
@@ -245,13 +275,14 @@ function OpenMediaModal(src, type) {
245275
const media = document.createElement(type === 'video' ? 'video' : 'img');
246276
media.className = 'changelog-modal-media';
247277
media.src = src;
278+
248279
if (type === 'video') {
249280
media.controls = true;
250281
media.autoplay = true;
251282
media.loop = true;
252283
}
253-
modal.appendChild(media);
254284

285+
modal.appendChild(media);
255286
modal.showModal();
256287
}
257288

0 commit comments

Comments
 (0)