Subversion Repositories DevTools

Rev

Rev 2735 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2735 Rev 3959
Line 64... Line 64...
64
     eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
64
     eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
65
     if (restore) selObj.selectedIndex=0;
65
     if (restore) selObj.selectedIndex=0;
66
  }
66
  }
67
}
67
}
68
 
68
 
-
 
69
//
-
 
70
//  Validate Forms
-
 
71
//  Arguments:
-
 
72
//    --Silent          - Optional. Supresses alert
-
 
73
//    Triplets          - Zero or more triplets.
-
 
74
//                        Eg: 'FRpkgName','Package Name','RisPackage'
-
 
75
//      FormObject      - Form Object ID
-
 
76
//      TextPrefix      - Error message Prefix
-
 
77
//      TestType        - Type of test to perfom.
-
 
78
//                        First letter may be R - Required.
-
 
79
//
69
function MM_validateForm() { //v5.0
80
function MM_validateForm() {
70
   var ii,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
81
   var ii,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
71
   var REresults;
82
   var REresults;
72
   var pass,passc;
83
   var pass,passc;
-
 
84
   var showAlert = true;
73
 
85
 
74
   // Other general validations
86
   // Other general validations
75
   var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
87
   var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
76
   var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
88
   var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
77
   var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
89
   var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
78
   var versionNumberRE = /^\d+\.\d+\.\d+$/;
-
 
79
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+\.[a-zA-Z0-9]+$/;
90
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+\.[a-zA-Z0-9]+$/;
80
   var urlRE = "^https?://[a-z1-9]";
91
   var urlRE = "^https?://[a-z1-9]";
81
   //character range disallowed
92
   //character range disallowed
82
   var HTMLchr = /[\<\>\'\"]+/i;
93
   var HTMLchr = /[\<\>\'\"]+/i;
83
   var alphanumRE = /^[a-z0-9]+$/i;
94
   var alphanumRE = /^[a-z0-9]+$/i;
84
 
95
 
85
   for (ii=0; ii<(args.length-2); ii+=3) {
-
 
86
      test=args[ii+2];
-
 
87
      val=MM_findObj(args[ii]);
-
 
88
 
-
 
89
      if (val) {
-
 
90
         nm=args[ii+1];
96
   // Options are first
91
         val=val.value;
-
 
92
 
-
 
93
 
-
 
94
 
-
 
95
         if (val!="") {
-
 
96
            if (test.indexOf('isEmail')!=-1) {
-
 
97
               p=val.indexOf('@');
-
 
98
               if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
97
   for (ii=0; ii<(args.length-2) && typeof(args[ii]) === 'string' && args[ii].indexOf('--') == 0; ii++) {
99
            }
-
 
100
 
-
 
101
            if (test.indexOf('isDate') != -1) {
-
 
102
               if (val.indexOf("/") != -1) {
-
 
103
                  tmpARR = val.split("/");
-
 
104
                  if (tmpARR.length == 3) {
98
    switch(args[ii].toLowerCase()) {
105
                     if (!(tmpARR[0]>0  && tmpARR[0]<32  && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
-
 
106
                        errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
-
 
107
                     }
99
      case "--silent" :
108
                  } else {
100
        showAlert = false;
109
                     errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
-
 
110
                  }
-
 
111
               } else {
-
 
112
                  errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
-
 
113
               }
-
 
114
            }
-
 
115
 
-
 
116
            if (test.indexOf('isPackage')!=-1) {
-
 
117
               REresults = val.search(pkgRE);
-
 
118
               if (REresults < 0) errors += val + ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
-
 
119
                        + 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
-
 
120
            }
101
        break;
121
 
-
 
122
            if (test.indexOf('isCleanStr')!=-1) {
-
 
123
               REresults = val.search(cleanStrRE);
-
 
124
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
-
 
125
            }
102
    }
126
 
103
  }
127
            if (test.indexOf('isVersionStr')!=-1) {
-
 
128
               REresults = val.search(versionRE);
-
 
129
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
-
 
130
            }
-
 
131
 
104
 
-
 
105
  // Iterate over arguments
-
 
106
  // These are in triplets
-
 
107
  //    Name of form object - Value is extracted for user as 'val'
-
 
108
  //    Text Prefix for error - 'nm'
-
 
109
  //    Type of Test to Perform -'test'
-
 
110
   for (; ii<(args.length-2); ii+=3) {
-
 
111
      nm=args[ii+1];
-
 
112
      test=args[ii+2];
-
 
113
      if ( typeof(args[ii]) === 'string' ) {
-
 
114
        val=MM_findObj(args[ii]);
-
 
115
        if (val) {
-
 
116
           val=val.value;
-
 
117
 
-
 
118
           if (val!="") {
-
 
119
              if (test.indexOf('isEmail')!=-1) {
-
 
120
                 p=val.indexOf('@');
-
 
121
                 if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
-
 
122
              }
-
 
123
 
-
 
124
              if (test.indexOf('isDate') != -1) {
-
 
125
                 if (val.indexOf("/") != -1) {
-
 
126
                    tmpARR = val.split("/");
-
 
127
                    if (tmpARR.length == 3) {
-
 
128
                       if (!(tmpARR[0]>0  && tmpARR[0]<32  && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
-
 
129
                          errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
-
 
130
                       }
-
 
131
                    } else {
-
 
132
                       errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
-
 
133
                    }
-
 
134
                 } else {
-
 
135
                    errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
-
 
136
                 }
-
 
137
              }
-
 
138
 
-
 
139
              if (test.indexOf('isPackage')!=-1) {
-
 
140
                 REresults = val.search(pkgRE);
-
 
141
                 if (REresults < 0) errors += val + ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
-
 
142
                          + 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
-
 
143
              }
-
 
144
 
-
 
145
              if (test.indexOf('isCleanStr')!=-1) {
-
 
146
                 REresults = val.search(cleanStrRE);
-
 
147
                 if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
-
 
148
              }
-
 
149
 
-
 
150
              if (test.indexOf('isVersionStr')!=-1) {
-
 
151
                 REresults = val.search(versionRE);
-
 
152
                 if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
-
 
153
              }
-
 
154
 
132
            if (test.indexOf('isPatchVersionStr')!=-1) {
155
              if (test.indexOf('isPatchVersionStr')!=-1) {
133
               if ( !re_patch_ver_format.test(val) ) {
156
                 if ( !re_patch_ver_format.test(val) ) {
134
                  errors += val + '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
157
                    errors += val + '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
135
               }
158
                 }
136
            }
159
              }
137
 
160
 
138
            if (test.indexOf('isCCPath')!=-1) {
161
              if (test.indexOf('isCCPath')!=-1) {
139
               var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
162
                 var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
140
 
163
 
141
               REresults = val.search(/^(\\|\/)/);
164
                 REresults = val.search(/^(\\|\/)/);
142
               if (REresults < 0) errors += val + '- '+nm+' must begin with \\ or /\n';
165
                 if (REresults < 0) errors += val + '- '+nm+' must begin with \\ or /\n';
143
               
166
               
144
               REresults = val.search(CCPathRE);
167
                 REresults = val.search(CCPathRE);
145
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\n';
168
                 if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\n';
146
            }
169
              }
147
 
170
 
148
            if (test.indexOf('isCCLabel')!=-1) {
171
              if (test.indexOf('isCCLabel')!=-1) {
149
               var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
172
                 var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
150
 
173
 
151
               REresults = val.search(CCLabelRE);
174
                 REresults = val.search(CCLabelRE);
152
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are A-Z a-z 0-9 . - _\n';
175
                 if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are A-Z a-z 0-9 . - _\n';
153
            }
176
              }
154
 
177
 
155
            if (test.indexOf('isSVNTag')!=-1) {
178
              if (test.indexOf('isSVNTag')!=-1) {
156
                // Subversion Tag validation
179
                  // Subversion Tag validation
157
                var SVNTagValidPeg = /^@?\d+$/;
180
                  var SVNTagValidPeg = /^@?\d+$/;
158
                var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
181
                  var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
159
                
182
                
160
               if ( val.search(SVNTagValidPeg) < 0) {
183
                 if ( val.search(SVNTagValidPeg) < 0) {
161
 
-
 
162
                    var stripped;
-
 
163
                    stripped = val.replace (/@\d+$/,"");
-
 
164
                    if (stripped.search(SVNTagRE) < 0)
-
 
165
                        errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
-
 
166
               }
-
 
167
            }
-
 
168
 
184
 
-
 
185
                      var stripped;
-
 
186
                      stripped = val.replace (/@\d+$/,"");
-
 
187
                      if (stripped.search(SVNTagRE) < 0)
-
 
188
                          errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
-
 
189
                 }
-
 
190
              }
-
 
191
 
169
            if (test.indexOf('isSVNPegTag')!=-1 && ! errors) {
192
              if (test.indexOf('isSVNPegTag')!=-1 && ! errors) {
170
                // Subversion Tag has peg - Must have done valid check first
193
                  // Subversion Tag has peg - Must have done valid check first
171
                var SVNTagPegged = /@?\d+$/;
194
                  var SVNTagPegged = /@?\d+$/;
172
 
195
 
173
                if ( val.search(SVNTagPegged) < 0) {
196
                  if ( val.search(SVNTagPegged) < 0) {
174
                    errors += val + '- '+nm+' Must be pegged for Manually Versioned Package. ie:tag@pegNumber\n';
197
                      errors += val + '- '+nm+' Must be pegged for Manually Versioned Package. ie:tag@pegNumber\n';
175
               }
198
                 }
176
            }
199
              }
177
            
200
            
178
            if (test.indexOf('isSVNPath')!=-1) {
201
              if (test.indexOf('isSVNPath')!=-1) {
179
               // Subversion Base Path validation
202
                 // Subversion Base Path validation
180
               var SVNTagValidCharsRE = /^[0-9a-z_\.\-\/]+$/i;
203
                 var SVNTagValidCharsRE = /^[0-9a-z_\.\-\/]+$/i;
181
               var SVNTagInValidSlashAtBOL = /^\/.*$/i;
204
                 var SVNTagInValidSlashAtBOL = /^\/.*$/i;
182
               var SVNTagInValidSlashAtEOL = /\/$/i;
205
                 var SVNTagInValidSlashAtEOL = /\/$/i;
183
               var SVNTagInValidSlash = /^.*\/\/.*$/i;
206
                 var SVNTagInValidSlash = /^.*\/\/.*$/i;
184
               var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
207
                 var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
185
               var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
208
                 var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
186
 
209
 
187
               if (val.search(SVNTagValidCharsRE) < 0)
210
                 if (val.search(SVNTagValidCharsRE) < 0)
188
                  errors += val + ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
211
                    errors += val + ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
189
               else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
212
                 else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
190
                  errors += val + ' - '+nm+' begins with a /. This is not allowed.\n';
213
                    errors += val + ' - '+nm+' begins with a /. This is not allowed.\n';
191
               else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
214
                 else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
192
                  errors += val + ' - '+nm+' ends with a /. This is not allowed.\n';
215
                    errors += val + ' - '+nm+' ends with a /. This is not allowed.\n';
193
               else if (val.search(SVNTagInValidSlash) >= 0)
216
                 else if (val.search(SVNTagInValidSlash) >= 0)
194
                  errors += val + ' - '+nm+' uses //. This is not allowed.\n';
217
                    errors += val + ' - '+nm+' uses //. This is not allowed.\n';
195
               else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
218
                 else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
196
                     errors += val + ' - '+nm+' contains /tags/. This is not allowed.\n';
219
                       errors += val + ' - '+nm+' contains /tags/. This is not allowed.\n';
197
               else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
220
                 else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
198
                     errors += val + ' - '+nm+' contains /trunk/. This is not allowed.\n';
221
                       errors += val + ' - '+nm+' contains /trunk/. This is not allowed.\n';
199
               else {
222
                 else {
200
                        var bits = val.split("/");
223
                          var bits = val.split("/");
201
                        if ( bits.length < 4 )
224
                          if ( bits.length < 4 )
202
                            errors += val + ' - Must contain at least 4 path items.\n';
225
                              errors += val + ' - Must contain at least 4 path items.\n';
203
                        
226
                        
204
                        var ttbcount = 0;
227
                          var ttbcount = 0;
205
                        var i
228
                          var i
206
                        for (i=0; i < bits.length; i++ )
229
                          for (i=0; i < bits.length; i++ )
207
                        {
230
                          {
208
                            var el = bits[i];
231
                              var el = bits[i];
209
                            if ( el == 'tags') ttbcount++;
232
                              if ( el == 'tags') ttbcount++;
210
                            if ( el == 'trunk') ttbcount++;
233
                              if ( el == 'trunk') ttbcount++;
211
                            if ( el == 'branches') ttbcount++;
234
                              if ( el == 'branches') ttbcount++;
212
                        }
235
                          }
213
                        if ( ttbcount != 1 )
236
                          if ( ttbcount != 1 )
214
                            errors += val + ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
237
                              errors += val + ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
215
                          
238
                          
216
                        if ( bits.pop() == 'branches' )    
239
                          if ( bits.pop() == 'branches' )    
217
                            errors += val + ' - '+nm+' must not end in branches.\n';
240
                              errors += val + ' - '+nm+' must not end in branches.\n';
218
                        
241
                        
219
                     }
242
                       }
220
            }
-
 
221
 
-
 
222
            if (test.indexOf('isVersionNumber')!=-1) {
-
 
223
               REresults = val.search(versionNumberRE);
-
 
224
               if (REresults < 0) errors += val + ' - '+nm+' is formatted incorrectly.\nVersion number should be (major).(minor).(patch)(build)\ne.g. 1.0.2002\n';
-
 
225
            }
-
 
226
 
-
 
227
            if (test.indexOf('isURL')!=-1) {
-
 
228
               REresults = val.match(urlRE);
-
 
229
               if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
-
 
230
            }
243
              }
231
 
244
 
-
 
245
              // No longer used in this simple form
-
 
246
              if (test.indexOf('isVersionNumber')!=-1) {
-
 
247
                 REresults = -1;
-
 
248
                 if (REresults < 0) errors += val + ' - '+nm+' isVersionNumber is no longer supported in this form';
-
 
249
              }
-
 
250
 
-
 
251
              if (test.indexOf('isURL')!=-1) {
-
 
252
                 REresults = val.match(urlRE);
-
 
253
                 if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
-
 
254
              }
-
 
255
 
232
            if (test.indexOf('isAlphaNum')!=-1) {
256
              if (test.indexOf('isAlphaNum')!=-1) {
233
               REresults = val.match(alphanumRE);
257
                 REresults = val.match(alphanumRE);
234
               if (REresults == null) errors += '"'+nm+'" must be an alphanumeric value.\n';
258
                 if (REresults == null) errors += '"'+nm+'" must be an alphanumeric value.\n';
235
            }
259
              }
236
 
260
 
237
            if (test.indexOf('isChangePassword')!=-1) {
261
              if (test.indexOf('isChangePassword')!=-1) {
238
               pass=MM_findObj('FRpassword');
262
                 pass=MM_findObj('FRpassword');
239
               passc=MM_findObj('FRpasswordc');
263
                 passc=MM_findObj('FRpasswordc');
240
               if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
264
                 if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
241
            }
265
              }
242
 
266
 
243
            if (test.indexOf('maxLength')!=-1) {
267
              if (test.indexOf('maxLength')!=-1) {
244
               p=test.indexOf(':');
268
                 p=test.indexOf(':');
245
               max=test.substring(p+1);
269
                 max=test.substring(p+1);
246
               if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
270
                 if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
247
            }
271
              }
248
 
272
 
249
            if (test.indexOf('notHTML')!=-1) {
273
              if (test.indexOf('notHTML')!=-1) {
250
               if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
274
                 if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
251
            }
275
              }
252
 
276
 
253
            if (test.charAt(0)=='R') {
277
              if (test.charAt(0)=='R') {
254
 
278
 
255
               if (test.indexOf('isNumber') != -1) {
279
                 if (test.indexOf('isNumber') != -1) {
256
                  if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
280
                    if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
257
               }
281
                 }
258
 
282
 
259
               if (test.indexOf('inRange') != -1) {
283
                 if (test.indexOf('inRange') != -1) {
260
                  p=test.indexOf(':');
284
                    p=test.indexOf(':');
261
                  min=test.substring(8,p);
285
                    min=test.substring(8,p);
262
                  max=test.substring(p+1);
286
                    max=test.substring(p+1);
263
                  if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
287
                    if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
264
               }
288
                 }
265
 
289
 
266
               if (test.indexOf('inLength')!=-1) {
290
                 if (test.indexOf('inLength')!=-1) {
267
                   pl=test.indexOf('inLength')
291
                     pl=test.indexOf('inLength')
268
                  p=test.indexOf(':');
292
                    p=test.indexOf(':');
269
                      min=test.substring(pl+8,p);
293
                        min=test.substring(pl+8,p);
270
                      if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
294
                        if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
271
                }
295
                  }
272
            }
296
              }
273
         } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
297
           } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
274
 
-
 
275
 
-
 
276
         if (test.indexOf('isPassword')!=-1) {
-
 
277
            pass=MM_findObj('FRpassword');
-
 
278
            passc=MM_findObj('FRpasswordc');
-
 
279
            if (!MM_findObj('FRdomainauth').checked) {
-
 
280
               if (test.indexOf('inLength')!=-1) {
-
 
281
                   pl=test.indexOf('inLength')
-
 
282
                  p=test.indexOf(':');
-
 
283
                      min=test.substring(pl+8,p);
-
 
284
                      if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
-
 
285
                }
-
 
286
               if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
-
 
287
            } else {
-
 
288
               if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
-
 
289
            }
-
 
290
         }
-
 
291
 
298
 
292
         if (test.indexOf('isDomainName')!=-1) {
-
 
293
            if (MM_findObj('FRdomainauth').checked) {
-
 
294
               if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
-
 
295
            }
-
 
296
         }
-
 
297
 
299
 
-
 
300
           if (test.indexOf('isPassword')!=-1) {
-
 
301
              pass=MM_findObj('FRpassword');
-
 
302
              passc=MM_findObj('FRpasswordc');
-
 
303
              if (!MM_findObj('FRdomainauth').checked) {
-
 
304
                 if (test.indexOf('inLength')!=-1) {
-
 
305
                     pl=test.indexOf('inLength')
-
 
306
                    p=test.indexOf(':');
-
 
307
                        min=test.substring(pl+8,p);
-
 
308
                        if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
-
 
309
                  }
-
 
310
                 if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
-
 
311
              } else {
-
 
312
                 if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
-
 
313
              }
-
 
314
           }
-
 
315
 
-
 
316
           if (test.indexOf('isDomainName')!=-1) {
-
 
317
              if (MM_findObj('FRdomainauth').checked) {
-
 
318
                 if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
-
 
319
              }
-
 
320
           }
-
 
321
        }
-
 
322
      }
-
 
323
      else {
-
 
324
        // Alternate form. First item is an object
-
 
325
        // Contents are test specific
-
 
326
        var valp = args[ii];
-
 
327
 
-
 
328
          // Expects object with data to examine
-
 
329
        if (test.indexOf('isVersionNumber')!=-1) {
-
 
330
          var rv = MM_ValidateVersion(valp.vBase, valp.vExt, valp.isAuto || false, valp.isPatch || false);
-
 
331
          if ( rv )
-
 
332
            errors += '- ' +nm+rv;
-
 
333
        }
298
      }
334
      }
299
   }
335
   }
300
 
336
 
301
   if (errors) {
337
   if (errors) {
-
 
338
      if ( showAlert )
302
      alert('The following error(s) occurred:\n\n'+errors);
339
        alert('The following error(s) occurred:\n\n'+errors);
303
      clickedButton=false;
340
      clickedButton=false;
304
   } else {
341
   } else {
305
      clickedButton=true;
342
      clickedButton=true;
306
   }
343
   }
307
   document.MM_returnValue = (errors == '');
344
   document.MM_returnValue = (errors == '');
-
 
345
   document.MM_error = errors;
-
 
346
 
-
 
347
  if (document.MM_returnValue && showAlert)
-
 
348
    MM_showProgressBar();
-
 
349
}
-
 
350
 
-
 
351
function MM_showProgressBar() {
-
 
352
  var pb = MM_findObj('ProgressBar');
-
 
353
  if ( pb )
-
 
354
    pb.style.visibility='visible';
-
 
355
}
308
 
356
 
-
 
357
function MM_hideProgressBar() {
309
   if (MM_findObj('ProgressBar') && document.MM_returnValue) MM_findObj('ProgressBar').style.visibility='visible';
358
  var pb = MM_findObj('ProgressBar');
-
 
359
  if ( pb )
-
 
360
    pb.style.visibility='hidden';
310
}
361
}
311
 
362
 
312
function isChecked(boxName, buttonId) {
363
function isChecked(boxName, buttonId) {
313
  var formButton = document.getElementById(buttonId);
364
  var formButton = document.getElementById(buttonId);
314
  var boxes = document.getElementsByName(boxName);
365
  var boxes = document.getElementsByName(boxName);
Line 333... Line 384...
333
 
384
 
334
function confirmDelete(m)
385
function confirmDelete(m)
335
{
386
{
336
   var agree=confirm('Are you sure you want to delete '+m+'?');
387
   var agree=confirm('Are you sure you want to delete '+m+'?');
337
   if (agree) {
388
   if (agree) {
338
      if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
389
      MM_showProgressBar();
339
      return true;
390
      return true;
340
   } else {
391
   } else {
341
      return false;
392
      return false;
342
   }
393
   }
343
}
394
}
344
 
395
 
345
function confirmAction(m)
396
function confirmAction(m)
346
{
397
{
347
   var agree=confirm(m);
398
   var agree=confirm(m);
348
   if (agree) {
399
   if (agree) {
349
      if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
400
      MM_showProgressBar();
350
      return true;
401
      return true;
351
   } else {
402
   } else {
352
      return false;
403
      return false;
353
   }
404
   }
354
}
405
}
Line 508... Line 559...
508
   }
559
   }
509
}
560
}
510
 
561
 
511
//////////////////////////////////////////////////////////////////////////////////////////////////
562
//////////////////////////////////////////////////////////////////////////////////////////////////
512
//
563
//
513
// MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild)
564
// MM_ValidateVersion(versionBase, versionExt, isAutobuild isPatch)
-
 
565
// Should NOT be used externally. Use MM_validateForm to access this function
514
//
566
//
515
//    pkgName       eg EA_DocGen
-
 
516
//    versionBase   eg 1.2.3
567
//    versionBase   eg 1.2.3
517
//    versionExt   eg .cr
568
//    versionExt    eg .cr
518
//    isAutobuild   true or false
-
 
519
//    isPatch       true or false
-
 
520
//
-
 
521
// Returns true if version is valid, else false
-
 
522
//
-
 
523
// This function can and should be used instead of MM_validateForm to validate
-
 
524
// version numbers for new or reversioned package versions.
-
 
525
//
-
 
526
// So far, this function is used in the following situations:
-
 
527
//    1) Add new version to release (_form_new_version_page.asp)
-
 
528
//    2) Reversion existing version (_wform_rename_version.asp)
-
 
529
//    3) Add package to release (Form_add_pkg_versions.asp)
-
 
530
//////////////////////////////////////////////////////////////////////////////////////////////////
-
 
531
function MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild, isPatch)
-
 
532
{
-
 
533
   var errString = MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch);
-
 
534
   if (errString.length > 0)
-
 
535
   {
-
 
536
      alert(errString);
-
 
537
      return false;
-
 
538
   }
-
 
539
   return true;
-
 
540
}
-
 
541
 
-
 
542
//////////////////////////////////////////////////////////////////////////////////////////////////
-
 
543
//
-
 
544
// MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild)
-
 
545
//
-
 
546
//    pkgName       eg buildtool
-
 
547
//    versionBase   eg 1.2.3
-
 
548
//    versionExt   eg .cr
-
 
549
//    isAutobuild   true or false
569
//    isAutobuild   true or false
550
//    isPatch       true or false
570
//    isPatch       true or false
551
//
571
//
552
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
572
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
553
//
573
//
554
// The MM_validateForm function should be modified to use this if possible, although I currently
-
 
555
// do not believe it has access to all the necessary parameter values needed.
-
 
556
//
-
 
557
//////////////////////////////////////////////////////////////////////////////////////////////////
574
//////////////////////////////////////////////////////////////////////////////////////////////////
558
function MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch)
575
function MM_ValidateVersion(versionBase, versionExt, isAutobuild, isPatch)
559
{
576
{
560
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
577
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
561
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
578
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
562
   var re_cots_ver_format  = /^[\w]+[\w\.\-]*$/;   // starts with letter or digit or underscore, subsequent chars can be letters or digits or _ or . or -
579
   var re_cots_ver_format  = /^[\w]+[\w\.\-]*$/;   // starts with letter or digit or underscore, subsequent chars can be letters or digits or _ or . or -
563
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
580
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
564
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
581
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
-
 
582
   var isCots = versionExt == ".cots" || versionExt == ".tool";
565
 
583
 
566
   var forPkgName = "";
-
 
567
   if (pkgName != null && pkgName.length > 0)
-
 
568
   {
-
 
569
      forPkgName = ", for package " + pkgName;
-
 
570
   }
-
 
571
 
-
 
572
   if (!isAutobuild)
584
   if (!isAutobuild) {
573
   {
-
 
574
      if ( versionBase.length == 0 )
585
      if ( versionBase.length == 0 ) {
575
      {
-
 
576
         return "Action failed: version number is of zero length" + forPkgName;
586
         return " is of zero length";
577
      }
-
 
578
      else if ( versionExt != ".cots" )
587
      } else if ( !isCots) {
579
      {
-
 
580
         if ( isPatch )
588
         if ( isPatch ) {
581
         {
-
 
582
            if ( !re_patch_ver_format.test(versionBase) )
589
            if ( !re_patch_ver_format.test(versionBase) ) {
-
 
590
               return " is not of form (integer).(integer).(integer).p(integer)";
583
            {
591
            }
-
 
592
         } else {
-
 
593
            if ( !re_std_ver_format.test(versionBase) ) {
584
               return "Action failed: patch version is not of form (integer).(integer).(integer).p(integer).(extension)" + forPkgName;
594
               return " is not of form (integer).(integer).(integer)";
585
            }
595
            }
586
         }
596
         }
587
         else
597
      } else if (isCots) {
588
         {
-
 
589
            if ( !re_std_ver_format.test(versionBase) )
598
         var extName = versionExt.toUpperCase().substr(1);
590
            {
-
 
591
               return "Action failed: version is not of form (integer).(integer).(integer).(extension)" + forPkgName;
-
 
592
            }
-
 
593
         }
-
 
594
      }
-
 
595
      else if ( versionExt == ".cots")
-
 
596
      {
599
 
597
         if ( !re_cots_ver_format.test(versionBase) )
600
         if ( !re_cots_ver_format.test(versionBase) ) {
598
         {
-
 
599
            return "Action failed: COTS version must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed" + forPkgName;
601
            return " " + extName + " package must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed";
600
         }
602
         }
601
 
603
 
602
         if ( re_cots_ver_format_exc1.test(versionBase) )
604
         if ( re_cots_ver_format_exc1.test(versionBase) ) {
603
         {
-
 
604
            return "Action failed: COTS version cannot contain two adjacent special characters (underscore/dash/dot)" + forPkgName;
605
            return " " + extName + " package cannot contain two adjacent special characters (underscore/dash/dot)";
605
         }
606
         }
606
 
607
 
607
         if ( !re_cots_ver_format_exc2.test(versionBase) )
608
         if ( !re_cots_ver_format_exc2.test(versionBase) ) {
608
         {
-
 
609
            return "Action failed: COTS version must contain one or more alphanumeric characters" + forPkgName;
609
            return " " + extName + " package must contain one or more alphanumeric characters";
610
         }
610
         }
611
      }
611
      }
612
   }
612
   }
613
 
613
 
614
   // everything ok - no error
614
   // everything ok - no error
615
   return "";
615
   return "";
616
}
616
}
617
 
617
 
618
 
618
 
-
 
619
// Manipulate the class list for a given element
-
 
620
function hasClass(ele, cls) {
-
 
621
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
-
 
622
}
-
 
623
 
-
 
624
function addClass(ele, cls) {
-
 
625
    if (!this.hasClass(ele, cls)) ele.className += " " + cls;
-
 
626
}
-
 
627
 
-
 
628
function removeClass(ele, cls) {
-
 
629
    if (hasClass(ele, cls)) {
-
 
630
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
-
 
631
        ele.className = ele.className.replace(reg, ' ');
-
 
632
    }
-
 
633
}
-
 
634
 
-
 
635
function toggleClass(ele, cls1, cls2){
-
 
636
    if(hasClass(ele, cls1)){
-
 
637
        replaceClass(ele, cls1, cls2);
-
 
638
    }else if(hasClass(ele, cls2)){
-
 
639
        replaceClass(ele, cls2, cls1);
-
 
640
    }else{
-
 
641
        addClass(ele, cls1);
-
 
642
    }
-
 
643
}
-
 
644
 
-
 
645
// Highlight combobox if selection is zero
-
 
646
// Returns true:  None-zero selection
-
 
647
// Returns false: Invalid element or item-0 selected
-
 
648
function checkSeletion(el)
-
 
649
{
-
 
650
   if (el ) {
-
 
651
     if ( el.selectedIndex == 0) {
-
 
652
        addClass(el, 'form_error');
-
 
653
     } else {
-
 
654
        removeClass(el, 'form_error');
-
 
655
        return true;
-
 
656
     }
-
 
657
   }
-
 
658
   return false;
-
 
659
}
-
 
660
 
-
 
661
function getElementsByClassName(classname, node)  {
-
 
662
    if(!node) node = document.getElementsByTagName("body")[0];
-
 
663
    var a = [];
-
 
664
    var re = new RegExp('\\b' + classname + '\\b');
-
 
665
    var els = node.getElementsByTagName("*");
-
 
666
    for(var i=0,j=els.length; i<j; i++)
-
 
667
        if(re.test(els[i].className))a.push(els[i]);
-
 
668
    return a;
-
 
669
}
-
 
670
 
-
 
671
function setCookie(c_name,value,exdays)
-
 
672
{
-
 
673
  var exdate=new Date();
-
 
674
  exdate.setDate(exdate.getDate() + exdays);
-
 
675
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
-
 
676
  document.cookie=c_name + "=" + c_value;
-
 
677
}
-
 
678
 
-
 
679
function getCookie(c_name)
-
 
680
{
-
 
681
  var c_value = document.cookie;
-
 
682
  var c_start = c_value.indexOf(" " + c_name + "=");
-
 
683
  if (c_start == -1)
-
 
684
  {
-
 
685
    c_start = c_value.indexOf(c_name + "=");
-
 
686
  }
-
 
687
  if (c_start == -1)
-
 
688
  {
-
 
689
    c_value = null;
-
 
690
  }
-
 
691
  else
-
 
692
  {
-
 
693
    c_start = c_value.indexOf("=", c_start) + 1;
-
 
694
    var c_end = c_value.indexOf(";", c_start);
-
 
695
    if (c_end == -1)
-
 
696
    {
-
 
697
      c_end = c_value.length;
-
 
698
    }
-
 
699
  c_value = unescape(c_value.substring(c_start,c_end));
-
 
700
}
-
 
701
return c_value;
-
 
702
}
619
 
703
 
620
//-->
704
//-->