Skip to content

Commit e877d37

Browse files
committed
Add JSDoc comments
1 parent c226232 commit e877d37

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) {
@@ -85,6 +100,12 @@ const _navigate_to_first_existing = (urls) => {
85100
window.location.href = '/';
86101
};
87102

103+
/**
104+
* Callback for the version switcher.
105+
* @param {Event} event
106+
* @returns {void}
107+
* @private
108+
*/
88109
const _on_version_switch = (event) => {
89110
if (_IS_LOCAL) return;
90111

@@ -110,6 +131,12 @@ const _on_version_switch = (event) => {
110131
}
111132
};
112133

134+
/**
135+
* Callback for the language switcher.
136+
* @param {Event} event
137+
* @returns {void}
138+
* @private
139+
*/
113140
const _on_language_switch = (event) => {
114141
if (_IS_LOCAL) return;
115142

@@ -130,6 +157,11 @@ const _on_language_switch = (event) => {
130157
}
131158
};
132159

160+
/**
161+
* Initialisation function for the version and language switchers.
162+
* @returns {void}
163+
* @private
164+
*/
133165
const _initialise_switchers = () => {
134166
const versions = _ALL_VERSIONS;
135167
const languages = _ALL_LANGUAGES;

0 commit comments

Comments
 (0)