Skip to content

Commit 727c71a

Browse files
day date => dist compass
1 parent 30033c4 commit 727c71a

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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>

0 commit comments

Comments
 (0)