44
55function ApplicableList ( logger ) {
66 this . log = logger ;
7+ this . active = { } ;
8+ this . inactive = { } ;
9+ this . moot = { } ; // rulesets that might be applicable but uris are already https
710} ;
811
912ApplicableList . prototype = {
10- active : { } ,
11- inactive : { } ,
1213
1314 active_rule : function ( ruleset ) {
14- this . log ( WARN , "active rule" + ruleset ) ;
15+ this . log ( WARN , "active rule " + ruleset ) ;
1516 this . active [ ruleset . name ] = ruleset ;
1617 } ,
1718
1819 inactive_rule : function ( ruleset ) {
19- this . log ( WARN , "inactive rule" + ruleset ) ;
20+ this . log ( WARN , "inactive rule " + ruleset ) ;
2021 this . inactive [ ruleset . name ] = ruleset ;
2122 } ,
2223
24+ moot_rule : function ( ruleset ) {
25+ this . log ( WARN , "moot rule " + ruleset . name ) ;
26+ this . moot [ ruleset . name ] = ruleset ;
27+ } ,
28+
29+
2330 populate_menu : function ( doc , xul_popupmenu ) {
2431 // called from the XUL when the context popup is about to be displayed;
2532 // fill out the UI showing which rules are active and inactive in this
2633 // page
2734 while ( xul_popupmenu . firstChild ) {
2835 // delete whatever was in the menu previously
36+ //this.log(WARN,"removing " + xul_popupmenu.firstChild.label +" from menu");
2937 xul_popupmenu . removeChild ( xul_popupmenu . firstChild ) ;
3038 }
3139
@@ -39,16 +47,27 @@ ApplicableList.prototype = {
3947 item . setAttribute ( "label" , this . inactive [ x ] . name ) ;
4048 xul_popupmenu . appendChild ( item ) ;
4149 }
50+
51+ for ( var x in this . moot ) {
52+ if ( ! ( x in this . active ) ) {
53+ // rules that are active for some uris are not really moot
54+ var item = doc . createElement ( "menuitem" ) ;
55+ item . setAttribute ( "label" , "moot " + this . moot [ x ] . name ) ;
56+ } else {
57+ this . log ( WARN , "Moot rule invisible " + this . moot [ x ] . name ) ;
58+ }
59+ }
60+ this . log ( WARN , "finished menu" ) ;
61+
4262 } ,
4363
4464 show_applicable : function ( ) {
45- for ( var x in this . active ) {
65+ for ( var x in this . active )
4666 this . log ( WARN , "Active: " + this . active [ x ] . name ) ;
47- }
4867
49- for ( x in this . inactive ) {
68+ for ( x in this . inactive )
5069 this . log ( WARN , "Inctive: " + this . inactive [ x ] . name ) ;
51- }
70+
5271 }
5372} ;
5473
0 commit comments