11< div id =result > working</ div >
22< script type =module >
3-
3+
44 const site = `http://found.ward.fed.wiki`
55 const slug = `places-winter-25`
66 const page = await fetch ( `${ site } /${ slug } .json` ) . then ( res => res . json ( ) )
99 const actions = page . journal
1010 . filter ( action => action . type == 'edit' && action . item . type == 'map' )
1111 . filter ( action => action . item . text . split ( / \n / ) . length > 1 )
12+ const quads = [ 'north' , 'south' , 'east' , 'west' ]
13+ const rows = [ ]
14+ let row = { }
1215
13- window . result . innerHTML = actions
16+ const list = actions
1417 . map ( action => {
1518 const when = new Date ( action . date )
1619 const date = when . toLocaleDateString ( ) . slice ( 0 , - 5 )
1720 const day = when . toLocaleString ( window . navigator . language , { weekday : 'short' } )
1821 const fold = items [ items . findIndex ( item => item . id == action . id ) - 1 ] . text
1922 const coord = action . item . text . split ( / \n / ) . pop ( )
23+ if ( occupied ( fold ) ) { rows . push ( row ) ; row = { } }
24+ row [ fold ] = `${ day } ⇒ ${ dist ( coord ) } `
2025 return `${ day } ${ date } ⇒ ${ dist ( coord ) } ${ fold } `
2126 } )
2227 . join ( "<br>" )
28+ rows . push ( row )
29+
30+ const table = `
31+ <table style="border-collapse: collapse;">
32+ ${ `<tr>${ quads . map ( quad => `<th style="text-align: center">
33+ ${ quad } ` ) . join ( "" ) } `}
34+ ${ rows . map ( row =>
35+ `<tr>${ quads . map ( quad => `<td style="border: 1px solid black; padding: 6px">
36+ ${ row [ quad ] || "" } ` ) . join ( "" ) } `
37+ ) . join ( "" ) }
38+ </table>`
39+
40+ window . result . innerHTML = `
41+ <details><summary>data</summary>
42+ ${ list }
43+ </details>
44+ <br>
45+ ${ table }
46+ `
2347
2448 function dist ( coord ) {
2549 const home = { lat :45.4701282 , lon :- 122.7462476 }
2953 return ( 2 * ( dx + dy ) ) . toFixed ( 2 )
3054 }
3155
56+ function occupied ( fold ) {
57+ const wants = quads . slice ( quads . indexOf ( fold ) )
58+ for ( const want of wants )
59+ if ( want in row ) return true
60+ return false
61+ }
62+
3263</ script >
0 commit comments