From 4ef203c974e889b74e4064ee04eddc55ba7b8c08 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 15 Jul 2011 23:59:22 +0200 Subject: Stabilization to make it merged to next. --- data/tweaks/bug-page-mod.js | 259 +++++++++++++++++++++++--------------------- 1 file changed, 138 insertions(+), 121 deletions(-) (limited to 'data/tweaks/bug-page-mod.js') diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js index d1a4abd..ece4f36 100644 --- a/data/tweaks/bug-page-mod.js +++ b/data/tweaks/bug-page-mod.js @@ -276,6 +276,8 @@ function displayCommentActions (comment, historyItem) { function processHistoryItem(objects, itemRaw) { console.log("processHistoryItem: itemRaw = " + itemRaw.toSource()); +return ; // FIXME just to get rid of this unfinished and unanalyzed function + var idx = itemRaw.when; // Given the mid-air protection we could assume // history time to be unique per second. if (idx in objects.attachment) { @@ -288,134 +290,149 @@ function processHistoryItem(objects, itemRaw) { displayRemainingActions(itemRaw); // ===================================================== -// var commentHead = commentTimes[j].parentNode; + var commentHead = commentTimes[j].parentNode; -// var mainUser = commentHead.querySelector(".bz_comment_user a.email") -// .href -// .substr(7); -// var user = trimContent(item[0]); -// var mainTime = trimContent(commentTimes[j]); -// var time = trimContent(item[1]); -// var inline = (mainUser == user && time == mainTime); + var mainUser = commentHead.querySelector(".bz_comment_user a.email") + .href + .substr(7); + var user = trimContent(item[0]); + var mainTime = trimContent(commentTimes[j]); + var time = trimContent(item[1]); -// var currentDiv = document.createElement("div"); -// var userPrefix = ''; -// if (inline) { -// // assume that the change was made by the same user -// commentHead.appendChild(currentDiv); -// currentDiv.setAttribute("class", "bztw_inlinehistory"); -// } else { -// // the change was made by another user -// if (!reachedEnd) { -// var parentDiv = commentHead.parentNode; -// if (parentDiv.previousElementSibling && -// parentDiv.previousElementSibling.className.indexOf("bztw_history") >= 0) { -// currentDiv = parentDiv.previousElementSibling; -// } else { -// parentDiv.parentNode.insertBefore(currentDiv, parentDiv); -// } -// } else { -// var parentDiv = commentHead.parentNode; -// if (parentDiv.nextElementSibling && -// parentDiv.nextElementSibling.className.indexOf("bztw_history") >= 0) { -// currentDiv = parentDiv.nextElementSibling; -// } else { -// parentDiv.parentNode.appendChild(currentDiv); -// } -// } -// currentDiv.setAttribute("class", "bz_comment bztw_history"); -// userPrefix += "" + -// getUserName(trimContent(item[0])) + ": "; -// } -// // check to see if this is a flag setting -// flagsFound = findFlag(item); -// for (var idx = 0; idx < flagsFound.length; ++idx) { -// var flag = flagsFound[idx]; -// flagOccurrences[flag] = 'flag' + flagCounter; -// if (inline) { -// var anchor = document.createElement("a"); -// anchor.setAttribute("name", "flag" + flagCounter); -// commentHead.insertBefore(anchor, commentHead.firstChild); -// } else { -// userPrefix += ''; -// } -// ++flagCounter; -// } +// ===================================================================== +// $$$ FIXME the change is made by commenter? is that it? + var inline = (mainUser == user && time == mainTime); -// var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item); -// if (inline) { -// for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) { -// var anchor = document.createElement("a"); -// anchor.setAttribute("name", attachmentFlagAnchors[idx]); -// commentHead.insertBefore(anchor, commentHead.firstChild); -// } -// } else { -// userPrefix += attachmentFlagAnchors.map(function(name) '').join(""); -// } -// var ccOnly = (trimContent(item[2]) == 'CC'); -// var ccPrefix = ccOnly ? '' : -// '', -// ccSuffix = ''; -// var html = userPrefix + -// ccPrefix + -// transformType(trimContent(item[2]), trimContent(item[3]), -// trimContent(item[4])) + ": " + -// formatTransition(trimContent(item[3]), trimContent(item[4]), -// trimContent(item[2]), iframe.contentDocument); +// §§§§ This is a function addToInlineHistory or something TODO + var currentDiv = document.createElement("div"); + var userPrefix = ''; + if (inline) { + // assume that the change was made by the same user // XXX? §§§ + commentHead.appendChild(currentDiv); + currentDiv.setAttribute("class", "bztw_inlinehistory"); + } else { + // the change was made by another user + if (!reachedEnd) { + var parentDiv = commentHead.parentNode; + if (parentDiv.previousElementSibling && + parentDiv.previousElementSibling.className.indexOf("bztw_history") >= 0) { + currentDiv = parentDiv.previousElementSibling; + } else { + parentDiv.parentNode.insertBefore(currentDiv, parentDiv); + } + } else { + var parentDiv = commentHead.parentNode; + if (parentDiv.nextElementSibling && + parentDiv.nextElementSibling.className.indexOf("bztw_history") >= 0) { + currentDiv = parentDiv.nextElementSibling; + } else { + parentDiv.parentNode.appendChild(currentDiv); + } + } + currentDiv.setAttribute("class", "bz_comment bztw_history"); + userPrefix += "" + + getUserName(trimContent(item[0])) + ": "; + } + // XXX END OF if (inline) CONSTRUCT -// var nextItemsCount = item[0].rowSpan; -// for (var k = 1; k < nextItemsCount; ++k) { -// ccOnly = false; -// item = historyItems[++i].querySelectorAll("td") -// ccPrefix = (trimContent(item[0]) == 'CC') ? -// '' : ''; -// // avoid showing a trailing semicolon if the previous entry -// // wasn't a CC and this one is -// var prefix = ccSuffix + ccPrefix; -// // check to see if this is a flag setting -// flagsFound = findFlag(item); -// for (var idx = 0; idx < flagsFound.length; ++idx) { -// var flag = flagsFound[idx]; -// flagOccurrences[flag] = 'flag' + flagCounter; -// if (inline) { -// var anchor = document.createElement("a"); -// anchor.setAttribute("name", "flag" + flagCounter); -// commentHead.insertBefore(anchor, commentHead.firstChild); -// } else { -// prefix += ''; -// } -// ++flagCounter; -// } +// XXX flags + // check to see if this is a flag setting + flagsFound = findFlag(item); // XXX findFlag call 2 + // XXX Add around every flag comment + for (var idx = 0; idx < flagsFound.length; ++idx) { + var flag = flagsFound[idx]; + flagOccurrences[flag] = 'flag' + flagCounter; + if (inline) { + var anchor = document.createElement("a"); + anchor.setAttribute("name", "flag" + flagCounter); + commentHead.insertBefore(anchor, commentHead.firstChild); + } else { + userPrefix += ''; + } + ++flagCounter; + } -// var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item); -// if (inline) { -// for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) { -// var anchor = document.createElement("a"); -// anchor.setAttribute("name", attachmentFlagAnchors[idx]); -// commentHead.insertBefore(anchor, commentHead.firstChild); -// } -// } else { -// prefix += attachmentFlagAnchors.map(function(name) '').join(""); -// } +// XXX attachments + var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item); + if (inline) { + for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) { + var anchor = document.createElement("a"); + anchor.setAttribute("name", attachmentFlagAnchors[idx]); + commentHead.insertBefore(anchor, commentHead.firstChild); + } + } else { + userPrefix += attachmentFlagAnchors.map(function(name) '').join(""); + } -// html += prefix + -// transformType(trimContent(item[0]), trimContent(item[1]), -// trimContent(item[2])) + ": " + -// formatTransition(trimContent(item[1]), trimContent(item[2]), -// trimContent(item[0]), iframe.contentDocument); -// } -// html += ccSuffix; -// if (ccOnly) { -// html = '
' + html + '
'; -// } else { -// html = '
' + html + '
'; -// } -// currentDiv.innerHTML += html; -// // FIXME here used to be a break; -// } +// XXX just adding/removing sometbody from CC list + var ccOnly = (trimContent(item[2]) == 'CC'); + var ccPrefix = ccOnly ? '' : + '', + ccSuffix = ''; + var html = userPrefix + + ccPrefix + + transformType(trimContent(item[2]), trimContent(item[3]), + trimContent(item[4])) + ": " + + formatTransition(trimContent(item[3]), trimContent(item[4]), + trimContent(item[2]), iframe.contentDocument); + +// + var nextItemsCount = item[0].rowSpan; + for (var k = 1; k < nextItemsCount; ++k) { + // XXX doing once more the same for non-first elements of the imte array. + ccOnly = false; + item = historyItems[++i].querySelectorAll("td") + ccPrefix = (trimContent(item[0]) == 'CC') ? + '' : ''; + // avoid showing a trailing semicolon if the previous entry + // wasn't a CC and this one is + var prefix = ccSuffix + ccPrefix; + // check to see if this is a flag setting + flagsFound = findFlag(item); // TODO findFlag call 1 + for (var idx = 0; idx < flagsFound.length; ++idx) { + var flag = flagsFound[idx]; + flagOccurrences[flag] = 'flag' + flagCounter; + if (inline) { + var anchor = document.createElement("a"); + anchor.setAttribute("name", "flag" + flagCounter); + commentHead.insertBefore(anchor, commentHead.firstChild); + } else { + prefix += ''; + } + ++flagCounter; + } + + var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item); + if (inline) { + for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) { + var anchor = document.createElement("a"); + anchor.setAttribute("name", attachmentFlagAnchors[idx]); + commentHead.insertBefore(anchor, commentHead.firstChild); + } + } else { + prefix += attachmentFlagAnchors.map(function(name) '').join(""); + } + + // END OF THE SAME STUFF FOR NON-FIRST ITEMS + + html += prefix + + transformType(trimContent(item[0]), trimContent(item[1]), + trimContent(item[2])) + ": " + + formatTransition(trimContent(item[1]), trimContent(item[2]), + trimContent(item[0]), iframe.contentDocument); + } + html += ccSuffix; + if (ccOnly) { + html = '
' + html + '
'; + } else { + html = '
' + html + '
'; + } + // Add the new stuff to the place below the top of the comment div + currentDiv.innerHTML += html; + // FIXME here used to be a break; } // =================================================== -- cgit