From 2d7ed43a67361cd2bea62e42d9f84e3aad226a5b Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Thu, 21 Jul 2016 14:26:01 -0400 Subject: [PATCH] Persist the current test dashboard mock on page reload --- devtools/test_dashboard/devtools.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/devtools/test_dashboard/devtools.js b/devtools/test_dashboard/devtools.js index ea5b7b71636..3968379c5a1 100644 --- a/devtools/test_dashboard/devtools.js +++ b/devtools/test_dashboard/devtools.js @@ -175,6 +175,14 @@ var plotArea = document.getElementById('plots'); searchBar.addEventListener('keyup', debounce(searchMocks, 250)); +window.onload = function() { + var initialMock = window.location.hash.replace(/^#/, ''); + + if(initialMock.length > 0) { + Tabs.plotMock(initialMock); + } +}; + function debounce(func, wait, immediate) { var timeout; return function() { @@ -206,10 +214,12 @@ function searchMocks(e) { result.innerText = r.name; result.addEventListener('click', function() { + var mockName = r.file.slice(0, -5); + window.location.hash = mockName; // Clear plots and plot selected. Tabs.purge(); - Tabs.plotMock(r.file.slice(0, -5)); + Tabs.plotMock(mockName); }); mocksList.appendChild(result);