1
0
mirror of https://github.com/dwaxweiler/connector-mobilizon synced 2025-06-05 21:59:25 +02:00

extract two methods from main file

This commit is contained in:
Daniel Waxweiler
2021-04-13 21:10:28 +02:00
parent cf49fb47d6
commit 72f2c12343
3 changed files with 65 additions and 21 deletions

View File

@ -1,4 +1,4 @@
import DateTimeWrapper from './date-time-wrapper'
import Formatter from './formatter'
import * as GraphqlWrapper from './graphql-wrapper'
import { createAnchorElement } from './html-creator'
@ -17,29 +17,15 @@ function displayEvents(data, list) {
const br = document.createElement('br')
li.appendChild(br)
const beginsOn = new DateTimeWrapper(events[i].beginsOn)
const endsOn = new DateTimeWrapper(events[i].endsOn)
let dateText = beginsOn.getShortDate()
dateText += ' ' + beginsOn.get24Time()
dateText += ' - '
if (!beginsOn.equalsDate(endsOn)) {
dateText += endsOn.getShortDate() + ' '
}
dateText += endsOn.get24Time()
const textnode = document.createTextNode(dateText)
const date = Formatter.formatDate({ start: events[i].beginsOn, end: events[i].endsOn })
const textnode = document.createTextNode(date)
li.appendChild(textnode)
if (events[i].physicalAddress) {
let location = ''
if (events[i].physicalAddress.description) {
location += events[i].physicalAddress.description
}
if (location && events[i].physicalAddress.locality) {
location += ', '
}
if (events[i].physicalAddress.locality) {
location += events[i].physicalAddress.locality
}
const location = Formatter.formatLocation({
description: events[i].physicalAddress.description,
locality: events[i].physicalAddress.locality
})
if (location) {
const brBeforeLocation = document.createElement('br')
li.appendChild(brBeforeLocation)