From d55670f4c17b1d0da53783aa9f630112c9c8ab3e Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 16 Oct 2006 22:34:11 +0000 Subject: [PATCH] Monotone-Parent: d6b4990ef8fb3415624d736697f139942ce37b9b Monotone-Revision: 18a409eaff289afd2b8a9aef52ce05b0389e19a1 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-10-16T22:34:11 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 ++ UI/WebServerResources/generic.js | 56 +++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4f687a21c..d66b1aac2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-10-16 Wolfgang Sourdeau + * UI/WebServerResources/generic.js: implemented some new helper + methods. + * SoObjects/Appointments/SOGoAppointmentFolder.m ([SOGoAppointmentFolder -deleteEntriesWithIds:ids]): don't delete entries if their owner is not the current user. diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 7e0ef95a9..3981a6945 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -200,7 +200,8 @@ function triggerAjaxRequest(url, callback, userdata) { catch( e ) { activeAjaxRequests -= 1; checkAjaxRequestsState(); - alert('AJAX Request, Caught Exception: ' + e.description); + log("AJAX Request, Caught Exception: " + e.name); + log(e.message); } }; http.url = url; @@ -905,6 +906,7 @@ function onContactAdd(node) var w = window.open(urlstr, "Addressbook", "width=640,height=400,resizable=1,scrollbars=0"); w.selector = selector; + w.opener = this; w.focus(); return false; @@ -994,6 +996,23 @@ function onTabClick(event) { } /* custom extensions to the DOM api */ +HTMLElement.prototype.childNodesWithTag = function(tagName) { + var matchingNodes = new Array(); + var tagName = tagName.toUpperCase(); + + for (var i = 0; i < this.childNodes.length; i++) { +// log("(" + tagName + ") childNodes " + i + " = " + this.childNodes[i]); + if (typeof(this.childNodes[i]) == "object" + && this.childNodes[i].tagName + && this.childNodes[i].tagName.toUpperCase() == tagName) + matchingNodes.push(this.childNodes[i]); + } + +// log ("matching: " + matchingNodes.length); + + return matchingNodes; +} + HTMLElement.prototype.addClassName = function(className) { var classStr = '' + this.getAttribute("class"); @@ -1139,6 +1158,10 @@ HTMLTableElement.prototype.deselectAll = function() { deselectNode(nodes[i]); } +HTMLUListElement.prototype.getSelectedRows = function() { + return this.getSelectedNodes(); +} + HTMLUListElement.prototype.getSelectedRowsId = function() { return this.getSelectedNodesId(); } @@ -1154,6 +1177,37 @@ String.prototype.decodeEntities = function() { }); } +function d2h(d) { + var hD = "0123456789abcdef"; + var h = hD.substr(d&15,1); + while (d>15) { + d>>=4; + h=hD.substr(d&15,1)+h; + } + return h; +} + +function indexColor(number) { + var colorTable = new Array(1, 1, 1); + + var currentValue = number; + var index = 0; + while (currentValue) + { + if (currentValue & 1) + colorTable[index]++; + if (index == 3) + index = 0; + currentValue >>= 1; + index++; + } + + return ("#" + + d2h((256 / colorTable[2]) - 1) + + d2h((256 / colorTable[1]) - 1) + + d2h((256 / colorTable[0]) - 1)); +} + // function BatchAjaxRequest() // { // this.init();