Hey guys i have written a simple function which reads the current url and sets some kind of highlight.
If I open up the url everything works fine but if I do more advanced request it's not working.
example: If i request "/customers" it works but if I request "/customers/10" it's not working anymore. Can someone provide me with some regex action ?
Thanks in advance
function setGUI() {
var url = window.location.pathname;
switch(url) {
case "/orders":
$(document).ready(function() {
$(".nav li:nth-child(2)").addClass("active");
});
break;
case "/customers": // match "customers/any_id"
$(document).ready(function() {
$(".nav li:nth-child(3)").addClass("active");
});
break;
case "/partners": match "partners/anyid"
$(document).ready(function() {
$(".nav li:nth-child(4)").addClass("active");
});
break;
case "/help":
$(document).ready(function() {
$(".nav li:nth-child(5)").addClass("active");
});
break;
case "/users/": // match "/users/any_id/"
$(document).ready(function() {
$(".nav li:nth-child(6)").addClass("active");
});
break;
default:
alert("debug");
}
}
setGUI();
if elseifconstructswitch(true)and put the conditions in eachcase.