@@ -93,15 +93,15 @@ function getCPUArchLabel(name) {
9393 }
9494}
9595
96- const BUILD_DATE_FORMAT = new Intl . DateTimeFormat ( " en-GB" , {
97- timeZone : " UTC" ,
98- year : " numeric" ,
99- month : " short" ,
100- day : " 2-digit" ,
101- weekday : " short" ,
96+ const BUILD_DATE_FORMAT = new Intl . DateTimeFormat ( ' en-GB' , {
97+ timeZone : ' UTC' ,
98+ year : ' numeric' ,
99+ month : ' short' ,
100+ day : ' 2-digit' ,
101+ weekday : ' short' ,
102102 hour12 : false ,
103- hour : " 2-digit" ,
104- minute : " 2-digit" ,
103+ hour : ' 2-digit' ,
104+ minute : ' 2-digit' ,
105105} )
106106
107107function formatBuildDate ( date ) {
@@ -112,7 +112,7 @@ function formatBuildDate(date) {
112112let runtimeFormat = null ;
113113if ( typeof Intl . DurationFormat !== 'undefined' ) {
114114 try {
115- runtimeFormat = new Intl . DurationFormat ( "en" , { style : " short" } ) ;
115+ runtimeFormat = new Intl . DurationFormat ( 'en' , { style : ' short' } ) ;
116116 } catch ( e ) {
117117 // Intl.DurationFormat not available
118118 }
@@ -126,8 +126,8 @@ function formatRuntime(runtime) {
126126 try {
127127 const duration = Temporal . Duration . from ( { seconds : totalSeconds } ) ;
128128 return runtimeFormat . format ( duration . round ( {
129- largestUnit : " hours" ,
130- smallestUnit : totalSeconds >= 3600 ? " minutes" : " seconds"
129+ largestUnit : ' hours' ,
130+ smallestUnit : totalSeconds >= 3600 ? ' minutes' : ' seconds'
131131 } ) ) ;
132132 } catch ( e ) {
133133 // Fall through to fallback implementation
@@ -161,12 +161,12 @@ function fetchAllJSON(urls) {
161161 return Promise . all ( promises )
162162}
163163
164- let pageData = null
164+ let _pageData = null
165165
166166function loadPageData ( dataPath , dataGenerator = null ) {
167- pageData = fetch ( dataPath ) . then ( res => res . json ( ) )
167+ _pageData = fetch ( dataPath ) . then ( res => res . json ( ) )
168168 if ( dataGenerator ) {
169- pageData = pageData . then ( dataGenerator )
169+ _pageData = _pageData . then ( dataGenerator )
170170 }
171171}
172172
@@ -189,12 +189,12 @@ function generate() {
189189 }
190190
191191 const generatedBody = generateBody ( ) ;
192- document . body . replaceChildren ( ... generatedBody ) ;
192+ document . body . replaceChildren ( generatedBody ) ;
193193
194194 generateTOCItems ( document . body ) // assume no headers (for the TOC) are generated dynamically
195195
196- if ( pageData ) {
197- pageData . then ( data => {
196+ if ( _pageData ) {
197+ _pageData . then ( data => {
198198 const mainElement = document . body . querySelector ( 'main' )
199199 const contentMain = mainElement . querySelector ( 'main' ) // This is the main element of the calling html file
200200 resolveDataReferences ( document , data )
@@ -221,12 +221,12 @@ function generateTOCItems(mainElement) {
221221 }
222222}
223223
224- const dataReferencePattern = / \$ { (?< path > [ \w -\. ] + ) } / g
224+ const dataReferencePattern = / \$ { (?< path > [ \w \ -\. ] + ) } / g
225225
226226function resolveDataReferences ( contextElement , contextData ) {
227- const dataElements = Array . from ( contextElement . getElementsByClassName ( " data-ref" ) )
227+ const dataElements = Array . from ( contextElement . getElementsByClassName ( ' data-ref' ) )
228228 for ( const element of dataElements ) {
229- element . classList . remove ( " data-ref" ) // Prevent multiple processing in subsequent passes with different context (therefore a copy is created from the list)
229+ element . classList . remove ( ' data-ref' ) // Prevent multiple processing in subsequent passes with different context (therefore a copy is created from the list)
230230 element . outerHTML = element . outerHTML . replaceAll ( dataReferencePattern , ( _match , pathGroup , _offset , _string ) => {
231231 return getValue ( contextData , pathGroup )
232232 } )
@@ -245,14 +245,14 @@ function getValue(data, path) {
245245}
246246
247247function logException ( message , loggedObject ) {
248- document . body . prepend ( ... toElements ( `<span >Failed to generate content: <span>< b style="color: FireBrick">${ message } </b><br/ >` ) ) ;
248+ document . body . prepend ( toElement ( `<p >Failed to generate content: <b style="color: FireBrick">${ message } </b></p >` ) ) ;
249249 console . log ( loggedObject ) ;
250250}
251251
252252function generateBody ( ) {
253253 const hasHeadersForTOC = document . querySelector ( 'h1[id], h2[id], h3[id], h4[id]' ) !== null ;
254254 const col = hasHeadersForTOC ? 'col-md-18' : ' col-md-24' ;
255- return toElements ( `
255+ return toElement ( `
256256<div>
257257 ${ generateHeader ( ) }
258258 <main id="content">
@@ -345,7 +345,7 @@ function generateMainContent() {
345345 if ( main != null ) {
346346 return main . outerHTML
347347 }
348- return " <main>The body specifies no content.</main>" ;
348+ return ' <main>The body specifies no content.</main>' ;
349349}
350350
351351function generateHeader ( ) {
@@ -444,7 +444,7 @@ function toElements(text) {
444444function toElement ( text ) {
445445 const elements = toElements ( text )
446446 if ( elements . length != 1 ) {
447- throw new Error ( " Not exactly one element: " + elements . length )
447+ throw new Error ( ` Not exactly one element: ${ elements . length } ` )
448448 }
449449 return elements [ 0 ]
450450}
0 commit comments