* 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 = '';
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 **********/
}
function newAction() {
- createActionRow(getElement('actions_row'), 0);
+ createActionRow(getElement('actionsRow'), [-1]);
}
/********** RULE.MATCH FORM FUNCTIONS **********/
}
function newMatch() {
- createMatchRow(getElement('matches_row'), 0);
+ createMatchRow(getElement('matchesRow'), [-1]);
}
/********** RULE FORM FUNCTIONS **********/
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]);
+++ /dev/null
-/********************************************************************************
-* 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:
-********************************************************************************/
<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";
</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()" />