Permalink
Browse files

get rid of show error and commenter prefs and stop caching most prefs

  • Loading branch information...
1 parent eeee83c commit 432809426ee8a29585c0b08dd5d8a19c87222bcb @harthur committed Mar 8, 2010
@@ -1,4 +1,4 @@
-bugidLinkifier = {
+bugidLinks = {
linkifyContent : function(doc, target) {
var textnodes = bugidHelper.xpathNodes(doc,
"descendant::text()[contains(translate(., 'BUG', 'bug'),'bug')]", target);
@@ -59,9 +59,7 @@
<preference id="tooldescpref" name="extensions.bugid.tooltip.showdesc" type="bool" />
<preference id="tooldatepref" name="extensions.bugid.tooltip.showdate" type="bool" />
<preference id="toolcomppref" name="extensions.bugid.tooltip.showcomp" type="bool" />
- <preference id="toolassignpref" name="extensions.bugid.tooltip.showassign" type="bool"/>
- <preference id="toolcommpref" name="extensions.bugid.tooltip.showcommenter" type="bool"/>
- <preference id="toolerrorpref" name="extensions.bugid.tooltip.showerror" type="bool"/>
+ <preference id="toolassignpref" name="extensions.bugid.tooltip.showassign" type="bool"/>
</preferences>
<vbox class="category-prime">
@@ -111,10 +109,6 @@
<checkbox id="assignbox" class="toolsubpref" preference="toolassignpref" label="&toolassignpref.label;" />
<checkbox id="compbox" class="toolsubpref" preference="toolcomppref" label="&toolcomppref.label;" />
<checkbox id="descbox" class="toolsubpref" preference="tooldescpref" label="&tooldescpref.label;" />
- <checkbox id="commbox" class="toolsubpref" preference="toolcommpref" label="&toolcommpref.label;"
- tooltiptext="&toolcommpref.tooltip;"/>
- <checkbox id="errorbox" class="toolsubpref" preference="toolerrorpref" label="&toolerrorpref.label;"
- tooltiptext="&toolerrorpref.tooltip;" />
</vbox>
</vbox>
</prefpane>
@@ -37,6 +37,13 @@ window.addEventListener("load", function(){ bugidHelper.init(); }, false);
var bugidHelper = {
+ prefs : Components.classes['@mozilla.org/preferences-service;1']
+ .getService(Components.interfaces.nsIPrefService)
+ .getBranch("extensions.bugid."),
+
+ prefService : Components.classes['@mozilla.org/preferences-service;1']
+ .getService(Components.interfaces.nsIPrefBranch2),
+
/* 1 - bug id */
contextExp : /^(?:.*bug|ug|g)?\s*#?(\d{2,7})(?:$|\b)/i,
@@ -66,10 +73,6 @@ var bugidHelper = {
this.baseUrl = this.toBaseUrl(this.userUrl);
this.prefService.addObserver("extensions.bugid.url", this, false);
- var resos = this.prefService.getCharPref("extensions.bugid.link.strike.resos");
- this.strikeResos = resos.split(/[\.,\s]+/);
- this.prefService.addObserver("extensions.bugid.link.strike.resos", this, false);
-
/* add content page load listener */
var content = document.getElementById("appcontent");
if(content)
@@ -88,14 +91,6 @@ var bugidHelper = {
this.userUrl = this.prefService.getCharPref("extensions.bugid.url")
this.baseUrl = this.toBaseUrl(this.userUrl);
break;
- case "extensions.bugid.whitelist":
- var urls = this.prefService.getCharPref("extensions.bugid.whitelist");
- this.domainExps = this.toDomains(urls);
- break;
- case "extensions.bugid.link.strike.resos":
- var resos = this.prefService.getCharPref("extensions.bugid.link.strike.resos");
- this.strikeResos = resos.split(/[\.,\s]+/);
- break;
default:
break;
}
@@ -125,9 +120,9 @@ var bugidHelper = {
bugifyContent : function(doc, target) {
if(this.getBoolPref("linkify"))
- bugidLinkifier.linkifyContent(doc, target);
+ bugidLinks.linkifyContent(doc, target);
if(this.getBoolPref("tooltipify"))
- bugidTooltipifier.tooltipifyContent(doc, target);
+ bugidTooltip.tooltipifyContent(doc, target);
},
toBugzillaDomain : function (fragment) {
@@ -160,7 +155,7 @@ var bugidHelper = {
},
getBoolPref : function(pref) {
- return this.prefService.getBoolPref("extensions.bugid." + pref);
+ return this.prefs.getBoolPref(pref);
},
getLogin : function() {
@@ -233,3 +228,5 @@ var bugidHelper = {
return doc.evaluate(expression, target, null, XPathResult.STRING_TYPE, null).stringValue;
}
}
+
+bugIdHelper.prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); // for addObserver
@@ -17,6 +17,7 @@
<li>http://bugs.gentoo.org/show_bug.cgi?id=3455</li>
<li>bugzilla.mozilla.org/show_bug.cgi?id=3455/li>
<li>https://bugzilla.mozilla.org/show_bug.cgi?id=3455</li>
+<li>http://bugzilla.mozilla.org/show_bug.cgi?id=3455#c1</li>
</ul>
</body>
</html>
@@ -1,6 +1,4 @@
-var bugidTooltipifier = {
-
- /*--- tooltip ---*/
+var bugidTooltip = {
tooltipifyContent : function(doc, target) {
var links = bugidHelper.xpathNodes(doc, 'descendant::a[contains(@href, "show_bug.cgi")]', target);
if(links.length > 0) {
@@ -9,8 +7,8 @@ var bugidTooltipifier = {
var userUrl = bugidHelper.prefService.getCharPref("extensions.bugid.url");
bugzillaRPC.setUrl(bugidHelper.toBugzillaDomain(userUrl));
bugzillaRPC.login(login.username, login.password,
- function(){ bugidTooltipifier.tooltipifyLinks(doc, links);},
- function(){ bugidToolipifier.tooltipifyLinks(doc, links);});
+ function(){ bugidTooltip.tooltipifyLinks(doc, links);},
+ function(){ bugidTooltip.tooltipifyLinks(doc, links);});
}
else
this.tooltipifyLinks(doc, links);
@@ -30,9 +28,9 @@ var bugidTooltipifier = {
var url = "http://" + base + "ctype=xml&excludefield=attachment&id=" + matches[3];
var commentId = matches[4];
if(commentId)
- bugidTooltipifier.setComment(link, url, commentId);
+ bugidTooltip.setComment(link, url, commentId);
else
- bugidTooltipifier.setTooltip(link, url);
+ bugidTooltip.setTooltip(link, url);
}
}
},
@@ -42,18 +40,15 @@ var bugidTooltipifier = {
function(wasSuccess, xml) {
if(!bugidHelper) // this happens sometimes
return;
- var showerror = bugidHelper.getBoolPref("tooltip.showerror");
if(!wasSuccess) {
- if(showerror)
- element.title = bugidHelper.strings.getFormattedString("invalidPage", [url]);
+ element.title = bugidHelper.strings.getFormattedString("invalidPage", [url]);
return;
}
var bug = xml.getElementsByTagName("bug");
if(bug && bug[0] && bug[0].hasAttribute("error")) {
var error = bug[0].getAttribute("error");
- if(showerror)
- element.title = bugidHelper.strings.getFormattedString("invalidId",
- [bugidHelper.userUrl, error]);
+ element.title = bugidHelper.strings.getFormattedString("invalidId",
+ [bugidHelper.userUrl, error]);
return;
}
var tooltip = [];
@@ -81,8 +76,9 @@ var bugidTooltipifier = {
tooltip.push(bugidHelper.bugAttribute(xml, "short_desc"));
if(bugidHelper.getBoolPref("link.strikethrough")) {
- var reso = bugidHelper.bugAttribute(xml, "resolution");
- if(bugidHelper.strikeResos.indexOf(reso) != -1)
+ var resolution = bugidHelper.bugAttribute(xml, "resolution");
+ var resos = bugidHelper.prefs.getCharPref("link.strike.resos").split(/[\.,\s]+/);
+ if(resos.indexOf(resolution) != -1)
element.style.textDecoration = "underline line-through";
}
@@ -96,17 +92,14 @@ var bugidTooltipifier = {
function(wasSuccess, xml) {
if(!bugidHelper) // this happens sometimes
return;
- var showerror = bugidHelper.getBoolPref("tooltip.showerror");
if(!wasSuccess) {
- if(showerror)
- element.title = bugidHelper.strings.getFormattedString("invalidPage", [url]);
+ element.title = bugidHelper.strings.getFormattedString("invalidPage", [url]);
return;
}
var bug = xml.getElementsByTagName("bug");
if(bug && bug[0] && bug[0].hasAttribute("error")) {
var error = bug[0].getAttribute("error");
- if(showerror)
- element.title = bugidHelper.strings.getFormattedString("invalidId",
+ element.title = bugidHelper.strings.getFormattedString("invalidId",
[bugidHelper.userUrl, error]);
return;
}
@@ -115,8 +108,7 @@ var bugidTooltipifier = {
if(comment) {
var text = bugidHelper.bugAttribute(comment, "thetext");
var tooltip = "";
- if(bugidHelper.getBoolPref("tooltip.showcommenter"))
- tooltip += bugidHelper.bugAttribute(comment, "who") + " -- ";
+ tooltip += bugidHelper.bugAttribute(comment, "who") + " -- ";
element.title = tooltip + text.substring(0, Math.min(text.length, 180)) + " ...";
}
});
@@ -12,12 +12,7 @@
<!ENTITY tooldescpref.label "Show Short Description">
<!ENTITY tooldatepref.label "Show Date Reported">
<!ENTITY toolassignpref.label "Show Assignee">
-<!ENTITY toolcomppref.label "Show Product/Component">
-<!ENTITY toolcommpref.label "Show Commenter">
-<!ENTITY toolerrorpref.label "Show Error">
-<!ENTITY toolerrorpref.tooltip "Display error message in tooltip if invalid bug id">
-<!ENTITY toolcommpref.tooltip "Display commenter in tooltip over urls with named comment anchor">
-<!ENTITY filterpref.label "Only Add Links/Tooltips to These Domains:">
+<!ENTITY toolcomppref.label "Show Product/Component">
<!ENTITY urlpref.label "Bugzilla URL (e.g. bugzilla.mozilla.org):">
<!ENTITY stringpref.accesskey "U">
<!ENTITY intpref.accesskey "T">
@@ -9,9 +9,7 @@ pref("extensions.bugid.tooltip.showstat", false);
pref("extensions.bugid.tooltip.showdesc", true);
pref("extensions.bugid.tooltip.showdate", false);
pref("extensions.bugid.tooltip.showcomp", false);
-pref("extensions.bugid.tooltip.showerror", true);
pref("extensions.bugid.tooltip.showassign", false);
-pref("extensions.bugid.tooltip.showcommenter", true);

0 comments on commit 4328094

Please sign in to comment.