X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fstatic%2Fwclib.js;h=c7d8a8516a3569c60ba970eeb2e98f8ddc9f6b00;hb=61dc1ed2f1a619b730ee1fb2d23cc6296bbe8ba7;hp=cf409d363c7a352599cdd6935f847f66c971902c;hpb=96a55a641f8f5ac47401be1635e8c3ecdf0ac893;p=citadel.git diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index cf409d363..c7d8a8516 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -1,20 +1,27 @@ /* - * Copyright 2005 - 2010 The Citadel Team - * Licensed under the GPL V3 - * * 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); @@ -47,8 +54,52 @@ function strcmp ( str1, str2 ) { 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) @@ -148,7 +199,50 @@ function hide_imsg_popup() { document.poppedLayer.style.visibility = "hidden"; } +function remove_something(what_to_search, new_visibility) { + if (browserType == "gecko") { + document.poppedLayer = eval('document.getElementById(\'' + what_to_search + '\')'); + } + else if (browserType == "ie") { + document.poppedLayer = eval('document.all[\'' + what_to_search + '\']'); + } + else { + document.poppedLayer = eval('document.layers[\'`' + what_to_search + '\']'); + } + if (document.poppedLayer!= null) + document.poppedLayer.innerHTML = ""; +} +function unhide_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 = "visible"; + setTimeout('hide_imsg_popup()', 5000); +} + +function ajax_important_message(messagetext) +{ + 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 = "visible"; + setTimeout('hide_imsg_popup()', 5000); + document.poppedLayer.innerHTML = messagetext; +} // This function activates the ajax-powered recipient autocompleters on the message entry screen. function activate_entmsg_autocompleters() { @@ -163,24 +257,16 @@ function activate_iconbar_wholist_populat0r() } function setupIconBar() { - if (!document.getElementById("switch")) { - return; - } - _switchToRoomList = getTextContent(document.getElementById("rmlist_template")); - _switchToMenu = getTextContent(document.getElementById("mnlist_template")); - var switchSpan = document.getElementById("switch").firstChild; - if (switchSpan != null) { - setTextContent(switchSpan, _switchToRoomList); - $(switchSpan).observe('click', changeIconBarEvent); - var currentView = ctdlLocalPrefs.readPref("iconbar_view"); - if (currentView != null) { - switchSpan.ctdlSwitchIconBarTo = currentView; - changeIconBar(switchSpan); - } else { - switchSpan.ctdlSwitchIconBarTo = "rooms"; - } - } - var online_users = document.getElementById("online_users"); + + /* 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 = 'block'; + $('roomlist').innerHTML = ''; + FillRooms(IconBarRoomList); + } + else { + $('roomlist').style.display = 'none'; + } /* 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" ) { @@ -192,42 +278,6 @@ function setupIconBar() { } } -function changeIconBarEvent(event) { - changeIconBar(event.target); -} -function changeIconBar(target) { - var switchTo = target.ctdlSwitchIconBarTo; - WCLog("Changing to: " + switchTo); - ctdlLocalPrefs.setPref("iconbar_view", target.ctdlSwitchIconBarTo); - if (switchTo == "rooms") { - switch_to_room_list(); - setTextContent(target, _switchToMenu); - target.ctdlSwitchIconBarTo = "menu"; - } else { - switch_to_menu_buttons(); - setTextContent(target, _switchToRoomList); - target.ctdlSwitchIconBarTo = "rooms"; - } -} -function switch_to_room_list() { - var roomlist = document.getElementById("roomlist"); - var summary = document.getElementById("iconbar_menu"); - if (!rooms || !floors || !roomlist) { - FillRooms(IconBarRoomList); - } - roomlist.className = roomlist.className.replace("hidden",""); - summary.className += " hidden"; -} - -function switch_to_menu_buttons() { - if (roomlist != null) { - roomlist.className += "hidden"; - } - var iconbar = document.getElementById("iconbar_menu"); - iconbar.className = iconbar.className.replace("hidden",""); - var roomlist = document.getElementById("roomlist"); - roomlist.className += " hidden"; -} function GenericTreeRoomList(roomlist) { var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded"); @@ -305,7 +355,7 @@ function addRoomToList(floorUL,room, roomToEmphasize) { var hasNewMsgs = ((raflags & UA_HASNEWMSGS) == UA_HASNEWMSGS); var roomLI = document.createElement("li"); var roomA = document.createElement("a"); - roomA.setAttribute("href","dotgoto?room="+roomName); + roomA.setAttribute("href","dotgoto?room="+encodeURIComponent(roomName)); roomA.appendChild(document.createTextNode(roomName)); roomLI.appendChild(roomA); floorUL.appendChild(roomLI); @@ -337,17 +387,26 @@ function addRoomToList(floorUL,room, roomToEmphasize) { function roomListDropHandler(target, dropped) { if (dropped.getAttribute("citadel:msgid")) { - var room = getTextContent(target); - var msgIds = ""; - for(msgId in currentlyMarkedRows) { //defined in summaryview.js - msgIds += ","+msgId; - } - var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0"); - new Ajax.Request('ajax_servcmd', { - method: 'post', + var room = getTextContent(target); + var msgIds = ""; + for(msgId in currentlyMarkedRows) { //defined in summaryview.js + msgIds += ","+msgId; + if (msgIds.length > 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); @@ -872,8 +931,8 @@ function WCLog(msg) { } function RefreshSMTPqueueDisplay() { - new Ajax.Updater('smtpqueue_inner_div', - 'display_smtpqueue_inner_div', { method: 'get', + new Ajax.Updater('mailqueue_list', + 'dotskip?room=__CitadelSMTPspoolout__&view=11&ListOnly=yes', { method: 'get', parameters: Math.random() } ); } @@ -883,7 +942,7 @@ function DeleteSMTPqueueMsg(msgnum1, msgnum2) { 'ajax_servcmd', { method: 'post', parameters: p, - onComplete: RefreshSMTPqueueDisplay() + onComplete: function(transport) { ajax_important_message(transport.responseText.substr(4)); RefreshSMTPqueueDisplay();} } ); } @@ -895,6 +954,7 @@ function ConfirmLogoff() { 'do_template?template=confirmlogoff', { method: 'get', + evalScripts: true, onSuccess: function(cl_success) { toggleModal(1); } @@ -910,18 +970,43 @@ function switch_to_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/expand.gif'; + $('expand_wholist').src = 'static/webcit_icons/expand.gif'; wstate=0; } else { $('online_users').style.display = 'block'; - $('expand_wholist').src = 'static/collapse.gif'; + $('expand_wholist').src = 'static/webcit_icons/collapse.gif'; activate_iconbar_wholist_populat0r(); wstate=1; } @@ -931,5 +1016,6 @@ function toggle_wholist() new Ajax.Request(p, { method: 'get' } ); return false; /* this prevents the click from registering as a wholist button press */ - } + +