2 Copyright (C) 2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 /* some generic JavaScript code for SOGo */
23 // TODO: replace things with Prototype where applicable
32 var activeAjaxRequests = 0;
35 var allDocumentElements = null;
37 /* a W3C compliant document.all */
38 function getAllScopeElements(scope) {
39 var elements = new Array();
41 for (var i = 0; i < scope.childNodes.length; i++)
42 if (typeof(scope.childNodes[i]) == "object"
43 && scope.childNodes[i].tagName
44 && scope.childNodes[i].tagName != '')
46 elements.push(scope.childNodes[i]);
47 var childElements = getAllElements(scope.childNodes[i]);
48 if (childElements.length > 0)
49 elements.push(childElements);
55 function getAllElements(scope) {
62 && allDocumentElements != null)
63 elements = allDocumentElements;
66 elements = getAllScopeElements(scope);
67 if (scope == document)
68 allDocumentElements = elements;
75 http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ */
76 function getElementsByClassName2(_tag, _class, _scope) {
77 var regexp, classes, elements, element, returnElements;
79 _scope = _scope || document;
81 elements = (!_tag || _tag == "*"
82 ? getAllElements(null)
83 : _scope.getElementsByTagName(_tag));
86 classes = _class.split(/\s+/);
87 regexp = new RegExp("(^|\s+)("+ classes.join("|") +")(\s+|$)","i");
90 for(var i = 0; element = elements[i]; i++) {
91 if (regexp.test(element.className)) {
92 returnElements.push(element);
95 return returnElements;
101 function ml_stripActionInURL(url) {
102 if (url[url.length - 1] != '/') {
105 i = url.lastIndexOf("/");
106 if (i != -1) url = url.substring(0, i);
108 if (url[url.length - 1] != '/') // ensure trailing slash
113 function URLForFolderID(folderID) {
114 var folderInfos = folderID.split(":");
116 if (folderInfos.length > 1) {
117 url = UserFolderURL + "../" + folderInfos[0];
118 if (folderInfos[1][0] != '/')
120 url += folderInfos[1];
123 url = ApplicationBaseURL + folderInfos[0];
125 if (url[url.length-1] == '/')
126 url = url.substr(0, url.length-1);
131 function extractEmailAddress(mailTo) {
135 = /([a-zA-Z0-9]+[a-zA-Z0-9\._-]+[a-zA-Z0-9]+@[a-zA-Z0-9]+[a-zA-Z0-9\._-]+[a-zA-Z0-9]+)/g;
136 if (emailre.test(mailTo)) {
137 emailre.exec(mailTo);
144 function extractEmailName(mailTo) {
147 var emailNamere = /(.+)\ </;
148 if (emailNamere.test(mailTo)) {
149 emailNamere.exec(mailTo);
150 emailName = RegExp.$1;
156 function sanitizeMailTo(dirtyMailTo) {
157 var emailName = extractEmailName(dirtyMailTo);
158 var email = "" + extractEmailAddress(dirtyMailTo);
161 if (emailName && emailName.length > 0)
162 mailto = emailName + ' <' + email + '>';
169 function openUserFolderSelector(callback, type) {
170 var urlstr = ApplicationBaseURL;
171 if (urlstr[urlstr.length-1] != '/')
173 urlstr += ("../../" + UserLogin + "/Contacts/userFolders");
174 var w = window.open(urlstr, "User Selector",
175 "width=322,height=250,resizable=1,scrollbars=0");
177 w.userFolderCallback = callback;
178 w.userFolderType = type;
182 function openMailComposeWindow(url) {
183 var w = window.open(url, null,
184 "width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
185 + "location=0,directories=0,status=0,menubar=0"
192 function openMailTo(senderMailto) {
193 var mailto = sanitizeMailTo(senderMailto);
195 if (mailto.length > 0)
196 openMailComposeWindow(ApplicationBaseURL
197 + "/../Mail/compose?mailto=" + mailto);
199 return false; /* stop following the link */
202 function createHTTPClient() {
203 // http://developer.apple.com/internet/webcontent/xmlhttpreq.html
204 if (typeof XMLHttpRequest != "undefined")
205 return new XMLHttpRequest();
207 try { return new ActiveXObject("Msxml2.XMLHTTP"); }
209 try { return new ActiveXObject("Microsoft.XMLHTTP"); }
215 function triggerAjaxRequest(url, callback, userdata) {
216 var http = createHTTPClient();
218 activeAjaxRequests += 1;
219 document.animTimer = setTimeout("checkAjaxRequestsState();", 200);
222 http.onreadystatechange
224 // log ("state changed (" + http.readyState + "): " + url);
226 if (http.readyState == 4
227 && activeAjaxRequests > 0) {
229 http.callbackData = userdata;
232 activeAjaxRequests -= 1;
233 checkAjaxRequestsState();
237 activeAjaxRequests -= 1;
238 checkAjaxRequestsState();
239 log("AJAX Request, Caught Exception: " + e.name);
244 http.open("GET", url, true);
251 function checkAjaxRequestsState() {
252 var toolbar = document.getElementById("toolbar");
254 if (activeAjaxRequests > 0
255 && !document.busyAnim) {
256 var anim = document.createElement("img");
257 document.busyAnim = anim;
258 anim.id = "progressIndicator";
259 anim.src = ResourcesURL + "/busy.gif";
260 anim.style.visibility = "hidden;";
261 toolbar.appendChild(anim);
262 anim.style.visibility = "visible;";
264 else if (activeAjaxRequests == 0
265 && document.busyAnim) {
266 document.busyAnim.parentNode.removeChild(document.busyAnim);
267 document.busyAnim = null;
272 function resetSelection(win) {
274 if (win && win.getSelection) {
275 t = win.getSelection().toString();
276 win.getSelection().removeAllRanges();
281 function refreshOpener() {
282 if (window.opener && !window.opener.closed) {
283 window.opener.location.reload();
289 function parseQueryString() {
290 var queryArray, queryDict
291 var key, value, s, idx;
292 queryDict.length = 0;
294 queryDict = new Array();
295 queryArray = location.search.substr(1).split('&');
296 for (var i in queryArray) {
297 if (!queryArray[i]) continue ;
299 idx = s.indexOf("=");
305 key = s.substr(0, idx);
306 value = unescape(s.substr(idx + 1));
309 if (typeof queryDict[key] == 'undefined')
312 queryDict[key] = value;
317 function generateQueryString(queryDict) {
319 for (var key in queryDict) {
324 s = s + key + "=" + escape(queryDict[key]);
329 function getQueryParaArray(s) {
330 if (s.charAt(0) == "?") s = s.substr(1, s.length - 1);
334 function getQueryParaValue(s, name) {
337 t = getQueryParaArray(s);
338 for (var i = 0; i < t.length; i++) {
341 if (s.indexOf(name) != 0)
344 s = s.substr(name.length, s.length - name.length);
345 return decodeURIComponent(s);
350 /* opener callback */
352 function triggerOpenerCallback() {
353 /* this code has some issue if the folder has no proper trailing slash! */
354 if (window.opener && !window.opener.closed) {
357 t = getQueryParaValue(window.location.search, "openerurl=");
358 cburl = window.opener.location.href;
359 if (cburl[cburl.length - 1] != "/") {
360 cburl = cburl.substr(0, cburl.lastIndexOf("/") + 1);
363 window.opener.location.href = cburl;
367 /* selection mechanism */
369 function deselectAll(parent) {
370 for (var i = 0; i < parent.childNodes.length; i++) {
371 var node = parent.childNodes.item(i);
372 if (node.nodeType == 1)
377 function isNodeSelected(node) {
378 var classStr = '' + node.getAttribute('class');
379 var position = classStr.indexOf('_selected', 0);
381 return (position > -1);
384 function acceptMultiSelect(node) {
385 var accept = ('' + node.getAttribute('multiselect')).toLowerCase();
387 return (accept == 'yes');
390 function onRowClick(event) {
391 var node = event.target;
393 if (node.tagName == 'TD')
394 node = node.parentNode;
396 var startSelection = node.parentNode.getSelectedNodes();
397 if (event.shiftKey == 1
398 && (acceptMultiSelect(node.parentNode)
399 || acceptMultiSelect(node.parentNode.parentNode))) {
400 if (isNodeSelected(node) == true) {
406 deselectAll(node.parentNode);
410 if (startSelection != node.parentNode.getSelectedNodes()) {
411 var parentNode = node.parentNode;
412 if (parentNode instanceof HTMLTableSectionElement)
413 parentNode = parentNode.parentNode;
414 var onSelectionChangeEvent = document.createEvent("UIEvents");
415 onSelectionChangeEvent.initEvent("selectionchange", true, true);
416 parentNode.dispatchEvent(onSelectionChangeEvent);
422 var bodyOnClick = "";
423 // var acceptClick = false;
425 function onMenuClick(event, menuId) {
426 var node = event.target;
428 if (document.currentPopupMenu)
429 hideMenu(event, document.currentPopupMenu);
431 var popup = document.getElementById(menuId);
433 var menuTop = event.pageY;
434 var menuLeft = event.pageX;
435 var heightDiff = (window.innerHeight
436 - (menuTop + popup.offsetHeight));
438 menuTop += heightDiff;
440 var leftDiff = (window.innerWidth
441 - (menuLeft + popup.offsetWidth));
443 menuLeft -= popup.offsetWidth;
445 popup.style.top = menuTop + "px;";
446 popup.style.left = menuLeft + "px;";
447 popup.style.visibility = "visible;";
448 setupMenuTarget(popup, node);
450 bodyOnClick = "" + document.body.getAttribute("onclick");
451 document.body.setAttribute("onclick", "onBodyClick(event);");
452 document.currentPopupMenu = popup;
454 event.cancelBubble = true;
455 event.returnValue = false;
460 function setupMenuTarget(menu, target) {
461 menu.menuTarget = target;
462 var menus = document.getElementsByClassName("menu", menu);
463 for (var i = 0; i < menus.length; i++) {
464 menus[i].menuTarget = target;
468 function getParentMenu(node) {
469 var currentNode, menuNode;
473 var menure = new RegExp("(^|\s+)menu(\s+|$)", "i");
475 while (menuNode == null
477 if (menure.test(currentNode.className))
478 menuNode = currentNode;
480 currentNode = currentNode.parentNode;
485 function onBodyClick(event) {
486 document.currentPopupMenu.menuTarget = null;
487 hideMenu(event, document.currentPopupMenu);
488 document.body.setAttribute("onclick", bodyOnClick);
493 function hideMenu(event, menuNode) {
496 // log('hiding menu "' + menuNode.getAttribute('id') + '"');
497 if (menuNode.submenu) {
498 hideMenu(event, menuNode.submenu);
499 menuNode.submenu = null;
502 menuNode.style.visibility = "hidden";
503 if (menuNode.parentMenuItem) {
504 menuNode.parentMenuItem.setAttribute('class', 'submenu');
505 menuNode.parentMenuItem = null;
506 menuNode.parentMenu.setAttribute('onmousemove', null);
507 menuNode.parentMenu.submenuItem = null;
508 menuNode.parentMenu.submenu = null;
509 menuNode.parentMenu = null;
512 var onhideEvent = document.createEvent("UIEvents");
513 onhideEvent.initEvent("hideMenu", false, true);
514 menuNode.dispatchEvent(onhideEvent);
517 function onMenuEntryClick(event, menuId) {
518 var node = event.target;
520 id = getParentMenu(node).menuTarget;
521 // log("clicked " + id + "/" + id.tagName);
526 function parseQueryParameters(url) {
527 var parameters = new Array();
529 var params = url.split("?")[1];
531 var pairs = params.split("&");
532 for (var i = 0; i < pairs.length; i++) {
533 var pair = pairs[i].split("=");
534 parameters[pair[0]] = pair[1];
541 function initLogConsole() {
542 var logConsole = $("logConsole");
544 logConsole.addEventListener("dblclick", onLogDblClick, false);
545 logConsole.innerHTML = "";
546 node = document.getElementsByTagName('body')[0];
547 node.addEventListener("keydown", onBodyKeyDown, true);
551 function onBodyKeyDown(event) {
552 if (event.keyCode == 27) {
554 event.cancelBubble = true;
555 event.returnValue = false;
559 function onLogDblClick(event) {
560 var logConsole = $("logConsole");
561 logConsole.innerHTML = "";
564 function toggleLogConsole(event) {
565 var logConsole = $("logConsole");
566 var display = '' + logConsole.style.display;
567 if (display.length == 0) {
568 logConsole.style.display = 'block;';
570 logConsole.style.display = '';
572 event.cancelBubble = true;
573 event.returnValue = false;
574 event.preventDefault();
577 function log(message) {
580 while (logWindow.opener)
581 logWindow = logWindow.opener;
583 var logConsole = logWindow.document.getElementById("logConsole");
585 logConsole.innerHTML += message.replace("<", "<") + '<br />' + "\n";
588 function backtrace() {
589 var func = backtrace.caller;
590 var str = "backtrace:<br/>";
596 str += " " + func.name;
598 str += " (" + this + ")";
601 str += "[anonymous]\n";
611 function dropDownSubmenu(event) {
612 var node = event.target;
613 var submenu = node.getAttribute("submenu");
614 if (submenu && submenu != "") {
615 var submenuNode = document.getElementById(submenu);
616 var parentNode = getParentMenu(node);
617 if (parentNode.submenu)
618 hideMenu(event, parentNode.submenu);
619 submenuNode.parentMenuItem = node;
620 submenuNode.parentMenu = parentNode;
621 parentNode.submenuItem = node;
622 parentNode.submenu = submenuNode;
624 var menuTop = (node.offsetTop - 2);
626 var heightDiff = (window.innerHeight
627 - (menuTop + submenuNode.offsetHeight));
629 menuTop += heightDiff;
631 var menuLeft = parentNode.offsetWidth - 3;
632 if (window.innerWidth
633 < (menuLeft + submenuNode.offsetWidth
634 + parentNode.cascadeLeftOffset()))
635 menuLeft = -submenuNode.offsetWidth + 3;
637 parentNode.setAttribute('onmousemove', 'checkDropDown(event);');
638 node.setAttribute('class', 'submenu-selected');
639 submenuNode.style.top = menuTop + "px;";
640 submenuNode.style.left = menuLeft + "px;";
641 submenuNode.style.visibility = "visible;";
645 function checkDropDown(event) {
646 var parentMenu = getParentMenu(event.target);
647 var submenuItem = parentMenu.submenuItem;
649 var menuX = event.clientX - parentMenu.cascadeLeftOffset();
650 var menuY = event.clientY - parentMenu.cascadeTopOffset();
651 var itemX = submenuItem.offsetLeft;
652 var itemY = submenuItem.offsetTop - 75;
655 && menuX < itemX + submenuItem.offsetWidth
657 || menuY > (itemY + submenuItem.offsetHeight))) {
658 hideMenu(event, parentMenu.submenu);
659 parentMenu.submenu = null;
660 parentMenu.submenuItem = null;
661 parentMenu.setAttribute('onmousemove', null);
667 function popupSearchMenu(event) {
668 var node = event.target;
670 var menuId = this.getAttribute("menuid");
671 relX = event.pageX - node.cascadeLeftOffset();
672 relY = event.pageY - node.cascadeTopOffset();
674 if (event.button == 0
676 event.cancelBubble = true;
677 event.returnValue = false;
679 if (document.currentPopupMenu)
680 hideMenu(event, document.currentPopupMenu);
682 var popup = document.getElementById(menuId);
683 popup.style.top = node.offsetHeight + "px";
684 popup.style.left = (node.offsetLeft + 3) + "px";
685 popup.style.visibility = "visible";
687 bodyOnClick = "" + document.body.getAttribute("onclick");
688 document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');");
689 document.currentPopupMenu = popup;
693 function setSearchCriteria(event) {
694 searchValue = $("searchValue");
695 searchCriteria = $("searchCriteria");
697 var node = event.target;
698 searchValue.setAttribute("ghost-phrase", node.innerHTML);
699 searchCriteria = node.getAttribute('id');
702 function checkSearchValue(event) {
703 var form = event.target;
704 var searchValue = $("searchValue");
705 var ghostPhrase = searchValue.getAttribute('ghost-phrase');
707 if (searchValue.value == ghostPhrase)
708 searchValue.value = "";
711 function onSearchChange() {
712 log ("onSearchChange()...");
715 function onSearchMouseDown(event) {
716 var superNode = this.parentNode.parentNode.parentNode;
717 relX = (event.pageX - superNode.offsetLeft - this.offsetLeft);
718 relY = (event.pageY - superNode.offsetTop - this.offsetTop);
721 event.cancelBubble = true;
722 event.returnValue = false;
726 function onSearchFocus() {
727 ghostPhrase = this.getAttribute("ghost-phrase");
728 if (this.value == ghostPhrase) {
730 this.setAttribute("modified", "");
735 this.style.color = "#000";
738 function onSearchBlur(event) {
739 var ghostPhrase = this.getAttribute("ghost-phrase");
740 // log ("search blur: '" + this.value + "'");
742 this.setAttribute("modified", "");
743 this.style.color = "#aaa";
744 this.value = ghostPhrase;
745 } else if (this.value == ghostPhrase) {
746 this.setAttribute("modified", "");
747 this.style.color = "#aaa";
749 this.setAttribute("modified", "yes");
750 this.style.color = "#000";
754 function onSearchKeyDown(event) {
756 clearTimeout(this.timer);
758 this.timer = setTimeout("onSearchFormSubmit()", 1000);
761 function initCriteria() {
762 var searchCriteria = $("searchCriteria");
763 var searchValue = $("searchValue");
766 var searchOptions = $("searchOptions");
768 firstOption = searchOptions.childNodes[1];
769 searchCriteria.value = firstOption.getAttribute('id');
770 searchValue.setAttribute('ghost-phrase', firstOption.innerHTML);
771 if (searchValue.value == '') {
772 searchValue.value = firstOption.innerHTML;
773 searchValue.setAttribute("modified", "");
774 searchValue.style.color = "#aaa";
779 /* toolbar buttons */
780 function popupToolbarMenu(event, menuId) {
781 var toolbar = $("toolbar");
782 var node = event.target;
783 if (node.tagName != 'A')
784 node = node.getParentWithTagName("a");
785 node = node.childNodesWithTag("span")[0];
787 if (event.button == 0) {
788 event.cancelBubble = true;
789 event.returnValue = false;
791 if (document.currentPopupMenu)
792 hideMenu(event, document.currentPopupMenu);
794 var popup = document.getElementById(menuId);
795 var top = node.offsetTop + node.offsetHeight - 2;
796 popup.style.top = top + "px";
797 popup.style.left = node.cascadeLeftOffset() + "px";
798 popup.style.visibility = "visible";
800 bodyOnClick = "" + document.body.getAttribute("onclick");
801 document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');");
802 document.currentPopupMenu = popup;
806 /* contact selector */
808 function folderSubscriptionCallback(http) {
809 if (http.readyState == 4) {
810 if (http.status == 204) {
811 if (http.callbackData)
812 http.callbackData["method"](http.callbackData["data"]);
815 window.alert(labels["Unable to subscribe to that folder!"].decodeEntities());
816 document.subscriptionAjaxRequest = null;
819 log ("ajax fuckage");
822 function subscribeToFolder(refreshCallback, refreshCallbackData) {
823 var folderData = refreshCallbackData["folder"].split(":");
824 var username = folderData[0];
825 var folderPath = folderData[1];
826 if (username != UserLogin) {
827 var url = (UserFolderURL + "../" + username
828 + folderPath + "/subscribe");
829 if (document.subscriptionAjaxRequest) {
830 document.subscriptionAjaxRequest.aborted = true;
831 document.subscriptionAjaxRequest.abort();
833 var rfCbData = { method: refreshCallback, data: refreshCallbackData };
834 document.subscriptionAjaxRequest = triggerAjaxRequest(url,
835 folderSubscriptionCallback,
839 window.alert(labels["You cannot subscribe to a folder that you own!"]
843 function folderUnsubscriptionCallback(http) {
844 if (http.readyState == 4) {
845 if (http.status == 204) {
846 if (http.callbackData)
847 http.callbackData["method"](http.callbackData["data"]);
850 window.alert(labels["Unable to unsubscribe from that folder!"].decodeEntities());
851 document.unsubscriptionAjaxRequest = null;
855 function unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData) {
856 if (document.body.hasClassName("popup")) {
857 window.opener.unsubscribeFromFolder(folder, refreshCallback,
858 refreshCallbackData);
861 var folderData = folder.split(":");
862 var username = folderData[0];
863 var folderPath = folderData[1];
864 if (username != UserLogin) {
865 var url = (UserFolderURL + "../" + username
866 + "/" + folderPath + "/unsubscribe");
867 if (document.unsubscriptionAjaxRequest) {
868 document.unsubscriptionAjaxRequest.aborted = true;
869 document.unsubscriptionAjaxRequest.abort();
871 var rfCbData = { method: refreshCallback, data: refreshCallbackData };
872 document.unsubscriptionAjaxRequest
873 = triggerAjaxRequest(url, folderUnsubscriptionCallback,
877 window.alert(labels["You cannot unsubscribe from a folder that you own!"].decodeEntities());
881 function listRowMouseDownHandler(event) {
882 event.preventDefault();
886 function initTabs() {
887 var containers = document.getElementsByClassName("tabsContainer");
888 for (var x = 0; x < containers.length; x++) {
889 var container = containers[x];
890 var nodes = container.childNodes[1].childNodes;
893 for (var i = 0; i < nodes.length; i++) {
894 if (nodes[i] instanceof HTMLLIElement) {
898 nodes[i].addEventListener("mousedown", onTabMouseDown, true);
899 nodes[i].addEventListener("click", onTabClick, true);
903 nodes[firstTab].addClassName("first");
904 nodes[firstTab].addClassName("active");
905 container.activeTab = nodes[firstTab];
907 var target = $(nodes[firstTab].getAttribute("target"));
908 target.addClassName("active");
912 function initMenusNamed(menuDivNames) {
913 for (var i = 0; i < menuDivNames.length; i++) {
914 var menuDIV = $(menuDivNames[i]);
918 log("menu named '" + menuDivNames[i] + "' not found");
922 function initMenu(menuDIV) {
923 var lis = menuDIV.childNodesWithTag("ul")[0].childNodesWithTag("li");
924 for (var j = 0; j < lis.length; j++)
925 lis[j].addEventListener("mousedown", listRowMouseDownHandler, false);
926 var subMenus = menuDIV.childNodesWithTag("div");
927 for (var i = 0; i < subMenus.length; i++)
928 initMenu(subMenus[i]);
931 function onTabMouseDown(event) {
932 event.cancelBubble = true;
933 event.preventDefault();
936 function openExternalLink(anchor) {
940 function openAclWindow(url) {
941 var w = window.open(url, "aclWindow",
942 "width=300,height=300,resizable=1,scrollbars=1,toolbar=0,"
943 + "location=0,directories=0,status=0,menubar=0"
951 function getUsersRightsWindowHeight() {
952 return usersRightsWindowHeight;
955 function getUsersRightsWindowWidth() {
956 return usersRightsWindowWidth;
959 function getTopWindow() {
960 var topWindow = null;
961 var currentWindow = window;
963 if (currentWindow.document.body.hasClassName("popup")
964 && currentWindow.opener)
965 currentWindow = currentWindow.opener;
967 topWindow = currentWindow;
973 function onTabClick(event) {
974 var node = event.target;
976 var target = node.getAttribute("target");
978 var container = node.parentNode.parentNode;
979 var oldTarget = container.activeTab.getAttribute("target");
980 var content = $(target);
981 var oldContent = $(oldTarget);
983 oldContent.removeClassName("active");
984 container.activeTab.removeClassName("active");
985 container.activeTab = node;
986 container.activeTab.addClassName("active");
987 content.addClassName("active");
992 function enableAnchor(anchor) {
993 var classStr = '' + anchor.getAttribute("class");
994 var position = classStr.indexOf("_disabled", 0);
996 var disabledHref = anchor.getAttribute("disabled-href");
998 anchor.setAttribute("href", disabledHref);
999 var disabledOnclick = anchor.getAttribute("disabled-onclick");
1000 if (disabledOnclick)
1001 anchor.setAttribute("onclick", disabledOnclick);
1002 anchor.removeClassName("_disabled");
1003 anchor.setAttribute("disabled-href", null);
1004 anchor.setAttribute("disabled-onclick", null);
1005 anchor.disabled = 0;
1010 function disableAnchor(anchor) {
1011 var classStr = '' + anchor.getAttribute("class");
1012 var position = classStr.indexOf("_disabled", 0);
1014 var href = anchor.getAttribute("href");
1016 anchor.setAttribute("disabled-href", href);
1017 var onclick = anchor.getAttribute("onclick");
1019 anchor.setAttribute("disabled-onclick", onclick);
1020 anchor.addClassName("_disabled");
1021 anchor.setAttribute("href", "#");
1022 anchor.setAttribute("onclick", "return false;");
1023 anchor.disabled = 1;
1029 var hD = "0123456789abcdef";
1030 var h = hD.substr(d & 15, 1);
1034 h = hD.substr(d & 15, 1) + h;
1040 function indexColor(number) {
1046 var colorTable = new Array(1, 1, 1);
1048 var currentValue = number;
1050 while (currentValue) {
1051 if (currentValue & 1)
1052 colorTable[index]++;
1060 + d2h((256 / colorTable[2]) - 1)
1061 + d2h((256 / colorTable[1]) - 1)
1062 + d2h((256 / colorTable[0]) - 1));
1068 var onLoadHandler = function (event) {
1069 queryParameters = parseQueryParameters('' + window.location);
1070 if (!document.body.hasClassName("popup")) {
1076 configureDragHandles();
1077 configureSortableTableHeaders();
1078 configureLinkBanner();
1079 var progressImage = $("progressIndicator");
1081 progressImage.parentNode.removeChild(progressImage);
1084 function configureSortableTableHeaders() {
1085 var headers = document.getElementsByClassName("sortableTableHeader");
1086 for (var i = 0; i < headers.length; i++) {
1087 var anchor = headers[i].childNodesWithTag("a")[0];
1089 anchor.link = anchor.getAttribute("href");
1091 anchor.addEventListener("click", onHeaderClick, true);
1096 function onLinkBannerClick() {
1097 activeAjaxRequests++;
1098 checkAjaxRequestsState();
1101 function configureLinkBanner() {
1102 var linkBanner = $("linkBanner");
1104 var anchors = linkBanner.childNodesWithTag("a");
1105 for (var i = 0; i < 2; i++) {
1106 anchors[i].addEventListener("mousedown", listRowMouseDownHandler,
1108 anchors[i].addEventListener("click", onLinkBannerClick, false);
1110 if (anchors.length > 3)
1111 anchors[3].addEventListener("click", toggleLogConsole, true);
1115 if (window.addEventListener) {
1116 window.addEventListener('load', onLoadHandler, false);
1117 } else if (document.addEventListener) {
1118 document.addEventListener('load', onLoadHandler, false);
1122 function configureDragHandles() {
1125 function initializeMenus() {
1128 function onHeaderClick(event) {
1129 window.alert("generic headerClick");
1132 function parent$(element) {
1133 return window.opener.document.getElementById(element);