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
1=== modified file 'lp_highlight_words.user.js'
2--- lp_highlight_words.user.js 2010-01-08 18:51:05 +0000
3+++ lp_highlight_words.user.js 2010-04-23 19:24:30 +0000
4@@ -26,23 +26,37 @@
5 {
6 // Regex of words to highlight : color to highlight them (hint don't use black!)
7 var color_map = {
8- 'DistroRelease:.*|SourcePackage:.*|lucid|karmic|jaunty|intrepid|hardy|dapper': "yellow", // things that might be helpful
9+ 'DistroRelease: [^ ]+ [^ ]+|SourcePackage: [^ ]+|lucid|karmic|jaunty|intrepid|hardy|dapper': "yellow", // things that might be helpful
10 'regression': "red", // critical importance
11 'gutsy|feisty|edgy|breezy|hoary|warty': "orange", // unsupported releases
12 };
13
14 for (var key in color_map) {
15- search = '('+key+')';
16- regex = new RegExp(search,'gi');
17- rn = Math.floor(Math.random()*100);
18- rid = 'z' + rn;
19- text = xpath("//text()");
20+ var search = '(.*?)('+key+')(.*)';
21+ var regex = new RegExp(search,'i');
22+ // Get all text nodes below elements with class report or boardComment
23+ var text = xpath("//*[@id = 'edit-description' or (@class and " +
24+ "contains(concat(' ', normalize-space(@class), ' '), ' boardComment ')" +
25+ ")]//text()");
26+
27 for (var i = 0; i < text.snapshotLength; i++) {
28- if ( text.snapshotItem(i).parentNode ) {
29- if ( regex.exec(text.snapshotItem(i).textContent) != null ) {
30- 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>');
31- }
32+ var texti = text.snapshotItem(i);
33+ var textiparent = texti.parentNode;
34+ while ( (match = regex.exec(texti.textContent)) != null ) {
35+ // split texti up into parts
36+ span = document.createElement("span");
37+ span.style.background = color_map[key];
38+ span.style.color = "black";
39+ span.textContent = match[2];
40+ // Insert the colored match
41+ textiparent.insertBefore(span, texti);
42+ // Insert the text preceeding the match
43+ beforeText = document.createTextNode(match[1]);
44+ textiparent.insertBefore(beforeText, span);
45+ // The remaining text after the match
46+ texti.textContent = match[3];
47 }
48 }
49 }
50 })();
51+

Subscribers

People subscribed via source and target branches