~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to proxy/mgmt2/html2/configure/f_update_config.ink

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////
 
2
// update.config form and rule contains following:
 
3
//    URL                   url
 
4
//    Request Headers       headers
 
5
//    Offset Hour           offset_hr
 
6
//    Interval              interval
 
7
//    Recursion depth       rec_depth
 
8
// ** NOTE: the input type names must match those created in 
 
9
//          writeUpdateConfigForm
 
10
//
 
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
 
18
//
 
19
//      http://www.apache.org/licenses/LICENSE-2.0
 
20
//
 
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
/////////////////////////////////////////////////////////////////////
 
27
 
 
28
// 
 
29
// creates a new Rule object; initializes with parameters passed in
 
30
//
 
31
function Rule(url, headers, offset_hr, interval, rec_depth) { 
 
32
 this.url = url;
 
33
 this.headers = headers;
 
34
 this.offset_hr = offset_hr;
 
35
 this.interval = interval;
 
36
 this.rec_depth = rec_depth;
 
37
}
 
38
 
 
39
// 
 
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
 
45
// 
 
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;
 
52
 
 
53
  var rule = new Rule(url, headers, offset_hr, interval, rec_depth);
 
54
 
 
55
  return rule;
 
56
}
 
57
 
 
58
//
 
59
// This function displays the Rule object's information in the format
 
60
// that's used in the select list.
 
61
//
 
62
function textFormat(rule, write)
 
63
{
 
64
  var text = "";
 
65
  var delim = "";
 
66
  var eq = "=";  
 
67
  var space = "";
 
68
  if (write == 1) {
 
69
     space = "  ";
 
70
  } else {  
 
71
     space = "  ";
 
72
  }
 
73
  delim = space + "," + space;
 
74
 
 
75
  text = "URL" + eq + rule.url;
 
76
   
 
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;
 
80
  
 
81
  return text;
 
82
}
 
83
 
 
84
//
 
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"
 
87
// 
 
88
function hiddenFormat(rule)
 
89
{
 
90
  var delim = "^"; 
 
91
 
 
92
  var text = rule.url + delim + rule.headers + delim + rule.offset_hr + delim + rule.interval + delim + rule.rec_depth + delim; 
 
93
  return text; 
 
94
}
 
95
 
 
96
// 
 
97
// This function updates the selected Rule object with the values 
 
98
// entered on the form. 
 
99
// 
 
100
function updateRule(index) 
 
101
{
 
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;
 
107
}
 
108
 
 
109
// 
 
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
 
112
// 
 
113
function updateForm(index)
 
114
 
115
  if (ruleList.length == 0) 
 
116
        return; 
 
117
        
 
118
  if (index == -1)      
 
119
    index = document.form1.list1.selectedIndex;
 
120
 
 
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;
 
126
}
 
127
 
 
128
// 
 
129
// clears all the fields in the form
 
130
// 
 
131
function clearForm() 
 
132
{
 
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 = "";
 
138
 
 
139
  document.form1.list1.selectedIndex = -1;      
 
140
}
 
141
 
 
142
// 
 
143
// form validation - put detailed alert messages in this function
 
144
//
 
145
function validInput()
 
146
{
 
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'.");
 
151
    return false;
 
152
  }
 
153
        
 
154
  if (document.form1.offset_hr.value < 0 || document.form1.offset_hr.value > 23) {
 
155
        alert("'Offset Hour' must be between 0 - 23"); 
 
156
        return false;
 
157
  } 
 
158
  return true;          
 
159
}