From 33513415fbea127615960fd55a725cd39cb31a17 Mon Sep 17 00:00:00 2001 From: Simon Green Date: Wed, 2 Apr 2014 16:52:30 +0800 Subject: Bug 891757: "Additional hours worked" displayed inline with comments is now superfluous --- extensions/InlineHistory/web/inline-history.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'extensions') diff --git a/extensions/InlineHistory/web/inline-history.js b/extensions/InlineHistory/web/inline-history.js index 95a664a42..c59c2932c 100644 --- a/extensions/InlineHistory/web/inline-history.js +++ b/extensions/InlineHistory/web/inline-history.js @@ -13,11 +13,13 @@ var inline_history = { init: function() { Dom = YAHOO.util.Dom; - // remove 'has been marked as a duplicate of this bug' comments var reDuplicate = /^\*\*\* \S+ \d+ has been marked as a duplicate of this/; var reBugId = /show_bug\.cgi\?id=(\d+)/; + var reHours = /Additional hours worked: \d+\.\d+/; + var comments = Dom.getElementsByClassName("bz_comment", 'div', 'comments'); for (var i = 1, il = comments.length; i < il; i++) { + // remove 'has been marked as a duplicate of this bug' comments var textDiv = Dom.getElementsByClassName('bz_comment_text', 'pre', comments[i]); if (textDiv) { var match = reDuplicate.exec(textDiv[0].textContent || textDiv[0].innerText); @@ -50,12 +52,22 @@ var inline_history = { } } } + + // remove 'Additional hours worked: ' comments + var commentNodes = comments[i].childNodes; + for (var j = 0, jl = commentNodes.length; j < jl; j++) { + if (reHours.exec(commentNodes[j].textContent)) { + comments[i].removeChild(commentNodes[j]); + // Remove the
before it + comments[i].removeChild(commentNodes[j-1]); + break; + } + } } // ensure new items are placed immediately after the last comment - var commentDivs = Dom.getElementsByClassName('bz_comment', 'div', 'comments'); - if (!commentDivs.length) return; - var lastCommentDiv = commentDivs[commentDivs.length - 1]; + if (!comments.length) return; + var lastCommentDiv = comments[comments.length - 1]; // insert activity into the correct location var commentTimes = Dom.getElementsByClassName('bz_comment_time', 'span', 'comments'); -- cgit v1.2.3-24-g4f1b