@@ -20,7 +20,7 @@ function playground_text(playground) {
2020 return Promise . race ( [
2121 fetch ( url , options ) ,
2222 new Promise ( ( _ , reject ) =>
23- setTimeout ( ( ) => reject ( new Error ( "timeout" ) ) , timeout )
23+ setTimeout ( ( ) => reject ( new Error ( "timeout" ) ) , timeout ) ,
2424 ) ,
2525 ] ) ;
2626 }
@@ -38,10 +38,10 @@ function playground_text(playground) {
3838 . then ( ( response ) => {
3939 // get list of crates available in the rust playground
4040 let playground_crates = response . crates . map (
41- ( item ) => item [ "id" ]
41+ ( item ) => item [ "id" ] ,
4242 ) ;
4343 playgrounds . forEach ( ( block ) =>
44- handle_crate_list_update ( block , playground_crates )
44+ handle_crate_list_update ( block , playground_crates ) ,
4545 ) ;
4646 } ) ;
4747 }
@@ -154,7 +154,7 @@ function playground_text(playground) {
154154 . catch (
155155 ( error ) =>
156156 ( result_block . innerText =
157- "Playground Communication: " + error . message )
157+ "Playground Communication: " + error . message ) ,
158158 ) ;
159159 }
160160
@@ -238,88 +238,92 @@ function playground_text(playground) {
238238 block . classList . add ( "hide-boring" ) ;
239239 }
240240 } ) ;
241- }
241+ } ,
242242 ) ;
243243
244244 if ( window . playground_copyable ) {
245- Array . from ( document . querySelectorAll ( "pre code" ) ) . forEach ( function (
246- block
247- ) {
248- var pre_block = block . parentNode ;
249- if ( ! pre_block . classList . contains ( "playground" ) ) {
250- var buttons = pre_block . querySelector ( ".buttons" ) ;
251- if ( ! buttons ) {
252- buttons = document . createElement ( "div" ) ;
253- buttons . className = "buttons" ;
254- pre_block . insertBefore ( buttons , pre_block . firstChild ) ;
255- }
245+ Array . from ( document . querySelectorAll ( "pre code" ) ) . forEach (
246+ function ( block ) {
247+ var pre_block = block . parentNode ;
248+ if ( ! pre_block . classList . contains ( "playground" ) ) {
249+ var buttons = pre_block . querySelector ( ".buttons" ) ;
250+ if ( ! buttons ) {
251+ buttons = document . createElement ( "div" ) ;
252+ buttons . className = "buttons" ;
253+ pre_block . insertBefore ( buttons , pre_block . firstChild ) ;
254+ }
256255
257- var clipButton = document . createElement ( "button" ) ;
258- clipButton . className = "fa fa-copy clip-button" ;
259- clipButton . title = "Copy to clipboard" ;
260- clipButton . setAttribute ( "aria-label" , clipButton . title ) ;
261- clipButton . innerHTML = '<i class="tooltiptext"></i>' ;
256+ var clipButton = document . createElement ( "button" ) ;
257+ clipButton . className = "fa fa-copy clip-button" ;
258+ clipButton . title = "Copy to clipboard" ;
259+ clipButton . setAttribute ( "aria-label" , clipButton . title ) ;
260+ clipButton . innerHTML = '<i class="tooltiptext"></i>' ;
262261
263- buttons . insertBefore ( clipButton , buttons . firstChild ) ;
264- }
265- } ) ;
262+ buttons . insertBefore ( clipButton , buttons . firstChild ) ;
263+ }
264+ } ,
265+ ) ;
266266 }
267267
268268 // Process playground code blocks
269- Array . from ( document . querySelectorAll ( ".playground" ) ) . forEach ( function (
270- pre_block
271- ) {
272- // Add play button
273- var buttons = pre_block . querySelector ( ".buttons" ) ;
274- if ( ! buttons ) {
275- buttons = document . createElement ( "div" ) ;
276- buttons . className = "buttons" ;
277- pre_block . insertBefore ( buttons , pre_block . firstChild ) ;
278- }
269+ Array . from ( document . querySelectorAll ( ".playground" ) ) . forEach (
270+ function ( pre_block ) {
271+ // Add play button
272+ var buttons = pre_block . querySelector ( ".buttons" ) ;
273+ if ( ! buttons ) {
274+ buttons = document . createElement ( "div" ) ;
275+ buttons . className = "buttons" ;
276+ pre_block . insertBefore ( buttons , pre_block . firstChild ) ;
277+ }
279278
280- var runCodeButton = document . createElement ( "button" ) ;
281- runCodeButton . className = "fa fa-play play-button" ;
282- runCodeButton . hidden = true ;
283- runCodeButton . title = "Run this code" ;
284- runCodeButton . setAttribute ( "aria-label" , runCodeButton . title ) ;
279+ var runCodeButton = document . createElement ( "button" ) ;
280+ runCodeButton . className = "fa fa-play play-button" ;
281+ runCodeButton . hidden = true ;
282+ runCodeButton . title = "Run this code" ;
283+ runCodeButton . setAttribute ( "aria-label" , runCodeButton . title ) ;
285284
286- buttons . insertBefore ( runCodeButton , buttons . firstChild ) ;
287- runCodeButton . addEventListener ( "click" , function ( e ) {
288- run_rust_code ( pre_block ) ;
289- } ) ;
285+ buttons . insertBefore ( runCodeButton , buttons . firstChild ) ;
286+ runCodeButton . addEventListener ( "click" , function ( e ) {
287+ run_rust_code ( pre_block ) ;
288+ } ) ;
290289
291- if ( window . playground_copyable ) {
292- var copyCodeClipboardButton = document . createElement ( "button" ) ;
293- copyCodeClipboardButton . className = "fa fa-copy clip-button" ;
294- copyCodeClipboardButton . innerHTML = '<i class="tooltiptext"></i>' ;
295- copyCodeClipboardButton . title = "Copy to clipboard" ;
296- copyCodeClipboardButton . setAttribute (
297- "aria-label" ,
298- copyCodeClipboardButton . title
299- ) ;
290+ if ( window . playground_copyable ) {
291+ var copyCodeClipboardButton = document . createElement ( "button" ) ;
292+ copyCodeClipboardButton . className = "fa fa-copy clip-button" ;
293+ copyCodeClipboardButton . innerHTML =
294+ '<i class="tooltiptext"></i>' ;
295+ copyCodeClipboardButton . title = "Copy to clipboard" ;
296+ copyCodeClipboardButton . setAttribute (
297+ "aria-label" ,
298+ copyCodeClipboardButton . title ,
299+ ) ;
300300
301- buttons . insertBefore ( copyCodeClipboardButton , buttons . firstChild ) ;
302- }
301+ buttons . insertBefore (
302+ copyCodeClipboardButton ,
303+ buttons . firstChild ,
304+ ) ;
305+ }
303306
304- let code_block = pre_block . querySelector ( "code" ) ;
305- if ( window . ace && code_block . classList . contains ( "editable" ) ) {
306- var undoChangesButton = document . createElement ( "button" ) ;
307- undoChangesButton . className = "fa fa-history reset-button" ;
308- undoChangesButton . title = "Undo changes" ;
309- undoChangesButton . setAttribute (
310- "aria-label" ,
311- undoChangesButton . title
312- ) ;
307+ let code_block = pre_block . querySelector ( "code" ) ;
308+ if ( window . ace && code_block . classList . contains ( "editable" ) ) {
309+ var undoChangesButton = document . createElement ( "button" ) ;
310+ undoChangesButton . className = "fa fa-history reset-button" ;
311+ undoChangesButton . title = "Undo changes" ;
312+ undoChangesButton . setAttribute (
313+ "aria-label" ,
314+ undoChangesButton . title ,
315+ ) ;
313316
314- buttons . insertBefore ( undoChangesButton , buttons . firstChild ) ;
317+ buttons . insertBefore ( undoChangesButton , buttons . firstChild ) ;
315318
316- undoChangesButton . addEventListener ( "click" , function ( ) {
317- let editor = window . ace . edit ( code_block ) ;
318- editor . setValue ( editor . originalCode ) ;
319- editor . clearSelection ( ) ;
320- } ) ;
321- }
322- } ) ;
319+ undoChangesButton . addEventListener ( "click" , function ( ) {
320+ let editor = window . ace . edit ( code_block ) ;
321+ editor . setValue ( editor . originalCode ) ;
322+ editor . clearSelection ( ) ;
323+ } ) ;
324+ }
325+ } ,
326+ ) ;
323327} ) ( ) ;
324328
325329( function themes ( ) {
@@ -380,7 +384,7 @@ function playground_text(playground) {
380384
381385 setTimeout ( function ( ) {
382386 themeColorMetaTag . content = getComputedStyle (
383- document . body
387+ document . body ,
384388 ) . backgroundColor ;
385389 } , 1 ) ;
386390
@@ -537,14 +541,14 @@ function playground_text(playground) {
537541 if ( html . classList . contains ( "sidebar-hidden" ) ) {
538542 var current_width = parseInt (
539543 document . documentElement . style . getPropertyValue (
540- "--sidebar-width"
544+ "--sidebar-width" ,
541545 ) ,
542- 10
546+ 10 ,
543547 ) ;
544548 if ( current_width < 150 ) {
545549 document . documentElement . style . setProperty (
546550 "--sidebar-width" ,
547- "150px"
551+ "150px" ,
548552 ) ;
549553 }
550554 showSidebar ( ) ;
@@ -577,7 +581,7 @@ function playground_text(playground) {
577581 pos = Math . min ( pos , window . innerWidth - 100 ) ;
578582 document . documentElement . style . setProperty (
579583 "--sidebar-width" ,
580- pos + "px"
584+ pos + "px" ,
581585 ) ;
582586 }
583587 }
@@ -596,7 +600,7 @@ function playground_text(playground) {
596600 time : Date . now ( ) ,
597601 } ;
598602 } ,
599- { passive : true }
603+ { passive : true } ,
600604 ) ;
601605
602606 document . addEventListener (
@@ -620,7 +624,7 @@ function playground_text(playground) {
620624 firstContact = null ;
621625 }
622626 } ,
623- { passive : true }
627+ { passive : true } ,
624628 ) ;
625629
626630 // Scroll sidebar to current active section
@@ -653,7 +657,7 @@ function playground_text(playground) {
653657 case "ArrowLeft" :
654658 e . preventDefault ( ) ;
655659 var previousButton = document . querySelector (
656- ".nav-chapters.previous"
660+ ".nav-chapters.previous" ,
657661 ) ;
658662 if ( previousButton ) {
659663 window . location . href = previousButton . href ;
@@ -755,7 +759,7 @@ function playground_text(playground) {
755759 }
756760 prevScrollTop = scrollTop ;
757761 } ,
758- { passive : true }
762+ { passive : true } ,
759763 ) ;
760764 } ) ( ) ;
761765 ( function controllBorder ( ) {
@@ -769,7 +773,7 @@ function playground_text(playground) {
769773 menu . classList . add ( "bordered" ) ;
770774 }
771775 } ,
772- { passive : true }
776+ { passive : true } ,
773777 ) ;
774778 } ) ( ) ;
775779} ) ( ) ;
0 commit comments