|
1404 | 1404 | elmnt.style.background = bgcolor; |
1405 | 1405 | elmnt.style.borderRight = borderstyle; |
1406 | 1406 | } |
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 | + }); |
1413 | 1450 | </script> |
1414 | 1451 | <script> |
1415 | 1452 | $(window).on('load',function(){$('.loader').fadeOut();}); |
|
0 commit comments