Adding color to Sharepoint 2007 calendar (MOSS)
November 28, 2007 1 Comment
Found a good walk through for this the other day
http://planetwilson.blogspot.com/2007/09/sharepoint-2007-colour-color-calendar.html
Note: The code does not copy right, and if you change the lables at the end of the code keep them in lower case. I ended up wasting some time on that little messup.
Here is a little easier way to copy the java script that is listed on the blog that I linked above.
<script> var SEPARATOR = "|||"; var nodes, category; nodes = document.getElementsByTagName("a"); for(var i = 0; i < nodes.length; i++) { if(nodes[i].innerText.indexOf(SEPARATOR) != -1) { UpdateCalendarEntryText(nodes[i]); var foundNode = nodes[i]; var trap = 0; while(foundNode.nodeName.toLowerCase() != "td") { foundNode = foundNode.parentNode; trap++; if(trap > 10) { break; // don't want to end up in a loop } } var colour = GetCalendarColour(category); if(colour != "") foundNode.style.background = colour; } } function UpdateCalendarEntryText(anchorNode) { var children = anchorNode.childNodes; for(var i = 0; i < children.length; i++) { if(children[i].nodeType == 3 && children[i].nodeValue.indexOf(SEPARATOR) != -1) { var parts = children[i].nodeValue.split(SEPARATOR); category = parts[0]; children[i].nodeValue = parts[1]; } else UpdateCalendarEntryText(children[i]); } } function GetCalendarColour(desc) { var colour; switch(desc.toLowerCase()) { case "appointment": colour = "#ffd266"; break; case "birthday": colour = "#ae99dc"; break; case "business": colour = "#8aabe0"; break; case "important": colour = "#e77379"; break; case "vacation": colour = "#fffa91"; break; default: colour = ""; } return colour; } </script>
Updated version of this can be found here :-
http://planetwilson.blogspot.com/2007/11/updated-colour-color-calendar-for.html