Skip to content

Commit 8cb6706

Browse files
committed
Add JSDoc comments
1 parent 3031085 commit 8cb6706

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

templates/switchers.js

+32
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const _CURRENT_PREFIX = (() => {
2222
const _ALL_VERSIONS = new Map(Object.entries($VERSIONS));
2323
const _ALL_LANGUAGES = new Map(Object.entries($LANGUAGES));
2424

25+
/**
26+
* @param {Map<string, string>} versions
27+
* @returns {HTMLSelectElement}
28+
* @private
29+
*/
2530
const _create_version_select = (versions) => {
2631
const select = document.createElement('select');
2732
select.className = 'version-select';
@@ -45,6 +50,11 @@ const _create_version_select = (versions) => {
4550
return select;
4651
};
4752

53+
/**
54+
* @param {Map<string, string>} languages
55+
* @returns {HTMLSelectElement}
56+
* @private
57+
*/
4858
const _create_language_select = (languages) => {
4959
if (!languages.has(_CURRENT_LANGUAGE)) {
5060
// In case we are browsing a language that is not yet in languages.
@@ -69,6 +79,11 @@ const _create_language_select = (languages) => {
6979
return select;
7080
};
7181

82+
/**
83+
* Change the current page to the first existing URL in the list.
84+
* @param {Array<string>} urls
85+
* @private
86+
*/
7287
const _navigate_to_first_existing = (urls) => {
7388
// Navigate to the first existing URL in urls.
7489
for (const url of urls) {
@@ -90,6 +105,12 @@ const _navigate_to_first_existing = (urls) => {
90105
return '/';
91106
};
92107

108+
/**
109+
* Callback for the version switcher.
110+
* @param {Event} event
111+
* @returns {void}
112+
* @private
113+
*/
93114
const _on_version_switch = (event) => {
94115
if (_IS_LOCAL) return;
95116

@@ -115,6 +136,12 @@ const _on_version_switch = (event) => {
115136
}
116137
};
117138

139+
/**
140+
* Callback for the language switcher.
141+
* @param {Event} event
142+
* @returns {void}
143+
* @private
144+
*/
118145
const _on_language_switch = (event) => {
119146
if (_IS_LOCAL) return;
120147

@@ -135,6 +162,11 @@ const _on_language_switch = (event) => {
135162
}
136163
};
137164

165+
/**
166+
* Initialisation function for the version and language switchers.
167+
* @returns {void}
168+
* @private
169+
*/
138170
const _initialise_switchers = () => {
139171
const versions = _ALL_VERSIONS;
140172
const languages = _ALL_LANGUAGES;

0 commit comments

Comments
 (0)