1
/////////////////////////////////////////////////////////////////////
2
// update.config form and rule contains following:
4
// Request Headers headers
5
// Offset Hour offset_hr
7
// Recursion depth rec_depth
8
// ** NOTE: the input type names must match those created in
9
// writeUpdateConfigForm
11
// Licensed to the Apache Software Foundation (ASF) under one
12
// or more contributor license agreements. See the NOTICE file
13
// distributed with this work for additional information
14
// regarding copyright ownership. The ASF licenses this file
15
// to you under the Apache License, Version 2.0 (the
16
// "License"); you may not use this file except in compliance
17
// with the License. You may obtain a copy of the License at
19
// http://www.apache.org/licenses/LICENSE-2.0
21
// Unless required by applicable law or agreed to in writing, software
22
// distributed under the License is distributed on an "AS IS" BASIS,
23
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
// See the License for the specific language governing permissions and
25
// limitations under the License.
26
/////////////////////////////////////////////////////////////////////
29
// creates a new Rule object; initializes with parameters passed in
31
function Rule(url, headers, offset_hr, interval, rec_depth) {
33
this.headers = headers;
34
this.offset_hr = offset_hr;
35
this.interval = interval;
36
this.rec_depth = rec_depth;
40
// This function creates a new Rule object for ruleList based
41
// on values entered in form.
42
// NOTE: In Netscape, we cannot access the selected value with:
43
// document.form1.rule_type.value. So we have to first get the
44
// selected index to get selected option's value
46
function createRuleFromForm() {
47
var url = document.form1.url.value;
48
var headers = document.form1.headers.value;
49
var offset_hr = document.form1.offset_hr.value;
50
var interval = document.form1.interval.value;
51
var rec_depth = document.form1.rec_depth.value;
53
var rule = new Rule(url, headers, offset_hr, interval, rec_depth);
59
// This function displays the Rule object's information in the format
60
// that's used in the select list.
62
function textFormat(rule, write)
69
space = " ";
73
delim = space + "," + space;
75
text = "URL" + eq + rule.url;
77
if (rule.headers != "") text += delim + "Headers" + eq + rule.headers;
78
text += delim + "Offset Hour" + eq + rule.offset_hr + delim + "Interval" + eq + rule.interval;
79
if (rule.rec_depth != "") text += delim + "Recursion Depth" + eq + rule.rec_depth;
85
// A Rule object also has a hidden format which will be used to help convert
86
// it into an Ele when user hits "Apply"
88
function hiddenFormat(rule)
92
var text = rule.url + delim + rule.headers + delim + rule.offset_hr + delim + rule.interval + delim + rule.rec_depth + delim;
97
// This function updates the selected Rule object with the values
98
// entered on the form.
100
function updateRule(index)
102
ruleList[index].url = document.form1.url.value;
103
ruleList[index].headers = document.form1.headers.value;
104
ruleList[index].offset_hr = document.form1.offset_hr.value;
105
ruleList[index].interval = document.form1.interval.value;
106
ruleList[index].rec_depth = document.form1.rec_depth.value;
110
// This function updates the elements on the form displayed to the
111
// user with the values sotred in the ruleList; has an optional index arg
113
function updateForm(index)
115
if (ruleList.length == 0)
119
index = document.form1.list1.selectedIndex;
121
document.form1.url.value = ruleList[index].url;
122
document.form1.headers.value = ruleList[index].headers;
123
document.form1.offset_hr.value = ruleList[index].offset_hr;
124
document.form1.interval.value = ruleList[index].interval;
125
document.form1.rec_depth.value = ruleList[index].rec_depth;
129
// clears all the fields in the form
133
document.form1.url.value = "";
134
document.form1.headers.value = "";
135
document.form1.offset_hr.value = "";
136
document.form1.interval.value = "";
137
document.form1.rec_depth.value = "";
139
document.form1.list1.selectedIndex = -1;
143
// form validation - put detailed alert messages in this function
145
function validInput()
147
if (document.form1.url.value == "" ||
148
document.form1.offset_hr.value == "" ||
149
document.form1.interval.value == ""){
150
alert("Need to specify 'URL', 'Offset Hour', 'Interval'.");
154
if (document.form1.offset_hr.value < 0 || document.form1.offset_hr.value > 23) {
155
alert("'Offset Hour' must be between 0 - 23");