Subversion Repositories DevTools

Rev

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