<script type="text/javascript">
if(typeof acme === "undefined"){
acme = {};
}
if(typeof acme.CAL === "undefined"){
acme.CAL = {};
}
acme.CAL.Initialize = function(){
SP.UI.ApplicationPages.CalendarService.prototype.$7a_1_OLD__ = SP.UI.ApplicationPages.CalendarService.prototype.$7a_1;
SP.UI.ApplicationPages.CalendarService.prototype.$7a_1 = function($p0, $p1) {
this.$7a_1_OLD__($p0, $p1);
window.setTimeout(acme.CAL.Colorize, 100);
};
};
acme.CAL.Colorize = function(){
$("div.ms-acal-rootdiv").find("div.ms-acal-item").each(function(index){
var self = this;
var title = $(self).attr("title");
var colors = acme.CAL.GetColors(title);
$(self).css("background-color",colors.BGColor);
$(self).find("div").each(function(index){
$(this).css('color', '');
var style = $(this).attr("style");
var newStyle = "color: " + colors.FGColor + " !important; " + (style || "");
$(this).attr("style", newStyle);
});
$(self).find("a").each(function(index){
$(this).css('color', '');
var style = $(this).attr("style");
var newStyle = "color: " + colors.FGColor + " !important; " + (style || "");
$(this).attr("style", newStyle);
});
});
};
acme.CAL.GetColors = function(title){
var allColors = [
{ "BGColor": "red", "FGColor": "yellow" },
{ "BGColor": "pink", "FGColor": "darkred" },
{ "BGColor": "yellow", "FGColor": "red" },
{ "BGColor": "green", "FGColor": "white" },
{ "BGColor": "blue", "FGColor": "yellow" },
{ "BGColor": "orange", "FGColor": "darkred" },
{ "BGColor": "black", "FGColor": "white" },
{ "BGColor": "darkred", "FGColor": "yellow" },
{ "BGColor": "darkgray", "FGColor": "yellow" },
{ "BGColor": "aqua", "FGColor": "darkred" },
{ "BGColor": "fuchsia", "FGColor": "white" },
{ "BGColor": "cyan", "FGColor": "white" },
{ "BGColor": "magenta", "FGColor": "white" }
];
var CurrentColorId = 0;
var patt = /^\s*(\d{1,2}):\d{1,2}\s*[ap]m/i;
if(patt.test(title)){
var mm = title.match(patt)[1];
CurrentColorId = Number(mm);
}
var len = allColors.length;
var color = allColors[CurrentColorId % len];
return color;
};
ExecuteOrDelayUntilScriptLoaded(acme.CAL.Initialize, "SP.UI.ApplicationPages.Calendar.js");
</script>
Comments