$(function() {
// if a #hash is specified, find and select that tab
var tab = window.location.hash;
if (tab != "") {
tab = tab.substring(1);
tab = decodeURIComponent(tab);
// Select tab, by clicking on it
$(`[data-w-tab="${tab}"`).click();
}
});
// When a tab is clicked, update the URL with that hash
$("[data-w-tab]").click(function() {
var tab = $(this).attr("data-w-tab");
var newUrl = window.location.origin + "/#" + encodeURIComponent(tab);
// Change displayed URL
window.history.replaceState ('', '', newUrl);
});