Skip to content

Commit aef2b7c

Browse files
fix URL reset on page load
1 parent 412378b commit aef2b7c

1 file changed

Lines changed: 43 additions & 6 deletions

File tree

html/template.html

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,12 +1404,49 @@
14041404
elmnt.style.background = bgcolor;
14051405
elmnt.style.borderRight = borderstyle;
14061406
}
1407-
// Get the element with id="defaultOpen" and click on it
1408-
document.getElementById("defaultOpen").click();
1409-
</script>
1410-
<script>
1411-
// Get the element with id="defaultOpen" and click on it
1412-
document.getElementById("defaultOpen").click();
1407+
1408+
// Function to open page based on URL hash
1409+
function openPageFromHash() {
1410+
var hash = window.location.hash.substring(1); // Remove the # symbol
1411+
if (hash) {
1412+
// Map hash to page IDs
1413+
var hashToPageMap = {
1414+
'dashboard': 'dashboard',
1415+
'suites': 'suiteMetrics',
1416+
'test-metrics': 'testMetrics',
1417+
'archives': 'archives',
1418+
'screenshots': 'screenshots'
1419+
};
1420+
1421+
var pageId = hashToPageMap[hash];
1422+
if (pageId) {
1423+
// Find the corresponding tab link
1424+
var tablinks = document.getElementsByClassName("tablink");
1425+
for (var i = 0; i < tablinks.length; i++) {
1426+
if (tablinks[i].getAttribute('href') === '#' + hash) {
1427+
tablinks[i].click();
1428+
return;
1429+
}
1430+
}
1431+
}
1432+
}
1433+
// If no hash or invalid hash, open default page
1434+
var defaultBtn = document.getElementById("defaultOpen");
1435+
if (defaultBtn) {
1436+
defaultBtn.click();
1437+
}
1438+
}
1439+
1440+
// Use jQuery ready to ensure DOM and scripts are loaded
1441+
$(document).ready(function() {
1442+
// Small delay to ensure this runs after window.onload in dashboard
1443+
setTimeout(function() {
1444+
openPageFromHash();
1445+
}, 100);
1446+
1447+
// Listen for hash changes (back/forward browser buttons)
1448+
window.addEventListener('hashchange', openPageFromHash);
1449+
});
14131450
</script>
14141451
<script>
14151452
$(window).on('load',function(){$('.loader').fadeOut();});

0 commit comments

Comments
 (0)