Subversion Repositories DevTools

Rev

Rev 3895 | 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
2546 dpurdie 52
  window.open(theURL,winName,'left=20,top=20,'+features);
119 ghuddy 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
1372 dpurdie 70
   var ii,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
129 ghuddy 71
   var REresults;
72
   var pass,passc;
3894 dpurdie 73
   var showAlert = true;
121 hknight 74
 
129 ghuddy 75
   // Other general validations
76
   var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
77
   var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
78
   var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
79
   var versionNumberRE = /^\d+\.\d+\.\d+$/;
145 ghuddy 80
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+\.[a-zA-Z0-9]+$/;
129 ghuddy 81
   var urlRE = "^https?://[a-z1-9]";
82
   //character range disallowed
83
   var HTMLchr = /[\<\>\'\"]+/i;
171 brianf 84
   var alphanumRE = /^[a-z0-9]+$/i;
121 hknight 85
 
3894 dpurdie 86
   // Options are first
87
   for (ii=0; ii<(args.length-2) && args[ii].indexOf('--') == 0; ii++) {
88
    switch(args[ii].toLowerCase()) {
89
      case "--silent" :
90
        showAlert = false;
91
        break;
92
    }
93
  }
94
 
3895 dpurdie 95
  // Iterate over arguments
3894 dpurdie 96
  // These are in triplets
3895 dpurdie 97
  //    Name of form object - Value is extracted for user as 'val'
98
  //    Text Prefix for error - 'nm'
99
  //    Type of Test to Perform -'test'
3894 dpurdie 100
   for (; ii<(args.length-2); ii+=3) {
1372 dpurdie 101
      test=args[ii+2];
102
      val=MM_findObj(args[ii]);
121 hknight 103
 
129 ghuddy 104
      if (val) {
1372 dpurdie 105
         nm=args[ii+1];
129 ghuddy 106
         val=val.value;
121 hknight 107
 
129 ghuddy 108
         if (val!="") {
109
            if (test.indexOf('isEmail')!=-1) {
110
               p=val.indexOf('@');
111
               if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
112
            }
121 hknight 113
 
129 ghuddy 114
            if (test.indexOf('isDate') != -1) {
115
               if (val.indexOf("/") != -1) {
116
                  tmpARR = val.split("/");
117
                  if (tmpARR.length == 3) {
118
                     if (!(tmpARR[0]>0  && tmpARR[0]<32  && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
119
                        errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
120
                     }
121
                  } else {
122
                     errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
123
                  }
124
               } else {
125
                  errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
126
               }
127
            }
121 hknight 128
 
129 ghuddy 129
            if (test.indexOf('isPackage')!=-1) {
130
               REresults = val.search(pkgRE);
1372 dpurdie 131
               if (REresults < 0) errors += val + ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
129 ghuddy 132
                        + 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
133
            }
121 hknight 134
 
129 ghuddy 135
            if (test.indexOf('isCleanStr')!=-1) {
136
               REresults = val.search(cleanStrRE);
1372 dpurdie 137
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
129 ghuddy 138
            }
121 hknight 139
 
129 ghuddy 140
            if (test.indexOf('isVersionStr')!=-1) {
141
               REresults = val.search(versionRE);
1372 dpurdie 142
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
129 ghuddy 143
            }
121 hknight 144
 
145 ghuddy 145
            if (test.indexOf('isPatchVersionStr')!=-1) {
146
               if ( !re_patch_ver_format.test(val) ) {
1372 dpurdie 147
                  errors += val + '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
145 ghuddy 148
               }
149
            }
150
 
129 ghuddy 151
            if (test.indexOf('isCCPath')!=-1) {
152
               var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
121 hknight 153
 
2362 dpurdie 154
               REresults = val.search(/^(\\|\/)/);
155
               if (REresults < 0) errors += val + '- '+nm+' must begin with \\ or /\n';
156
 
129 ghuddy 157
               REresults = val.search(CCPathRE);
2362 dpurdie 158
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\n';
129 ghuddy 159
            }
121 hknight 160
 
129 ghuddy 161
            if (test.indexOf('isCCLabel')!=-1) {
162
               var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
121 hknight 163
 
129 ghuddy 164
               REresults = val.search(CCLabelRE);
2362 dpurdie 165
               if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are A-Z a-z 0-9 . - _\n';
129 ghuddy 166
            }
121 hknight 167
 
129 ghuddy 168
            if (test.indexOf('isSVNTag')!=-1) {
1339 dpurdie 169
                // Subversion Tag validation
170
                var SVNTagValidPeg = /^@?\d+$/;
171
                var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
172
 
173
               if ( val.search(SVNTagValidPeg) < 0) {
174
 
1372 dpurdie 175
                    var stripped;
176
                    stripped = val.replace (/@\d+$/,"");
177
                    if (stripped.search(SVNTagRE) < 0)
178
                        errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
1339 dpurdie 179
               }
180
            }
1372 dpurdie 181
 
182
            if (test.indexOf('isSVNPegTag')!=-1 && ! errors) {
183
                // Subversion Tag has peg - Must have done valid check first
184
                var SVNTagPegged = /@?\d+$/;
185
 
186
                if ( val.search(SVNTagPegged) < 0) {
2636 dpurdie 187
                    errors += val + '- '+nm+' Must be pegged for Manually Versioned Package. ie:tag@pegNumber\n';
1372 dpurdie 188
               }
189
            }
1339 dpurdie 190
 
191
            if (test.indexOf('isSVNPath')!=-1) {
192
               // Subversion Base Path validation
193
               var SVNTagValidCharsRE = /^[0-9a-z_\.\-\/]+$/i;
129 ghuddy 194
               var SVNTagInValidSlashAtBOL = /^\/.*$/i;
1339 dpurdie 195
               var SVNTagInValidSlashAtEOL = /\/$/i;
129 ghuddy 196
               var SVNTagInValidSlash = /^.*\/\/.*$/i;
1339 dpurdie 197
               var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
129 ghuddy 198
               var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
121 hknight 199
 
129 ghuddy 200
               if (val.search(SVNTagValidCharsRE) < 0)
1372 dpurdie 201
                  errors += val + ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
1339 dpurdie 202
               else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
1372 dpurdie 203
                  errors += val + ' - '+nm+' begins with a /. This is not allowed.\n';
1339 dpurdie 204
               else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
1372 dpurdie 205
                  errors += val + ' - '+nm+' ends with a /. This is not allowed.\n';
1339 dpurdie 206
               else if (val.search(SVNTagInValidSlash) >= 0)
1372 dpurdie 207
                  errors += val + ' - '+nm+' uses //. This is not allowed.\n';
1339 dpurdie 208
               else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
1372 dpurdie 209
                     errors += val + ' - '+nm+' contains /tags/. This is not allowed.\n';
1339 dpurdie 210
               else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
1372 dpurdie 211
                     errors += val + ' - '+nm+' contains /trunk/. This is not allowed.\n';
129 ghuddy 212
               else {
1339 dpurdie 213
                        var bits = val.split("/");
214
                        if ( bits.length < 4 )
1372 dpurdie 215
                            errors += val + ' - Must contain at least 4 path items.\n';
1339 dpurdie 216
 
217
                        var ttbcount = 0;
1372 dpurdie 218
                        var i
1339 dpurdie 219
                        for (i=0; i < bits.length; i++ )
220
                        {
221
                            var el = bits[i];
222
                            if ( el == 'tags') ttbcount++;
223
                            if ( el == 'trunk') ttbcount++;
224
                            if ( el == 'branches') ttbcount++;
129 ghuddy 225
                        }
1339 dpurdie 226
                        if ( ttbcount != 1 )
1372 dpurdie 227
                            errors += val + ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
1339 dpurdie 228
 
229
                        if ( bits.pop() == 'branches' )    
1372 dpurdie 230
                            errors += val + ' - '+nm+' must not end in branches.\n';
1339 dpurdie 231
 
129 ghuddy 232
                     }
233
            }
234
 
3895 dpurdie 235
            // No longer used. See mm_ValidateVersion
129 ghuddy 236
            if (test.indexOf('isVersionNumber')!=-1) {
237
               REresults = val.search(versionNumberRE);
1372 dpurdie 238
               if (REresults < 0) errors += val + ' - '+nm+' is formatted incorrectly.\nVersion number should be (major).(minor).(patch)(build)\ne.g. 1.0.2002\n';
129 ghuddy 239
            }
240
 
241
            if (test.indexOf('isURL')!=-1) {
242
               REresults = val.match(urlRE);
243
               if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
244
            }
245
 
171 brianf 246
            if (test.indexOf('isAlphaNum')!=-1) {
247
               REresults = val.match(alphanumRE);
248
               if (REresults == null) errors += '"'+nm+'" must be an alphanumeric value.\n';
249
            }
250
 
129 ghuddy 251
            if (test.indexOf('isChangePassword')!=-1) {
252
               pass=MM_findObj('FRpassword');
253
               passc=MM_findObj('FRpasswordc');
254
               if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
255
            }
256
 
257
            if (test.indexOf('maxLength')!=-1) {
258
               p=test.indexOf(':');
259
               max=test.substring(p+1);
260
               if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
261
            }
262
 
263
            if (test.indexOf('notHTML')!=-1) {
264
               if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
265
            }
266
 
267
            if (test.charAt(0)=='R') {
268
 
269
               if (test.indexOf('isNumber') != -1) {
270
                  if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
271
               }
272
 
273
               if (test.indexOf('inRange') != -1) {
274
                  p=test.indexOf(':');
275
                  min=test.substring(8,p);
276
                  max=test.substring(p+1);
277
                  if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
278
               }
279
 
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
            }
287
         } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
288
 
289
 
290
         if (test.indexOf('isPassword')!=-1) {
291
            pass=MM_findObj('FRpassword');
292
            passc=MM_findObj('FRpasswordc');
293
            if (!MM_findObj('FRdomainauth').checked) {
294
               if (test.indexOf('inLength')!=-1) {
295
                   pl=test.indexOf('inLength')
296
                  p=test.indexOf(':');
297
                      min=test.substring(pl+8,p);
298
                      if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
299
                }
300
               if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
301
            } else {
302
               if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
303
            }
304
         }
305
 
306
         if (test.indexOf('isDomainName')!=-1) {
307
            if (MM_findObj('FRdomainauth').checked) {
308
               if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
309
            }
310
         }
3892 dpurdie 311
      }
129 ghuddy 312
   }
313
 
314
   if (errors) {
3895 dpurdie 315
      if ( showAlert )
316
        alert('The following error(s) occurred:\n\n'+errors);
129 ghuddy 317
      clickedButton=false;
318
   } else {
319
      clickedButton=true;
320
   }
321
   document.MM_returnValue = (errors == '');
3892 dpurdie 322
   document.MM_error = errors;
129 ghuddy 323
 
3895 dpurdie 324
  if (document.MM_returnValue && showAlert)
325
    MM_showProgressBar();
119 ghuddy 326
}
327
 
3895 dpurdie 328
function MM_showProgressBar() {
329
  var pb = MM_findObj('ProgressBar');
330
  if ( pb )
331
    pb.style.visibility='visible';
332
}
333
 
334
function MM_hideProgressBar() {
335
  var pb = MM_findObj('ProgressBar');
336
  if ( pb )
337
    pb.style.visibility='hidden';
338
}
339
 
340
 
119 ghuddy 341
function isChecked(boxName, buttonId) {
342
  var formButton = document.getElementById(buttonId);
343
  var boxes = document.getElementsByName(boxName);
344
  var btnChecked = false;
345
  if (formButton) {
346
    for (var i = 0; i < boxes.length; i++) {
347
      if (boxes[i].checked) {
348
        btnChecked = true;
349
      }
350
    }
121 hknight 351
 
119 ghuddy 352
    if (btnChecked) {
353
      formButton.disabled = false;
354
      formButton.style.color="";
355
    }
356
    else {
357
      formButton.disabled = true;
358
      formButton.style.color="silver";
359
    }
360
  }
361
}
362
 
363
function confirmDelete(m)
364
{
129 ghuddy 365
   var agree=confirm('Are you sure you want to delete '+m+'?');
366
   if (agree) {
3895 dpurdie 367
      MM_showProgressBar();
129 ghuddy 368
      return true;
369
   } else {
370
      return false;
371
   }
119 ghuddy 372
}
373
 
374
function confirmAction(m)
375
{
129 ghuddy 376
   var agree=confirm(m);
377
   if (agree) {
3895 dpurdie 378
      MM_showProgressBar();
129 ghuddy 379
      return true;
380
   } else {
381
      return false;
382
   }
119 ghuddy 383
}
384
 
385
function DisplaySPAN(show) {
129 ghuddy 386
   if (show) {
387
      MM_findObj("spanHideDetails").style.display = "block";
388
      MM_findObj("spanPkgInfo").style.display = "block";
389
      MM_findObj("spanShowDetails").style.display = "none";
390
   } else {
391
      MM_findObj("spanHideDetails").style.display = "none";
392
      MM_findObj("spanPkgInfo").style.display = "none";
393
      MM_findObj("spanShowDetails").style.display = "block";
394
   }
119 ghuddy 395
}
396
 
397
function ToggleDisplay () {
129 ghuddy 398
   var i, args, div_name, visibility
399
   args=ToggleDisplay.arguments;
400
   for (i=0; i<(args.length); i+=1) {
401
      div_name=args[i];
402
      if ( MM_findObj(div_name).style.display == 'block' ) {
403
         MM_findObj(div_name).style.display = 'none';
404
      } else {
405
         MM_findObj(div_name).style.display = 'block';
406
      }
121 hknight 407
 
129 ghuddy 408
   }
119 ghuddy 409
}
410
 
411
function Visible () {
121 hknight 412
 
129 ghuddy 413
   var i, args, div_name, visibility
414
   args=Visible.arguments;
415
   for (i=0; i<(args.length); i+=2) {
416
      div_name=args[i];
417
      visibility=args[i+1]
418
      MM_findObj(div_name).style.display = visibility;
121 hknight 419
 
129 ghuddy 420
   }
119 ghuddy 421
}
422
 
423
function DisplayObjects () {
129 ghuddy 424
   var i, args, div_name
425
   args=DisplayObjects.arguments;
426
   for (i=0; i<(args.length); i+=1) {
427
      div_name=args[i];
428
      MM_findObj(div_name).style.display = 'block';
429
   }
119 ghuddy 430
}
431
 
121 hknight 432
function GetCookieVal (offset) {
129 ghuddy 433
   var endstr = document.cookie.indexOf (";", offset);
434
   if (endstr == -1) { endstr = document.cookie.length; }
435
   return unescape(document.cookie.substring(offset, endstr));
119 ghuddy 436
}
437
 
438
 
121 hknight 439
function GetCookie (name) {
129 ghuddy 440
   var arg = name + "=";
441
   var alen = arg.length;
442
   var clen = document.cookie.length;
443
   var i = 0;
119 ghuddy 444
 
129 ghuddy 445
   while (i < clen) {
446
      var j = i + alen;
447
      if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);
448
      i = document.cookie.indexOf(" ", i) + 1;
449
      if (i == 0) break;
450
   }
119 ghuddy 451
 
129 ghuddy 452
   return null;
119 ghuddy 453
}
454
 
455
function go_submit( formname, actionname )
456
{
129 ghuddy 457
   formname.action.value = actionname;
458
   formname.submit();
119 ghuddy 459
}
460
 
461
function ExpandAll()
462
{
129 ghuddy 463
   var elem
121 hknight 464
 
129 ghuddy 465
   if (document.all)
466
   {
467
      // Run this for IE
468
      elem = document.all;
469
   } else {
470
      // Run this for other browsers
471
      elem = document.getElementsByTagName('div');
472
   }
121 hknight 473
 
129 ghuddy 474
   for (i in elem)
475
   {
476
      if (elem[i].id)
477
      {
478
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
479
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
480
      }
481
   }
121 hknight 482
 
119 ghuddy 483
}
484
 
485
function CollapseAll()
486
{
129 ghuddy 487
   var elem
121 hknight 488
 
129 ghuddy 489
   if (document.all)
490
   {
491
      // Run this for IE
492
      elem = document.all;
493
   } else {
494
      // Run this for other browsers
495
      elem = document.getElementsByTagName('div');
496
   }
121 hknight 497
 
129 ghuddy 498
   for (i in elem)
499
   {
500
      if (elem[i].id)
501
      {
502
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
503
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
504
      }
505
   }
121 hknight 506
 
119 ghuddy 507
}
508
 
509
 
510
function height()
121 hknight 511
{
129 ghuddy 512
   if( typeof( window.innerWidth ) == 'number' )
513
   {
514
      h = window.innerHeight;
515
   }
516
   else if(document.documentElement&&(document.documentElement.clientHeight ))
517
   {
518
      h = document.documentElement.clientHeight;
519
   }
520
   else if( document.body &&   ( document.body.clientWidth || document.body.clientHeight ) )
521
   {
522
      h = document.body.clientHeight;
523
   }
121 hknight 524
 
129 ghuddy 525
   var e = document.getElementById("LayerDescription");
121 hknight 526
 
129 ghuddy 527
   if (navigator.userAgent.indexOf('Internet Explorer'))
528
   {
529
      e.style.height = h - 350 + "px";
530
      e.style.overflow = "auto";
531
   }
532
   else
533
   {
534
      // This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
535
      e.style.minHeight= h - 350 + "px";
536
      e.style.overflow = "auto";
537
   }
119 ghuddy 538
}
539
 
121 hknight 540
//////////////////////////////////////////////////////////////////////////////////////////////////
541
//
542
// MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild)
543
//
544
//    pkgName       eg EA_DocGen
545
//    versionBase   eg 1.2.3
129 ghuddy 546
//    versionExt   eg .cr
121 hknight 547
//    isAutobuild   true or false
133 ghuddy 548
//    isPatch       true or false
121 hknight 549
//
550
// Returns true if version is valid, else false
551
//
552
// This function can and should be used instead of MM_validateForm to validate
553
// version numbers for new or reversioned package versions.
554
//
555
// So far, this function is used in the following situations:
556
//    1) Add new version to release (_form_new_version_page.asp)
557
//    2) Reversion existing version (_wform_rename_version.asp)
558
//    3) Add package to release (Form_add_pkg_versions.asp)
559
//////////////////////////////////////////////////////////////////////////////////////////////////
133 ghuddy 560
function MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild, isPatch)
121 hknight 561
{
133 ghuddy 562
   var errString = MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch);
129 ghuddy 563
   if (errString.length > 0)
564
   {
565
      alert(errString);
566
      return false;
567
   }
568
   return true;
121 hknight 569
}
570
 
571
//////////////////////////////////////////////////////////////////////////////////////////////////
572
//
573
// MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild)
574
//
575
//    pkgName       eg buildtool
576
//    versionBase   eg 1.2.3
129 ghuddy 577
//    versionExt   eg .cr
121 hknight 578
//    isAutobuild   true or false
133 ghuddy 579
//    isPatch       true or false
121 hknight 580
//
581
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
582
//
583
// The MM_validateForm function should be modified to use this if possible, although I currently
584
// do not believe it has access to all the necessary parameter values needed.
585
//
586
//////////////////////////////////////////////////////////////////////////////////////////////////
133 ghuddy 587
function MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch)
121 hknight 588
{
133 ghuddy 589
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
590
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
591
   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 592
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
593
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
121 hknight 594
 
129 ghuddy 595
   var forPkgName = "";
596
   if (pkgName != null && pkgName.length > 0)
597
   {
598
      forPkgName = ", for package " + pkgName;
599
   }
121 hknight 600
 
133 ghuddy 601
   if (!isAutobuild)
129 ghuddy 602
   {
133 ghuddy 603
      if ( versionBase.length == 0 )
129 ghuddy 604
      {
605
         return "Action failed: version number is of zero length" + forPkgName;
606
      }
3621 dpurdie 607
      else if ( versionExt != ".cots" && versionExt != ".tool")
129 ghuddy 608
      {
133 ghuddy 609
         if ( isPatch )
610
         {
611
            if ( !re_patch_ver_format.test(versionBase) )
612
            {
613
               return "Action failed: patch version is not of form (integer).(integer).(integer).p(integer).(extension)" + forPkgName;
614
            }
615
         }
616
         else
617
         {
618
            if ( !re_std_ver_format.test(versionBase) )
619
            {
620
               return "Action failed: version is not of form (integer).(integer).(integer).(extension)" + forPkgName;
621
            }
622
         }
129 ghuddy 623
      }
3621 dpurdie 624
      else if ( versionExt == ".cots" || versionExt == ".tool")
129 ghuddy 625
      {
3621 dpurdie 626
         var extName = versionExt.toUpperCase().substr(1);
627
 
133 ghuddy 628
         if ( !re_cots_ver_format.test(versionBase) )
129 ghuddy 629
         {
3621 dpurdie 630
            return "Action failed: " + extName + " version must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed" + forPkgName;
129 ghuddy 631
         }
121 hknight 632
 
133 ghuddy 633
         if ( re_cots_ver_format_exc1.test(versionBase) )
129 ghuddy 634
         {
3621 dpurdie 635
            return "Action failed: " + extName + " version cannot contain two adjacent special characters (underscore/dash/dot)" + forPkgName;
129 ghuddy 636
         }
121 hknight 637
 
133 ghuddy 638
         if ( !re_cots_ver_format_exc2.test(versionBase) )
129 ghuddy 639
         {
3621 dpurdie 640
            return "Action failed: " + extName + " version must contain one or more alphanumeric characters" + forPkgName;
129 ghuddy 641
         }
642
      }
643
   }
121 hknight 644
 
129 ghuddy 645
   // everything ok - no error
646
   return "";
121 hknight 647
}
648
 
649
 
3895 dpurdie 650
// Manipulate the class list for a given element
651
function hasClass(ele, cls) {
652
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
653
}
121 hknight 654
 
3895 dpurdie 655
function addClass(ele, cls) {
656
    if (!this.hasClass(ele, cls)) ele.className += " " + cls;
657
}
658
 
659
function removeClass(ele, cls) {
660
    if (hasClass(ele, cls)) {
661
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
662
        ele.className = ele.className.replace(reg, ' ');
663
    }
664
}
665
 
666
function toggleClass(ele, cls1, cls2){
667
    if(hasClass(ele, cls1)){
668
        replaceClass(ele, cls1, cls2);
669
    }else if(hasClass(ele, cls2)){
670
        replaceClass(ele, cls2, cls1);
671
    }else{
672
        addClass(ele, cls1);
673
    }
674
}
675
 
676
// Highlight combobox if selection is zero
677
// Returns true:  None-zero selection
678
// Returns false: Invalid element or item-0 selected
679
function checkSeletion(el)
680
{
681
   if (el ) {
682
     if ( el.selectedIndex == 0) {
683
        addClass(el, 'form_error');
684
     } else {
685
        removeClass(el, 'form_error');
686
        return true;
687
     }
688
   }
689
   return false;
690
}
691
 
3898 dpurdie 692
function getElementsByClassName(classname, node)  {
693
    if(!node) node = document.getElementsByTagName("body")[0];
694
    var a = [];
695
    var re = new RegExp('\\b' + classname + '\\b');
696
    var els = node.getElementsByTagName("*");
697
    for(var i=0,j=els.length; i<j; i++)
698
        if(re.test(els[i].className))a.push(els[i]);
699
    return a;
700
}
701
 
702
function setCookie(c_name,value,exdays)
703
{
704
  var exdate=new Date();
705
  exdate.setDate(exdate.getDate() + exdays);
706
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
707
  document.cookie=c_name + "=" + c_value;
708
}
709
 
710
function getCookie(c_name)
711
{
712
  var c_value = document.cookie;
713
  var c_start = c_value.indexOf(" " + c_name + "=");
714
  if (c_start == -1)
715
  {
716
    c_start = c_value.indexOf(c_name + "=");
717
  }
718
  if (c_start == -1)
719
  {
720
    c_value = null;
721
  }
722
  else
723
  {
724
    c_start = c_value.indexOf("=", c_start) + 1;
725
    var c_end = c_value.indexOf(";", c_start);
726
    if (c_end == -1)
727
    {
728
      c_end = c_value.length;
729
    }
730
  c_value = unescape(c_value.substring(c_start,c_end));
731
}
732
return c_value;
733
}
734
 
119 ghuddy 735
//-->