diff --git a/assets/config/.eslintrc b/assets/config/.eslintrc --- a/assets/config/.eslintrc +++ b/assets/config/.eslintrc @@ -247,6 +247,10 @@ "classes": "never" }], "prefer-promise-reject-errors": "error", + "prefer-const": ["error", { + "destructuring": "any", + "ignoreReadBeforeAssign": false + }], "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true diff --git a/assets/config/webpack-plugins/dump-highlightjs-languages-data-plugin.js b/assets/config/webpack-plugins/dump-highlightjs-languages-data-plugin.js --- a/assets/config/webpack-plugins/dump-highlightjs-languages-data-plugin.js +++ b/assets/config/webpack-plugins/dump-highlightjs-languages-data-plugin.js @@ -26,12 +26,12 @@ const languages = hljs.listLanguages(); const hljsLanguagesData = {'languages': languages}; const languageAliases = {}; - for (let language of languages) { + for (const language of languages) { const languageData = hljs.getLanguage(language); if (!languageData.hasOwnProperty('aliases')) { continue; } - for (let alias of languageData.aliases) { + for (const alias of languageData.aliases) { languageAliases[alias] = language; languageAliases[alias.toLowerCase()] = language; } diff --git a/assets/config/webpack-plugins/fix-swh-source-maps-webpack-plugin.js b/assets/config/webpack-plugins/fix-swh-source-maps-webpack-plugin.js --- a/assets/config/webpack-plugins/fix-swh-source-maps-webpack-plugin.js +++ b/assets/config/webpack-plugins/fix-swh-source-maps-webpack-plugin.js @@ -32,10 +32,10 @@ }).forEach(key => { let bundleName = key.replace(/^js\//, ''); bundleName = bundleName.replace(/^css\//, ''); - let pos = bundleName.indexOf('.'); + const pos = bundleName.indexOf('.'); bundleName = bundleName.slice(0, pos); - let asset = compilation.assets[key]; - let source = asset.source().replace(/swh.\[name\]/g, 'swh.' + bundleName); + const asset = compilation.assets[key]; + const source = asset.source().replace(/swh.\[name\]/g, 'swh.' + bundleName); compilation.updateAsset(key, new sources.RawSource(source)); }); } diff --git a/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/index.js b/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/index.js --- a/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/index.js +++ b/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/index.js @@ -56,7 +56,7 @@ compiler.hooks.done.tap(pluginName, statsObj => { // get the stats object in JSON format - let stats = statsObj.toJson(); + const stats = statsObj.toJson(); this.stats = stats; // set output folder @@ -72,7 +72,7 @@ // map each generated webpack chunk to its js asset Object.keys(stats.assetsByChunkName).forEach((chunkName, i) => { if (Array.isArray(stats.assetsByChunkName[chunkName])) { - for (let asset of stats.assetsByChunkName[chunkName]) { + for (const asset of stats.assetsByChunkName[chunkName]) { if (asset.endsWith('.js')) { this.chunkNameToJsAsset[chunkName] = asset; this.chunkNameToJsAsset[i] = asset; @@ -101,22 +101,22 @@ } // do not process modules in the exclusion list - for (let toExclude of this.exclude) { + for (const toExclude of this.exclude) { if (srcFilePath.startsWith(toExclude)) { return; } } // remove webpack loader call if any - let loaderEndPos = srcFilePath.indexOf('!'); + const loaderEndPos = srcFilePath.indexOf('!'); if (loaderEndPos !== -1) { srcFilePath = srcFilePath.slice(loaderEndPos + 1); } // iterate on all chunks containing the module mod.chunks.forEach(chunk => { - let chunkName = this.chunkIdToName[chunk]; - let chunkJsAsset = stats.publicPath + this.chunkNameToJsAsset[chunkName]; + const chunkName = this.chunkIdToName[chunk]; + const chunkJsAsset = stats.publicPath + this.chunkNameToJsAsset[chunkName]; // init the chunk to source files mapping if needed if (!this.chunkJsAssetToSrcFiles.hasOwnProperty(chunkJsAsset)) { @@ -129,31 +129,31 @@ } // init source file metadata - let srcFileData = {'id': this.cleanupPath(srcFilePath)}; + const srcFileData = {'id': this.cleanupPath(srcFilePath)}; // find and parse the corresponding package.json file let packageJsonPath; - let nodeModule = srcFilePath.startsWith('./node_modules/'); + const nodeModule = srcFilePath.startsWith('./node_modules/'); if (nodeModule) { packageJsonPath = this.findPackageJsonPath(srcFilePath); } else { packageJsonPath = './package.json'; } - let packageJson = this.parsePackageJson(packageJsonPath); + const packageJson = this.parsePackageJson(packageJsonPath); // extract license information, overriding it if needed let licenseOverridden = false; let licenseFilePath; if (this.options['licenseOverride']) { - for (let srcFilePrefixKey of Object.keys(this.options['licenseOverride'])) { + for (const srcFilePrefixKey of Object.keys(this.options['licenseOverride'])) { let srcFilePrefix = srcFilePrefixKey; if (!srcFilePrefixKey.startsWith('.')) { srcFilePrefix = './' + path.join('node_modules', srcFilePrefixKey); } if (srcFilePath.startsWith(srcFilePrefix)) { - let spdxLicenseExpression = this.options['licenseOverride'][srcFilePrefixKey]['spdxLicenseExpression']; + const spdxLicenseExpression = this.options['licenseOverride'][srcFilePrefixKey]['spdxLicenseExpression']; licenseFilePath = this.options['licenseOverride'][srcFilePrefixKey]['licenseFilePath']; - let parsedSpdxLicenses = this.parseSpdxLicenseExpression(spdxLicenseExpression, `file ${srcFilePath}`); + const parsedSpdxLicenses = this.parseSpdxLicenseExpression(spdxLicenseExpression, `file ${srcFilePath}`); srcFileData['licenses'] = this.spdxToWebLabelsLicenses(parsedSpdxLicenses); licenseOverridden = true; break; @@ -163,12 +163,12 @@ if (!licenseOverridden) { srcFileData['licenses'] = this.extractLicenseInformation(packageJson); - let licenseDir = path.join(...packageJsonPath.split('/').slice(0, -1)); + const licenseDir = path.join(...packageJsonPath.split('/').slice(0, -1)); licenseFilePath = this.findLicenseFile(licenseDir); } // copy original license file and get its url - let licenseCopyUrl = this.copyLicenseFile(licenseFilePath); + const licenseCopyUrl = this.copyLicenseFile(licenseFilePath); srcFileData['licenses'].forEach(license => { license['copy_url'] = licenseCopyUrl; }); @@ -186,20 +186,20 @@ // process additional scripts if needed if (this.options['additionalScripts']) { for (let script of Object.keys(this.options['additionalScripts'])) { - let scriptFilesData = this.options['additionalScripts'][script]; + const scriptFilesData = this.options['additionalScripts'][script]; if (script.indexOf('://') === -1 && !script.startsWith('/')) { script = stats.publicPath + script; } this.chunkJsAssetToSrcFiles[script] = []; this.srcIdsInChunkJsAsset[script] = new Set(); - for (let scriptSrc of scriptFilesData) { - let scriptSrcData = {'id': scriptSrc['id']}; - let licenceFilePath = scriptSrc['licenseFilePath']; - let parsedSpdxLicenses = this.parseSpdxLicenseExpression(scriptSrc['spdxLicenseExpression'], - `file ${scriptSrc['path']}`); + for (const scriptSrc of scriptFilesData) { + const scriptSrcData = {'id': scriptSrc['id']}; + const licenceFilePath = scriptSrc['licenseFilePath']; + const parsedSpdxLicenses = this.parseSpdxLicenseExpression(scriptSrc['spdxLicenseExpression'], + `file ${scriptSrc['path']}`); scriptSrcData['licenses'] = this.spdxToWebLabelsLicenses(parsedSpdxLicenses); if (licenceFilePath.indexOf('://') === -1 && !licenceFilePath.startsWith('/')) { - let licenseCopyUrl = this.copyLicenseFile(licenceFilePath); + const licenseCopyUrl = this.copyLicenseFile(licenceFilePath); scriptSrcData['licenses'].forEach(license => { license['copy_url'] = licenseCopyUrl; }); @@ -219,18 +219,18 @@ } } - for (let srcFiles of Object.values(this.chunkJsAssetToSrcFiles)) { + for (const srcFiles of Object.values(this.chunkJsAssetToSrcFiles)) { srcFiles.sort((a, b) => a.id.localeCompare(b.id)); } if (this.outputType === 'json') { // generate the jslicenses.json file - let weblabelsData = JSON.stringify(this.chunkJsAssetToSrcFiles); - let weblabelsJsonFile = path.join(this.weblabelsOutputDir, 'jslicenses.json'); + const weblabelsData = JSON.stringify(this.chunkJsAssetToSrcFiles); + const weblabelsJsonFile = path.join(this.weblabelsOutputDir, 'jslicenses.json'); fs.writeFileSync(weblabelsJsonFile, weblabelsData); } else { // generate the jslicenses.html file - let weblabelsPageFile = path.join(this.weblabelsOutputDir, 'jslicenses.html'); + const weblabelsPageFile = path.join(this.weblabelsOutputDir, 'jslicenses.html'); ejs.renderFile(path.join(__dirname, 'jslicenses.ejs'), {'jslicenses_data': this.chunkJsAssetToSrcFiles}, {'rmWhitespace': true}, @@ -253,7 +253,7 @@ } findPackageJsonPath(srcFilePath) { - let pathSplit = srcFilePath.split('/'); + const pathSplit = srcFilePath.split('/'); let packageJsonPath; for (let i = 3; i < pathSplit.length; ++i) { packageJsonPath = path.join(...pathSplit.slice(0, i), 'package.json'); @@ -298,7 +298,7 @@ parsePackageJson(packageJsonPath) { if (!this.packageJsonCache.hasOwnProperty(packageJsonPath)) { - let packageJsonStr = fs.readFileSync(packageJsonPath).toString('utf8'); + const packageJsonStr = fs.readFileSync(packageJsonPath).toString('utf8'); this.packageJsonCache[packageJsonPath] = JSON.parse(packageJsonStr); } return this.packageJsonCache[packageJsonPath]; @@ -324,7 +324,7 @@ spdxToWebLabelsLicense(spdxLicenceId) { for (let i = 0; i < spdxLicensesMapping.length; ++i) { if (spdxLicensesMapping[i]['spdx_ids'].indexOf(spdxLicenceId) !== -1) { - let licenseData = Object.assign({}, spdxLicensesMapping[i]); + const licenseData = Object.assign({}, spdxLicensesMapping[i]); delete licenseData['spdx_ids']; delete licenseData['magnet_link']; licenseData['copy_url'] = ''; @@ -349,7 +349,7 @@ ret.push(this.spdxToWebLabelsLicense(spdxLicenses['license'])); } else if (spdxLicenses.hasOwnProperty('left')) { if (spdxLicenses['left'].hasOwnProperty('license')) { - let licenseData = this.spdxToWebLabelsLicense(spdxLicenses['left']['license']); + const licenseData = this.spdxToWebLabelsLicense(spdxLicenses['left']['license']); ret.push(licenseData); } else { ret = ret.concat(this.spdxToWebLabelsLicenses(spdxLicenses['left'])); @@ -365,9 +365,9 @@ spdxLicenseExpression = packageJson['license']; } else if (packageJson.hasOwnProperty('licenses')) { // for node packages using deprecated licenses property - let licenses = packageJson['licenses']; + const licenses = packageJson['licenses']; if (Array.isArray(licenses)) { - let l = []; + const l = []; licenses.forEach(license => { l.push(license['type']); }); @@ -376,8 +376,8 @@ spdxLicenseExpression = licenses['type']; } } - let parsedSpdxLicenses = this.parseSpdxLicenseExpression(spdxLicenseExpression, - `module ${packageJson['name']}`); + const parsedSpdxLicenses = this.parseSpdxLicenseExpression(spdxLicenseExpression, + `module ${packageJson['name']}`); return this.spdxToWebLabelsLicenses(parsedSpdxLicenses); } @@ -387,7 +387,7 @@ return; } let destPath = this.cleanupPath(srcFilePath); - let destDir = path.join(this.weblabelsOutputDir, ...destPath.split('/').slice(0, -1)); + const destDir = path.join(this.weblabelsOutputDir, ...destPath.split('/').slice(0, -1)); this.recursiveMkdir(destDir); destPath = path.join(this.weblabelsOutputDir, destPath + ext); fs.copyFileSync(srcFilePath, destPath); @@ -395,9 +395,9 @@ } recursiveMkdir(destPath) { - let destPathSplit = destPath.split('/'); + const destPathSplit = destPath.split('/'); for (let i = 1; i < destPathSplit.length; ++i) { - let currentPath = path.join('/', ...destPathSplit.slice(0, i + 1)); + const currentPath = path.join('/', ...destPathSplit.slice(0, i + 1)); if (!fs.existsSync(currentPath)) { fs.mkdirSync(currentPath); } diff --git a/assets/config/webpack.config.development.js b/assets/config/webpack.config.development.js --- a/assets/config/webpack.config.development.js +++ b/assets/config/webpack.config.development.js @@ -45,7 +45,7 @@ }); // common loaders for css related assets (css, sass) -let cssLoaders = [ +const cssLoaders = [ MiniCssExtractPlugin.loader, { loader: 'cache-loader' diff --git a/assets/src/bundles/admin/deposit.js b/assets/src/bundles/admin/deposit.js --- a/assets/src/bundles/admin/deposit.js +++ b/assets/src/bundles/admin/deposit.js @@ -56,12 +56,12 @@ name: 'swhid_context', render: (data, type, row) => { if (data && type === 'display') { - let originPattern = ';origin='; - let originPatternIdx = data.indexOf(originPattern); + const originPattern = ';origin='; + const originPatternIdx = data.indexOf(originPattern); if (originPatternIdx !== -1) { let originUrl = data.slice(originPatternIdx + originPattern.length); - let nextSepPattern = ';'; - let nextSepPatternIdx = originUrl.indexOf(nextSepPattern); + const nextSepPattern = ';'; + const nextSepPatternIdx = originUrl.indexOf(nextSepPattern); if (nextSepPatternIdx !== -1) { /* Remove extra context */ originUrl = originUrl.slice(0, nextSepPatternIdx); } @@ -76,7 +76,7 @@ name: 'reception_date', render: (data, type, row) => { if (type === 'display') { - let date = new Date(data); + const date = new Date(data); return date.toLocaleString(); } return data; diff --git a/assets/src/bundles/admin/origin-save.js b/assets/src/bundles/admin/origin-save.js --- a/assets/src/bundles/admin/origin-save.js +++ b/assets/src/bundles/admin/origin-save.js @@ -54,7 +54,7 @@ enableRowSelection('#swh-unauthorized-origin-urls'); swh.webapp.addJumpToPagePopoverToDataTable(unauthorizedOriginTable); - let columnsData = [ + const columnsData = [ { data: 'id', name: 'id', @@ -66,7 +66,7 @@ name: 'request_date', render: (data, type, row) => { if (type === 'display') { - let date = new Date(data); + const date = new Date(data); return date.toLocaleString(); } return data; @@ -309,7 +309,7 @@ export function rejectOriginSaveRequest() { const selectedRow = pendingSaveRequestsTable.row('.selected'); if (selectedRow.length) { - let rejectOriginSaveRequestCallback = async() => { + const rejectOriginSaveRequestCallback = async() => { const rowData = selectedRow.data(); const rejectSaveRequestUrl = Urls.admin_origin_save_request_reject(rowData['visit_type'], rowData['origin_url']); await csrfPost(rejectSaveRequestUrl); @@ -324,10 +324,10 @@ } function removeOriginSaveRequest(requestTable) { - let selectedRow = requestTable.row('.selected'); + const selectedRow = requestTable.row('.selected'); if (selectedRow.length) { - let requestId = selectedRow.data()['id']; - let removeOriginSaveRequestCallback = async() => { + const requestId = selectedRow.data()['id']; + const removeOriginSaveRequestCallback = async() => { const removeSaveRequestUrl = Urls.admin_origin_save_request_remove(requestId); await csrfPost(removeSaveRequestUrl); requestTable.ajax.reload(null, false); diff --git a/assets/src/bundles/auth/index.js b/assets/src/bundles/auth/index.js --- a/assets/src/bundles/auth/index.js +++ b/assets/src/bundles/auth/index.js @@ -150,7 +150,7 @@ name: 'creation_date', render: (data, type, row) => { if (type === 'display') { - let date = new Date(data); + const date = new Date(data); return date.toLocaleString(); } return data; diff --git a/assets/src/bundles/browse/origin-search.js b/assets/src/bundles/browse/origin-search.js --- a/assets/src/bundles/browse/origin-search.js +++ b/assets/src/bundles/browse/origin-search.js @@ -8,13 +8,13 @@ import {handleFetchError, isArchivedOrigin} from 'utils/functions'; const limit = 100; -let linksPrev = []; +const linksPrev = []; let linkNext = null; let linkCurrent = null; let inSearch = false; function parseLinkHeader(s) { - let re = /<(.+)>; rel="next"/; + const re = /<(.+)>; rel="next"/; return s.match(re)[1]; } @@ -33,10 +33,10 @@ $('#swh-origin-search-results').show(); $('#swh-no-result').hide(); clearOriginSearchResultsTable(); - let table = $('#origin-search-results tbody'); - let promises = []; - for (let [i, origin] of origins.entries()) { - let browseUrl = `${Urls.browse_origin()}?origin_url=${encodeURIComponent(origin.url)}`; + const table = $('#origin-search-results tbody'); + const promises = []; + for (const [i, origin] of origins.entries()) { + const browseUrl = `${Urls.browse_origin()}?origin_url=${encodeURIComponent(origin.url)}`; let tableRow = ``; tableRow += @@ -104,7 +104,7 @@ function searchOriginsFirst(searchQueryText, limit) { let baseSearchUrl; - let searchMetadata = $('#swh-search-origin-metadata').prop('checked'); + const searchMetadata = $('#swh-search-origin-metadata').prop('checked'); if (searchMetadata) { baseSearchUrl = new URL(Urls.api_1_origin_metadata_search(), window.location); baseSearchUrl.searchParams.append('fulltext', searchQueryText); @@ -112,14 +112,14 @@ baseSearchUrl = new URL(Urls.api_1_origin_search(searchQueryText), window.location); } - let withVisit = $('#swh-search-origins-with-visit').prop('checked'); + const withVisit = $('#swh-search-origins-with-visit').prop('checked'); baseSearchUrl.searchParams.append('limit', limit); baseSearchUrl.searchParams.append('with_visit', withVisit); const visitType = $('#swh-search-visit-type').val(); if (visitType !== 'any') { baseSearchUrl.searchParams.append('visit_type', visitType); } - let searchUrl = baseSearchUrl.toString(); + const searchUrl = baseSearchUrl.toString(); searchOrigins(searchUrl); } @@ -135,7 +135,7 @@ // Save link to the next results page. linkNext = null; if (response.headers.has('Link')) { - let parsedLink = parseLinkHeader(response.headers.get('Link')); + const parsedLink = parseLinkHeader(response.headers.get('Link')); if (parsedLink !== undefined) { linkNext = parsedLink; } @@ -195,12 +195,12 @@ event.preventDefault(); if (event.target.checkValidity()) { $(event.target).removeClass('was-validated'); - let searchQueryText = $('#swh-origins-url-patterns').val().trim(); - let withVisit = $('#swh-search-origins-with-visit').prop('checked'); - let withContent = $('#swh-filter-empty-visits').prop('checked'); - let searchMetadata = $('#swh-search-origin-metadata').prop('checked'); + const searchQueryText = $('#swh-origins-url-patterns').val().trim(); + const withVisit = $('#swh-search-origins-with-visit').prop('checked'); + const withContent = $('#swh-filter-empty-visits').prop('checked'); + const searchMetadata = $('#swh-search-origin-metadata').prop('checked'); const visitType = $('#swh-search-visit-type').val(); - let queryParameters = new URLSearchParams(); + const queryParameters = new URLSearchParams(); queryParameters.append('q', searchQueryText); if (withVisit) { queryParameters.append('with_visit', withVisit); @@ -240,12 +240,12 @@ event.preventDefault(); }); - let urlParams = new URLSearchParams(window.location.search); - let query = urlParams.get('q'); - let withVisit = urlParams.has('with_visit'); - let withContent = urlParams.has('with_content'); - let searchMetadata = urlParams.has('search_metadata'); - let visitType = urlParams.get('visit_type'); + const urlParams = new URLSearchParams(window.location.search); + const query = urlParams.get('q'); + const withVisit = urlParams.has('with_visit'); + const withContent = urlParams.has('with_content'); + const searchMetadata = urlParams.has('search_metadata'); + const visitType = urlParams.get('visit_type'); if (query) { $('#swh-origins-url-patterns').val(query); $('#swh-search-origins-with-visit').prop('checked', withVisit); diff --git a/assets/src/bundles/browse/snapshot-navigation.js b/assets/src/bundles/browse/snapshot-navigation.js --- a/assets/src/bundles/browse/snapshot-navigation.js +++ b/assets/src/bundles/browse/snapshot-navigation.js @@ -38,7 +38,7 @@ // taking icons into account, in order to make the whole names readable $('#swh-branches-releases-dd').on('show.bs.dropdown', () => { if (dropdownResized) return; - let dropdownWidth = $('.swh-branches-releases').width(); + const dropdownWidth = $('.swh-branches-releases').width(); $('.swh-branches-releases').width(dropdownWidth + 25); dropdownResized = true; }); diff --git a/assets/src/bundles/browse/swhid-utils.js b/assets/src/bundles/browse/swhid-utils.js --- a/assets/src/bundles/browse/swhid-utils.js +++ b/assets/src/bundles/browse/swhid-utils.js @@ -18,9 +18,9 @@ export function swhIdContextOptionToggled(event) { event.stopPropagation(); - let swhIdElt = $(event.target).closest('.swhid-ui').find('.swhid'); - let swhIdWithContext = $(event.target).data('swhid-with-context'); - let swhIdWithContextUrl = $(event.target).data('swhid-with-context-url'); + const swhIdElt = $(event.target).closest('.swhid-ui').find('.swhid'); + const swhIdWithContext = $(event.target).data('swhid-with-context'); + const swhIdWithContextUrl = $(event.target).data('swhid-with-context-url'); let currentSwhId = swhIdElt.text(); if ($(event.target).prop('checked')) { swhIdElt.attr('href', swhIdWithContextUrl); @@ -38,11 +38,11 @@ } function addLinesInfo() { - let swhIdElt = $('#swhid-tab-content').find('.swhid'); + const swhIdElt = $('#swhid-tab-content').find('.swhid'); let currentSwhId = swhIdElt.text().replace(/;\n/g, ';'); - let lines = []; + const lines = []; let linesPart = ';lines='; - let linesRegexp = new RegExp(/L(\d+)/g); + const linesRegexp = new RegExp(/L(\d+)/g); let line = linesRegexp.exec(window.location.hash); while (line) { lines.push(parseInt(line[1])); @@ -69,14 +69,14 @@ $(document).ready(() => { new ClipboardJS('.btn-swhid-copy', { text: trigger => { - let swhId = $(trigger).closest('.swhid-ui').find('.swhid').text(); + const swhId = $(trigger).closest('.swhid-ui').find('.swhid').text(); return swhId.replace(/;\n/g, ';'); } }); new ClipboardJS('.btn-swhid-url-copy', { text: trigger => { - let swhIdUrl = $(trigger).closest('.swhid-ui').find('.swhid').attr('href'); + const swhIdUrl = $(trigger).closest('.swhid-ui').find('.swhid').attr('href'); return window.location.origin + swhIdUrl; } }); @@ -85,7 +85,7 @@ $('#swh-identifiers').css('width', '1000px'); } - let tabSlideOptions = { + const tabSlideOptions = { tabLocation: 'right', clickScreenToCloseFilters: ['.ui-slideouttab-panel', '.modal'], offset: function() { diff --git a/assets/src/bundles/origin/visits-calendar.js b/assets/src/bundles/origin/visits-calendar.js --- a/assets/src/bundles/origin/visits-calendar.js +++ b/assets/src/bundles/origin/visits-calendar.js @@ -8,8 +8,8 @@ import Calendar from 'js-year-calendar'; import 'js-year-calendar/dist/js-year-calendar.css'; -let minSize = 15; -let maxSize = 28; +const minSize = 15; +const maxSize = 28; let currentPopover = null; let visitsByDate = {}; @@ -28,9 +28,9 @@ for (let i = 0; i < filteredVisits.length; ++i) { filteredVisits[i]['startDate'] = filteredVisits[i]['date']; filteredVisits[i]['endDate'] = filteredVisits[i]['startDate']; - let date = new Date(filteredVisits[i]['date']); + const date = new Date(filteredVisits[i]['date']); date.setHours(0, 0, 0, 0); - let dateStr = date.toDateString(); + const dateStr = date.toDateString(); if (!visitsByDate.hasOwnProperty(dateStr)) { visitsByDate[dateStr] = [filteredVisits[i]]; } else { @@ -59,24 +59,24 @@ startYear: year, renderEnd: e => yearClickedCallback(e.currentYear), customDataSourceRenderer: (element, date, events) => { - let dateStr = date.toDateString(); - let nbVisits = visitsByDate[dateStr].length; + const dateStr = date.toDateString(); + const nbVisits = visitsByDate[dateStr].length; let t = nbVisits / maxNbVisitsByDate; if (maxNbVisitsByDate === 1) { t = 0; } - let size = minSize + t * (maxSize - minSize); - let offsetX = (maxSize - size) / 2 - parseInt($(element).css('padding-left')); - let offsetY = (maxSize - size) / 2 - parseInt($(element).css('padding-top')) + 1; - let cellWrapper = $('
'); + const size = minSize + t * (maxSize - minSize); + const offsetX = (maxSize - size) / 2 - parseInt($(element).css('padding-left')); + const offsetY = (maxSize - size) / 2 - parseInt($(element).css('padding-top')) + 1; + const cellWrapper = $('
'); cellWrapper.css('position', 'relative'); - let dayNumber = $('
'); + const dayNumber = $('
'); dayNumber.text($(element).text()); - let circle = $('
'); + const circle = $('
'); let r = 0; let g = 0; for (let i = 0; i < nbVisits; ++i) { - let visit = visitsByDate[dateStr][i]; + const visit = visitsByDate[dateStr][i]; if (visit.status === 'full') { g += 255; } else if (visit.status === 'partial') { @@ -103,14 +103,14 @@ if (currentPopover !== e.element) { closePopover(); } - let dateStr = e.date.toDateString(); + const dateStr = e.date.toDateString(); if (visitsByDate.hasOwnProperty(dateStr)) { - let visits = visitsByDate[dateStr]; + const visits = visitsByDate[dateStr]; let content = '
' + e.date.toDateString() + '
'; content += '