Skip to content

Commit

Permalink
remove if false, make for loop more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
FireLemons committed Sep 1, 2023
1 parent dd993fd commit 4c2ee45
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/javascript/src/add_to_calendar_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ const Add2Calendar = require('add2calendar')

function createCalendarEvents () {
const calendarButtons = document.querySelectorAll('div.cal-btn')
if (!calendarButtons) return
calendarButtons.forEach((btn) => {

for (const calendarButton of calendarButtons) {
const calendarEvent = new Add2Calendar({
title: btn.dataset.title,
start: btn.dataset.start,
end: btn.dataset.end,
description: btn.dataset.title,
title: calendarButton.dataset.title,
start: calendarButton.dataset.start,
end: calendarButton.dataset.end,
description: calendarButton.dataset.title,
isAllDay: true
})

calendarEvent.createWidget(`#${btn.id}`)
btn.title = btn.dataset.tooltip
})
calendarEvent.createWidget(`#${calendarButton.id}`)
calendarButton.title = calendarButton.dataset.tooltip
}
}

$(() => { // JQuery's callback for the DOM loading
Expand Down

0 comments on commit 4c2ee45

Please sign in to comment.