From e122b99107de05686cd3809dbf0c8349fd9452fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 12:53:25 +0100 Subject: [PATCH 01/10] fix bug - typeof xxx is never undefined --- src/definitions/modules/popup.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/definitions/modules/popup.js b/src/definitions/modules/popup.js index ffc9173643..7a54cca9d2 100644 --- a/src/definitions/modules/popup.js +++ b/src/definitions/modules/popup.js @@ -1497,12 +1497,12 @@ html = '', escape = $.fn.popup.settings.templates.escape ; - if (typeof text !== undefined) { - if (typeof text.title !== undefined && text.title) { + if (text !== undefined) { + if (text.title) { text.title = escape(text.title); html += '
' + text.title + '
'; } - if (typeof text.content !== undefined && text.content) { + if (text.content) { text.content = escape(text.content); html += '
' + text.content + '
'; } From aaeb3f86a9326cac2a70496aa93a599bf01dc0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 12:59:45 +0100 Subject: [PATCH 02/10] fix unicorn/prefer-string-slice - same under expected input --- src/definitions/modules/calendar.js | 2 +- tasks/docs/metadata.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index 3fe1c42414..61cda10ecd 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -1721,7 +1721,7 @@ } for (j = 0; j < settings.text.months.length; j++) { monthString = settings.text.months[j]; - monthString = monthString.substring(0, word.length).toLowerCase(); + monthString = monthString.slice(0, word.length).toLowerCase(); if (monthString === word) { month = j + 1; diff --git a/tasks/docs/metadata.js b/tasks/docs/metadata.js index a6648c3764..1c110617eb 100644 --- a/tasks/docs/metadata.js +++ b/tasks/docs/metadata.js @@ -53,7 +53,7 @@ function parser(file, callback) { /** @type {string} */ text = String(file.contents.toString('utf8')), lines = text.split('\n'), - filename = file.path.substring(0, file.path.length - 4), + filename = file.path.slice(0, -4), key = 'server/documents', position = filename.indexOf(key) ; @@ -66,7 +66,7 @@ function parser(file, callback) { return callback(null, file); } - filename = filename.substring(position + key.length + 1, filename.length); + filename = filename.slice(position + key.length + 1, filename.length); var lineCount = lines.length, From e0e68940f5457709c4973e347c0878b157ed0175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 13:04:22 +0100 Subject: [PATCH 03/10] fix bug - typo in variable name --- src/definitions/modules/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index df39b3b2d5..75acfce953 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -2391,7 +2391,7 @@ $nextSelectedItem .addClass(className.selected) ; - if (settings.selectOnKeydown && module.is.single() && !$nextItem.hasClass(className.actionable)) { + if (settings.selectOnKeydown && module.is.single() && !$nextSelectedItem.hasClass(className.actionable)) { module.set.selectedItem($nextSelectedItem); } $menu From cb0dc38e27eec8b4b54433611e25923a1e759f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 13:21:38 +0100 Subject: [PATCH 04/10] fix bug - whitespace escape is probably wanted --- src/definitions/modules/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index c2589cf932..01ee77f8c8 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -1356,7 +1356,7 @@ regExp: { escape: /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, - beginsWith: '(?:\s|^)', + beginsWith: '(?:\\s|^)', }, // maps api response attributes to internal representation From 50af8743c47a6b934e16b04e6d7cff40057ac6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 13:14:19 +0100 Subject: [PATCH 05/10] fix unicorn/prefer-add-event-listener manually --- src/definitions/behaviors/visibility.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/definitions/behaviors/visibility.js b/src/definitions/behaviors/visibility.js index d3cdefd73c..866857fca2 100755 --- a/src/definitions/behaviors/visibility.js +++ b/src/definitions/behaviors/visibility.js @@ -246,8 +246,8 @@ ; while (imagesLength--) { cacheImage = document.createElement('img'); - cacheImage.onload = handleLoad; - cacheImage.onerror = handleLoad; + cacheImage.addEventListener('load', handleLoad); + cacheImage.addEventListener('error', handleLoad); cacheImage.src = images[imagesLength]; cache.push(cacheImage); } From d006601db5827817d17796af7254707573a22093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 13:18:52 +0100 Subject: [PATCH 06/10] fix $().map to $().each - as return is not used --- .eslintrc.js | 1 + src/definitions/modules/progress.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index a40765a90a..b23870a677 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -104,6 +104,7 @@ module.exports = { semi: ['error'], 'no-extra-semi': ['error'], 'no-trailing-spaces': ['error'], + 'array-callback-return': ['error', { allowImplicit: true }], }, reportUnusedDisableDirectives: true, }; \ No newline at end of file diff --git a/src/definitions/modules/progress.js b/src/definitions/modules/progress.js index b25a7b5c72..c1dfc44bd6 100644 --- a/src/definitions/modules/progress.js +++ b/src/definitions/modules/progress.js @@ -606,7 +606,7 @@ } }, barLabel: function (text) { - $progresses.map(function (index, element) { + $progresses.each(function (index, element) { var $progress = $(element); if (text !== undefined) { $progress.text(module.get.text(text, index)); From 0a8adeb933901d273beb4072a48f6ce83ea81aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 13:30:51 +0100 Subject: [PATCH 07/10] fix passing undefined explicitly --- src/definitions/modules/calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index 61cda10ecd..a1678e1535 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -885,7 +885,7 @@ var endDate = module.get.endDate(); if (!!endDate && !!date && date > endDate) { // selected date is greater than end date in range, so clear end date - module.set.endDate(undefined); + module.set.endDate(); } module.set.dataKeyValue(metadata.date, date); @@ -1022,7 +1022,7 @@ }, clear: function () { - module.set.date(undefined); + module.set.date(); }, popup: function () { From d510a48f99c633a85be9313d40ed11e70eba4f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 13:34:51 +0100 Subject: [PATCH 08/10] fix dead code - cache any response, even if empty --- src/definitions/behaviors/api.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/definitions/behaviors/api.js b/src/definitions/behaviors/api.js index d0e29a923d..8aa7918744 100644 --- a/src/definitions/behaviors/api.js +++ b/src/definitions/behaviors/api.js @@ -157,11 +157,6 @@ }, write: { cachedResponse: function (url, response) { - if (response && response === '') { - module.debug('Response empty, not caching', response); - - return; - } if (window.Storage === undefined) { module.error(error.noStorage); From 3156d3a6918dc923826230d466c97cae4c9b811d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 13:37:11 +0100 Subject: [PATCH 09/10] fix missing EOL --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index b23870a677..7d49b1ea4d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -107,4 +107,4 @@ module.exports = { 'array-callback-return': ['error', { allowImplicit: true }], }, reportUnusedDisableDirectives: true, -}; \ No newline at end of file +}; From db524bdf5bc6e1711000fd6f8875dd8697bdb937 Mon Sep 17 00:00:00 2001 From: Marco 'Lubber' Wienkoop Date: Sat, 10 Dec 2022 16:27:34 +0100 Subject: [PATCH 10/10] fix(calendar): central return for .some() --- src/definitions/modules/calendar.js | 55 ++++++++++++++++------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index a1678e1535..3a7a880c29 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -1104,57 +1104,59 @@ }, isDisabled: function (date, mode) { return (mode === 'day' || mode === 'month' || mode === 'year' || mode === 'hour') && (((mode === 'day' && settings.disabledDaysOfWeek.indexOf(date.getDay()) !== -1) || settings.disabledDates.some(function (d) { + var blocked = false; + if (typeof d === 'string') { d = module.helper.sanitiseDate(d); } if (d instanceof Date) { - return module.helper.dateEqual(date, d, mode); - } - if (d !== null && typeof d === 'object') { + blocked = module.helper.dateEqual(date, d, mode); + } else if (d !== null && typeof d === 'object') { if (d[metadata.year]) { if (typeof d[metadata.year] === 'number') { - return date.getFullYear() == d[metadata.year]; + blocked = date.getFullYear() == d[metadata.year]; } else if (Array.isArray(d[metadata.year])) { - return d[metadata.year].indexOf(date.getFullYear()) > -1; + blocked = d[metadata.year].indexOf(date.getFullYear()) > -1; } } else if (d[metadata.month]) { if (typeof d[metadata.month] === 'number') { - return date.getMonth() == d[metadata.month]; + blocked = date.getMonth() == d[metadata.month]; } else if (Array.isArray(d[metadata.month])) { - return d[metadata.month].indexOf(date.getMonth()) > -1; + blocked = d[metadata.month].indexOf(date.getMonth()) > -1; } else if (d[metadata.month] instanceof Date) { var sdate = module.helper.sanitiseDate(d[metadata.month]); - return (date.getMonth() == sdate.getMonth()) && (date.getFullYear() == sdate.getFullYear()); + blocked = (date.getMonth() == sdate.getMonth()) && (date.getFullYear() == sdate.getFullYear()); } } else if (d[metadata.date] && mode === 'day') { if (d[metadata.date] instanceof Date) { - return module.helper.dateEqual(date, module.helper.sanitiseDate(d[metadata.date]), mode); + blocked = module.helper.dateEqual(date, module.helper.sanitiseDate(d[metadata.date]), mode); } else if (Array.isArray(d[metadata.date])) { - return d[metadata.date].some(function (idate) { + blocked = d[metadata.date].some(function (idate) { return module.helper.dateEqual(date, idate, mode); }); } } } + + return blocked; })) || (mode === 'hour' && settings.disabledHours.some(function (d) { + var blocked = false; + if (typeof d === 'string') { d = module.helper.sanitiseDate(d); } if (d instanceof Date) { - return module.helper.dateEqual(date, d, mode); + blocked = module.helper.dateEqual(date, d, mode); } else if (typeof d === 'number') { - return date.getHours() === d; - } - if (d !== null && typeof d === 'object') { - var blocked = true; - + blocked = date.getHours() === d; + } else if (d !== null && typeof d === 'object') { if (d[metadata.date]) { if (d[metadata.date] instanceof Date) { blocked = module.helper.dateEqual(date, module.helper.sanitiseDate(d[metadata.date])); } else if (Array.isArray(d[metadata.date])) { - return d[metadata.date].some(function (idate) { - blocked = module.helper.dateEqual(date, idate, mode); + blocked = d[metadata.date].some(function (idate) { + return module.helper.dateEqual(date, idate, mode); }); } } @@ -1169,26 +1171,31 @@ if (d[metadata.hours]) { if (typeof d[metadata.hours] === 'number') { - return blocked && date.getHours() == d[metadata.hours]; + blocked = blocked && date.getHours() == d[metadata.hours]; } else if (Array.isArray(d[metadata.hours])) { - return blocked && d[metadata.hours].indexOf(date.getHours()) > -1; + blocked = blocked && d[metadata.hours].indexOf(date.getHours()) > -1; } } } + + return blocked; }))); }, isEnabled: function (date, mode) { if (mode === 'day') { return settings.enabledDates.length === 0 || settings.enabledDates.some(function (d) { + var enabled = false; + if (typeof d === 'string') { d = module.helper.sanitiseDate(d); } if (d instanceof Date) { - return module.helper.dateEqual(date, d, mode); - } - if (d !== null && typeof d === 'object' && d[metadata.date]) { - return module.helper.dateEqual(date, module.helper.sanitiseDate(d[metadata.date]), mode); + enabled = module.helper.dateEqual(date, d, mode); + } else if (d !== null && typeof d === 'object' && d[metadata.date]) { + enabled = module.helper.dateEqual(date, module.helper.sanitiseDate(d[metadata.date]), mode); } + + return enabled; }); } else { return true;