Subversion Repositories DevTools

Rev

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