Subversion Repositories DevTools

Rev

Details | 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;
121 hknight 85
 
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) {
155
               // Subversion TAG validation
156
               var SVNTagValidCharsRE = /^[0-9a-z_\.\-\/\@]+$/i;
157
               var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
158
               var SVNTagInValidAt = /@[0-9]*[^0-9$]+/i;
159
               var SVNTagInValidSlashAtBOL = /^\/.*$/i;
160
               var SVNTagInValidTrunkRE = /\/trunk[^@$]+/i;
161
               var SVNTagInValidSlashAt = /\/@/i;
162
               var SVNTagInValidAtSlash = /@\//i;
163
               var SVNTagInValidSlash = /^.*\/\/.*$/i;
164
               var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
165
               var SVNTagValidBranchAnywhereRE = /^.*\/branches\/.*$/i;
166
               var SVNTagValidTrunkEOLRE = /^.*\/trunk$/i;
167
               var SVNTagValidTrunkAtNumberRE = /^.*\/trunk@[0-9]+$/i;
121 hknight 168
 
129 ghuddy 169
               if (val.search(SVNTagValidCharsRE) < 0)
170
                  errors += val += ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _ @\n';
171
               else {
172
                  if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
173
                     errors += val += ' - '+nm+' contains /trunk/. This is not allowed.\n';
174
                  else {
175
                     if (val.search(SVNTagInValidAt) >= 0)
176
                        errors += val += ' - '+nm+' contains an @ symbol that is not followed by a numeric value and the end of the line.\n';
177
                     else {
178
                        if (val.search(SVNTagInValidSlashAtBOL) >= 0)
179
                           errors += val += ' - '+nm+' begins with a /. This is not allowed.\n';
180
                        else {
181
                           if (val.search(SVNTagInValidTrunkRE) >= 0)
182
                              errors += val += ' - '+nm+' contains invlaid /trunk. This must be followed by an @<number>, or the end of the line.\n';
183
                           else {
184
                              if ((val.search(SVNTagInValidSlashAt) >= 0) || (val.search(SVNTagInValidAtSlash) >= 0))
185
                                 errors += val += ' - '+nm+' contains /@ or @/. This is not allowed.\n';
186
                              else {
187
                                 if (val.search(SVNTagInValidSlash) >= 0)
188
                                    errors += val += ' - '+nm+' uses //. This is not allowed.\n';
189
                                 else {
190
                                    var count_valid_forms = 0;
121 hknight 191
 
129 ghuddy 192
                                    if (val.search(SVNTagValidTrunkAtNumberRE) >= 0) count_valid_forms++;
121 hknight 193
 
129 ghuddy 194
                                    if (val.search(SVNTagValidTrunkEOLRE) >= 0) count_valid_forms++;
121 hknight 195
 
129 ghuddy 196
                                    if (val.search(SVNTagValidBranchAnywhereRE) >= 0) count_valid_forms++;
121 hknight 197
 
129 ghuddy 198
                                    if (val.search(SVNTagValidTagAnywhereRE) >= 0) count_valid_forms++;
121 hknight 199
 
129 ghuddy 200
                                    if (count_valid_forms == 0) errors += val += ' - '+nm+' does not end in /trunk or /trunk@<number>,\nor does not contain /tags/ or /branches/\n';
121 hknight 201
 
129 ghuddy 202
                                    if (count_valid_forms > 1) errors += val += ' - '+nm+' cannot combine use of trunk, /tags/, or /branches/ in one subversion tag\n';
203
                                 }
204
                              }
205
                           }
206
                        }
207
                     }
208
                  }
209
               }
210
            }
211
 
212
            if (test.indexOf('isVersionNumber')!=-1) {
213
               REresults = val.search(versionNumberRE);
214
               if (REresults < 0) errors += val += ' - '+nm+' is formatted incorrectly.\nVersion number should be (major).(minor).(patch)(build)\ne.g. 1.0.2002\n';
215
            }
216
 
217
            if (test.indexOf('isURL')!=-1) {
218
               REresults = val.match(urlRE);
219
               if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
220
            }
221
 
222
            if (test.indexOf('isChangePassword')!=-1) {
223
               pass=MM_findObj('FRpassword');
224
               passc=MM_findObj('FRpasswordc');
225
               if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
226
            }
227
 
228
            if (test.indexOf('maxLength')!=-1) {
229
               p=test.indexOf(':');
230
               max=test.substring(p+1);
231
               if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
232
            }
233
 
234
            if (test.indexOf('notHTML')!=-1) {
235
               if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
236
            }
237
 
238
            if (test.charAt(0)=='R') {
239
 
240
               if (test.indexOf('isNumber') != -1) {
241
                  if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
242
               }
243
 
244
               if (test.indexOf('inRange') != -1) {
245
                  p=test.indexOf(':');
246
                  min=test.substring(8,p);
247
                  max=test.substring(p+1);
248
                  if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
249
               }
250
 
251
               if (test.indexOf('inLength')!=-1) {
252
                   pl=test.indexOf('inLength')
253
                  p=test.indexOf(':');
254
                      min=test.substring(pl+8,p);
255
                      if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
256
                }
257
            }
258
         } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
259
 
260
 
261
         if (test.indexOf('isPassword')!=-1) {
262
            pass=MM_findObj('FRpassword');
263
            passc=MM_findObj('FRpasswordc');
264
            if (!MM_findObj('FRdomainauth').checked) {
265
               if (test.indexOf('inLength')!=-1) {
266
                   pl=test.indexOf('inLength')
267
                  p=test.indexOf(':');
268
                      min=test.substring(pl+8,p);
269
                      if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
270
                }
271
               if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
272
            } else {
273
               if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
274
            }
275
         }
276
 
277
         if (test.indexOf('isDomainName')!=-1) {
278
            if (MM_findObj('FRdomainauth').checked) {
279
               if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
280
            }
281
         }
282
 
283
      }
284
   }
285
 
286
   if (errors) {
287
      alert('The following error(s) occurred:\n\n'+errors);
288
      clickedButton=false;
289
   } else {
290
      clickedButton=true;
291
   }
292
   document.MM_returnValue = (errors == '');
293
 
294
   if (MM_findObj('ProgressBar') && document.MM_returnValue) MM_findObj('ProgressBar').style.visibility='visible';
119 ghuddy 295
}
296
 
297
function isChecked(boxName, buttonId) {
298
  var formButton = document.getElementById(buttonId);
299
  var boxes = document.getElementsByName(boxName);
300
  var btnChecked = false;
301
  if (formButton) {
302
    for (var i = 0; i < boxes.length; i++) {
303
      if (boxes[i].checked) {
304
        btnChecked = true;
305
      }
306
    }
121 hknight 307
 
119 ghuddy 308
    if (btnChecked) {
309
      formButton.disabled = false;
310
      formButton.style.color="";
311
    }
312
    else {
313
      formButton.disabled = true;
314
      formButton.style.color="silver";
315
    }
316
  }
317
}
318
 
319
function confirmDelete(m)
320
{
129 ghuddy 321
   var agree=confirm('Are you sure you want to delete '+m+'?');
322
   if (agree) {
323
      if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
324
      return true;
325
   } else {
326
      return false;
327
   }
119 ghuddy 328
}
329
 
330
function confirmAction(m)
331
{
129 ghuddy 332
   var agree=confirm(m);
333
   if (agree) {
334
      if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
335
      return true;
336
   } else {
337
      return false;
338
   }
119 ghuddy 339
}
340
 
341
function DisplaySPAN(show) {
129 ghuddy 342
   if (show) {
343
      MM_findObj("spanHideDetails").style.display = "block";
344
      MM_findObj("spanPkgInfo").style.display = "block";
345
      MM_findObj("spanShowDetails").style.display = "none";
346
   } else {
347
      MM_findObj("spanHideDetails").style.display = "none";
348
      MM_findObj("spanPkgInfo").style.display = "none";
349
      MM_findObj("spanShowDetails").style.display = "block";
350
   }
119 ghuddy 351
}
352
 
353
function ToggleDisplay () {
129 ghuddy 354
   var i, args, div_name, visibility
355
   args=ToggleDisplay.arguments;
356
   for (i=0; i<(args.length); i+=1) {
357
      div_name=args[i];
358
      if ( MM_findObj(div_name).style.display == 'block' ) {
359
         MM_findObj(div_name).style.display = 'none';
360
      } else {
361
         MM_findObj(div_name).style.display = 'block';
362
      }
121 hknight 363
 
129 ghuddy 364
   }
119 ghuddy 365
}
366
 
367
function Visible () {
121 hknight 368
 
129 ghuddy 369
   var i, args, div_name, visibility
370
   args=Visible.arguments;
371
   for (i=0; i<(args.length); i+=2) {
372
      div_name=args[i];
373
      visibility=args[i+1]
374
      MM_findObj(div_name).style.display = visibility;
121 hknight 375
 
129 ghuddy 376
   }
119 ghuddy 377
}
378
 
379
function DisplayObjects () {
129 ghuddy 380
   var i, args, div_name
381
   args=DisplayObjects.arguments;
382
   for (i=0; i<(args.length); i+=1) {
383
      div_name=args[i];
384
      MM_findObj(div_name).style.display = 'block';
385
   }
119 ghuddy 386
}
387
 
121 hknight 388
function GetCookieVal (offset) {
129 ghuddy 389
   var endstr = document.cookie.indexOf (";", offset);
390
   if (endstr == -1) { endstr = document.cookie.length; }
391
   return unescape(document.cookie.substring(offset, endstr));
119 ghuddy 392
}
393
 
394
 
121 hknight 395
function GetCookie (name) {
129 ghuddy 396
   var arg = name + "=";
397
   var alen = arg.length;
398
   var clen = document.cookie.length;
399
   var i = 0;
119 ghuddy 400
 
129 ghuddy 401
   while (i < clen) {
402
      var j = i + alen;
403
      if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);
404
      i = document.cookie.indexOf(" ", i) + 1;
405
      if (i == 0) break;
406
   }
119 ghuddy 407
 
129 ghuddy 408
   return null;
119 ghuddy 409
}
410
 
411
function go_submit( formname, actionname )
412
{
129 ghuddy 413
   formname.action.value = actionname;
414
   formname.submit();
119 ghuddy 415
}
416
 
417
function ExpandAll()
418
{
129 ghuddy 419
   var elem
121 hknight 420
 
129 ghuddy 421
   if (document.all)
422
   {
423
      // Run this for IE
424
      elem = document.all;
425
   } else {
426
      // Run this for other browsers
427
      elem = document.getElementsByTagName('div');
428
   }
121 hknight 429
 
129 ghuddy 430
   for (i in elem)
431
   {
432
      if (elem[i].id)
433
      {
434
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
435
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
436
      }
437
   }
121 hknight 438
 
119 ghuddy 439
}
440
 
441
function CollapseAll()
442
{
129 ghuddy 443
   var elem
121 hknight 444
 
129 ghuddy 445
   if (document.all)
446
   {
447
      // Run this for IE
448
      elem = document.all;
449
   } else {
450
      // Run this for other browsers
451
      elem = document.getElementsByTagName('div');
452
   }
121 hknight 453
 
129 ghuddy 454
   for (i in elem)
455
   {
456
      if (elem[i].id)
457
      {
458
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
459
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
460
      }
461
   }
121 hknight 462
 
119 ghuddy 463
}
464
 
465
 
466
function height()
121 hknight 467
{
129 ghuddy 468
   if( typeof( window.innerWidth ) == 'number' )
469
   {
470
      h = window.innerHeight;
471
   }
472
   else if(document.documentElement&&(document.documentElement.clientHeight ))
473
   {
474
      h = document.documentElement.clientHeight;
475
   }
476
   else if( document.body &&   ( document.body.clientWidth || document.body.clientHeight ) )
477
   {
478
      h = document.body.clientHeight;
479
   }
121 hknight 480
 
129 ghuddy 481
   var e = document.getElementById("LayerDescription");
121 hknight 482
 
129 ghuddy 483
   if (navigator.userAgent.indexOf('Internet Explorer'))
484
   {
485
      e.style.height = h - 350 + "px";
486
      e.style.overflow = "auto";
487
   }
488
   else
489
   {
490
      // This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
491
      e.style.minHeight= h - 350 + "px";
492
      e.style.overflow = "auto";
493
   }
119 ghuddy 494
}
495
 
121 hknight 496
//////////////////////////////////////////////////////////////////////////////////////////////////
497
//
498
// MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild)
499
//
500
//    pkgName       eg EA_DocGen
501
//    versionBase   eg 1.2.3
129 ghuddy 502
//    versionExt   eg .cr
121 hknight 503
//    isAutobuild   true or false
133 ghuddy 504
//    isPatch       true or false
121 hknight 505
//
506
// Returns true if version is valid, else false
507
//
508
// This function can and should be used instead of MM_validateForm to validate
509
// version numbers for new or reversioned package versions.
510
//
511
// So far, this function is used in the following situations:
512
//    1) Add new version to release (_form_new_version_page.asp)
513
//    2) Reversion existing version (_wform_rename_version.asp)
514
//    3) Add package to release (Form_add_pkg_versions.asp)
515
//////////////////////////////////////////////////////////////////////////////////////////////////
133 ghuddy 516
function MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild, isPatch)
121 hknight 517
{
133 ghuddy 518
   var errString = MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch);
129 ghuddy 519
   if (errString.length > 0)
520
   {
521
      alert(errString);
522
      return false;
523
   }
524
   return true;
121 hknight 525
}
526
 
527
//////////////////////////////////////////////////////////////////////////////////////////////////
528
//
529
// MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild)
530
//
531
//    pkgName       eg buildtool
532
//    versionBase   eg 1.2.3
129 ghuddy 533
//    versionExt   eg .cr
121 hknight 534
//    isAutobuild   true or false
133 ghuddy 535
//    isPatch       true or false
121 hknight 536
//
537
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
538
//
539
// The MM_validateForm function should be modified to use this if possible, although I currently
540
// do not believe it has access to all the necessary parameter values needed.
541
//
542
//////////////////////////////////////////////////////////////////////////////////////////////////
133 ghuddy 543
function MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch)
121 hknight 544
{
133 ghuddy 545
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
546
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
547
   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 548
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
549
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
121 hknight 550
 
129 ghuddy 551
   var forPkgName = "";
552
   if (pkgName != null && pkgName.length > 0)
553
   {
554
      forPkgName = ", for package " + pkgName;
555
   }
121 hknight 556
 
133 ghuddy 557
   if (!isAutobuild)
129 ghuddy 558
   {
133 ghuddy 559
      if ( versionBase.length == 0 )
129 ghuddy 560
      {
561
         return "Action failed: version number is of zero length" + forPkgName;
562
      }
133 ghuddy 563
      else if ( versionExt != ".cots" )
129 ghuddy 564
      {
133 ghuddy 565
         if ( isPatch )
566
         {
567
            if ( !re_patch_ver_format.test(versionBase) )
568
            {
569
               return "Action failed: patch version is not of form (integer).(integer).(integer).p(integer).(extension)" + forPkgName;
570
            }
571
         }
572
         else
573
         {
574
            if ( !re_std_ver_format.test(versionBase) )
575
            {
576
               return "Action failed: version is not of form (integer).(integer).(integer).(extension)" + forPkgName;
577
            }
578
         }
129 ghuddy 579
      }
133 ghuddy 580
      else if ( versionExt == ".cots")
129 ghuddy 581
      {
133 ghuddy 582
         if ( !re_cots_ver_format.test(versionBase) )
129 ghuddy 583
         {
584
            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;
585
         }
121 hknight 586
 
133 ghuddy 587
         if ( re_cots_ver_format_exc1.test(versionBase) )
129 ghuddy 588
         {
589
            return "Action failed: COTS version cannot contain two adjacent special characters (underscore/dash/dot)" + forPkgName;
590
         }
121 hknight 591
 
133 ghuddy 592
         if ( !re_cots_ver_format_exc2.test(versionBase) )
129 ghuddy 593
         {
594
            return "Action failed: COTS version must contain one or more alphanumeric characters" + forPkgName;
595
         }
596
      }
597
   }
121 hknight 598
 
129 ghuddy 599
   // everything ok - no error
600
   return "";
121 hknight 601
}
602
 
603
 
604
 
119 ghuddy 605
//-->