Subversion Repositories DevTools

Rev

Rev 1281 | Rev 1372 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
/*
129 ghuddy 2
 *    COMMON JAVASCRIPTS
119 ghuddy 3
 */
4
 
5
<!--
6
var clickedButton = false;
7
function check() {
129 ghuddy 8
   if (clickedButton) {
9
       clickedButton = false;
119 ghuddy 10
        return true;
11
    } else {
129 ghuddy 12
       return false;
13
   }
119 ghuddy 14
}
15
 
16
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
17
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
18
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
19
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
20
}
21
MM_reloadPage(true);
22
 
23
function MM_preloadImages() { //v3.0
24
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
25
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
26
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
27
}
28
 
29
function MM_swapImgRestore() { //v3.0
30
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
31
}
32
 
33
function MM_findObj(n, d) { //v4.0
121 hknight 34
  var p,i,x;
35
  if(!d) d=document;
119 ghuddy 36
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
129 ghuddy 37
     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
119 ghuddy 38
  }
121 hknight 39
  if(!(x=d[n])&&d.all) x=d.all[n];
119 ghuddy 40
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
41
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
121 hknight 42
  if(!x && document.getElementById) x=document.getElementById(n);
119 ghuddy 43
  return x;
44
}
45
 
46
function MM_swapImage() { //v3.0
47
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
48
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
49
}
50
 
51
function MM_openBrWindow(theURL,winName,features) { //v2.0
52
  window.open(theURL,winName,features);
53
}
54
 
55
function MM_jumpMenu(targ,selObj,restore){ //v3.1
56
  if (selObj.options[selObj.selectedIndex].value) {
129 ghuddy 57
     eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
58
     if (restore) selObj.selectedIndex=0;
119 ghuddy 59
  }
60
}
61
 
62
function Cascaded_Menu(targ,url,selObj,restore){ //v3.1
63
  if (selObj.options[selObj.selectedIndex].value) {
129 ghuddy 64
     eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
65
     if (restore) selObj.selectedIndex=0;
119 ghuddy 66
  }
67
}
68
 
69
function MM_validateForm() { //v5.0
129 ghuddy 70
   var i,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
71
   var REresults;
72
   var pass,passc;
121 hknight 73
 
74
 
75
 
129 ghuddy 76
   // Other general validations
77
   var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
78
   var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
79
   var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
80
   var versionNumberRE = /^\d+\.\d+\.\d+$/;
145 ghuddy 81
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+\.[a-zA-Z0-9]+$/;
129 ghuddy 82
   var urlRE = "^https?://[a-z1-9]";
83
   //character range disallowed
84
   var HTMLchr = /[\<\>\'\"]+/i;
171 brianf 85
   var alphanumRE = /^[a-z0-9]+$/i;
121 hknight 86
 
129 ghuddy 87
   for (i=0; i<(args.length-2); i+=3) {
88
      test=args[i+2];
89
      val=MM_findObj(args[i]);
121 hknight 90
 
129 ghuddy 91
      if (val) {
92
         nm=args[i+1];
93
         val=val.value;
121 hknight 94
 
95
 
96
 
129 ghuddy 97
         if (val!="") {
98
            if (test.indexOf('isEmail')!=-1) {
99
               p=val.indexOf('@');
100
               if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
101
            }
121 hknight 102
 
129 ghuddy 103
            if (test.indexOf('isDate') != -1) {
104
               if (val.indexOf("/") != -1) {
105
                  tmpARR = val.split("/");
106
                  if (tmpARR.length == 3) {
107
                     if (!(tmpARR[0]>0  && tmpARR[0]<32  && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
108
                        errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
109
                     }
110
                  } else {
111
                     errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
112
                  }
113
               } else {
114
                  errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
115
               }
116
            }
121 hknight 117
 
129 ghuddy 118
            if (test.indexOf('isPackage')!=-1) {
119
               REresults = val.search(pkgRE);
120
               if (REresults < 0) errors += val += ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
121
                        + 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
122
            }
121 hknight 123
 
129 ghuddy 124
            if (test.indexOf('isCleanStr')!=-1) {
125
               REresults = val.search(cleanStrRE);
126
               if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
127
            }
121 hknight 128
 
129 ghuddy 129
            if (test.indexOf('isVersionStr')!=-1) {
130
               REresults = val.search(versionRE);
131
               if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
132
            }
121 hknight 133
 
145 ghuddy 134
            if (test.indexOf('isPatchVersionStr')!=-1) {
135
               if ( !re_patch_ver_format.test(val) ) {
136
                  errors += val += '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
137
               }
138
            }
139
 
129 ghuddy 140
            if (test.indexOf('isCCPath')!=-1) {
141
               var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
121 hknight 142
 
129 ghuddy 143
               REresults = val.search(CCPathRE);
144
               if (REresults < 0) errors += val += '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\nAnd the path must begin with \\ or /';
145
            }
121 hknight 146
 
129 ghuddy 147
            if (test.indexOf('isCCLabel')!=-1) {
148
               var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
121 hknight 149
 
129 ghuddy 150
               REresults = val.search(CCLabelRE);
151
               if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
152
            }
121 hknight 153
 
129 ghuddy 154
            if (test.indexOf('isSVNTag')!=-1) {
1339 dpurdie 155
                // Subversion Tag validation
156
                var SVNTagValidPeg = /^@?\d+$/;
157
                var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
158
 
159
               if ( val.search(SVNTagValidPeg) < 0) {
160
                    val = val.replace (/@\d+$/,"");
161
 
162
               if (val.search(SVNTagRE) < 0) 
163
                    errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
164
               }
165
            }
166
 
167
            if (test.indexOf('isSVNPath')!=-1) {
168
               // Subversion Base Path validation
169
               var SVNTagValidCharsRE = /^[0-9a-z_\.\-\/]+$/i;
129 ghuddy 170
               var SVNTagInValidSlashAtBOL = /^\/.*$/i;
1339 dpurdie 171
               var SVNTagInValidSlashAtEOL = /\/$/i;
129 ghuddy 172
               var SVNTagInValidSlash = /^.*\/\/.*$/i;
1339 dpurdie 173
               var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
129 ghuddy 174
               var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
121 hknight 175
 
129 ghuddy 176
               if (val.search(SVNTagValidCharsRE) < 0)
1339 dpurdie 177
                  errors += val += ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
178
               else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
179
                  errors += val += ' - '+nm+' begins with a /. This is not allowed.\n';
180
               else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
181
                  errors += val += ' - '+nm+' ends with a /. This is not allowed.\n';
182
               else if (val.search(SVNTagInValidSlash) >= 0)
183
                  errors += val += ' - '+nm+' uses //. This is not allowed.\n';
184
               else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
185
                     errors += val += ' - '+nm+' contains /tags/. This is not allowed.\n';
186
               else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
187
                     errors += val += ' - '+nm+' contains /trunk/. This is not allowed.\n';
129 ghuddy 188
               else {
1339 dpurdie 189
                        var bits = val.split("/");
190
                        if ( bits.length < 4 )
191
                            errors += val += ' - Must contain at least 4 path items.\n';
192
 
193
                        var ttbcount = 0;
194
                        for (i=0; i < bits.length; i++ )
195
                        {
196
                            var el = bits[i];
197
                            if ( el == 'tags') ttbcount++;
198
                            if ( el == 'trunk') ttbcount++;
199
                            if ( el == 'branches') ttbcount++;
129 ghuddy 200
                        }
1339 dpurdie 201
                        if ( ttbcount != 1 )
202
                            errors += val += ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
203
 
204
                        if ( bits.pop() == 'branches' )    
205
                            errors += val += ' - '+nm+' must not end in branches.\n';
206
 
129 ghuddy 207
                     }
208
            }
209
 
210
            if (test.indexOf('isVersionNumber')!=-1) {
211
               REresults = val.search(versionNumberRE);
212
               if (REresults < 0) errors += val += ' - '+nm+' is formatted incorrectly.\nVersion number should be (major).(minor).(patch)(build)\ne.g. 1.0.2002\n';
213
            }
214
 
215
            if (test.indexOf('isURL')!=-1) {
216
               REresults = val.match(urlRE);
217
               if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
218
            }
219
 
171 brianf 220
            if (test.indexOf('isAlphaNum')!=-1) {
221
               REresults = val.match(alphanumRE);
222
               if (REresults == null) errors += '"'+nm+'" must be an alphanumeric value.\n';
223
            }
224
 
129 ghuddy 225
            if (test.indexOf('isChangePassword')!=-1) {
226
               pass=MM_findObj('FRpassword');
227
               passc=MM_findObj('FRpasswordc');
228
               if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
229
            }
230
 
231
            if (test.indexOf('maxLength')!=-1) {
232
               p=test.indexOf(':');
233
               max=test.substring(p+1);
234
               if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
235
            }
236
 
237
            if (test.indexOf('notHTML')!=-1) {
238
               if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
239
            }
240
 
241
            if (test.charAt(0)=='R') {
242
 
243
               if (test.indexOf('isNumber') != -1) {
244
                  if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
245
               }
246
 
247
               if (test.indexOf('inRange') != -1) {
248
                  p=test.indexOf(':');
249
                  min=test.substring(8,p);
250
                  max=test.substring(p+1);
251
                  if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
252
               }
253
 
254
               if (test.indexOf('inLength')!=-1) {
255
                   pl=test.indexOf('inLength')
256
                  p=test.indexOf(':');
257
                      min=test.substring(pl+8,p);
258
                      if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
259
                }
260
            }
261
         } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
262
 
263
 
264
         if (test.indexOf('isPassword')!=-1) {
265
            pass=MM_findObj('FRpassword');
266
            passc=MM_findObj('FRpasswordc');
267
            if (!MM_findObj('FRdomainauth').checked) {
268
               if (test.indexOf('inLength')!=-1) {
269
                   pl=test.indexOf('inLength')
270
                  p=test.indexOf(':');
271
                      min=test.substring(pl+8,p);
272
                      if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
273
                }
274
               if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
275
            } else {
276
               if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
277
            }
278
         }
279
 
280
         if (test.indexOf('isDomainName')!=-1) {
281
            if (MM_findObj('FRdomainauth').checked) {
282
               if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
283
            }
284
         }
285
 
286
      }
287
   }
288
 
289
   if (errors) {
290
      alert('The following error(s) occurred:\n\n'+errors);
291
      clickedButton=false;
292
   } else {
293
      clickedButton=true;
294
   }
295
   document.MM_returnValue = (errors == '');
296
 
297
   if (MM_findObj('ProgressBar') && document.MM_returnValue) MM_findObj('ProgressBar').style.visibility='visible';
119 ghuddy 298
}
299
 
300
function isChecked(boxName, buttonId) {
301
  var formButton = document.getElementById(buttonId);
302
  var boxes = document.getElementsByName(boxName);
303
  var btnChecked = false;
304
  if (formButton) {
305
    for (var i = 0; i < boxes.length; i++) {
306
      if (boxes[i].checked) {
307
        btnChecked = true;
308
      }
309
    }
121 hknight 310
 
119 ghuddy 311
    if (btnChecked) {
312
      formButton.disabled = false;
313
      formButton.style.color="";
314
    }
315
    else {
316
      formButton.disabled = true;
317
      formButton.style.color="silver";
318
    }
319
  }
320
}
321
 
322
function confirmDelete(m)
323
{
129 ghuddy 324
   var agree=confirm('Are you sure you want to delete '+m+'?');
325
   if (agree) {
326
      if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
327
      return true;
328
   } else {
329
      return false;
330
   }
119 ghuddy 331
}
332
 
333
function confirmAction(m)
334
{
129 ghuddy 335
   var agree=confirm(m);
336
   if (agree) {
337
      if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
338
      return true;
339
   } else {
340
      return false;
341
   }
119 ghuddy 342
}
343
 
344
function DisplaySPAN(show) {
129 ghuddy 345
   if (show) {
346
      MM_findObj("spanHideDetails").style.display = "block";
347
      MM_findObj("spanPkgInfo").style.display = "block";
348
      MM_findObj("spanShowDetails").style.display = "none";
349
   } else {
350
      MM_findObj("spanHideDetails").style.display = "none";
351
      MM_findObj("spanPkgInfo").style.display = "none";
352
      MM_findObj("spanShowDetails").style.display = "block";
353
   }
119 ghuddy 354
}
355
 
356
function ToggleDisplay () {
129 ghuddy 357
   var i, args, div_name, visibility
358
   args=ToggleDisplay.arguments;
359
   for (i=0; i<(args.length); i+=1) {
360
      div_name=args[i];
361
      if ( MM_findObj(div_name).style.display == 'block' ) {
362
         MM_findObj(div_name).style.display = 'none';
363
      } else {
364
         MM_findObj(div_name).style.display = 'block';
365
      }
121 hknight 366
 
129 ghuddy 367
   }
119 ghuddy 368
}
369
 
370
function Visible () {
121 hknight 371
 
129 ghuddy 372
   var i, args, div_name, visibility
373
   args=Visible.arguments;
374
   for (i=0; i<(args.length); i+=2) {
375
      div_name=args[i];
376
      visibility=args[i+1]
377
      MM_findObj(div_name).style.display = visibility;
121 hknight 378
 
129 ghuddy 379
   }
119 ghuddy 380
}
381
 
382
function DisplayObjects () {
129 ghuddy 383
   var i, args, div_name
384
   args=DisplayObjects.arguments;
385
   for (i=0; i<(args.length); i+=1) {
386
      div_name=args[i];
387
      MM_findObj(div_name).style.display = 'block';
388
   }
119 ghuddy 389
}
390
 
121 hknight 391
function GetCookieVal (offset) {
129 ghuddy 392
   var endstr = document.cookie.indexOf (";", offset);
393
   if (endstr == -1) { endstr = document.cookie.length; }
394
   return unescape(document.cookie.substring(offset, endstr));
119 ghuddy 395
}
396
 
397
 
121 hknight 398
function GetCookie (name) {
129 ghuddy 399
   var arg = name + "=";
400
   var alen = arg.length;
401
   var clen = document.cookie.length;
402
   var i = 0;
119 ghuddy 403
 
129 ghuddy 404
   while (i < clen) {
405
      var j = i + alen;
406
      if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);
407
      i = document.cookie.indexOf(" ", i) + 1;
408
      if (i == 0) break;
409
   }
119 ghuddy 410
 
129 ghuddy 411
   return null;
119 ghuddy 412
}
413
 
414
function go_submit( formname, actionname )
415
{
129 ghuddy 416
   formname.action.value = actionname;
417
   formname.submit();
119 ghuddy 418
}
419
 
420
function ExpandAll()
421
{
129 ghuddy 422
   var elem
121 hknight 423
 
129 ghuddy 424
   if (document.all)
425
   {
426
      // Run this for IE
427
      elem = document.all;
428
   } else {
429
      // Run this for other browsers
430
      elem = document.getElementsByTagName('div');
431
   }
121 hknight 432
 
129 ghuddy 433
   for (i in elem)
434
   {
435
      if (elem[i].id)
436
      {
437
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
438
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
439
      }
440
   }
121 hknight 441
 
119 ghuddy 442
}
443
 
444
function CollapseAll()
445
{
129 ghuddy 446
   var elem
121 hknight 447
 
129 ghuddy 448
   if (document.all)
449
   {
450
      // Run this for IE
451
      elem = document.all;
452
   } else {
453
      // Run this for other browsers
454
      elem = document.getElementsByTagName('div');
455
   }
121 hknight 456
 
129 ghuddy 457
   for (i in elem)
458
   {
459
      if (elem[i].id)
460
      {
461
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
462
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
463
      }
464
   }
121 hknight 465
 
119 ghuddy 466
}
467
 
468
 
469
function height()
121 hknight 470
{
129 ghuddy 471
   if( typeof( window.innerWidth ) == 'number' )
472
   {
473
      h = window.innerHeight;
474
   }
475
   else if(document.documentElement&&(document.documentElement.clientHeight ))
476
   {
477
      h = document.documentElement.clientHeight;
478
   }
479
   else if( document.body &&   ( document.body.clientWidth || document.body.clientHeight ) )
480
   {
481
      h = document.body.clientHeight;
482
   }
121 hknight 483
 
129 ghuddy 484
   var e = document.getElementById("LayerDescription");
121 hknight 485
 
129 ghuddy 486
   if (navigator.userAgent.indexOf('Internet Explorer'))
487
   {
488
      e.style.height = h - 350 + "px";
489
      e.style.overflow = "auto";
490
   }
491
   else
492
   {
493
      // This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
494
      e.style.minHeight= h - 350 + "px";
495
      e.style.overflow = "auto";
496
   }
119 ghuddy 497
}
498
 
121 hknight 499
//////////////////////////////////////////////////////////////////////////////////////////////////
500
//
501
// MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild)
502
//
503
//    pkgName       eg EA_DocGen
504
//    versionBase   eg 1.2.3
129 ghuddy 505
//    versionExt   eg .cr
121 hknight 506
//    isAutobuild   true or false
133 ghuddy 507
//    isPatch       true or false
121 hknight 508
//
509
// Returns true if version is valid, else false
510
//
511
// This function can and should be used instead of MM_validateForm to validate
512
// version numbers for new or reversioned package versions.
513
//
514
// So far, this function is used in the following situations:
515
//    1) Add new version to release (_form_new_version_page.asp)
516
//    2) Reversion existing version (_wform_rename_version.asp)
517
//    3) Add package to release (Form_add_pkg_versions.asp)
518
//////////////////////////////////////////////////////////////////////////////////////////////////
133 ghuddy 519
function MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild, isPatch)
121 hknight 520
{
133 ghuddy 521
   var errString = MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch);
129 ghuddy 522
   if (errString.length > 0)
523
   {
524
      alert(errString);
525
      return false;
526
   }
527
   return true;
121 hknight 528
}
529
 
530
//////////////////////////////////////////////////////////////////////////////////////////////////
531
//
532
// MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild)
533
//
534
//    pkgName       eg buildtool
535
//    versionBase   eg 1.2.3
129 ghuddy 536
//    versionExt   eg .cr
121 hknight 537
//    isAutobuild   true or false
133 ghuddy 538
//    isPatch       true or false
121 hknight 539
//
540
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
541
//
542
// The MM_validateForm function should be modified to use this if possible, although I currently
543
// do not believe it has access to all the necessary parameter values needed.
544
//
545
//////////////////////////////////////////////////////////////////////////////////////////////////
133 ghuddy 546
function MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch)
121 hknight 547
{
133 ghuddy 548
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
549
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
550
   var re_cots_ver_format  = /^[\w]+[\w\.\-]*$/;   // starts with letter or digit or underscore, subsequent chars can be letters or digits or _ or . or -
129 ghuddy 551
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
552
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
121 hknight 553
 
129 ghuddy 554
   var forPkgName = "";
555
   if (pkgName != null && pkgName.length > 0)
556
   {
557
      forPkgName = ", for package " + pkgName;
558
   }
121 hknight 559
 
133 ghuddy 560
   if (!isAutobuild)
129 ghuddy 561
   {
133 ghuddy 562
      if ( versionBase.length == 0 )
129 ghuddy 563
      {
564
         return "Action failed: version number is of zero length" + forPkgName;
565
      }
133 ghuddy 566
      else if ( versionExt != ".cots" )
129 ghuddy 567
      {
133 ghuddy 568
         if ( isPatch )
569
         {
570
            if ( !re_patch_ver_format.test(versionBase) )
571
            {
572
               return "Action failed: patch version is not of form (integer).(integer).(integer).p(integer).(extension)" + forPkgName;
573
            }
574
         }
575
         else
576
         {
577
            if ( !re_std_ver_format.test(versionBase) )
578
            {
579
               return "Action failed: version is not of form (integer).(integer).(integer).(extension)" + forPkgName;
580
            }
581
         }
129 ghuddy 582
      }
133 ghuddy 583
      else if ( versionExt == ".cots")
129 ghuddy 584
      {
133 ghuddy 585
         if ( !re_cots_ver_format.test(versionBase) )
129 ghuddy 586
         {
587
            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;
588
         }
121 hknight 589
 
133 ghuddy 590
         if ( re_cots_ver_format_exc1.test(versionBase) )
129 ghuddy 591
         {
592
            return "Action failed: COTS version cannot contain two adjacent special characters (underscore/dash/dot)" + forPkgName;
593
         }
121 hknight 594
 
133 ghuddy 595
         if ( !re_cots_ver_format_exc2.test(versionBase) )
129 ghuddy 596
         {
597
            return "Action failed: COTS version must contain one or more alphanumeric characters" + forPkgName;
598
         }
599
      }
600
   }
121 hknight 601
 
129 ghuddy 602
   // everything ok - no error
603
   return "";
121 hknight 604
}
605
 
606
 
607
 
119 ghuddy 608
//-->