From a4f8c8b2a58e89e2042836f22b5bc5610c9577bb Mon Sep 17 00:00:00 2001 From: Aron den Ouden Date: Wed, 25 Sep 2024 10:07:54 +0200 Subject: [PATCH 1/3] Resolved the error 'Cannot read property '' of undefined' caused by incorrectly importing dayjs --- static/js/common.js | 4 +--- templates/home.html | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/static/js/common.js b/static/js/common.js index f06a5aa..d1d66a8 100644 --- a/static/js/common.js +++ b/static/js/common.js @@ -21,6 +21,4 @@ var selectedLogoId; var emailCode; var pointersOnMap = []; -var logoIcons = []; - -dayjs.extend(window.dayjs_plugin_relativeTime) \ No newline at end of file +var logoIcons = []; \ No newline at end of file diff --git a/templates/home.html b/templates/home.html index 79095e4..b91c931 100644 --- a/templates/home.html +++ b/templates/home.html @@ -96,8 +96,8 @@ crossorigin=""> + - From e7551cf47a2890a9b33278704ff37a1223894df5 Mon Sep 17 00:00:00 2001 From: Aron den Ouden Date: Wed, 25 Sep 2024 10:25:10 +0200 Subject: [PATCH 2/3] Temp fix of Logo GET request by commenting all logo code out. Personally I think all the code related to Logo requests can be removed, but I still don't know what the intended use of it was --- static/js/main.js | 116 +++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index 445b04c..af0b145 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,68 +1,68 @@ // ****LOGO ADDER //Load the logo for the add view and the icons -var logoSourceRequest = new XMLHttpRequest(); -logoSourceRequest.open('GET', 'static/img/logo.svg', true); -logoSourceRequest.onreadystatechange = function(){ - if(this.readyState == 4 && this.status == 200){ - //Get the logo - const logo = this.responseText; - // Make request to server to get all logos - var logoRequest = new XMLHttpRequest(); - logoRequest.open('GET', 'logos', true); +// var logoSourceRequest = new XMLHttpRequest(); +// logoSourceRequest.open('GET', 'static/img/logo.svg', true); +// logoSourceRequest.onreadystatechange = function(){ +// if(this.readyState == 4 && this.status == 200){ +// //Get the logo +// const logo = this.responseText; +// // Make request to server to get all logos +// var logoRequest = new XMLHttpRequest(); +// logoRequest.open('GET', 'logos', true); - logoRequest.onreadystatechange = function() { - if(this.readyState == 4 && this.status == 200){ - //Create JSON object of response - var logoJson = JSON.parse(this.responseText); - for(var i = 0; i < logoJson.length; i ++){ - const color = logoJson[i][2]; - const logoId = logoJson[i][0]; - const title = logoJson[i][1]; - //Create the object - const logoElement = document.createElement('div'); - logoElement.classList.add('logoElement'); - logoElement.innerHTML = logo.replaceAll('COLORPLACE', color); - logoElement.style.width = '50px'; +// logoRequest.onreadystatechange = function() { +// if(this.readyState == 4 && this.status == 200){ +// //Create JSON object of response +// var logoJson = JSON.parse(this.responseText); +// for(var i = 0; i < logoJson.length; i ++){ +// const color = logoJson[i][2]; +// const logoId = logoJson[i][0]; +// const title = logoJson[i][1]; +// //Create the object +// const logoElement = document.createElement('div'); +// logoElement.classList.add('logoElement'); +// logoElement.innerHTML = logo.replaceAll('COLORPLACE', color); +// logoElement.style.width = '50px'; - //Handle selection - logoElement.addEventListener('click', function(){ - if(selectedLogo != null){ - selectedLogo.classList.remove('logoElementSelected'); - } - logoElement.classList.add('logoElementSelected'); - selectedLogo = logoElement; - selectedLogoId = logoId; - }); +// //Handle selection +// logoElement.addEventListener('click', function(){ +// if(selectedLogo != null){ +// selectedLogo.classList.remove('logoElementSelected'); +// } +// logoElement.classList.add('logoElementSelected'); +// selectedLogo = logoElement; +// selectedLogoId = logoId; +// }); - //Select if first one - if(i == 0){ - logoElement.classList.add('logoElementSelected'); - selectedLogo = logoElement; - selectedLogoId = logoId; - } +// //Select if first one +// if(i == 0){ +// logoElement.classList.add('logoElementSelected'); +// selectedLogo = logoElement; +// selectedLogoId = logoId; +// } - addLogoSelector.appendChild(logoElement); +// addLogoSelector.appendChild(logoElement); - //Create icon for map - const logoIcon = { - id: logoId, - icon: L.divIcon({ - className: 'customDivIcon', - html: logo.replaceAll('COLORPLACE', color), - iconSize: [40, 40], - iconAnchor: [24, 24] - }) - } - logoIcons.push(logoIcon); - } - //Logo's ready, map ready - updateMap(); - } - } - logoRequest.send(); - } -} -logoSourceRequest.send(); +// //Create icon for map +// const logoIcon = { +// id: logoId, +// icon: L.divIcon({ +// className: 'customDivIcon', +// html: logo.replaceAll('COLORPLACE', color), +// iconSize: [40, 40], +// iconAnchor: [24, 24] +// }) +// } +// logoIcons.push(logoIcon); +// } +// //Logo's ready, map ready +// updateMap(); +// } +// } +// logoRequest.send(); +// } +// } +// logoSourceRequest.send(); //Update email From 74bf2c91b51778591e899ef9dcfb314c7b335176 Mon Sep 17 00:00:00 2001 From: Aron den Ouden Date: Tue, 1 Oct 2024 19:27:36 +0200 Subject: [PATCH 3/3] common.js: every file should end with an empty line --- static/js/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/common.js b/static/js/common.js index d1d66a8..e4ed4f1 100644 --- a/static/js/common.js +++ b/static/js/common.js @@ -21,4 +21,4 @@ var selectedLogoId; var emailCode; var pointersOnMap = []; -var logoIcons = []; \ No newline at end of file +var logoIcons = [];