Go to the calendar settings page and create a new column called "TitleColorized". The column will calculate its own value by concatenating the title and category text separated by three pipes ("|||"). You don't need to add this column to the default view.
But before we do that we have to make a final change to the standard calendar view. Again go to the calendar settings and choose the "Calendar" view to edit.
All requirements for the script logic are set up now. Let's insert the script. Open the calendar in the standard view (Calendar.aspx) and start editing that page. You will see the Web Part frame called "Main". On top of that click on "Add a Web Part". Go to the "Media and Content" categories and choose the "Script Editor" Web Part and add it to the page. The Web Part has been added now. Click on "Edit Snippet" and copy and paste the following code into the pop-up window:
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type=
"text/javascript"
>
LoadSodByKey(
"SP.UI.ApplicationPages.Calendar.js"
,
function
() {
WaitForCalendarToLoad();
});
var
SEPARATOR =
"|||"
;
WaitForCalendarToLoad() {
SP.UI.ApplicationPages.SummaryCalendarView.prototype.renderGrids =
SP_UI_ApplicationPages_SummaryCalendarView$renderGrids($p0) {
$v_0 =
new
Sys.StringBuilder();
$v_1 = $p0.length;
for
(
$v_2 = 0; $v_2 < $v_1; $v_2++) {
this
.$7V_2($v_2, $p0[$v_2]);
}
$v_3 = 0; $v_3 < $v_1; $v_3++) {
$v_0.append(
'<div>'
);
.$I_2.$7Q_1($v_0, $p0[$v_3], $v_3);
.emptY_DIV);
'</div>'
.setInnerHtml($v_0.toString());
ColourCalendar();
SP.UI.ApplicationPages.CalendarStateHandler.prototype.onItemsSucceed =
($p0, $p1) {
if
.$K_1.$8G_0()) {
.$28_1();
return
.$41_1 =
false
.$3G_1) {
.$D_1.$4T_1();
.$3G_1 =
(SP.UI.ApplicationPages.SU.$2(
.$39_1[
.$j_1])) {
.$j_1] = [];
Array.addRange(
.$j_1], $p0);
.$D_1.$7S_1(
.$j_1,
.$v_1, $p1,
.$j_1]);
.$j_1++;
.$1h_1();
ColourCalendar() {
(jQuery(
'a:contains('
+ SEPARATOR +
')'
) !=
null
)
{
jQuery(
).each(
(i) {
$box = jQuery(
).parents(
'div[title]'
colour = GetColourCodeFromCategory(GetCategory(
.innerHTML));
.innerHTML = GetActualText(
.innerHTML);
jQuery($box).attr(
"title"
, GetActualText(jQuery($box).attr(
)));
$box.css(
'background-color'
, colour);
GetActualText(originalText) {
parts = originalText.split(SEPARATOR);
parts[0] + parts[2];
GetCategory(originalText) {
parts[1];
GetColourCodeFromCategory(category) {
colour =
switch
(category.trim()) {
case
'Meeting'
:
'#4FDB51'
break
'Work hours'
'#4FB8DB'
'Business'
"#F08616"
'Holiday'
"#F55875"
'Get-together'
"#E0F558"
'Gifts'
"#F558D5"
'Birthday'
"#6E80FA"
'Anniversary'
"#FF4040"
colour;
</script>
TODO