Created
September 20, 2020 21:43
-
-
Save muradddd/c939ddebc0eea215eba350f4a9ce2e59 to your computer and use it in GitHub Desktop.
notify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelectorAll('.companies-brands li').forEach(e => { | |
e.addEventListener('click', function () { | |
let url = window.location.href; | |
if (url.includes("?")) { | |
if (url.includes("company=")){ | |
let index = url.indexOf('company='); | |
let indexFirst = url.indexOf('=', index); | |
let indexLast = url.indexOf('&', indexFirst); | |
let newUrl = url.slice(0, indexFirst + 1) + this.id; | |
window.location = url.indexOf('&', indexFirst) === -1 ? newUrl : newUrl + url.slice(indexLast); | |
}else{ | |
window.location += `&company=${this.id}` | |
} | |
} else { | |
window.location += `?company=${this.id}` | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment