[Livehttpheaders] Filtering facility

Wojtek Meler wmeler at wp-sa.pl
Tue Oct 7 11:17:14 EDT 2003


I've added simple URL-based filtering facility. It allows fe. to show .html 
files only.

Regards,
Wojtek Meler

PS. I don't know french so someone could change configuration label.
-------------- next part --------------
diff -urN content/LiveHTTPHeaders.js /usr/local/mozilla/chrome/livehttpheaders/content/LiveHTTPHeaders.js
--- content/LiveHTTPHeaders.js	Sat Oct  4 17:52:09 2003
+++ /usr/local/mozilla/chrome/livehttpheaders/content/LiveHTTPHeaders.js	Tue Oct  7 09:59:10 2003
@@ -74,6 +74,8 @@
   this.usestyle= this.getIntPref(this.lpref, "style", 0); // Use style sheet
   this.mode    = this.getIntPref(this.lpref, "mode", 1);    // Post capture mode
   this.usetab  = this.getBoolPref(this.lpref, "tab", false); // Tab mode
+  this.usefilter  = this.getBoolPref(this.lpref, "filter", false); // Filter mode
+  this.filterRegexp  = this.getCharPref(this.lpref, "filterRegexp",'/$|\.html$'); // Filter mode
 }
 HeaderInfoLive.prototype =
 {
@@ -323,6 +325,18 @@
     branch.setBoolPref(name, value);
   },
 
+  getCharPref : function(branch, name, value) {
+    if (branch.prefHasUserValue(name)) {
+      return branch.getCharPref(name);
+    } else {
+      this.setCharPref(branch, name, value);
+      return value;
+    }
+  },
+  setCharPref : function(branch, name, value) {
+    branch.setCharPref(name, value);
+  },
+
   // Initialisation and termination functions
   start : function()
   {
@@ -333,6 +347,8 @@
     document.getElementById("headerinfo-mode").selectedIndex=this.mode;
     document.getElementById("headerinfo-style").checked=this.usestyle;
     document.getElementById("headerinfo-tab").checked=this.usetab;
+    document.getElementById("headerinfo-filter").checked=this.usefilter;
+    document.getElementById("headerinfo-filterRegexp").value=this.filterRegexp;
 
     // Set scrollbar
     this.hScrollBar = document.getElementById("headerinfo-dump-scroll");
@@ -541,6 +557,14 @@
   setTab : function(tab) {
     this.setBoolPref(this.lpref, "tab", tab);
   },
+  setFilter : function(filter) {
+    this.setBoolPref(this.lpref, "filter", filter);
+    this.usefilter = filter;
+  },
+  setFilterRegexp : function(regex) {
+    this.setCharPref(this.lpref, "filterRegexp", regex);
+    this.filterRegexp = regex;
+  },
   setStyle : function(style) {
     if (style) { style=1; } else { style=0; }
     this.setIntPref(this.lpref, "style", style);
@@ -554,6 +578,7 @@
   {
     //dumpall("REQUEST",request);
     if (this.isCapturing) {
+      if (this.usefilter && !name.match(this.filterRegexp)) return;
       var oldrows = this.rowCount;
       this.addRow(name + "\r\n", this.URL);
       this.addRow("\r\n", this.REQSPACE);
diff -urN content/LiveHTTPHeaders.xul /usr/local/mozilla/chrome/livehttpheaders/content/LiveHTTPHeaders.xul
--- content/LiveHTTPHeaders.xul	Sat Oct  4 19:06:17 2003
+++ /usr/local/mozilla/chrome/livehttpheaders/content/LiveHTTPHeaders.xul	Tue Oct  7 09:55:05 2003
@@ -142,6 +142,12 @@
     <checkbox id="headerinfo-tab"
               label="&livehttpheaders.config.usetab;" checked="false"
               oncommand="oHeaderInfoLive.setTab(this.checked)" />
+    <separator class="thin" />
+    <checkbox id="headerinfo-filter"
+              label="&livehttpheaders.config.usefilter;" checked="false"
+              oncommand="oHeaderInfoLive.setFilter(this.checked)" />
+    <textbox id="headerinfo-filterRegexp" 
+    	value="" oninput="oHeaderInfoLive.setFilterRegexp(this.value)"/>
     <spacer flex="1"/>
     <hbox>
       <spacer flex="1" />
diff -urN locale/en-US/livehttpheaders/livehttpheaders.dtd /usr/local/mozilla/chrome/livehttpheaders/locale/en-US/livehttpheaders/livehttpheaders.dtd
--- locale/en-US/livehttpheaders/livehttpheaders.dtd	Sat Oct  4 11:20:41 2003
+++ /usr/local/mozilla/chrome/livehttpheaders/locale/en-US/livehttpheaders/livehttpheaders.dtd	Tue Oct  7 10:01:20 2003
@@ -14,6 +14,7 @@
 
 <!ENTITY livehttpheaders.config.usetab          "Open LiveHTTPHeaders in a new tab" >
 <!ENTITY livehttpheaders.config.usestyle        "Use style sheet" >
+<!ENTITY livehttpheaders.config.usefilter        "Filter URLs with regexp" >
 <!ENTITY livehttpheaders.config.post            "POST:" >
 
 <!ENTITY livehttpheaders.about.version          "Version information" >
diff -urN locale/fr-FR/livehttpheaders/livehttpheaders.dtd /usr/local/mozilla/chrome/livehttpheaders/locale/fr-FR/livehttpheaders/livehttpheaders.dtd
--- locale/fr-FR/livehttpheaders/livehttpheaders.dtd	Sat Oct  4 11:20:35 2003
+++ /usr/local/mozilla/chrome/livehttpheaders/locale/fr-FR/livehttpheaders/livehttpheaders.dtd	Tue Oct  7 10:06:27 2003
@@ -15,6 +15,7 @@
 <!ENTITY livehttpheaders.config.usetab          "Ouvrir LiveHTTPHeaders dans un onglet">
 <!ENTITY livehttpheaders.config.usestyle        "Utiliser la feuille de style">
 <!ENTITY livehttpheaders.config.post		"POST:" >
+<!ENTITY livehttpheaders.config.filter		"Filter URLs with regexp" >
 
 <!ENTITY livehttpheaders.about.version          "Information sur la version" >
 <!ENTITY livehttpheaders.about.versiontext	"LiveHTTPHeaders version " >


More information about the Livehttpheaders mailing list