Skip to content

Instantly share code, notes, and snippets.

@muradddd
Created September 20, 2020 21:43
Show Gist options
  • Save muradddd/c939ddebc0eea215eba350f4a9ce2e59 to your computer and use it in GitHub Desktop.
Save muradddd/c939ddebc0eea215eba350f4a9ce2e59 to your computer and use it in GitHub Desktop.
notify
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