X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fstatic%2Fwclib.js;h=c7d8a8516a3569c60ba970eeb2e98f8ddc9f6b00;hb=61dc1ed2f1a619b730ee1fb2d23cc6296bbe8ba7;hp=0f32b4e80f59518ed58673b19228d4573ca2fd14;hpb=a7bc8c8d38804f4366ee916867e6e24e306b0ac1;p=citadel.git diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index 0f32b4e80..c7d8a8516 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -1,25 +1,33 @@ -// -// $Id$ -// -// JavaScript function library for WebCit. -// -// - +/* + * JavaScript function library for WebCit. + * + * Copyright (c) 2005-2012 by the citadel.org team + * + * This program is open source software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 3. + * the Free Software Foundation, either version 3 of the License, or + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * along with this program. If not, see . + */ var browserType; var room_is_trash = 0; var currentlyExpandedFloor = null; var roomlist = null; - -var _switchToRoomList = "switch to room list"; -var _switchToMenu = "switch to menu"; - var currentDropTarget = null; var supportsAddEventListener = (!!document.addEventListener); var today = new Date(); +var wc_log = ""; if (document.all) {browserType = "ie"} if (window.navigator.userAgent.toLowerCase().match("gecko")) { browserType= "gecko"; @@ -29,15 +37,88 @@ Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate); Event.observe(window, 'load', taskViewActivate); //document.observe("dom:loaded", setupPrefEngine); document.observe("dom:loaded", setupIconBar); -document.observe('dom:loaded', function() { if (!!document.getElementById("ib_chat_launch")) { $('ib_chat_launch').observe('click', launchChat); } }); function CtdlRandomString() { return((Math.random()+'').substr(3)); } +function strcmp ( str1, str2 ) { + // http://kevin.vanzonneveld.net + // + original by: Waldo Malqui Silva + // + input by: Steve Hilder + // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + revised by: gorthaur + // * example 1: strcmp( 'waldo', 'owald' ); + // * returns 1: 1 + // * example 2: strcmp( 'owald', 'waldo' ); + // * returns 2: -1 + + return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) ); +} + +function CtdlMarkLog($Which, $Status) +{ + if ($Status) + document.getElementById($Which).checked == false; + else + document.getElementById($Which).checked == true; + +} +function ToggleLogEnable($Which) +{ + var p; + var Status = !document.getElementById($Which).checked; + if (Status) + p= encodeURI('g_cmd=LOGS ' + $Which + '|0'); + else + p= encodeURI('g_cmd=LOGS ' + $Which + '|1'); + new Ajax.Request('ajax_servcmd', { + method: 'post', + parameters: p, + onComplete: CtdlMarkLog($Which, Status) + }); +} + +function SMTPRunQueue() +{ + var p; + + p= encodeURI('g_cmd=SMTP runqueue'); + new Ajax.Request('ajax_servcmd', { + method: 'post', + parameters: p, + onComplete: function(transport) { ajax_important_message(transport.responseText.substr(4));} + }); +} + +function NetworkSynchronizeRoom(NodeName) +{ + var p; + + p= encodeURI('g_cmd=NSYN ' + NodeName); + new Ajax.Request('ajax_servcmd', { + method: 'post', + parameters: p, + onComplete: function(transport) { ajax_important_message(transport.responseText.substr(4));} + }); +} +function ToggleVisibility ($Which) +{ + if (document.getElementById) + { + if (document.getElementById($Which).style.display == "none") + document.getElementById($Which).style.display = "inline"; + else + document.getElementById($Which).style.display = "none"; + } +} function emptyElement(element) { childNodes = element.childNodes; for(var i=0; i 800) { + var mvCommand = "g_cmd=MOVE%20" + msgIds + "|"+encodeURIComponent(room)+"|0"; + new Ajax.Request("ajax_servcmd", { + parameters: mvCommand, + method: 'post', + }); + msgIds = ""; + } + + } + var mvCommand = "g_cmd=MOVE%20" + msgIds + "|"+encodeURIComponent(room)+"|0"; + new Ajax.Request('ajax_servcmd', { + method: 'post', parameters: mvCommand, onComplete: deleteAllMarkedRows()}); - } + } } function expandFloorEvent(event) { expandFloor(event.target); @@ -475,8 +600,14 @@ function NotesResizeMouseMove(evt) { divTop = parseInt(d.style.height); divLeft = parseInt(d.style.width); - d.style.height = (divTop + y_increment) + 'px'; - d.style.width = (divLeft + x_increment) + 'px'; + newHeight = divTop + y_increment; + if (newHeight < 50) newHeight = 50; + + newWidth = divLeft + x_increment; + if (newWidth < 50) newWidth = 50; + + d.style.height = newHeight + 'px'; + d.style.width = newWidth + 'px'; saved_x = x; saved_y = y; @@ -547,7 +678,7 @@ function ctdl_ts_getInnerText(el) { // Place a gradient loadscreen on an element, e.g to use before Ajax.updater function CtdlLoadScreen(elementid) { var elem = document.getElementById(elementid); -elem.innerHTML = "

  Loading....

"; +elem.innerHTML = "

  Loading....

"; } @@ -569,7 +700,7 @@ function PopOpenAddressBook(target_input) { } function PopulateAddressBookInnerDiv(which_addr_book, target_input) { - $('address_book_inner_div').innerHTML = "

  Loading....

"; + $('address_book_inner_div').innerHTML = "

  Loading....

"; p = 'which_addr_book=' + which_addr_book + '&target_input=' + target_input + '&r=' + CtdlRandomString(); @@ -615,28 +746,42 @@ function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) { // TODO: Collapse into one function function toggleTaskDtStart(event) { var checkBox = $('nodtstart'); - dtStart = document.getElementById("dtstart"); + var checkBoxTime = $('dtstart_time_assoc'); + var dtstart = document.getElementById("dtstart"); + var dtstart_date = document.getElementById("dtstart_date"); + var dtstart_time = document.getElementById("dtstart_time"); if (checkBox.checked) { - dtStart.disabled = true; - dtStart.style.textDecoration = "line-through"; + dtstart_date.style.visibility = "hidden"; + dtstart_time.style.visibility = "hidden"; } else { - dtStart.disabled = false; - dtStart.style.textDecoration = ""; - if (dtStart.value.length == 0) - dtStart.dpck._initCurrentDate(); + if (checkBoxTime.checked) { + dtstart_time.style.visibility = "visible"; + } else { + dtstart_time.style.visibility = "hidden"; + } + dtstart_date.style.visibility = "visible"; + if (dtstart.value.length == 0) + dtstart.dpck._initCurrentDate(); } } function toggleTaskDue(event) { var checkBox = $('nodue'); - dueField = document.getElementById("due"); + var checkBoxTime = $('due_time_assoc'); + var due = document.getElementById("due"); + var due_date = document.getElementById("due_date"); + var due_time = document.getElementById("due_time"); if (checkBox.checked) { - dueField.disabled = true; - dueField.style.textDecoration = "line-through"; + due_date.style.visibility = "hidden"; + due_time.style.visibility = "hidden"; } else { - dueField.disabled = false; - dueField.style.textDecoration = ""; - if (dueField.value.length == 0) - dueField.dpck._initCurrentDate(); + if (checkBoxTime.checked) { + due_time.style.visibility = "visible"; + } else { + due_time.style.visibility = "hidden"; + } + due_date.style.visibility = "visible"; + if (due.value.length == 0) + due.dpck._initCurrentDate(); } } function ToggleTaskDateOrNoDateActivate(event) { @@ -645,7 +790,9 @@ function ToggleTaskDateOrNoDateActivate(event) { toggleTaskDtStart(null); toggleTaskDue(null); $('nodtstart').observe('click', toggleTaskDtStart); + $('dtstart_time_assoc').observe('click', toggleTaskDtStart); $('nodue').observe('click', toggleTaskDue); + $('due_time_assoc').observe('click', toggleTaskDue); } } function TaskViewGatherCategoriesFromTable() { @@ -664,13 +811,14 @@ function attachDatePicker(relative) { } function eventEditAllDay() { var allDayCheck = document.getElementById("alldayevent"); - var dtend= document.getElementById("dtendcell"); + var dtend_time = document.getElementById("dtend_time"); + var dtstart_time = document.getElementById("dtstart_time"); if(allDayCheck.checked) { - //dtend.disabled = true; - dtend.style.textDecoration = "line-through"; + dtstart_time.style.visibility = "hidden"; + dtend_time.style.visibility = "hidden"; } else { - //dtend_day.disabled = false; - dtend.style.textDecoration = ""; + dtstart_time.style.visibility = "visible"; + dtend_time.style.visibility = "visible"; } } @@ -751,6 +899,23 @@ function RecurrenceShowHide() { } } + + +// Enable or disable the 'check attendee availability' button depending on whether +// the attendees list is empty +function EnableOrDisableCheckButton() +{ + if ($('attendees_box').value.length == 0) { + $('check_button').disabled = true; + } + else { + $('check_button').disabled = false; + } +} + + + + function launchChat(event) { window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes'); } @@ -760,5 +925,97 @@ function WCLog(msg) { console.log(msg); } else if (!!window.opera && !!opera.postError) { opera.postError(msg); + } else { + wc_log += msg + "\r\n"; } } + +function RefreshSMTPqueueDisplay() { + new Ajax.Updater('mailqueue_list', + 'dotskip?room=__CitadelSMTPspoolout__&view=11&ListOnly=yes', { method: 'get', + parameters: Math.random() } ); +} + +function DeleteSMTPqueueMsg(msgnum1, msgnum2) { + var p = encodeURI('g_cmd=DELE ' + msgnum1 + ',' + msgnum2); + new Ajax.Request( + 'ajax_servcmd', { + method: 'post', + parameters: p, + onComplete: function(transport) { ajax_important_message(transport.responseText.substr(4)); RefreshSMTPqueueDisplay();} + } + ); +} + + +function ConfirmLogoff() { + new Ajax.Updater( + 'md-content', + 'do_template?template=confirmlogoff', + { + method: 'get', + evalScripts: true, + onSuccess: function(cl_success) { + toggleModal(1); + } + } + ); +} + + +function switch_to_lang(new_lang) { + p = 'push?url=' + encodeURI(window.location); + new Ajax.Request(p, { method: 'get' } ); + window.location = 'switch_language?lang=' + new_lang ; +} + + +function toggle_roomlist() +{ + /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */ + if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) { + $('roomlist').style.display = 'none'; + $('expand_roomlist').src = 'static/webcit_icons/expand.gif'; + wstate=0; + } + + else { + $('roomlist').style.display = 'block'; + $('expand_roomlist').src = 'static/webcit_icons/collapse.gif'; + $('roomlist').innerHTML = ''; + FillRooms(IconBarRoomList); + wstate=1; + } + + // tell the server what I did + p = 'toggle_roomlist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ; + new Ajax.Request(p, { method: 'get' } ); + + return false; /* this prevents the click from registering as a roomlist button press */ +} + + +function toggle_wholist() +{ + /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */ + if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) { + $('online_users').style.display = 'none'; + $('expand_wholist').src = 'static/webcit_icons/expand.gif'; + wstate=0; + } + + else { + $('online_users').style.display = 'block'; + $('expand_wholist').src = 'static/webcit_icons/collapse.gif'; + activate_iconbar_wholist_populat0r(); + wstate=1; + } + + // tell the server what I did + p = 'toggle_wholist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ; + new Ajax.Request(p, { method: 'get' } ); + + return false; /* this prevents the click from registering as a wholist button press */ +} + +