Skip to content

Commit

Permalink
mrPreview subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewharvey committed Dec 14, 2024
1 parent e1bc618 commit c776707
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions www/mrPreview.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,14 @@
section.setAttribute('id', id)

const header = document.createElement('h2')
header.textContent = id
const headerLink = document.createElement('a')
headerLink.textContent = id
headerLink.setAttribute('href', `https://www.openstreetmap.org/${id}`)
headerLink.setAttribute('target', '_blank')
header.appendChild(headerLink)
section.appendChild(header)
const subtitle = document.createElement('span')
section.appendChild(subtitle)

const table = document.createElement('table')

Expand All @@ -169,19 +175,19 @@
let tagsRemoved = false

// properties
const distinctKeys = [...new Set([...Object.keys(change.before.properties), ...Object.keys(change.after.properties)])]
const distinctKeys = [...new Set([...Object.keys(change.before?.properties || {}), ...Object.keys(change.after?.properties || {})])]
for (const key of distinctKeys) {
const tr = document.createElement('tr')

const tdKey = document.createElement('td')
tdKey.textContent = key

const tdBefore = document.createElement('td')
const beforeValue = change.before.properties[key]
const beforeValue = change.before?.properties[key]
tdBefore.textContent = beforeValue

const tdAfter = document.createElement('td')
const afterValue = change.after.properties[key]
const afterValue = change.after?.properties[key]
tdAfter.textContent = afterValue

if (beforeValue && afterValue && beforeValue !== afterValue) {
Expand Down Expand Up @@ -212,7 +218,7 @@

table.appendChild(tr)
}
header.textContent = `${id} (${tagsAdded ? 'Added' : ''} ${tagsModified ? 'Modified' : ''} ${tagsRemoved ? 'Removed' : ''})`
subtitle.textContent = `(${tagsAdded ? 'Added' : ''} ${tagsModified ? 'Modified' : ''} ${tagsRemoved ? 'Removed' : ''})`

section.appendChild(table)
content.appendChild(section)
Expand Down

0 comments on commit c776707

Please sign in to comment.