From 028245fe8b82811e689c825c6e30e81366c902f3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 Jan 2023 13:31:24 +0000 Subject: [PATCH 1/1] Bug 32614: Highlight important comments This patch is suggesting to have an 'important' tag that could be attach to comments, and that would highlight them. * There is a new note at the top right "There are 2 important comments in this bug!" * The 'important' tag is red * The comment flagged with the 'important' tag will have a red background for better visilibity --- js/comment-tagging.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/js/comment-tagging.js b/js/comment-tagging.js index b6f02f0..b01046f 100644 --- a/js/comment-tagging.js +++ b/js/comment-tagging.js @@ -199,6 +199,9 @@ YAHOO.bugzilla.commentTagging = { var li = document.createElement('li'); ul.appendChild(li); var a = document.createElement('a'); + if ( tag == 'important' ) { + a.setAttribute('style', 'font-weight: bold; color: red;'); + } li.appendChild(a); Dom.setAttribute(a, 'href', '#'); YAHOO.util.Event.addListener(a, 'click', function(evt, tag) { @@ -212,6 +215,44 @@ YAHOO.bugzilla.commentTagging = { container.removeChild(container.lastChild); } container.appendChild(div); + + if (this.nos_by_tag.hasOwnProperty('important')) { + var nb_important_comments = this.nos_by_tag['important'].length; + var text = ""; + if ( nb_important_comments == 1 ) { + text = "There is an important comment in this bug!"; + } else if ( nb_important_comments > 1 ) { + text = "There are " + this.nos_by_tag['important'].length + " important comments in this bug!"; + } + if ( text ) { + var existing_tr = document.getElementById('important_comments_note'); + if ( existing_tr ) { + existing_tr.remove(); + } + + var tbody = document.evaluate('//*[@id="bz_show_bug_column_2"]/table/tbody', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + + var tr = document.createElement('tr'); + tr.setAttribute('id', 'important_comments_note'); + var th = document.createElement('th'); + var td = document.createElement('td'); + + var span = document.createElement('span'); + span.setAttribute('style', 'font-weight: bold; color: red;'); + span.appendChild(document.createTextNode(text)); + td.appendChild(span); + tr.appendChild(th); + tr.appendChild(td); + tbody.appendChild(tr); + + var important_nos = this.nos_by_tag['important']; + for (var i = 0, l = important_nos.length; i < l; i++) { + var comment_no = important_nos[i].match(/\d+$/)[0]; + var div_comment = document.getElementById('c' + comment_no); + div_comment.style.backgroundColor = 'red'; + } + } + } } else { while (container.hasChildNodes()) { container.removeChild(container.lastChild); -- 2.30.2