From 4c2ee452c2322bc696de68288c4da860f452c7be Mon Sep 17 00:00:00 2001 From: firelemons Date: Thu, 31 Aug 2023 23:34:22 -0500 Subject: [PATCH] remove if false, make for loop more readable --- app/javascript/src/add_to_calendar_button.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/javascript/src/add_to_calendar_button.js b/app/javascript/src/add_to_calendar_button.js index bb2d157c70..90733e4c28 100644 --- a/app/javascript/src/add_to_calendar_button.js +++ b/app/javascript/src/add_to_calendar_button.js @@ -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