diff --git a/js/date_only.js b/js/date_only.js index a5309cb1a792fc54ea614f0d36a39d7a0f011bef..7a1b1a06604f0df211d9862dd9b1ee1c634bd097 100644 --- a/js/date_only.js +++ b/js/date_only.js @@ -37,7 +37,7 @@ end.addDays(duration); // ISO 8601 string get encoded as UTC so add the timezone offset. let isIso8061 = startDate.match(/\d{4}-\d{2}-\d{2}/); - if (isIso8061 && end.getTimezoneOffset() != 0) { + if (isIso8061 && end.getTimezoneOffset() !== 0) { end.setMinutes(end.getMinutes() + end.getTimezoneOffset()); newEnd = end.getFullYear() + '-' + pad(end.getMonth() + 1, 2) + '-' + pad(end.getDate(), 2); } else { diff --git a/js/localize.js b/js/localize.js index 861f9f23a8a85e61c14facfbce0425b1b541b48f..5a3fbe6ae323e2266c422c99bbc0244b0933e764 100644 --- a/js/localize.js +++ b/js/localize.js @@ -16,7 +16,7 @@ const offset = element.dataset.tzoffset; // Check if timezones are different. - if (when.getTimezoneOffset() == offset) { + if (when.getTimezoneOffset() === offset) { return; } @@ -58,15 +58,15 @@ case 'S': // English ordinal suffix for the day of the month, 2 characters switch (d.toString().slice(-1)) { case '1': - string += (d == 11) ? 'th' : 'st'; + string += d === 11 ? 'th' : 'st'; break; case '2': - string += (d == 12) ? 'th' : 'nd'; + string += d === 12 ? 'th' : 'nd'; break; case '3': - string += (d == 13) ? 'th' : 'rd'; + string += d === 13 ? 'th' : 'rd'; break; default: @@ -80,7 +80,7 @@ break; case 'l': // (lowercase 'L') A full textual representation of the day of the week - string += tzl.formatToParts(date).find((part) => part.type == 'weekday').value; + string += tzl.formatToParts(date).find((part) => part.type === 'weekday').value; break; case 'w': // Numeric representation of the day of the week (0=Sunday,1=Monday,...6=Saturday) @@ -88,7 +88,7 @@ break; case 'D': // A textual representation of a day, three letters - string += tzs.formatToParts(date).find((part) => part.type == 'weekday').value; + string += tzs.formatToParts(date).find((part) => part.type === 'weekday').value; break; case 'm': // Numeric representation of a month, with leading zeros (01 to 12) @@ -100,11 +100,11 @@ break; case 'F': // A full textual representation of a month, such as January or March - string += tzl.formatToParts(date).find((part) => part.type == 'month').value; + string += tzl.formatToParts(date).find((part) => part.type === 'month').value; break; case 'M': // A short textual representation of a month, three letters (Jan - Dec) - string += tzs.formatToParts(date).find((part) => part.type == 'month').value; + string += tzs.formatToParts(date).find((part) => part.type === 'month').value; break; case 'Y': // A full numeric representation of a year, 4 digits (1999 OR 2003) @@ -147,11 +147,11 @@ break; case 'T': // Timezone identifier (abbreviation) - string += tzs.formatToParts(date).find((part) => part.type == 'timeZoneName').value; + string += tzs.formatToParts(date).find((part) => part.type === 'timeZoneName').value; break; case 'e': // Timezone identifier (abbreviation) - string += tzl.formatToParts(date).find((part) => part.type == 'timeZoneName').value; + string += tzl.formatToParts(date).find((part) => part.type === 'timeZoneName').value; break; default: diff --git a/js/smart_date.js b/js/smart_date.js index 41643e6a6fac8bbcb661c45987c9235fd620c47f..ffef05c035cdce11dde5e6c044cc0123c3ce9a19 100644 --- a/js/smart_date.js +++ b/js/smart_date.js @@ -19,7 +19,7 @@ once('smartDateHideSeconds', '.smartdate--widget input[type="time"]', context).forEach(function (element) { element.step = 60; // For browsers that don't respect the step value, trim empty seconds. - if (element.defaultValue && element.defaultValue.substring(6, 8) == '00') { + if (element.defaultValue && element.defaultValue.substring(6, 8) === '00') { element.defaultValue = element.defaultValue.substring(0, 5); } }); @@ -44,7 +44,7 @@ else { duration = parseInt(durationSelect.value); } - if (duration === false || duration == 'custom') { return; } + if (duration === false || duration === 'custom') { return; } let startDate = wrapper.querySelector('.time-start.form-date').value; if (!startDate) { @@ -64,13 +64,13 @@ // ISO 8601 string get encoded as UTC so add the timezone offset. end = new Date(Date.parse(startDate)); let isIso8061 = startDate.match(/\d{4}-\d{2}-\d{2}/); - if (isIso8061 && end.getTimezoneOffset() != 0) { + if (isIso8061 && end.getTimezoneOffset() !== 0) { end.setMinutes(end.getMinutes() + end.getTimezoneOffset()); } } // Calculate and set End Time only if All Day is not checked. - if (!wrapper.querySelector('input.allday') || wrapper.querySelector('input.allday').checked == false) { + if (!wrapper.querySelector('input.allday') || wrapper.querySelector('input.allday').checked === false) { end.setHours(startArray[0]); end.setMinutes(parseInt(startArray[1]) + duration); @@ -126,19 +126,19 @@ function setInitialDuration(element) { let duration = element.value; - if (duration == 'custom') { + if (duration === 'custom') { let wrapper = element.closest('.smartdate--widget'); duration = calcDuration(wrapper); } - else if (duration == 0) { + else if (duration === 0) { // Call this to hide the end date and time. durationChanged(element); } // Store the numeric value in a property so it can be used programmatically. element.dataset.duration = duration; // Handle cases where only one non-custom value is allowed. - if (element.options.length == 1 && duration != 'custom') { - if (duration == 0) { + if (element.options.length === 1 && duration !== 'custom') { + if (duration === 0) { // Hide the entire duration wrapper. element.parentElement.style.display = 'none'; } @@ -156,7 +156,7 @@ function augmentInputs(element) { // Add "All day checkbox" if config permits. const allday = element.dataset.allday; - if (allday && allday != "0" && (element.querySelectorAll('select [value="custom"]').length > 0 || element.querySelectorAll('select [value="1439"]').length > 0)) { + if (allday && allday !== "0" && (element.querySelectorAll('select [value="custom"]').length > 0 || element.querySelectorAll('select [value="1439"]').length > 0)) { // Create the input element. let checkbox = document.createElement('input'); checkbox.type = 'checkbox'; @@ -172,7 +172,7 @@ element.parentElement.insertAdjacentElement('beforebegin', label); } // If a forced duration, make end date and time read only. - if (element.querySelectorAll('select [value="custom"]').length == 0) { + if (element.querySelectorAll('select [value="custom"]').length === 0) { const fieldset = element.closest('fieldset'); const endTimeInput = fieldset.querySelector('.time-end.form-time'); const endDateInput = fieldset.querySelector('.time-end.form-date'); @@ -188,14 +188,14 @@ function setDuration(element) { let wrapper = element.closest('.smartdate--widget'); let duration = calcDuration(wrapper); - if (duration == 0) { + if (duration === 0) { return; } let durationSelect = wrapper.querySelector('select.field-duration'); // Store the numeric value in a property so it can be used programmatically. durationSelect.dataset.duration = duration; // Update the select to show the appropriate value. - if (durationSelect.querySelectorAll('option[value="' + duration + '"]').length != 0) { + if (durationSelect.querySelectorAll('option[value="' + duration + '"]').length !== 0) { durationSelect.value = duration; } else { durationSelect.value = 'custom'; @@ -239,7 +239,7 @@ let startDate = wrapper.querySelector('input.time-start.form-date'); let endDate = wrapper.querySelector('input.time-end.form-date'); // Set initial state of checkbox based on initial values. - if (startTime.value == '00:00:00' && endTime.value == '23:59:00') { + if (startTime.value === '00:00:00' && endTime.value === '23:59:00') { checkbox.checked = true; checkbox.dataset.duration = duration.dataset.default; startTime.style.display = 'none'; @@ -251,7 +251,7 @@ else { checkbox.dataset.duration = duration.value; } - if (startDate.value !== '' && endDate.value !== '' && checkbox.checked == true) { + if (startDate.value !== '' && endDate.value !== '' && checkbox.checked === true) { duration.parentElement.style.visibility = 'hidden'; duration.parentElement.style.display = ''; } @@ -265,8 +265,8 @@ let duration = wrapper.querySelector('select.field-duration'); let durationWrapper = duration.parentElement; - if (checkbox.checked == true) { - if (checkbox.dataset.duration == 0) { + if (checkbox.checked === true) { + if (checkbox.dataset.duration === 0) { let endDate = wrapper.querySelector('input.time-end.form-date'); endDate.style.display = ''; let endDateLabel = wrapper.querySelector('.time-start + .label'); @@ -280,10 +280,10 @@ checkbox.dataset.duration = duration.value; durationWrapper.style.visibility = 'hidden'; // Set the duration to a corresponding value. - if (duration.querySelectorAll('option[value="custom"]').length != 0) { + if (duration.querySelectorAll('option[value="custom"]').length !== 0) { duration.value = 'custom'; } - else if (duration.querySelectorAll('option[value="1439"]').length != 0) { + else if (duration.querySelectorAll('option[value="1439"]').length !== 0) { duration.value = '1439'; } // Set to all day $values and hide time elements. @@ -322,7 +322,7 @@ endTime.style.display = ''; durationWrapper.style.visibility = 'visible'; hideLabels(wrapper, false); - if (duration.value == 0) { + if (duration.value === 0) { // Call this to hide the end date and time. durationChanged(duration); } @@ -340,7 +340,7 @@ let endDate = wrapper.querySelector('.time-end.form-date'); let hideMe = endDate.dataset.hide; let allday = wrapper.querySelector('.allday'); - if (hideMe == 1 && endDate.value == startDate.value && (!allday || allday.checked == false)) { + if (hideMe === 1 && endDate.value === startDate.value && (!allday || allday.checked === false)) { endDate.style.visibility = 'hidden'; } else { diff --git a/modules/smart_date_recur/js/smart_date_recur.js b/modules/smart_date_recur/js/smart_date_recur.js index 2e240d519335f12bf5599cfbbc78793926cfc30c..f6b81464100d71636f9c9e16877fc03e15af11fe 100644 --- a/modules/smart_date_recur/js/smart_date_recur.js +++ b/modules/smart_date_recur/js/smart_date_recur.js @@ -23,7 +23,7 @@ element.tabIndex = 0; // Check the input on spacebar or return. element.addEventListener("keydown", function (event) { - if (event.keyCode == 13 || event.keyCode == 32) { + if (event.keyCode === 13 || event.keyCode === 32) { element.previousElementSibling.click(); event.preventDefault(); }