f7595f0f13e0f33ba539c28d75fdf4eba7514d93 max Fri Mar 24 07:49:58 2023 -0700 adding warning box if page load is too slow, activated via hg.conf, refs #30591 diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 405c872..6e368e0 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -5474,15 +5474,44 @@ // add a 'link' to download the current track data (under hg.conf control) if (typeof showDownloadButton !== 'undefined' && showDownloadButton) { newListEl = document.createElement("li"); newLink = document.createElement("a"); newLink.setAttribute("id", "hgTracksDownload"); newLink.setAttribute("name", "downloadTracks"); newLink.textContent = "Download Current Track Data"; newLink.href = "#"; newListEl.appendChild(newLink); $("#downloads > ul")[0].appendChild(newListEl); $("#hgTracksDownload").click(downloadCurrentTrackData.showDownloadUi); } }); + +function hgtWarnTiming(maxSeconds) { + /* show a dialog box if the page load time was slower than x seconds. Has buttons to hide or never show this again. */ + var loadTime = window.performance.timing.domContentLoadedEventStart-window.performance.timing.navigationStart; /// in msecs + var loadSeconds = loadTime/1000; + var skipNotification = localStorage.getItem("hgTracks.hideSpeedNotification"); + if (loadSeconds > maxSeconds && !skipNotification) { + var div = document.createElement("div"); + div.style.display = "none"; + div.id = "notifBox"; + div.innerHTML = "This page took "+loadSeconds+" seconds to load. We try to make the UCSC Genome Browser responsive. If you want us to look into "+ + "why the page is so slow, you can create a "+ + "session link with My Data > My Sessions and send it to genome@soe.ucsc.edu.
"+ + "
"+ + " "+ + ""+ + "
"; + document.body.appendChild(div); + notifBoxShow(); + + $("#notifyHide").click( function() { + $("#notifBox").remove(); + }); + $("#notifyHideForever").click( function() { + $("#notifBox").remove(); + localStorage.setItem("hgTracks.hideSpeedNotification", "1"); + }); + } +}