860701f5cd184dc8809597a60156cc90be76fff8 hiram Thu Oct 29 13:10:12 2020 -0700 jshint clean refs #21980 diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index c26bcd1..772e4c5 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -4555,42 +4555,40 @@ var tdLeft = Math.floor(tdRect.left); var tdTop = Math.floor(tdRect.top); // find the location of the image itself, this could be the single complete // graphic image of all the tracks, or possibly the single image of the // track itself. This location also follows the window scrolling and can // even go negative when the web browser scrolls a window that is larger // than the width of the web browser. var imageId = document.getElementById(evt.target.id); var imageRect = imageId.getBoundingClientRect(); var imageLeft = Math.floor(imageRect.left); var imageTop = Math.floor(imageRect.top); var srcUrl = evt.target.src; var evX = evt.x; // location of mouse on the web browser screen var evY = evt.y; var offLeft = Math.max(0, Math.floor(evt.x - tdLeft)); -var msg = ". . . mouse x,y: " + evX + "," + evY + ", offLeft: " + offLeft; -$('#xyMouse').html(msg); var windowUp = false; // see if window is supposed to become visible var foundIdx = -1; if (mouseOver.spans[trackName]) { foundIdx = mouseOver.findRange(offLeft, mouseOver.spans[trackName]); } // might want to indicate 'no data' when not found if (foundIdx > -1) { // value to display - var msg = " " + mouseOver.spans[trackName][foundIdx].v + " "; - $('#mouseOverText').html(msg); + var mouseOverValue = " " + mouseOver.spans[trackName][foundIdx].v + " "; + $('#mouseOverText').html(mouseOverValue); var msgWidth = Math.ceil($('#mouseOverText').width()); var msgHeight = Math.ceil($('#mouseOverText').height()); var posLeft = evt.x - msgWidth + "px"; var posTop = tdTop + "px"; $('#mouseOverContainer').css('left',posLeft); $('#mouseOverContainer').css('top',posTop); windowUp = true; // yes, window is to become visible } if (windowUp) { // the window should become visible mouseOver.popUpVisible(); } else { // the window should disappear mouseOver.popUpDisappear(); } // window visible/not visible }, // mouseInTrackImage function (evt) @@ -4618,32 +4616,35 @@ // add a 'mousemove' and 'mouseout' event listener to each track // display object var objectName = "td_data_" + trackName; var objectId = document.getElementById(objectName); if (! objectId) { return; } // not sure why objects are not found // there should be a more simple jQuery function to bind these events objectId.addEventListener('mousemove', mouseOver.mouseInTrackImage); objectId.addEventListener('mouseout', mouseOver.popUpDisappear); // would be nice to know when the window is scrolling in the browser so // the text box could disappear. These do not appear to work. // Beware, onscroll event is continuous while scrolling. // objectId.addEventListener('onscroll', popUpDisappear); // window.addEventListener('onscroll', popUpDisappear); var itemCount = 0; // just for monitoring purposes // save incoming x1,x2,v data into the mouseOver.spans[trackName][] array - arr[trackName].forEach(function(box) { - mouseOver.spans[trackName].push(box); ++itemCount}); +// arr[trackName].forEach(function(box) { + for (var span in arr[trackName]) { + mouseOver.spans[trackName].push(span); + ++itemCount; + } mouseOver.tracks[trackName] = itemCount; // merely for debugging watch } }, // receiveData: function (arr) // ========================================================================= // fetchMapData() sends JSON request, callback to receiveData() upon return // ========================================================================= fetchMapData: function (url) { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (4 === this.readyState && 200 === this.status) { var mapData = JSON.parse(this.responseText); mouseOver.receiveData(mapData); }