1- // Toggle persistent display of documentation version and language options
2- document . querySelectorAll ( '.doc-switcher li.current' ) . forEach ( function ( el ) {
1+ for ( const el of document . querySelectorAll ( '.doc-switcher li.current' ) ) {
32 el . addEventListener ( 'click' , function ( ) {
43 this . parentElement . classList . toggle ( 'open' ) ;
54 } ) ;
6- } ) ;
5+ }
76
8- // Propagate the current fragment identifier when switching docs versions
9- document . querySelectorAll ( '#doc-versions a' ) . forEach ( function ( el ) {
7+ for ( const el of document . querySelectorAll ( '#doc-versions a' ) ) {
108 el . addEventListener ( 'click' , function ( ) {
119 this . href = this . href . split ( '#' ) [ 0 ] + window . location . hash ;
1210 } ) ;
13- } ) ;
11+ }
1412
15- // Fade out and remove message elements when close icon is clicked
16- document . querySelectorAll ( '.messages li .close' ) . forEach ( function ( el ) {
13+ for ( const el of document . querySelectorAll ( '.messages li .close' ) ) {
1714 el . addEventListener ( 'click' , function ( ) {
1815 this . parentElement . addEventListener ( 'transitionend' , function ( ) {
1916 this . style . display = 'none' ;
2017 } ) ;
2118
2219 this . parentElement . classList . add ( 'fade-out' ) ;
2320 } ) ;
24- } ) ;
21+ }
2522
26- // Check all console tab inputs of the same type when one's label is clicked
27- document . querySelectorAll ( '.console-block label' ) . forEach ( function ( el ) {
28- el . addEventListener ( 'click' , function ( e ) {
23+ for ( const el of document . querySelectorAll ( '.console-block label' ) ) {
24+ el . addEventListener ( 'click' , ( e ) => {
2925 const input_id = e . currentTarget . getAttribute ( 'for' ) ;
3026 const selector = input_id . endsWith ( 'unix' ) ? '.c-tab-unix' : '.c-tab-win' ;
3127
32- document . querySelectorAll ( selector ) . forEach ( function ( input_el ) {
28+ for ( const input_el of document . querySelectorAll ( selector ) ) {
3329 input_el . checked = true ;
34- } ) ;
30+ }
3531 } ) ;
36- } ) ;
32+ }
3733
3834// Add animation class to feature icons when they are fully visible
39- ( function ( ) {
35+ ( ( ) => {
4036 const observer = new IntersectionObserver (
41- function ( entries ) {
42- entries . forEach ( function ( entry ) {
37+ ( entries ) => {
38+ entries . forEach ( ( entry ) => {
4339 if ( ! entry . isIntersecting ) {
4440 return ;
4541 }
@@ -52,9 +48,9 @@ document.querySelectorAll('.console-block label').forEach(function (el) {
5248 { threshold : 1.0 } ,
5349 ) ;
5450
55- document . querySelectorAll ( '.list-features i' ) . forEach ( function ( el ) {
51+ for ( const el of document . querySelectorAll ( '.list-features i' ) ) {
5652 observer . observe ( el ) ;
57- } ) ;
53+ }
5854} ) ( ) ;
5955
6056// Toggle mobile menu on button click
@@ -66,7 +62,7 @@ document.querySelector('.menu-button').addEventListener('click', function () {
6662} ) ;
6763
6864// Update search input placeholder text based on the user's operating system
69- ( function ( ) {
65+ ( ( ) => {
7066 const el = document . getElementById ( 'id_q' ) ;
7167
7268 if ( ! el ) {
@@ -81,7 +77,7 @@ document.querySelector('.menu-button').addEventListener('click', function () {
8177} ) ( ) ;
8278
8379// Focus, select, and scroll to search input when key combination is pressed
84- window . addEventListener ( 'keydown' , function ( e ) {
80+ window . addEventListener ( 'keydown' , ( e ) => {
8581 const is_ctrl_k = ( e . metaKey || e . ctrlKey ) && e . key === 'k' ;
8682
8783 if ( ! ( is_ctrl_k || e . key === '/' ) ) {
@@ -103,7 +99,7 @@ window.addEventListener('keydown', function (e) {
10399} ) ;
104100
105101// Add copy buttons to code snippets
106- ( function ( ) {
102+ ( ( ) => {
107103 const button_el = document . createElement ( 'span' ) ;
108104
109105 button_el . classList . add ( 'btn-clipboard' ) ;
@@ -112,13 +108,12 @@ window.addEventListener('keydown', function (e) {
112108
113109 const selector = '.snippet-filename, .code-block-caption' ;
114110
115- document . querySelectorAll ( selector ) . forEach ( function ( el ) {
111+ for ( const el of document . querySelectorAll ( selector ) ) {
116112 el . insertBefore ( button_el . cloneNode ( true ) , null ) ;
117- } ) ;
113+ }
118114} ) ( ) ;
119115
120- // Attach copy functionality to dynamically-created buttons
121- document . querySelectorAll ( '.btn-clipboard' ) . forEach ( function ( el ) {
116+ for ( const el of document . querySelectorAll ( '.btn-clipboard' ) ) {
122117 el . addEventListener ( 'click' , function ( ) {
123118 const success_el = document . createElement ( 'span' ) ;
124119
@@ -133,15 +128,15 @@ document.querySelectorAll('.btn-clipboard').forEach(function (el) {
133128 function on_success ( el ) {
134129 success_el . innerText = 'Copied!' ;
135130
136- setTimeout ( function ( ) {
131+ setTimeout ( ( ) => {
137132 success_el . classList . add ( 'fade-out' ) ;
138133 } , 1000 ) ;
139134 }
140135
141136 function on_error ( el ) {
142137 success_el . innerText = 'Could not copy!' ;
143138
144- setTimeout ( function ( ) {
139+ setTimeout ( ( ) => {
145140 success_el . classList . add ( 'fade-out' ) ;
146141 } , 5000 ) ;
147142 }
@@ -150,10 +145,10 @@ document.querySelectorAll('.btn-clipboard').forEach(function (el) {
150145
151146 navigator . clipboard . writeText ( text ) . then ( on_success , on_error ) ;
152147 } ) ;
153- } ) ;
148+ }
154149
155150// Compensate for floating warning element when scrolling to a URL hash in docs
156- ( function ( ) {
151+ ( ( ) => {
157152 const warning_el = document . querySelector ( '.doc-floating-warning' ) ;
158153
159154 if ( ! warning_el ) {
@@ -186,7 +181,7 @@ document.querySelectorAll('.btn-clipboard').forEach(function (el) {
186181} ) ( ) ;
187182
188183// Update donate button text on fundraising page based on interval selection
189- ( function ( ) {
184+ ( ( ) => {
190185 const el = document . querySelector ( '#donate #id_interval' ) ;
191186
192187 if ( ! el ) {
@@ -201,7 +196,7 @@ document.querySelectorAll('.btn-clipboard').forEach(function (el) {
201196} ) ( ) ;
202197
203198// Manage custom donation amount input on fundraising page
204- ( function ( ) {
199+ ( ( ) => {
205200 const el = document . querySelector ( '#donate #id_amount' ) ;
206201
207202 if ( ! el ) {
@@ -231,7 +226,7 @@ document.querySelectorAll('.btn-clipboard').forEach(function (el) {
231226} ) ( ) ;
232227
233228// Manage amount and membership level fields on corporate membership page
234- ( function ( ) {
229+ ( ( ) => {
235230 const form_el = document . querySelector ( '.corporate-membership-join-form' ) ;
236231
237232 if ( ! form_el ) {
0 commit comments