d53f7ac6b0845499960d6ce6d9c8e04324145706 chmalee Mon Mar 22 13:17:48 2021 -0700 Don't warn the same message multiple times in the hgTracks warn box, refs #27247 diff --git src/hg/js/utils.js src/hg/js/utils.js index 93b5e0e..2723950 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -741,31 +741,42 @@ $('body').prepend(html); document.getElementById('warnOK').onclick = function() {hideWarnBox();return false;}; } function warn(msg) { // adds warnings to the warnBox var warnList = normed($('#warnList')); // warnBox contains warnList if (!warnList) { warnBoxJsSetup(); warnList = normed($('#warnList')); } if (!warnList) alert(msg); else { - $( warnList ).append('<li>'+msg+'</li>'); + // don't add warnings that already exist: + var oldMsgs = []; + $('#warnList li').each(function(i, elem) { + oldMsgs.push(elem.innerHTML); + }); + // make the would-be new message into an <li> element so the case and quotes + // match any pre-existing ones + var newNode = document.createElement('li'); + newNode.innerHTML = msg; + if (oldMsgs.indexOf(newNode.innerHTML) === -1) { + $( warnList ).append(newNode); + } if ($.isFunction(showWarnBox)) showWarnBox(); else alert(msg); } } var gWarnSinceMSecs = 0; function warnSince(msg) // DEAD CODE? { // Warn messages with msecs since last warnSince msg // This is necessary because IE Developer tools are hanging var now = new Date(); var msecs = now.getTime(); var since = 0; if (gWarnSinceMSecs > 0)