Skip to content

Commit

Permalink
Merge pull request #4 from svsticky/FixSmallConsoleBugs
Browse files Browse the repository at this point in the history
Fix small console bugs
  • Loading branch information
ArondenOuden authored Oct 1, 2024
2 parents 6593b83 + 74bf2c9 commit 0d2f85e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 61 deletions.
2 changes: 0 additions & 2 deletions static/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ var emailCode;

var pointersOnMap = [];
var logoIcons = [];

dayjs.extend(window.dayjs_plugin_relativeTime)
116 changes: 58 additions & 58 deletions static/js/main.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
crossorigin=""></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/relativeTime.js"></script>
<script>dayjs.extend(window.dayjs_plugin_relativeTime)</script>
<script src="https://cdn.jsdelivr.net/npm/leaflet.locatecontrol/dist/L.Control.Locate.min.js" charset="utf-8"></script>
<script>dayjs.extend(window.dayjs_plugin_utc)</script>
<script src="/static/js/common.js"></script>
<script src="/static/js/map.js"></script>
<script src="/static/js/UI.js"></script>
Expand Down

0 comments on commit 0d2f85e

Please sign in to comment.