X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit%2Fstatic%2Fwclib.js;h=e9f88042e302e7eb6f0ec5e655d32c645acc1435;hp=1b3b8f78c65eea6d4dd2e2c457841d67033ebf5f;hb=8a31ae37cda10b701d6db0f3a6935eec0eb2d5ab;hpb=60bf2f07bbb0d5f23595cb6c45fdfe670bab76f4 diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index 1b3b8f78c..e9f88042e 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -1,428 +1,296 @@ -// -// $Id$ -// -// JavaScript function library for WebCit. -// -// - +/*jshint strict: false, bitwise: false */ +/*global document, window, Ajax, currentlyMarkedRows, Event, event, taskViewActivate, setTimeout, fillRooms, $, ctdlLocalPrefs, currentDropTargets, iconBarRoomList, confirm, Effect */ +/* + * 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; -if (document.layers) {browserType = "nn4"} -if (document.all) {browserType = "ie"} +var currentlyExpandedFloor = null; +var roomlist = 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" + browserType= "gecko"; } - var ns6=document.getElementById&&!document.all; Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate); Event.observe(window, 'load', taskViewActivate); -function CtdlRandomString() { +//document.observe("dom:loaded", setupPrefEngine); +document.observe("dom:loaded", setupIconBar); +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 ) ); +} - - -// We love string tokenizers. -function extract_token(source_string, token_num, delimiter) { - var i = 0; - var extracted_string = source_string; - - if (token_num > 0) { - for (i=0; i= 0) { - extracted_string = extracted_string.substr(j+1); - } - } +function ctdlMarkLog(Which, Status) +{ + if (Status) { + document.getElementById(Which).checked = false; + } + else { + document.getElementById(Which).checked = true; + } + +} +function ToggleLogEnable(Which) +{ + var p; + var element = document.getElementById(Which); + if (element.hasOwnProperty('checked')) { + var Status = element.checked; + if (!Status) { + p = encodeURI('g_cmd=LOGS ' + Which + '|0'); } - - j = extracted_string.indexOf(delimiter); - if (j >= 0) { - extracted_string = extracted_string.substr(0, j); + else { + p = encodeURI('g_cmd=LOGS ' + Which + '|1'); } - - return extracted_string; -} - - - -// This code handles the popups for important-messages. -function hide_imsg_popup() { - if (browserType == "gecko" ) - document.poppedLayer = eval('document.getElementById(\'important_message\')'); - else if (browserType == "ie") - document.poppedLayer = eval('document.all[\'important_message\']'); - else - document.poppedLayer = eval('document.layers[\'`important_message\']'); - - document.poppedLayer.style.visibility = "hidden"; + new Ajax.Request('ajax_servcmd', { + method: 'post', + parameters: p, + onComplete: ctdlMarkLog(Which, Status) + }); + } } +function SMTPRunQueue() +{ + var p; -// This function activates the ajax-powered recipient autocompleters on the message entry screen. -function activate_entmsg_autocompleters() { - new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} ); - new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} ); - new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} ); + 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; - -// Toggle the icon bar between menu/roomlist... -var which_div_expanded = null; -var num_drop_targets = 0; -var drop_targets_elements = new Array(); -var drop_targets_roomnames = new Array(); - -function switch_to_room_list() { - $('iconbar').innerHTML = $('iconbar').innerHTML.substr(0, $('iconbar').innerHTML.indexOf('switch')); - CtdlLoadScreen('iconbar'); - new Ajax.Updater('iconbar', 'iconbar_ajax_rooms', { method: 'get' } ); + 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 expand_floor(floor_div) { - if (which_div_expanded != null) { - if ($(which_div_expanded) != null) { - $(which_div_expanded).style.display = 'none' ; - } +function ToggleVisibility ($Which) +{ + if (document.getElementById) + { + if (document.getElementById($Which).style.display === "none") { + document.getElementById($Which).style.display = "inline"; } - - // clicking on the already-expanded floor causes the whole list to collapse - if (which_div_expanded == floor_div) { - which_div_expanded = null; - - // notify the server that no floors are expanded - new Ajax.Request( - 'set_floordiv_expanded/-1', { - method: 'post' - } - ); - return true; + else { + document.getElementById($Which).style.display = "none"; } - - // expand the requested floor - $(floor_div).style.display = 'block'; - which_div_expanded = floor_div; - - // notify the server of which floor is expanded - new Ajax.Request( - 'set_floordiv_expanded/'+floor_div, { - method: 'post' - } - ); + } } -function switch_to_menu_buttons() { - which_div_expanded = null; - num_drop_targets = 0; - CtdlLoadScreen('iconbar'); - new Ajax.Updater('iconbar', 'iconbar_ajax_menu', { method: 'get' } ); +function emptyElement(element) { + var childNodes = element.childNodes; + for(var i=0; i 0) { - for (i=0; i 0) ) { - for (i=0; i 0) { - for (i=0; i 0) { + for (i=0; i= 0) { + extracted_string = extracted_string.substr(j+1); + } } + } - else { - // Select: first highlight it... - $('m'+msgnum).style.backgroundColor='#69aaff'; - $('m'+msgnum).style.color='#fff'; - - // Then add it to the selected messages list. - CtdlNumMsgsSelected = CtdlNumMsgsSelected + 1; - CtdlMsgsSelected[CtdlNumMsgsSelected-1] = msgnum; - - // Gradient - CtdlLoadScreen('preview_pane'); - // Update the preview pane - new Ajax.Updater('preview_pane', 'msg/'+msgnum, { method: 'get' } ); - - // Mark the message as read - new Ajax.Request( - 'ajax_servcmd', { - method: 'post', - parameters: 'g_cmd=SEEN '+msgnum+'|1', - onComplete: CtdlRemoveTheUnseenBold(msgnum) - } - ); - } - - // Save the selected position in case the user does a group select next time. - CtdlLastMsgnumSelected = msgnum; + j = extracted_string.indexOf(delimiter); + if (j >= 0) { + extracted_string = extracted_string.substr(0, j); + } - return false; // try to defeat the default click behavior + return extracted_string; } -// Delete selected messages. -function CtdlDeleteSelectedMessages(evt) { - - if (CtdlNumMsgsSelected < 1) { - // Nothing to delete, so exit silently. - return false; - } - for (i=0; i 0) { - new Ajax.Request( - 'ajax_servcmd', { - method: 'post', - parameters: 'g_cmd=DELE ' + CtdlMsgsSelected[i], - onComplete: CtdlClearDeletedMsg(CtdlMsgsSelected[i]) - } - ); - } - else { - new Ajax.Request( - 'ajax_servcmd', { - method: 'post', - parameters: 'g_cmd=MOVE ' + CtdlMsgsSelected[i] + '|_TRASH_|0', - onComplete: CtdlClearDeletedMsg(CtdlMsgsSelected[i]) - } - ); - } - } - CtdlNumMsgsSelected = 0; - - // Clear the preview pane too. - $('preview_pane').innerHTML = ''; +function CtdlSpawnContextMenu(event, source) { + // remove any existing menus + disintergrateContextMenus(null); + var x = event.clientX-10; // cut a few pixels out so our mouseout works right + var y = event.clientY-10; + var contextDIV = document.createElement("div"); + contextDIV.setAttribute("id", "ctdlContextMenu"); + document.body.appendChild(contextDIV); + var sourceChildren = source.childNodes; + for(var j=0; j 0) { - p = 'note_uid=' + uid_of_note_being_dragged - + '&left=' + d.style.left - + '&top=' + d.style.top - + '&r=' + CtdlRandomString(); - new Ajax.Request( - 'ajax_update_note', - { - method: 'post', - parameters: p - } - ); - } + document.onmouseup = null; + document.onmousemove = null; + if (document.layers) { + document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE); + } + + var d = $('note-' + uid_of_note_being_dragged); + d.style.cursor = saved_cursor_style; + + // If any motion actually occurred, submit an ajax http call to record it to the server + if (note_was_dragged > 0) { + var p = 'note_uid=' + uid_of_note_being_dragged + + '&left=' + d.style.left + + '&top=' + d.style.top + + '&r=' + ctdlRandomString(); + new Ajax.Request( + 'ajax_update_note', + { + method: 'post', + parameters: p + } + ); + } - uid_of_note_being_dragged = ''; - return true; + uid_of_note_being_dragged = ''; + return true; } - +var saved_x, saved_y; function NotesDragMouseMove(evt) { - x = (ns6 ? evt.clientX : event.clientX); - x_increment = x - saved_x; - y = (ns6 ? evt.clientY : event.clientY); - y_increment = y - saved_y; + var x = (ns6 ? evt.clientX : event.clientX); + var x_increment = x - saved_x; + var y = (ns6 ? evt.clientY : event.clientY); + var y_increment = y - saved_y; - // Move the div - d = $('note-' + uid_of_note_being_dragged); + // Move the div + var d = $('note-' + uid_of_note_being_dragged); - divTop = parseInt(d.style.top); - divLeft = parseInt(d.style.left); + var divTop = parseInt(d.style.top); + var divLeft = parseInt(d.style.left); - d.style.top = (divTop + y_increment) + 'px'; - d.style.left = (divLeft + x_increment) + 'px'; + d.style.top = (divTop + y_increment) + 'px'; + d.style.left = (divLeft + x_increment) + 'px'; - saved_x = x; - saved_y = y; - note_was_dragged = 1; - return true; + saved_x = x; + saved_y = y; + note_was_dragged = 1; + return true; } function NotesDragMouseDown(evt, uid) { - saved_x = (ns6 ? evt.clientX : event.clientX); - saved_y = (ns6 ? evt.clientY : event.clientY); - document.onmouseup = NotesDragMouseUp; - document.onmousemove = NotesDragMouseMove; - if (document.layers) { - document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE); - } - uid_of_note_being_dragged = uid; - d = $('note-' + uid_of_note_being_dragged); - saved_cursor_style = d.style.cursor; - d.style.cursor = 'move'; - return false; // disable the default action + saved_x = (ns6 ? evt.clientX : event.clientX); + saved_y = (ns6 ? evt.clientY : event.clientY); + document.onmouseup = NotesDragMouseUp; + document.onmousemove = NotesDragMouseMove; + if (document.layers) { + document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE); + } + uid_of_note_being_dragged = uid; + var d = $('note-' + uid_of_note_being_dragged); + saved_cursor_style = d.style.cursor; + d.style.cursor = 'move'; + return false; // disable the default action } @@ -501,22 +369,22 @@ function NotesDragMouseDown(evt, uid) { // It toggles the color selector visible or invisible. function NotesClickPalette(evt, uid) { - uid_of_note_being_colored = uid; - d = $('palette-' + uid_of_note_being_colored); + var uid_of_note_being_colored = uid; + var d = $('palette-' + uid_of_note_being_colored); - if (d.style.display) { - if (d.style.display == 'none') { - d.style.display = 'block'; - } - else { - d.style.display = 'none'; - } + if (d.style.display) { + if (d.style.display === 'none') { + d.style.display = 'block'; } else { - d.style.display = 'block'; + d.style.display = 'none'; } + } + else { + d.style.display = 'block'; + } - return true; + return true; } @@ -524,30 +392,30 @@ function NotesClickPalette(evt, uid) { // Sets the desired color and then closes the color selector. function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) { - uid_of_note_being_colored = uid; - palette_button = $('palette-' + uid_of_note_being_colored); - note_div = $('note-' + uid_of_note_being_colored); - titlebar_div = $('titlebar-' + uid_of_note_being_colored); - - // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue); - - note_div.style.backgroundColor = notecolor; - titlebar_div.style.backgroundColor = titlecolor; - palette_button.style.display = 'none'; - - // submit an ajax http call to record it to the server - p = 'note_uid=' + uid_of_note_being_colored - + '&red=' + red - + '&green=' + green - + '&blue=' + blue - + '&r=' + CtdlRandomString(); - new Ajax.Request( - 'ajax_update_note', - { - method: 'post', - parameters: p - } - ); + var uid_of_note_being_colored = uid; + var palette_button = $('palette-' + uid_of_note_being_colored); + var note_div = $('note-' + uid_of_note_being_colored); + var titlebar_div = $('titlebar-' + uid_of_note_being_colored); + + // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue); + + note_div.style.backgroundColor = notecolor; + titlebar_div.style.backgroundColor = titlecolor; + palette_button.style.display = 'none'; + + // submit an ajax http call to record it to the server + var p = 'note_uid=' + uid_of_note_being_colored + + '&red=' + red + + '&green=' + green + + '&blue=' + blue + + '&r=' + ctdlRandomString(); + new Ajax.Request( + 'ajax_update_note', + { + method: 'post', + parameters: p + } + ); } @@ -560,302 +428,138 @@ var saved_cursor_style = 'default'; var note_was_resized = 0; function NotesResizeMouseUp(evt) { - document.onmouseup = null; - document.onmousemove = null; - if (document.layers) { - document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE); - } - - d = $('note-' + uid_of_note_being_resized); - d.style.cursor = saved_cursor_style; - - // If any motion actually occurred, submit an ajax http call to record it to the server - if (note_was_resized > 0) { - p = 'note_uid=' + uid_of_note_being_resized - + '&width=' + d.style.width - + '&height=' + d.style.height - + '&r=' + CtdlRandomString(); - new Ajax.Request( - 'ajax_update_note', - { - method: 'post', - parameters: p - } - ); - } + document.onmouseup = null; + document.onmousemove = null; + if (document.layers) { + document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE); + } + + var d = $('note-' + uid_of_note_being_resized); + d.style.cursor = saved_cursor_style; + + // If any motion actually occurred, submit an ajax http call to record it to the server + if (note_was_resized > 0) { + var p = 'note_uid=' + uid_of_note_being_resized + + '&width=' + d.style.width + + '&height=' + d.style.height + + '&r=' + ctdlRandomString(); + new Ajax.Request( + 'ajax_update_note', + { + method: 'post', + parameters: p + } + ); + } - uid_of_note_being_resized = ''; - return false; // disable the default action + uid_of_note_being_resized = ''; + return false; // disable the default action } function NotesResizeMouseMove(evt) { - x = (ns6 ? evt.clientX : event.clientX); - x_increment = x - saved_x; - y = (ns6 ? evt.clientY : event.clientY); - y_increment = y - saved_y; - - // Move the div - d = $('note-' + uid_of_note_being_resized); - - divTop = parseInt(d.style.height); - divLeft = parseInt(d.style.width); - - d.style.height = (divTop + y_increment) + 'px'; - d.style.width = (divLeft + x_increment) + 'px'; - - saved_x = x; - saved_y = y; - note_was_resized = 1; - return false; // disable the default action + var x = (ns6 ? evt.clientX : event.clientX); + var x_increment = x - saved_x; + var y = (ns6 ? evt.clientY : event.clientY); + var y_increment = y - saved_y; + + // Move the div + var d = $('note-' + uid_of_note_being_resized); + + var divTop = parseInt(d.style.height); + var divLeft = parseInt(d.style.width); + + var newHeight = divTop + y_increment; + if (newHeight < 50) { + newHeight = 50; + } + + var 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; + note_was_resized = 1; + return false; // disable the default action } function NotesResizeMouseDown(evt, uid) { - saved_x = (ns6 ? evt.clientX : event.clientX); - saved_y = (ns6 ? evt.clientY : event.clientY); - document.onmouseup = NotesResizeMouseUp; - document.onmousemove = NotesResizeMouseMove; - if (document.layers) { - document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE); - } - uid_of_note_being_resized = uid; - d = $('note-' + uid_of_note_being_resized); - saved_cursor_style = d.style.cursor; - d.style.cursor = 'move'; - return false; // disable the default action + var saved_x = (ns6 ? evt.clientX : event.clientX); + var saved_y = (ns6 ? evt.clientY : event.clientY); + document.onmouseup = NotesResizeMouseUp; + document.onmousemove = NotesResizeMouseMove; + if (document.layers) { + document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE); + } + uid_of_note_being_resized = uid; + var d = $('note-' + uid_of_note_being_resized); + saved_cursor_style = d.style.cursor; + d.style.cursor = 'move'; + return false; // disable the default action } function DeleteStickyNote(evt, uid, confirmation_prompt) { - uid_of_note_being_deleted = uid; - d = $('note-' + uid_of_note_being_deleted); - - if (confirm(confirmation_prompt)) { - new Effect.Puff(d); - - // submit an ajax http call to delete it on the server - p = 'note_uid=' + uid_of_note_being_deleted - + '&deletenote=yes' - + '&r=' + CtdlRandomString(); - new Ajax.Request( - 'ajax_update_note', - { - method: 'post', - parameters: p - } - ); - } -} - - - - - - - - - + var uid_of_note_being_deleted = uid; + var d = $('note-' + uid_of_note_being_deleted); + if (confirm(confirmation_prompt)) { + new Effect.Puff(d); - - - - -// These functions handle drag and drop message moving - -var mm_div = null; - -function CtdlMoveMsgMouseDown(evt, msgnum) { - - // do the highlight first - CtdlSingleClickMsg(evt, msgnum); - - // Now handle the possibility of dragging - saved_x = (ns6 ? evt.clientX : event.clientX); - saved_y = (ns6 ? evt.clientY : event.clientY); - document.onmouseup = CtdlMoveMsgMouseUp; - document.onmousemove = CtdlMoveMsgMouseMove; - if (document.layers) { - document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE); - } - - return false; -} - -function CtdlMoveMsgMouseMove(evt) { - x = (ns6 ? evt.clientX : event.clientX); - y = (ns6 ? evt.clientY : event.clientY); - - if ( (x == saved_x) && (y == saved_y) ) { - return true; - } - - if (CtdlNumMsgsSelected < 1) { - return true; - } - - if (!mm_div) { - - - drag_o_text = "
"; - for (i=0; i'; - } - drag_o_text = drag_o_text + "
"; - - mm_div = document.createElement("DIV"); - mm_div.style.position='absolute'; - mm_div.style.top = y + 'px'; - mm_div.style.left = x + 'px'; - mm_div.style.pixelHeight = '300'; - mm_div.style.pixelWidth = '300'; - mm_div.innerHTML = drag_o_text; - document.body.appendChild(mm_div); - } - else { - mm_div.style.top = y + 'px'; - mm_div.style.left = x + 'px'; - } - - return false; // prevent the default mouse action from happening? + // submit an ajax http call to delete it on the server + var p = 'note_uid=' + uid_of_note_being_deleted + + '&deletenote=yes' + + '&r=' + ctdlRandomString(); + new Ajax.Request( + 'ajax_update_note', + { + method: 'post', + parameters: p + } + ); + } } -function CtdlMoveMsgMouseUp(evt) { - document.onmouseup = null; - document.onmousemove = null; - if (document.layers) { - document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE); - } - - if (mm_div) { - document.body.removeChild(mm_div); - mm_div = null; - } - - if (num_drop_targets < 1) { // nowhere to drop - return true; - } - - // Did we release the mouse button while hovering over a drop target? - // NOTE: this only works cross-browser because the iconbar div is always - // positioned at 0,0. Browsers differ in whether the 'offset' - // functions return pos relative to the document or parent. - - for (i=0; i= l) && (x <= r) && (y >= t) && (y <= b) ) { - // Yes, we dropped it on a hotspot. - CtdlMoveSelectedMessages(evt, drop_targets_roomnames[i]); - return true; - } +function ctdl_ts_getInnerText(el) { + if (typeof el === "string") { + return el; + } + if (typeof el === "undefined") { + return el; + } + if (el.innerText) { + return el.innerText; //Not needed but it is faster + } + var str = ""; + + var cs = el.childNodes; + var l = cs.length; + for (var i = 0; i < l; i++) { + switch (cs[i].nodeType) { + case 1: //ELEMENT_NODE + str += ts_getInnerText(cs[i]); + break; + case 3: //TEXT_NODE + str += cs[i].nodeValue; + break; } - - return true; + } + return str; } -function ctdl_ts_getInnerText(el) { - if (typeof el == "string") return el; - if (typeof el == "undefined") { return el }; - if (el.innerText) return el.innerText; //Not needed but it is faster - var str = ""; - - var cs = el.childNodes; - var l = cs.length; - for (var i = 0; i < l; i++) { - switch (cs[i].nodeType) { - case 1: //ELEMENT_NODE - str += ts_getInnerText(cs[i]); - break; - case 3: //TEXT_NODE - str += cs[i].nodeValue; - break; - } - } - return str; -} - - -function CtdlShowRaw(msgnum) { -var customnav = document.createElement("span"); -var mode_citadel = document.createElement("a"); -mode_citadel.appendChild(document.createTextNode("Citadel Source")); -var mode_rfc822 = document.createElement("a"); -mode_rfc822.appendChild(document.createTextNode(" RFC822 Source")); -mode_citadel.setAttribute("href","#"); -mode_rfc822.setAttribute("href","#"); -mode_rfc822.setAttribute("onclick","rawSwitch822('" + msgnum + "');"); -mode_citadel.setAttribute("onclick","rawSwitchCitadel('" + msgnum + "');"); -customnav.appendChild(mode_citadel); -customnav.appendChild(mode_rfc822); -customnav.setAttribute("class","floatcustomnav"); -floatwindow("headerscreen","pre",customnav); -rawSwitch822(msgnum); -} - -function rawSwitch822(msgnum) { -CtdlLoadScreen("headerscreen"); -new Ajax.Updater("headerscreen", -'ajax_servcmd_esc', - { method: 'post',parameters: 'g_cmd=MSG2 ' +msgnum } ); - -} - -function rawSwitchCitadel(msgnum) { -CtdlLoadScreen("headerscreen"); -new Ajax.Updater("headerscreen", -'ajax_servcmd_esc', - { method: 'post',parameters: 'g_cmd=MSG0 ' +msgnum } ); - -} - -function floatwindow(newdivid,contentelementtype,customnav) { -var windiv = document.createElement("div"); -windiv.setAttribute("class","floatwindow"); -var winid = newdivid+"_window"; -windiv.setAttribute("id",winid); -var nav = document.createElement("div"); -if (customnav != null) { -nav.appendChild(customnav); -} -var minimizeA = document.createElement("a"); -var minimizeButton = document.createTextNode("Close"); -minimizeA.appendChild(minimizeButton); -minimizeA.setAttribute("onclick","killFloatWindow(this);"); -minimizeA.setAttribute("href","#"); -nav.appendChild(minimizeA); -nav.setAttribute("class","floatnav"); -windiv.appendChild(nav); -var contentarea = document.createElement("pre"); -contentarea.setAttribute("class","floatcontent"); -contentarea.setAttribute("id",newdivid); -windiv.appendChild(contentarea); -document.body.appendChild(windiv); -} -function killFloatWindow(caller) { -var span = caller.parentNode; -var fwindow = span.parentNode; -fwindow.parentNode.removeChild(fwindow); -} // 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...." + + "

"; } @@ -864,10 +568,10 @@ elem.innerHTML = "

  Loading....

"; - p = 'which_addr_book=' + which_addr_book - + '&target_input=' + target_input - + '&r=' + CtdlRandomString(); - new Ajax.Updater( - 'address_book_inner_div', - 'display_address_book_inner_div', - { - method: 'get', - parameters: p - } - ); + + $('address_book_inner_div').innerHTML = + "

" + + "" + + "
" + + "" + + "  Loading...." + + "

"; + + p = 'which_addr_book=' + which_addr_book + + '&target_input=' + target_input + + '&r=' + ctdlRandomString() + + "&template=addressbook_namelist"; + new Ajax.Updater( + 'address_book_inner_div', + 'do_template', + { + method: 'get', + parameters: p + } + ); } // What happens when a contact is selected from the address book popup // (populate the specified target) function AddContactsToTarget(target, whichaddr) { - while (whichaddr.selectedIndex != -1) { + while (whichaddr.selectedIndex !== -1) { if (target.value.length > 0) { target.value = target.value + ', '; } @@ -917,43 +630,61 @@ function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) { new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } ); Effect.Fade(question_divname, { duration: 0.5 }); } -var fakeMouse = document.createEvent("MouseEvents"); -fakeMouse.initMouseEvent("click", true, true, window, - 0,0,0,0,0, false, false, false, false, 0, null); +/* var fakeMouse = document.createEvent("MouseEvents"); + fakeMouse.initMouseEvent("click", true, true, window, + 0,0,0,0,0, false, false, false, false, 0, null); */ // TODO: Collapse into one function function toggleTaskDtStart(event) { - var checkBox = $('nodtstart'); - dtStart = document.getElementById("dtstart"); - if (checkBox.checked) { - dtStart.disabled = true; - dtStart.style.textDecoration = "line-through"; + var checkBox = $('nodtstart'); + 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_date.style.visibility = "hidden"; + dtstart_time.style.visibility = "hidden"; + } else { + if (checkBoxTime.checked) { + dtstart_time.style.visibility = "visible"; } else { - dtStart.disabled = false; - dtStart.style.textDecoration = ""; - if (dtStart.value.length == 0) - dtStart.dpck._initCurrentDate(); + 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"); - if (checkBox.checked) { - dueField.disabled = true; - dueField.style.textDecoration = "line-through"; + var checkBox = $('nodue'); + 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) { + due_date.style.visibility = "hidden"; + due_time.style.visibility = "hidden"; + } else { + if (checkBoxTime.checked) { + due_time.style.visibility = "visible"; } else { - dueField.disabled = false; - dueField.style.textDecoration = ""; - if (dueField.value.length == 0) - dueField.dpck._initCurrentDate(); + due_time.style.visibility = "hidden"; + } + due_date.style.visibility = "visible"; + if (due.value.length === 0) { + due.dpck._initCurrentDate(); } + } } function ToggleTaskDateOrNoDateActivate(event) { var dtstart = document.getElementById("nodtstart"); - if (dtstart != null) { + if (dtstart !== null) { 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() { @@ -963,33 +694,451 @@ function TaskViewGatherCategoriesFromTable() { function attachDatePicker(relative) { var dpck = new DatePicker({ relative: relative, - language: 'en', // fix please - disableFutureDate: false + language: 'en', //wclang.substr(0,2), + disableFutureDate: false, + dateFormat: [ ["yyyy", "mm", "dd"], "-"], + showDuration: 0.2 }); document.getElementById(relative).dpck = dpck; // attach a ref to it } 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"; } } - - - // Functions which handle show/hide of various elements in the recurrence editor function RecurrenceShowHide() { + if ($('is_recur').checked) { - $('rrule').style.display = 'block'; + $('rrule_div').style.display = 'block'; + } + else { + $('rrule_div').style.display = 'none'; + } + + if ($('freq_selector').selectedIndex === 4) { + $('weekday_selector').style.display = 'block'; + } + else { + $('weekday_selector').style.display = 'none'; + } + + if ($('freq_selector').selectedIndex === 5) { + $('monthday_selector').style.display = 'block'; + } + else { + $('monthday_selector').style.display = 'none'; + } + + if ($('rrend_count').checked) { + $('rrcount').disabled = false; + } + else { + $('rrcount').disabled = true; + } + + if ($('rrend_until').checked) { + $('rruntil').disabled = false; } else { - $('rrule').style.display = 'none'; + $('rruntil').disabled = true; } + + if ($('rrmonthtype_mday').checked) { + $('rrmday').disabled = false; + } + else { + $('rrmday').disabled = true; + } + + if ($('rrmonthtype_wday').checked) { + $('rrmweek').disabled = false; + $('rrmweekday').disabled = false; + } + else { + $('rrmweek').disabled = true; + $('rrmweekday').disabled = true; + } + + if ($('freq_selector').selectedIndex === 6) { + $('yearday_selector').style.display = 'block'; + } + else { + $('yearday_selector').style.display = 'none'; + } + + $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5); + $('rrmday').innerHTML = $('dtstart').value.substr(8); + + if ($('rryeartype_ywday').checked) { + $('rrymweek').disabled = false; + $('rrymweekday').disabled = false; + $('rrymonth').disabled = false; + } + else { + $('rrymweek').disabled = true; + $('rrymweekday').disabled = true; + $('rrymonth').disabled = true; + } + +} + + +// 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'); +} +// logger +function wCLog(msg) { + if (!!window.console && !!console.log) { + 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 */ +} + +function getBlogStartText(wikitype) { + var wikitext = document.getElementById("wikitext").innerHTML; + var wikipublish = document.getElementById("wikipublish").innerHTML; + var wikilinktext = document.getElementById("wikilinktext").innerHTML; + var wikilinkmore = document.getElementById("wikilinkmore").innerHTML; + var wikilinkembedmedia = document.getElementById("wikilinkembedmedia").innerHTML; + if (wikitype) { + return "\n" + + "

" + wikitext + "

\n" + + "

" + wikipublish + "

\n" + + "" + wikilinktext + "" + + "

" + wikilinkmore + "

\n" + + "

" + wikilinkembedmedia + "

\n

\"alttext\"

\n" + + ""; + } + else { + return "#" + wikitext + "\n" + + wikipublish + "\n\n" + + "[" + wikilinktext + "](wiki?page=firstarticle)\n\n" + + wikilinkmore + "\n\n" + + wikilinkembedmedia + "\n\n ![alttext](/download_file/test.jpg)"; + } +} + +function create_blog() +{ + var er_view_blog = document.getElementById('er_view_blog'); + var Nonce = document.getElementById('Nonce'); + var roomname = document.getElementById('er_name').value; + var editroomname = roomname + '\\edit'; + var filePath = "files_" + roomname; + var floorID = document.getElementById('er_floor').value; + + var selects = document.getElementById("er_floor"); + var selectedFloor = selects.options[selects.selectedIndex].value; + var selectedFloorName = selects.options[selects.selectedIndex].text; + + var vselects = document.getElementById("er_view"); + var vselectedMarkup = vselects.options[vselects.selectedIndex].value; + var vselectedMarkupName = vselects.options[vselects.selectedIndex].text; + + var adminPW = document.getElementById('adminlist_passworded').checked; + + var passvoid = document.getElementById('er_password').value; + var roomtypeWiki = document.getElementById('er_blog_markup_html').value; + + var isHtmlWiki = vselectedMarkup === roomtypeWiki; + var starttext = getBlogStartText(isHtmlWiki); + + ToggleVisibility('er_password'); + var type_edit; + if (adminPW) { + type_edit = document.getElementById('adminlist_passworded').value; + ToggleVisibility('li_adminlist_invonly'); + ToggleVisibility('adminlist_passworded'); + + } + else { + type_edit = document.getElementById('adminlist_invonly').value; + ToggleVisibility('adminlist_invonly'); + ToggleVisibility('li_adminlist_passworded'); + } + + ToggleVisibility('er_floor'); + document.getElementById('er_floor_fixed').innerHTML = selectedFloorName; + ToggleVisibility('er_floor_fixed'); + + ToggleVisibility('er_name'); + document.getElementById('er_name_fixed').innerHTML = roomname; + ToggleVisibility('er_name_fixed'); + + ToggleVisibility('er_view'); + document.getElementById('er_view_fixed').innerHTML = vselectedMarkupName; + ToggleVisibility('er_view_fixed'); + + ToggleVisibility('create_buttons'); + + ToggleVisibility('edit_info'); + ToggleVisibility('throbber'); + + + var roomdata = { + create_blog_room: { + nonce: Nonce, + er_name: roomname, + type: 'public', + er_view: er_view_blog, + er_floor: floorID, + template: "room_result_json", + ok_button: 1 + }, + setflags_blog_room: { + nonce: Nonce, + er_name: roomname, + go: roomname, + type: 'public', + er_floor: floorID, + + directory: "yes", + er_dirname: filePath, + ulallowed: "no", + dlallowed: "yes", + ulmsg: "no", + visdir: "no", + + anon: "no", + last_tabsel: 1, + er_view: er_view_blog, + template: "room_result_json", + ok_button: 1 + }, + create_blog_edit_room: { + nonce: Nonce, + er_name: editroomname, + type: type_edit, + er_view: vselectedMarkup, + er_floor: floorID, + er_password: passvoid, + template: "room_result_json", + ok_button: 1 + }, + setflags_blog_edit_room: { + nonce: Nonce, + er_name: editroomname, + go: editroomname, + type: type_edit, + er_floor: floorID, + + directory: "yes", + er_dirname: filePath, + ulallowed: "yes", + dlallowed: "yes", + ulmsg: "no", + visdir: "yes", + + anon: "no", + last_tabsel: 1, + er_view: er_view_blog, + template: "room_result_json", + ok_button: 1 + }, + blog_wiki_startmessage : { + nonce: Nonce, + force_room: editroomname, + page: "home", + markdown: (isHtmlWiki)?0:1, + msgtext: starttext + + } + }; + + /* promises anyone? + * - create the blog room + * - set the blog rooms file flags + * - create the edit room + * - set the blog edit room flags + */ + new Ajax.Request("/entroom", + { method: 'post', + parameters: $H(roomdata.create_blog_room).toQueryString(), + onComplete: function(transport) { + new Ajax.Request("/editroom", + { method: 'post', + parameters: $H(roomdata.setflags_blog_room).toQueryString(), + onComplete: function(transport) { + new Ajax.Request("/entroom", + { method: 'post', + parameters: $H(roomdata.create_blog_edit_room).toQueryString(), + onComplete: function(transport) { + new Ajax.Request("/editroom", + { method: 'post', + parameters: $H(roomdata.setflags_blog_edit_room).toQueryString(), + onComplete: function(transport) { + ToggleVisibility('throbber'); + new Ajax.Request("/post", + { method: 'post', + parameters: $H(roomdata.blog_wiki_startmessage).toQueryString(), + onComplete: function(transport) { + + } + } + ); + } + } + ); + } + } + ); + } + } + ) + } + } + ); + + return false; +} + + +function deleteAllSelectedMessages() { + +} + + +function publishMessage() +{ + var messages = document.getElementsByClassName("message"); + var messageIdParts = messages[0].id.split('|'); + var editRoomName = getTextContent(document.getElementById("rmname")); + var roomName = editRoomName.substring(0, editRoomName.length - 5); + + var publish = { + editRoom: editRoomName, + blogRoom: roomName, + msgNo : messageIdParts[1], + msgIdStr : messageIdParts[2] + } + + mvCommand = encodeURI("g_cmd=MOVE " + publish.msgNo + "|" + publish.blogRoom + "|1"); + + new Ajax.Request("ajax_servcmd", { + parameters: mvCommand, + method: 'post', + onSuccess: function(transport) { + wCLog(transport.responseText); + } + }); +} \ No newline at end of file