Monotone-Parent: 4da2e2aa68da3f6c69bddae3167041872607c9d2

Monotone-Revision: 589cbe87a5260166298c57c4fa50494edb7b9fbd

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2008-04-22T17:16:37
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau committed 2008-04-22 17:16:37 +00:00
1 parent 092b303a45
commit 99d4c95556
5 files changed
+74 -33

No files matched your search

+5 -30
View File
@@ -4,7 +4,6 @@ var listFilter = 'view_today';
var listOfSelection = null;
var selectedCalendarCell;
var calendarColorIndex = null;
var showCompletedTasks = 0;
@@ -1689,32 +1688,6 @@ function appendCalendar(folderName, folderPath) {
li.setAttribute("id", folderPath);
li.setAttribute("owner", owner);
// Generate new color
if (calendarColorIndex == null)
calendarColorIndex = items.length;
calendarColorIndex++;
var colorTable = [1, 1, 1];
var color;
var currentValue = calendarColorIndex;
var index = 0;
while (currentValue) {
if (currentValue & 1)
colorTable[index]++;
if (index == 3)
index = 0;
currentValue >>= 1;
index++;
}
colorTable[0] = parseInt(255 / colorTable[0]) - 1;
colorTable[1] = parseInt(255 / colorTable[1]) - 1;
colorTable[2] = parseInt(255 / colorTable[2]) - 1;
color = "#"
+ colorTable[2].toString(16)
+ colorTable[1].toString(16)
+ colorTable[0].toString(16);
//log ("color = " + color);
var checkBox = document.createElement("input");
checkBox.setAttribute("type", "checkbox");
li.appendChild(checkBox);
@@ -1738,12 +1711,13 @@ function appendCalendar(folderName, folderPath) {
triggerAjaxRequest(url, calendarEntryCallback, folderPath);
// Update CSS for events color
appendStyleElement(folderPath, color);
appendStyleElement(folderPath, "#AAAAAA");
}
}
function appendStyleElement(folderPath, color) {
if (document.styleSheets) {
if (document.styleSheets) {
var fgColor = getContrastingTextColor(color);
var styleElement = document.createElement("style");
styleElement.type = "text/css";
var selectors = [
@@ -1751,7 +1725,8 @@ function appendStyleElement(folderPath, color) {
'div.colorBox.calendarFolder' + folderPath.substr(1)
];
var rules = [
' { background-color: ' + color + ' !important; }',
' { background-color: ' + color + ' !important;'
+ ' color: ' + fgColor + ' !important; }',
' { color: ' + color + ' !important; }'
];
for (var i = 0; i < rules.length; i++)
+17
View File
@@ -307,6 +307,23 @@ function onAjaxRequestStateChange(http) {
}
}
/* taken from Lightning */
function getContrastingTextColor(bgColor) {
var calcColor = bgColor.substring(1);
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 brightness (Y) value using the YUV color system.
var brightness = (0.299 * red) + (0.587 * green) + (0.114 * blue);
// Consider all colors with less than 56% brightness as dark colors and
// use white as the foreground color, otherwise use black.
return ((brightness < 144)
? "white"
: "black");
}
function triggerAjaxRequest(url, callback, userdata, content, headers) {
var http = createHTTPClient();