dc954816332fdd522f6999b04cb7409a2a9f8239 tdreszer Wed Jun 4 17:42:48 2014 -0700 Tightened the screws on several descrete cases where comparison to undefined might have been acting on undeclared variable. I have looked through all the js files I altered for jshint and only found these few cases which might (but in practice probably don't) trigger exceptions. diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 708398c..1109f22 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -1420,69 +1420,69 @@ if (altColors) { // lastMatch and lastBlue or not lastMatch and notLastBlue lastBlue = (lastMatchesLast === lastBlue); if (lastBlue) // Too smart by 1/3rd $( lastBtn ).addClass( 'btnBlue' ); else $( lastBtn ).removeClass( 'btnBlue' ); } count++; } //warn("Zipped "+count+" buttons "+countN+" are independent."); }, dragHandleMouseOver: function () { // Highlights a single row when mouse over a dragHandle column (sideLabel and buttons) - if ( ! jQuery.tableDnD ) { + if ( typeof(jQuery.tableDnD) === 'undefined' ) { //var handle = $("td.dragHandle"); //$(handle) // .unbind('mouseenter')//, jQuery.tableDnD.mousemove); // .unbind('mouseleave');//, jQuery.tableDnD.mouseup); return; } - if ( ! jQuery.tableDnD.dragObject ) { + if ( jQuery.tableDnD.dragObject === null ) { $( this ).parents("tr.trDraggable").addClass("trDrag"); } }, dragHandleMouseOut: function () { // Ends row highlighting by mouse over $( this ).parents("tr.trDraggable").removeClass("trDrag"); }, buttonMouseOver: function () { // Highlights a composite set of buttons, regarless of whether tracks are adjacent - if ( ! jQuery.tableDnD || ! jQuery.tableDnD.dragObject ) { + if ( typeof(jQuery.tableDnD) === 'undefined' || jQuery.tableDnD.dragObject === null ) { var classList = $( this ).attr("class").split(" "); var btns = $( "p." + classList[0] ); $( btns ).removeClass('btnGrey'); $( btns ).addClass('btnBlue'); - if (jQuery.tableDnD) { + if (typeof(jQuery.tableDnD) !== 'undefined') { var rows = dragReorder.getContiguousRowSet($(this).parents('tr.trDraggable')[0]); if (rows) $( rows ).addClass("trDrag"); } } }, buttonMouseOut: function () { // Ends composite highlighting by mouse over var classList = $( this ).attr("class").split(" "); var btns = $( "p." + classList[0] ); $( btns ).removeClass('btnBlue'); $( btns ).addClass('btnGrey'); - if (jQuery.tableDnD) { + if (typeof(jQuery.tableDnD) !== 'undefined') { var rows = dragReorder.getContiguousRowSet($(this).parents('tr.trDraggable')[0]); if (rows) $( rows ).removeClass("trDrag"); } }, trMouseOver: function (e) { // Trying to make sure there is always a imageV2.lastTrack so that we know where we are var id = ''; var a = /tr_(.*)/.exec($(this).attr('id')); // voodoo if (a && a[1]) { id = a[1]; } if (id.length > 0) { if ( ! imageV2.lastTrack || imageV2.lastTrack.id !== id) @@ -1900,31 +1900,31 @@ /////////////////////////////////////// //// rightClick (aka context menu) //// /////////////////////////////////////// var rightClick = { menu: null, selectedMenuItem: null, // currently choosen context menu item (via context menu). floatingMenuItem: null, currentMapItem: null, supportZoomCodon: false, // turns on experimental feature (currently only in larry's tree). makeMapItem: function (id) { // Create a dummy mapItem on the fly // (for objects that don't have corresponding entry in the map). - if (id && id.length > 0 && hgTracks.trackDb) { + if (id && id.length > 0 && typeof(hgTracks.trackDb) !== 'undefined') { var title; var rec = hgTracks.trackDb[id]; if (rec) { title = rec.shortLabel; } else { title = id; } return {id: id, title: "configure " + title}; } else { return null; } }, findMapItem: function (e) { // Find mapItem for given event; returns item object or null if none found.