home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / admin / javascript.inc < prev    next >
Encoding:
Text File  |  2003-08-24  |  5.1 KB  |  198 lines

  1. <?php
  2. /////////////////////////////////////////////////////////
  3. //    
  4. //    include/javascript.inc
  5. //
  6. //    (C)Copyright 2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
  7. //
  8. //        This file is part of IlohaMail.
  9. //        IlohaMail is free software released under the GPL 
  10. //        license.  See enclosed file COPYING for details,
  11. //        or see http://www.fsf.org/copyleft/gpl.html
  12. //
  13. /////////////////////////////////////////////////////////
  14.  
  15. /********************************************************
  16.  
  17.     AUTHOR: Ryo Chijiiwa <ryo@ilohamail.org>, Jeroen van der Vegt <jeroen@ilohamail.org>
  18.     FILE:  include/javascript.inc
  19.     PURPOSE:
  20.         Display JavaScript (included from header_main.inc)
  21.     COMMENTS:
  22.         Assume that no global vars are available at this
  23.         stage.  Anything that requires embedded PHP vars
  24.         should be passed as JS parameters.
  25.     
  26. ********************************************************/
  27.  
  28. $current_page = $_SERVER["PHP_SELF"];
  29. $pos = strrpos($current_page, "/");
  30. if ($pos !== false){
  31.     $current_page = substr($current_page, $pos+1);
  32. }
  33.  
  34. echo "\n<!-- $current_page //-->\n";
  35.  
  36.  
  37. if (strpos($current_page, "main.php")!==false){
  38. ?>
  39.         <SCRIPT type="text/javascript" language="JavaScript1.2">
  40.         function SelectAllMessages(val) {
  41.             for (var i = 0; i < document.messages.elements.length; i++) {
  42.                 if(document.messages.elements[i].type == 'checkbox') {
  43.                     document.messages.elements[i].checked = !(document.messages.elements[i].checked);
  44.                     document.messages.elements[i].checked = val;
  45.                 }
  46.             }
  47.         }
  48.         </SCRIPT>
  49.  
  50. <?php
  51. }else if (strpos($current_page, "compose2.php")!==false){
  52. ?>
  53.         <script type="text/javascript" language="JavaScript1.2">
  54.         var contacts_popup_visible=false;
  55.         var contacts_popup;
  56.         function CopyAdresses() {
  57.             switch (document.forms[0].to_a_field.selectedIndex) {
  58.             case 1:
  59.                 var target = document.forms[0].cc;
  60.                 break;
  61.             case 2:
  62.                 var target = document.forms[0].bcc;
  63.                 break;
  64.             default:
  65.                 var target = document.forms[0].to;
  66.             }
  67.             var selbox=document.forms[0].elements['to_a[]'];
  68.             for (var i=0; selbox.length>i; i++) {
  69.                 if ((selbox.options[i].selected == true) &&
  70.                   (target.value.indexOf(selbox.options[i].text, 0)==-1)) { //A check to prevent adresses from getting listed twice.
  71.                     if (target.value != '') 
  72.                         target.value += ', ';
  73.                     target.value += selbox.options[i].text;
  74.                 }
  75.             }
  76.         }
  77.         
  78.         function DeselectAdresses() {
  79.             var selbox = document.forms[0].elements['to_a[]'];
  80.             if (selbox) {
  81.                 for (var i=0; selbox.length>i; i++)
  82.                     selbox.options[i].selected = false;
  83.             }
  84.         }
  85.         
  86.         function DoCloseWindow(redirect_url){
  87.             if(parent.frames.length!=0){
  88.                 parent.list2.location=redirect_url;
  89.             }else{
  90.                 window.close();
  91.             }
  92.         }        
  93.         
  94.         function fixtitle(title_str) {
  95.             if (document.forms[0].subject.value=='')
  96.                 document.title=title;
  97.             else
  98.                 document.title=title_str+": "+document.forms[0].subject.value;
  99.         }
  100.         
  101.         function open_popup(comp_uri) {
  102.             if (comp_uri) {
  103.                 if (contacts_popup_visible==false) {
  104.                     if (document.forms[0].cc) comp_uri += "&cc=1";
  105.                     if (document.forms[0].bcc) comp_uri += "&bcc=1";
  106.                     contacts_popup = window.open(comp_uri, "_blank","width=500,height=500,scrollbars=yes,resizable=yes");
  107.                     if (contacts_popup.opener == null)
  108.                     contacts_popup.opener = window;
  109.                 }
  110.                 contacts_popup.focus();
  111.             }
  112.             return;
  113.         }
  114.         
  115.           function close_popup(){
  116.             if (contacts_popup_visible)
  117.                   contacts_popup.close();
  118.           }
  119.  
  120.         </SCRIPT>
  121. <?php
  122. }else if (strpos($current_page, "contacts_popup.php")!==false){
  123. ?>
  124.         <script type="text/javascript" language="JavaScript1.2">
  125.         var contacts;
  126.         function gettarget() {
  127.             switch (document.contactsopts.to_a_field.selectedIndex) {
  128.             case 1:
  129.                 var target = opener.document.forms[0].cc;
  130.                 break;
  131.             case 2:
  132.                 var target = opener.document.forms[0].bcc;
  133.                 break;
  134.             default:
  135.                 var target = opener.document.forms[0].to;
  136.             }
  137.             return target;
  138.         }
  139.  
  140.         function addcontact(address) {
  141.             var target = gettarget();
  142.             if (target.value.indexOf(address, 0)==-1) { //A check to prevent adresses from getting listed twice.
  143.                 if (target.value != '') target.value += ', ';
  144.                 target.value += address;
  145.             }
  146.         }
  147.         
  148.         function addcontact2(id) {
  149.             for (var i=0; i<contacts.length; i++) {
  150.                 if (id==contacts[i][0])
  151.                     addcontact("\""+contacts[i][1]+"\" <"+contacts[i][2]+">");
  152.             }
  153.         }
  154.         
  155.         function addgroup(group) {
  156.             for (var i=0; i<contacts.length; i++) {
  157.                 if (group==contacts[i][3])
  158.                     addcontact("\""+contacts[i][1]+"\" <"+contacts[i][2]+">");
  159.             }
  160.         }
  161.  
  162.         function acknowledge_popup() {
  163.             opener.contacts_popup_visible=true;
  164.         }
  165.         
  166.         function alert_close() {
  167.             opener.contacts_popup_visible=false;
  168.         }
  169.         </script>
  170. <?php
  171. }else if (strpos($current_page, "prefs.php")!==false){
  172. ?>
  173.         <script type="text/javascript" language="JavaScript1.2">
  174.         var colprefs_popup_visible=false;
  175.         var colprefs_popup;
  176.  
  177.         
  178.         function open_popup(comp_uri) {
  179.             if (comp_uri) {
  180.                 if (colprefs_popup_visible==false) {
  181.                     colprefs_popup = window.open(comp_uri, "_blank","width=350,height=350,scrollbars=yes,resizable=yes");
  182.                     if (colprefs_popup.opener == null)
  183.                     colprefs_popup.opener = window;
  184.                 }
  185.                 colprefs_popup.focus();
  186.             }
  187.             return;
  188.         }
  189.         
  190.           function close_popup(){
  191.             if (colprefs_popup_visible)
  192.                   colprefs_popup.close();
  193.           }
  194.  
  195.         </SCRIPT>
  196. <?php
  197. }
  198. ?>