752ca37b9f0031e59abc0dedef4752b7eb890946 chmalee Fri May 19 12:11:41 2023 -0700 Generalize the notification box setups so we can have multiple of them. Starting on getting the tutorial to show up conditionally diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 2a7ccf0..6c2d297 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -1,22 +1,23 @@ // hgTracks.js - Javascript for use in hgTracks CGI // Copyright (C) 2008 The Regents of the University of California // "use strict"; // Don't complain about line break before '||' etc: /* jshint -W014 */ +/* jshint esnext: true */ var debug = false; /* Data passed in from CGI via the hgTracks object: * * string cgiVersion // CGI_VERSION * string chromName // current chromosome * int winStart // genomic start coordinate (0-based, half-open) * int winEnd // genomic end coordinate * int newWinWidth // new width (in bps) if user clicks on the top ruler * boolean revCmplDisp // true if we are in reverse display * int insideX // width of side-bar (in pixels) * int rulerClickHeight // height of ruler (in pixels) - zero if ruler is hidden * boolean inPlaceUpdate // true if in-place-update is turned on @@ -5474,44 +5475,52 @@ // 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); } // show a tutorial page if this is a new user - if (tour !== undefined) { + if (typeof tour !== 'undefined' && tour) { + let lsKey = "hgTracks_hideTutorial"; + let hideTutorial = localStorage.getItem(lsKey); + if (typeof hideTutorial === 'undefined') { + let msg = "We now have a guided tutorial available, click here" + + "to start the tutorial"; + notifBoxSetup("hgTracks", "hideTutorial", msg); + notifBoxShow("hgTracks", "hideTutorial"); tour.start(); } + } }); 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; if (loadSeconds < maxSeconds) return; - var lsKey = "hgTracks.hideSpeedNotification"; + let lsKey = "hgTracks_hideSpeedNotification"; var skipNotification = localStorage.getItem(lsKey); writeToApacheLog("warnTiming "+getHgsid()+" time=" + loadSeconds + " skipNotif="+skipNotification); if (skipNotification) return; msg = "This page took "+loadSeconds+" seconds to load. We strive to keep "+ "the UCSC Genome Browser quick and responsive. See our "+ "display speed FAQ for "+ "common causes and solutions to slow performance. If this problem continues, you can create a "+ "session link via My Data > My Sessions and send the link to genome-www@soe.ucsc.edu."; notifBoxSetup("hgTracks", "hideSpeedNotification", msg); notifBoxShow("hgTracks", "hideSpeedNotification"); }