Opera7 compatibility cvs upcvs upcvs upcvs up! some IE ameliorations, still
authorPierre Habouzit <madcoder@debian.org>
Thu, 28 Aug 2003 10:36:34 +0000 (10:36 +0000)
committerPierre Habouzit <madcoder@debian.org>
Thu, 28 Aug 2003 10:36:34 +0000 (10:36 +0000)
    buggy

philter/philter/include/philter.js
philter/philter/include/philter.js2 [deleted file]
philter/philter/include/plugin_autoreply.inc.php
philter/philter/index.php

index 834f07c..f7a9c6a 100644 (file)
@@ -6,6 +6,14 @@
 * Copyright: See COPYING files that comes with this distribution
 ********************************************************************************/
 
+function ta_onfocus(obj) {
+    obj.setAttribute('rows', '10');
+}
+
+function ta_onblur(obj) {
+    obj.setAttribute('rows', '2');
+}
+
 function text_onfocus(object,val) {
     if(object.value == val)
         object.value = '';
@@ -21,15 +29,11 @@ function cleanChilds(Node, nbChilds) {
         Node.removeChild(Node.childNodes[nbChilds]);
 }
 
-function getElement(obj) {
-    return getNthElement(obj,0);
-}
-
-function getNthElement(obj, index) {
-    if(document.getElementsByName)
-        return document.getElementsByName(obj)[index];
+function getElement(obj, index) {
+    if(document.getElementById)
+        return document.getElementById(obj);
     if(document.all)
-        return document.all[obj][index];
+        return document.all[obj];
 }
 
 /********** ORDER FORM FUNCTIONS **********/
@@ -138,7 +142,7 @@ function createActionRow(Node,data) {
 }
 
 function newAction() {
-    createActionRow(getElement('actions_row'), 0);
+    createActionRow(getElement('actionsRow'), [-1]);
 }
 
 /********** RULE.MATCH FORM FUNCTIONS **********/
@@ -181,7 +185,7 @@ function createMatchRow(Node,data) {
 }
 
 function newMatch() {
-    createMatchRow(getElement('matches_row'), 0);
+    createMatchRow(getElement('matchesRow'), [-1]);
 }
 
 /********** RULE FORM FUNCTIONS **********/
@@ -202,15 +206,16 @@ function createRuleForm() {
 
     getElement('rule[id]').value = index;
     getElement('rule[name]').value = current_rule.name;
-    getNthElement('rule[all]',[1-current_rule.all]).checked = true;
+    var c = (current_rule.all ? '1' : '0');
+    getElement('rule[all'+c+']').checked = true;
     getElement('rule[block]').checked = current_rule.block;
 
-    var mr = getElement('matches_row');
+    var mr = getElement('matchesRow');
     cleanChilds(mr,0);
     for(i=0; i<current_rule.matches.length; i++)
         createMatchRow(mr, current_rule.matches[i]);
     
-    var ar = getElement('actions_row');
+    var ar = getElement('actionsRow');
     cleanChilds(ar,0);
     for(i=0; i<current_rule.actions.length; i++)
         createActionRow(ar, current_rule.actions[i]);
diff --git a/philter/philter/include/philter.js2 b/philter/philter/include/philter.js2
deleted file mode 100644 (file)
index 29ee024..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-/********************************************************************************
-* include/philter.js : philter javascript functions
-* ------------------
-*
-* This file is part of the philter distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-function text_onfocus(object,val) {
-    if(object.value == val)
-        object.value = '';
-}
-
-function text_onblur(object,val) {
-    if(object.value == '')
-        object.value = val;
-}
-
-function cleanChilds(Node, nbChilds) {
-    while(Node.childNodes.length>nbChilds)
-        Node.removeChild(Node.childNodes[nbChilds]);
-}
-
-/********** ORDER FORM FUNCTIONS **********/
-
-function order_up() {
-    form = document.forms['order'];
-    select = form.elements['order[select]'];
-
-    if(select.selectedIndex>1) {
-        i = select.selectedIndex;
-        value1 = select.options[i].value;
-        text1 = select.options[i].text;
-        value2 = select.options[i-1].value;
-        text2 = select.options[i-1].text;
-
-        select.options[i] = new Option(text2,value2,false,false);
-        select.options[i-1] = new Option(text1,value1,false,false);
-        select.selectedIndex = i-1;
-
-        form.elements['order['+value1+']'].value = i-1;
-        form.elements['order['+value2+']'].value = i;
-    }
-}
-
-function order_dn() {
-    form = document.forms['order'];
-    select = form.elements['order[select]'];
-
-    if(select.selectedIndex>0 && select.selectedIndex<select.length-1) {
-        i = select.selectedIndex;
-        value1 = select.options[i].value;
-        text1 = select.options[i].text;
-        value2 = select.options[i+1].value;
-        text2 = select.options[i+1].text;
-
-        select.options[i] = new Option(text2,value2,false,false);
-        select.options[i+1] = new Option(text1,value1,false,false);
-        select.selectedIndex = i+1;
-
-        form.elements['order['+value1+']'].value = i+1;
-        form.elements['order['+value2+']'].value = i;
-    }
-}
-
-function order_submit(obj) {
-    if(obj.name == 'order[submit]')
-        obj.form.elements['order[action]'].value = 'submit';
-    if(obj.name == 'order[delete]')
-        obj.form.elements['order[action]'].value = 'delete';
-    obj.form.submit();
-}
-
-/********** RULE FORM GLOBALS **********/
-
-var matches_list = new Array();
-var matches_func = new Array();
-
-var actions_list = new Array()
-var actions_func = new Array();
-
-var mail_pool = new Array();
-var filter = new Array();
-
-var current_rule;
-
-var actions_i = 0;
-var matches_i = 0;
-
-/********** RULE.ACTION FORM FUNCTIONS **********/
-
-function createActionSelect(data,base) {
-    var i,j;
-    var select = document.createElement("select");
-    select.name = base+'[0]';
-
-    for(i=0, j=0; i<actions_list.length; i++)
-        if(actions_list[i])
-            select.options[j++] = new Option(actions_list[i],i,false,(data==i));
-
-    select.setAttribute("onchange", "changeRow(this,actions_func)");
-
-    if(select.selectedIndex<0)
-        select.selectedIndex = 0;
-    return select;
-}
-
-function createActionRow(Node,data) {
-    var div = document.createElement("div");
-    div.className = 'row';
-    div.name = 'rule[actions]['+actions_i+']';
-    actions_i++;
-    Node.appendChild(div);
-
-    var del = document.createElement("input");
-    del.setAttribute("type", "submit");
-    del.setAttribute("value", "Del");
-    del.setAttribute("onclick", "parentNode.parentNode.removeChild(parentNode)");
-    div.appendChild(del);
-
-    div.appendChild(document.createTextNode(" "));
-
-    var select = createActionSelect(data[0],div.name);
-    div.appendChild(select);
-
-    actions_func[select.options[select.selectedIndex].value](div,data);
-}
-
-function newAction() {
-    createActionRow(document.all['actions_row'], 0);
-}
-
-/********** RULE.MATCH FORM FUNCTIONS **********/
-
-function createMatchSelect(data,base) {
-    var i,j;
-    var select = document.createElement("select");
-    select.name = base+'[0]';
-
-    for(i=0, j=0; i<matches_list.length; i++)
-        if(matches_list[i])
-            select.options[j++] = new Option(matches_list[i],i,false,(data==i));
-
-    select.setAttribute("onchange", "changeRow(this,matches_func)");
-
-    if(select.selectedIndex<0)
-        select.selectedIndex = 0;
-    return select;
-}
-
-function createMatchRow(Node,data) {
-    var div = document.createElement("div");
-    div.className = 'row';
-    div.name = 'rule[matches]['+actions_i+']';
-    actions_i++;
-    Node.appendChild(div);
-
-    var del = document.createElement("input");
-    del.setAttribute("type", "submit");
-    del.setAttribute("value", "Del");
-    del.setAttribute("onclick", "parentNode.parentNode.removeChild(parentNode)");
-    div.appendChild(del);
-
-    div.appendChild(document.createTextNode(" "));
-
-    var select = createMatchSelect(data[0],div.name);
-    div.appendChild(select);
-
-    matches_func[select.options[select.selectedIndex].value](div,data);
-}
-
-function newMatch() {
-    createMatchRow(document.all['matches_row'], 0);
-}
-
-/********** RULE FORM FUNCTIONS **********/
-
-function changeRow(sel, funcs) {
-    var row = sel.parentNode;
-    cleanChilds(row,3);
-    funcs[sel.options[sel.selectedIndex].value](row,0);
-}
-
-function createRuleForm() {
-    var i;
-    var sel = document.all['order[select]'];
-    var index = sel.options[sel.selectedIndex].value;
-
-    actions_i = matches_i = 0;
-    current_rule = filter[index];
-
-    document.all['rule[id]'].value = index;
-    document.all['rule[name]'].value = current_rule.name;
-    document.all['rule[all]'][1-current_rule.all].checked = true;
-    document.all['rule[block]'].checked = current_rule.block;
-
-    var mr = document.all['matches_row'];
-    cleanChilds(mr,0);
-    for(i=0; i<current_rule.matches.length; i++)
-        createMatchRow(mr, current_rule.matches[i]);
-    
-    var ar = document.all['actions_row'];
-    cleanChilds(ar,0);
-    for(i=0; i<current_rule.actions.length; i++)
-        createActionRow(ar, current_rule.actions[i]);
-}
-
-/********************************************************************************
-* $Id$
-* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
-********************************************************************************/
index 84c4f7c..561e4f9 100644 (file)
@@ -18,8 +18,9 @@ class AutoReplyPlugin extends ActionPlugin {
             .   "    var ta = document.createElement('textarea');\n"
             .   "    ta.setAttribute('name', Node.name+'[1]');\n"
             .   "    ta.setAttribute('cols', '74');\n"
-            .   "    ta.setAttribute('rows', '10');\n"
+            .   "    ta.setAttribute('rows', '2');\n"
             .   "    ta.setAttribute('onfocus', 'ta_onfocus(this);');\n"
+            .   "    ta.setAttribute('onblur', 'ta_onblur(this);');\n"
             .   "    if(data[1]) ta.value = data[1];\n"
             .   "\n"
             .   "    Node.appendChild(document.createElement('br'));\n"
index fa5b890..5f4ab09 100644 (file)
@@ -73,17 +73,17 @@ echo "</td></tr>\n</table>\n";
 <table width="100%">
 <tr><th colspan="2">Filtering rules</th></tr>
 <tr><td width="25%" valign="top">
-        <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" name="order" onsubmit="return false;">
+        <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="order" name="order" onsubmit="return false;">
         <table width="100%">
         <tr><td>
 <?php
             foreach($filter->rules as $id=>$rule)
-                echo "<input type=\"hidden\" name=\"order[$id]\" value=\"{$rule->rank}\" />\n";
+                echo "<input type=\"hidden\" id=\"order[$id]\" name=\"order[$id]\" value=\"{$rule->rank}\" />\n";
            
             $presel = (isset($_POST['rule']['id']) ? $_POST['rule']['id']
                         : (isset($_POST['order']['select']) ? $_POST['order']['select'] : 0));
                 
-            echo "<select size=\"16\" name=\"order[select]\" onchange=\"createRuleForm()\">\n";
+            echo "<select size=\"16\" id=\"order[select]\" name=\"order[select]\" onchange=\"createRuleForm()\">\n";
             echo "<option value=\"0\" ".($presel ? "" : " selected=\"selected\"")
                 .">[ new rule ]</option>\n";
             
@@ -104,23 +104,23 @@ echo "</td></tr>\n</table>\n";
         </form>
     </td>
     <td valign="top">
-        <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" name="rule" onsubmit="return false;">
+        <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="rule" name="rule" onsubmit="return false;">
         <table width="100%">
         <tr><th>Rule Configuration
         </th></tr><tr><td>
-            <input type="hidden" value="0" name="rule[id]" />
+            <input type="hidden" value="0" id="rule[id]" name="rule[id]" />
             Name of this rule :
-            <input type="text" size="60" value="" name="rule[name]"
+            <input type="text" size="60" value="" id="rule[name]" name="rule[name]"
                 onfocus="text_onfocus(this,'[ new rule ]')" onblur="text_onblur(this,'[ new rule ]')" />
             <br />
-            <input type="radio" value="1" name="rule[all]">All matches</input>
-            <input type="radio" value="0" name="rule[all]">One match</input>
+            <input type="radio" value="1" id="rule[all1]" name="rule[all]">All matches</input>
+            <input type="radio" value="0" id="rule[all0]" name="rule[all]">One match</input>
             <br />
-            <input type="checkbox" checked="checked" name="rule[block]">Blocking Rule</input>
+            <input type="checkbox" checked="checked" id="rule[block]" name="rule[block]">Blocking Rule</input>
         </td></tr><tr><th>Matches List
-        </th></tr><tr><td name="matches_row">
+        </th></tr><tr><td id="matchesRow" name="matches_row">
         </td></tr><tr><th>Actions List
-        </th></tr><tr><td name="actions_row">
+        </th></tr><tr><td id="actionsRow" name="actions_row">
         </td></tr><tr><td>
             <input type="submit" value="New Match" name="rule[new_match]" onclick="newMatch() "/>
             <input type="submit" value="New Action" name="rule[new_action]" onclick="newAction()" />