Merge lp:~olberd/launchpad-gm-scripts/main into lp:launchpad-gm-scripts

Proposed by Rune Philosof
Status: Merged
Merged at revision: 131
Proposed branch: lp:~olberd/launchpad-gm-scripts/main
Merge into: lp:launchpad-gm-scripts
Diff against target: 51 lines (+24/-10)
1 file modified
lp_highlight_words.user.js (+24/-10)
To merge this branch: bzr merge lp:~olberd/launchpad-gm-scripts/main
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+23965@code.launchpad.net
To post a comment you must log in.
lp:~olberd/launchpad-gm-scripts/main updated
132. By Rune Schjellerup Philosof <rune@rune-laptop>

as mentioned in previous commit, tags was not supposed to be included. This intension is now implemented too :)

Revision history for this message
Brian Murray (brian-murray) wrote :

Awesome - works well thank you!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lp_highlight_words.user.js'
--- lp_highlight_words.user.js 2010-01-08 18:51:05 +0000
+++ lp_highlight_words.user.js 2010-04-23 19:24:30 +0000
@@ -26,23 +26,37 @@
26{26{
27 // Regex of words to highlight : color to highlight them (hint don't use black!)27 // Regex of words to highlight : color to highlight them (hint don't use black!)
28 var color_map = {28 var color_map = {
29 'DistroRelease:.*|SourcePackage:.*|lucid|karmic|jaunty|intrepid|hardy|dapper': "yellow", // things that might be helpful29 'DistroRelease: [^ ]+ [^ ]+|SourcePackage: [^ ]+|lucid|karmic|jaunty|intrepid|hardy|dapper': "yellow", // things that might be helpful
30 'regression': "red", // critical importance30 'regression': "red", // critical importance
31 'gutsy|feisty|edgy|breezy|hoary|warty': "orange", // unsupported releases31 'gutsy|feisty|edgy|breezy|hoary|warty': "orange", // unsupported releases
32 }; 32 };
3333
34 for (var key in color_map) {34 for (var key in color_map) {
35 search = '('+key+')';35 var search = '(.*?)('+key+')(.*)';
36 regex = new RegExp(search,'gi');36 var regex = new RegExp(search,'i');
37 rn = Math.floor(Math.random()*100);37 // Get all text nodes below elements with class report or boardComment
38 rid = 'z' + rn;38 var text = xpath("//*[@id = 'edit-description' or (@class and " +
39 text = xpath("//text()");39 "contains(concat(' ', normalize-space(@class), ' '), ' boardComment ')" +
40 ")]//text()");
41
40 for (var i = 0; i < text.snapshotLength; i++) {42 for (var i = 0; i < text.snapshotLength; i++) {
41 if ( text.snapshotItem(i).parentNode ) {43 var texti = text.snapshotItem(i);
42 if ( regex.exec(text.snapshotItem(i).textContent) != null ) {44 var textiparent = texti.parentNode;
43 text.snapshotItem(i).parentNode.innerHTML = text.snapshotItem(i).textContent.replace(regex,'<span name=' + rid + ' id=' + rid + ' style=\'color:#000;background-color:'+ color_map[key] +';\'>$1</span>');45 while ( (match = regex.exec(texti.textContent)) != null ) {
44 }46 // split texti up into parts
47 span = document.createElement("span");
48 span.style.background = color_map[key];
49 span.style.color = "black";
50 span.textContent = match[2];
51 // Insert the colored match
52 textiparent.insertBefore(span, texti);
53 // Insert the text preceeding the match
54 beforeText = document.createTextNode(match[1]);
55 textiparent.insertBefore(beforeText, span);
56 // The remaining text after the match
57 texti.textContent = match[3];
45 }58 }
46 }59 }
47 }60 }
48})();61})();
62

Subscribers

People subscribed via source and target branches