rem:  calendarColor = calendarNode.getAttribute("http: 
add:  var catergoryPrefBranch = prefService.getBranch(""); var pbi = catergoryPrefBranch.QueryInterface( Components.interfaces.nsIPrefBranchInternal); pbi.addObserver("calendar.category.color.", categoryPrefObserver, false); categoryPrefObserver.mCalendarStyleSheet = calStyleSheet; categoryPrefObserver.observe(null, null, ""); 
context: function updateColors(){   // Change made by CofC for Calendar Coloring   // initialize calendar color style rules in the calendar's styleSheet   // find calendar's style sheet index   var i;   for (i=0; i<document.styleSheets.length; i++)   {      if (document.styleSheets[i].href.match(/chrome.*\/skin.*\/calendar.css$/))      {          gCalendarStyleSheet = document.styleSheets[i];          break;      }   }   var calendarNode;   var containerName;   var calendarColor;   // loop through the calendars via the rootSequence of the RDF datasource   var seq = gCalendarWindow.calendarManager.rdf.getRootSeq("urn:calendarcontainer");   var list = seq.getSubNodes();   var calListItems = document.getElementById( "list-calendars-listbox" ).getElementsByTagName("listitem");   for(i=0; i<list.length;i++)   {     calendarNode = gCalendarWindow.calendarManager.rdf.getNode( list[i].subject );          // grab the container name and use it for the name of the style rule     containerName = list[i].subject.split(":")[2];     // obtain calendar color from the rdf datasource     calendarColor = calendarNode.getAttribute("http://home.netscape.com/NC-rdf#color");     // if the calendar had a color attribute create a style sheet for it     if (calendarColor != null)     {       gCalendarStyleSheet.insertRule("." + containerName + " { background-color:" + calendarColor + "!important;}", 1);       var calcColor = calendarColor.replace(/#/g, "");       var red = parseInt(calcColor.substring(0, 2), 16);       var green = parseInt(calcColor.substring(2, 4), 16);       var blue = parseInt(calcColor.substring(4, 6), 16);       // Calculate the L(ightness) value of the HSL color system.       // L = (max(R, G, B) + min(R, G, B)) / 2       var max = Math.max(Math.max(red, green), blue);       var min = Math.min(Math.min(red, green), blue);       var lightness = (max + min) / 2;       // Consider all colors with less than 50% Lightness as dark colors       // and use white as the foreground color; otherwise use black.       // Actually we use a treshold a bit below 50%, so colors like       // #FF0000, #00FF00 and #0000FF still get black text which looked       // better when we tested this.       if (lightness < 120) {         gCalendarStyleSheet.insertRule("." + containerName + " { color:" + " white" + "!important;}", 1);       } else {         gCalendarStyleSheet.insertRule("." + containerName + " { color:" + " black" + "!important;}", 1);       }       var calListItem = calListItems[i+1];       if (calListItem && calListItem.childNodes[0]) {         calListItem.childNodes[0].setAttribute("class", "calendar-list-item-class " + containerName);       }     }   }   // Setup css classes for category colors   var catergoryPrefBranch = prefService.getBranch("");   var pbi = catergoryPrefBranch.QueryInterface(Components.interfaces.nsIPrefBranchInternal);   pbi.addObserver("calendar.category.color.", categoryPrefObserver, false);   categoryPrefObserver.mCalendarStyleSheet = gCalendarStyleSheet;   categoryPrefObserver.observe(null, null, "");   if( ("arguments" in window) &&       (window.arguments.length) &&       (typeof(window.arguments[0]) == "object") &&       ("channel" in window.arguments[0]) )   {      gCalendarWindow.calendarManager.checkCalendarURL( window.arguments[0].channel );   }   //a bit of a hack since the menulist doesn't remember the selected value        var value = document.getElementById( 'event-filter-menulist' ).value;   document.getElementById( 'event-filter-menulist' ).selectedItem = document.getElementById( 'event-filter-'+value );   gEventSource.alarmObserver.firePendingAlarms();   //All is settled, enable feedbacks to observers   gICalLib.batchMode = false;   var toolbox = document.getElementById("calendar-toolbox");   toolbox.customizeDone = CalendarToolboxCustomizeDone;}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/2b00a981e0eaad0c4d49c61d53dc15bb6012ba19/calendar.js/buggy/calendar/resources/content/calendar.js