Skip to content

Commit

Permalink
removed all logs and replaced one let with const and fixed indentatio…
Browse files Browse the repository at this point in the history
…n in dom.js because it hurt my eyes

relates #8
  • Loading branch information
FarahZaqout committed May 28, 2018
1 parent 903ba6f commit de1437d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
18 changes: 9 additions & 9 deletions public/js/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ var slideIndex = 0;
showSlides();

function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
slides[slideIndex-1].style.display = "block";
setTimeout(showSlides, 2000); // Change image every 2 seconds
var i;
var slides = document.getElementsByClassName("mySlides");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
slides[slideIndex-1].style.display = "block";
setTimeout(showSlides, 2000); // Change image every 2 seconds
}
19 changes: 4 additions & 15 deletions public/js/filter_elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ window.onload = () => {
const path = location.pathname.split('/')[3];
let url;
const pathArray = path.split('&');
let elementList = [];
const elementList = [];
let priceElements = [];
let sizeElements = [];
let locationElements = [];
Expand All @@ -53,16 +53,11 @@ if (path) {
}); // end of first forEach;
}

console.log('price', priceElements);
console.log('size', sizeElements);
console.log('loc', locationElements);

const listener = (element) => {
element.addEventListener('change', () => {
if (!path || path === undefined) {
url = element.id;
} else if (path) {
console.log(element.id);
if (element.id.startsWith('p') && priceElements.includes(element.id) && !element.checked) priceElements.splice(priceElements.indexOf(element.id), 1);
if (element.id.startsWith('p') && !priceElements.includes(element.id) && element.checked) priceElements = priceElements.concat(element.id).sort();

Expand All @@ -75,20 +70,14 @@ const listener = (element) => {
if (element.id.startsWith('l') && !locationElements.includes(element.id) && element.checked) locationElements = locationElements.concat(element.id).sort();


priceString = priceElements.join(',')
sizeString = sizeElements.join(',')
locationString = locationElements.join(',')
priceString = priceElements.join(',');
sizeString = sizeElements.join(',');
locationString = locationElements.join(',');

url = elementList.concat(priceString).concat(sizeString).concat(locationString).filter(e => e !== '')
.join('&');
} // end of else statement;

console.log('newprice', priceString);
console.log('newsize', sizeString);
console.log('newloc', locationString);
console.log(url);


fetch(url, {
method: 'GET',
})
Expand Down

0 comments on commit de1437d

Please sign in to comment.