File tree Expand file tree Collapse file tree
pages/parks-by-compass-points Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ < div id =result > working</ div >
2+ < script type =module >
3+
4+ const site = `http://found.ward.fed.wiki`
5+ const slug = `places-winter-25`
6+ const page = await fetch ( `${ site } /${ slug } .json` ) . then ( res => res . json ( ) )
7+ const items = page . story
8+ . filter ( item => [ 'pagefold' , 'map' ] . includes ( item . type ) )
9+ const actions = page . journal
10+ . filter ( action => action . type == 'edit' && action . item . type == 'map' )
11+ . filter ( action => action . item . text . split ( / \n / ) . length > 1 )
12+
13+ window . result . innerHTML = actions
14+ . map ( action => {
15+ const when = new Date ( action . date )
16+ const date = when . toLocaleDateString ( ) . slice ( 0 , - 5 )
17+ const day = when . toLocaleString ( window . navigator . language , { weekday : 'short' } )
18+ const fold = items [ items . findIndex ( item => item . id == action . id ) - 1 ] . text
19+ const coord = action . item . text . split ( / \n / ) . pop ( )
20+ return `${ day } ${ date } ⇒ ${ dist ( coord ) } ${ fold } `
21+ } )
22+ . join ( "<br>" )
23+
24+ function dist ( coord ) {
25+ const home = { lat :45.4701282 , lon :- 122.7462476 }
26+ const [ lat , lon ] = coord . split ( / , / )
27+ const dx = Math . abs ( home . lon - lon ) * 49
28+ const dy = Math . abs ( home . lat - lat ) * 69
29+ return ( 2 * ( dx + dy ) ) . toFixed ( 2 )
30+ }
31+
32+ </ script >
You can’t perform that action at this time.
0 commit comments