Subversion Repositories DevTools

Rev

Rev 6613 | 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
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
 
3959 dpurdie 261
              // No longer used in this simple form
262
              if (test.indexOf('isVersionNumber')!=-1) {
263
                 REresults = -1;
5596 dpurdie 264
                 if (REresults < 0) errors += prefix + ' isVersionNumber is no longer supported in this form';
3959 dpurdie 265
              }
129 ghuddy 266
 
3959 dpurdie 267
              if (test.indexOf('isURL')!=-1) {
268
                 REresults = val.match(urlRE);
269
                 if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
270
              }
129 ghuddy 271
 
3959 dpurdie 272
              if (test.indexOf('isAlphaNum')!=-1) {
273
                 REresults = val.match(alphanumRE);
274
                 if (REresults == null) errors += '"'+nm+'" must be an alphanumeric value.\n';
275
              }
171 brianf 276
 
3959 dpurdie 277
              if (test.indexOf('isChangePassword')!=-1) {
278
                 pass=MM_findObj('FRpassword');
279
                 passc=MM_findObj('FRpasswordc');
280
                 if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
281
              }
129 ghuddy 282
 
3959 dpurdie 283
              if (test.indexOf('maxLength')!=-1) {
284
                 p=test.indexOf(':');
285
                 max=test.substring(p+1);
286
                 if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
287
              }
129 ghuddy 288
 
4025 dpurdie 289
              if (test.indexOf('minLength')!=-1) {
290
                 p=test.indexOf(':');
291
                 max=test.substring(p+1);
292
                 if (val.length<max) errors+='- '+nm+' must be minimum '+max+' characters long.\n';
293
              }
294
 
3959 dpurdie 295
              if (test.indexOf('notHTML')!=-1) {
296
                 if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
297
              }
129 ghuddy 298
 
3959 dpurdie 299
              if (test.charAt(0)=='R') {
129 ghuddy 300
 
3959 dpurdie 301
                 if (test.indexOf('isNumber') != -1) {
302
                    if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
303
                 }
129 ghuddy 304
 
3959 dpurdie 305
                 if (test.indexOf('inRange') != -1) {
306
                    p=test.indexOf(':');
307
                    min=test.substring(8,p);
308
                    max=test.substring(p+1);
309
                    if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
310
                 }
129 ghuddy 311
 
3959 dpurdie 312
                 if (test.indexOf('inLength')!=-1) {
313
                     pl=test.indexOf('inLength')
314
                    p=test.indexOf(':');
315
                        min=test.substring(pl+8,p);
316
                        if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
317
                  }
318
              }
319
           } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
129 ghuddy 320
 
321
 
3959 dpurdie 322
           if (test.indexOf('isPassword')!=-1) {
323
              pass=MM_findObj('FRpassword');
324
              passc=MM_findObj('FRpasswordc');
325
              if (!MM_findObj('FRdomainauth').checked) {
326
                 if (test.indexOf('inLength')!=-1) {
327
                     pl=test.indexOf('inLength')
328
                    p=test.indexOf(':');
329
                        min=test.substring(pl+8,p);
330
                        if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
331
                  }
332
                 if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
333
              } else {
334
                 if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
335
              }
336
           }
129 ghuddy 337
 
3959 dpurdie 338
           if (test.indexOf('isDomainName')!=-1) {
339
              if (MM_findObj('FRdomainauth').checked) {
340
                 if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
341
              }
342
           }
343
        }
344
      }
345
      else {
346
        // Alternate form. First item is an object
347
        // Contents are test specific
348
        var valp = args[ii];
129 ghuddy 349
 
3959 dpurdie 350
          // Expects object with data to examine
351
        if (test.indexOf('isVersionNumber')!=-1) {
352
          var rv = MM_ValidateVersion(valp.vBase, valp.vExt, valp.isAuto || false, valp.isPatch || false);
353
          if ( rv )
354
            errors += '- ' +nm+rv;
355
        }
129 ghuddy 356
      }
357
   }
358
 
359
   if (errors) {
3959 dpurdie 360
      if ( showAlert )
361
        alert('The following error(s) occurred:\n\n'+errors);
129 ghuddy 362
      clickedButton=false;
363
   } else {
364
      clickedButton=true;
365
   }
366
   document.MM_returnValue = (errors == '');
3959 dpurdie 367
   document.MM_error = errors;
129 ghuddy 368
 
3959 dpurdie 369
  if (document.MM_returnValue && showAlert)
370
    MM_showProgressBar();
119 ghuddy 371
}
372
 
3959 dpurdie 373
function MM_showProgressBar() {
374
  var pb = MM_findObj('ProgressBar');
375
  if ( pb )
376
    pb.style.visibility='visible';
5590 dpurdie 377
  else {
378
	  pb = MM_findObj('divProgressBar');
379
	  if ( pb )
380
		pb.style.visibility='visible';
381
  }
3959 dpurdie 382
}
383
 
384
function MM_hideProgressBar() {
7288 dpurdie 385
    var pb = MM_findObj('ProgressBar');
386
    if ( pb )
387
      pb.style.visibility='hidden';
388
    else {
389
        pb = MM_findObj('divProgressBar');
390
        if ( pb )
391
          pb.style.visibility='hidden';
392
    }
3959 dpurdie 393
}
394
 
119 ghuddy 395
function isChecked(boxName, buttonId) {
396
  var formButton = document.getElementById(buttonId);
397
  var boxes = document.getElementsByName(boxName);
398
  var btnChecked = false;
399
  if (formButton) {
400
    for (var i = 0; i < boxes.length; i++) {
401
      if (boxes[i].checked) {
402
        btnChecked = true;
403
      }
404
    }
121 hknight 405
 
119 ghuddy 406
    if (btnChecked) {
407
      formButton.disabled = false;
408
      formButton.style.color="";
409
    }
410
    else {
411
      formButton.disabled = true;
412
      formButton.style.color="silver";
413
    }
414
  }
415
}
416
 
417
function DisplaySPAN(show) {
129 ghuddy 418
   if (show) {
419
      MM_findObj("spanHideDetails").style.display = "block";
420
      MM_findObj("spanPkgInfo").style.display = "block";
421
      MM_findObj("spanShowDetails").style.display = "none";
422
   } else {
423
      MM_findObj("spanHideDetails").style.display = "none";
424
      MM_findObj("spanPkgInfo").style.display = "none";
425
      MM_findObj("spanShowDetails").style.display = "block";
426
   }
119 ghuddy 427
}
428
 
429
function ToggleDisplay () {
4388 dpurdie 430
   var i, args, div_name, el
129 ghuddy 431
   args=ToggleDisplay.arguments;
432
   for (i=0; i<(args.length); i+=1) {
433
      div_name=args[i];
4388 dpurdie 434
      el = MM_findObj(div_name);
435
      if (el) { 
436
        if ( el.style.display == 'block' ) {
437
           el.style.display = 'none';
438
        } else {
439
           el.style.display = 'block';
440
        }
441
     }
129 ghuddy 442
   }
119 ghuddy 443
}
444
 
6613 dpurdie 445
function ToggleDisplayNone () {
446
   var i, args, div_name, el
447
   args=ToggleDisplayNone.arguments;
448
   for (i=0; i<(args.length); i+=1) {
449
      div_name=args[i];
450
      el = MM_findObj(div_name);
451
      if (el) { 
452
        if ( el.style.display == 'none' ) {
453
           el.style.display = '';
454
        } else {
455
           el.style.display = 'none';
456
        }
457
     }
458
   }
459
}
460
 
119 ghuddy 461
function Visible () {
121 hknight 462
 
129 ghuddy 463
   var i, args, div_name, visibility
464
   args=Visible.arguments;
465
   for (i=0; i<(args.length); i+=2) {
466
      div_name=args[i];
467
      visibility=args[i+1]
468
      MM_findObj(div_name).style.display = visibility;
121 hknight 469
 
129 ghuddy 470
   }
119 ghuddy 471
}
472
 
473
function DisplayObjects () {
129 ghuddy 474
   var i, args, div_name
475
   args=DisplayObjects.arguments;
476
   for (i=0; i<(args.length); i+=1) {
477
      div_name=args[i];
478
      MM_findObj(div_name).style.display = 'block';
479
   }
119 ghuddy 480
}
481
 
121 hknight 482
function GetCookieVal (offset) {
129 ghuddy 483
   var endstr = document.cookie.indexOf (";", offset);
484
   if (endstr == -1) { endstr = document.cookie.length; }
485
   return unescape(document.cookie.substring(offset, endstr));
119 ghuddy 486
}
487
 
488
 
121 hknight 489
function GetCookie (name) {
129 ghuddy 490
   var arg = name + "=";
491
   var alen = arg.length;
492
   var clen = document.cookie.length;
493
   var i = 0;
119 ghuddy 494
 
129 ghuddy 495
   while (i < clen) {
496
      var j = i + alen;
497
      if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);
498
      i = document.cookie.indexOf(" ", i) + 1;
499
      if (i == 0) break;
500
   }
119 ghuddy 501
 
129 ghuddy 502
   return null;
119 ghuddy 503
}
504
 
505
function go_submit( formname, actionname )
506
{
129 ghuddy 507
   formname.action.value = actionname;
508
   formname.submit();
119 ghuddy 509
}
510
 
511
function ExpandAll()
512
{
129 ghuddy 513
   var elem
121 hknight 514
 
129 ghuddy 515
   if (document.all)
516
   {
517
      // Run this for IE
518
      elem = document.all;
519
   } else {
520
      // Run this for other browsers
521
      elem = document.getElementsByTagName('div');
522
   }
121 hknight 523
 
129 ghuddy 524
   for (i in elem)
525
   {
526
      if (elem[i].id)
527
      {
528
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
529
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
530
      }
531
   }
121 hknight 532
 
119 ghuddy 533
}
534
 
535
function CollapseAll()
536
{
129 ghuddy 537
   var elem
121 hknight 538
 
129 ghuddy 539
   if (document.all)
540
   {
541
      // Run this for IE
542
      elem = document.all;
543
   } else {
544
      // Run this for other browsers
545
      elem = document.getElementsByTagName('div');
546
   }
121 hknight 547
 
129 ghuddy 548
   for (i in elem)
549
   {
550
      if (elem[i].id)
551
      {
552
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
553
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
554
      }
555
   }
121 hknight 556
 
119 ghuddy 557
}
558
 
559
 
560
function height()
121 hknight 561
{
129 ghuddy 562
   if( typeof( window.innerWidth ) == 'number' )
563
   {
564
      h = window.innerHeight;
565
   }
566
   else if(document.documentElement&&(document.documentElement.clientHeight ))
567
   {
568
      h = document.documentElement.clientHeight;
569
   }
570
   else if( document.body &&   ( document.body.clientWidth || document.body.clientHeight ) )
571
   {
572
      h = document.body.clientHeight;
573
   }
121 hknight 574
 
129 ghuddy 575
   var e = document.getElementById("LayerDescription");
121 hknight 576
 
129 ghuddy 577
   if (navigator.userAgent.indexOf('Internet Explorer'))
578
   {
579
      e.style.height = h - 350 + "px";
580
      e.style.overflow = "auto";
581
   }
582
   else
583
   {
584
      // This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
585
      e.style.minHeight= h - 350 + "px";
586
      e.style.overflow = "auto";
587
   }
119 ghuddy 588
}
589
 
121 hknight 590
//////////////////////////////////////////////////////////////////////////////////////////////////
591
//
3959 dpurdie 592
// MM_ValidateVersion(versionBase, versionExt, isAutobuild isPatch)
593
// Should NOT be used externally. Use MM_validateForm to access this function
121 hknight 594
//
595
//    versionBase   eg 1.2.3
3959 dpurdie 596
//    versionExt    eg .cr
121 hknight 597
//    isAutobuild   true or false
133 ghuddy 598
//    isPatch       true or false
121 hknight 599
//
600
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
601
//
602
//////////////////////////////////////////////////////////////////////////////////////////////////
3959 dpurdie 603
function MM_ValidateVersion(versionBase, versionExt, isAutobuild, isPatch)
121 hknight 604
{
133 ghuddy 605
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
606
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
607
   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 608
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
609
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
5791 dpurdie 610
   var re_cots_ver_format_end = /\.\d{4,}$/;    // Must have a patch build number. ie: .nnnn or .
611
 
3959 dpurdie 612
   var isCots = versionExt == ".cots" || versionExt == ".tool";
121 hknight 613
 
3959 dpurdie 614
   if (!isAutobuild) {
615
      if ( versionBase.length == 0 ) {
616
         return " is of zero length";
617
      } else if ( !isCots) {
618
         if ( isPatch ) {
619
            if ( !re_patch_ver_format.test(versionBase) ) {
620
               return " is not of form (integer).(integer).(integer).p(integer)";
133 ghuddy 621
            }
3959 dpurdie 622
         } else {
623
            if ( !re_std_ver_format.test(versionBase) ) {
624
               return " is not of form (integer).(integer).(integer)";
133 ghuddy 625
            }
626
         }
3959 dpurdie 627
      } else if (isCots) {
628
         var extName = versionExt.toUpperCase().substr(1);
629
 
630
         if ( !re_cots_ver_format.test(versionBase) ) {
631
            return " " + extName + " package must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed";
129 ghuddy 632
         }
121 hknight 633
 
3959 dpurdie 634
         if ( re_cots_ver_format_exc1.test(versionBase) ) {
635
            return " " + extName + " package cannot contain two adjacent special characters (underscore/dash/dot)";
129 ghuddy 636
         }
121 hknight 637
 
3959 dpurdie 638
         if ( !re_cots_ver_format_exc2.test(versionBase) ) {
639
            return " " + extName + " package must contain one or more alphanumeric characters";
129 ghuddy 640
         }
5791 dpurdie 641
 
642
         if ( !re_cots_ver_format_end.test(versionBase) ) {
643
		    return " " + extName + " package must end with a patchBuild number (ie: .0000)";
644
         }
129 ghuddy 645
      }
646
   }
121 hknight 647
 
129 ghuddy 648
   // everything ok - no error
649
   return "";
121 hknight 650
}
651
 
652
 
3959 dpurdie 653
// Manipulate the class list for a given element
654
function hasClass(ele, cls) {
655
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
656
}
121 hknight 657
 
3959 dpurdie 658
function addClass(ele, cls) {
659
    if (!this.hasClass(ele, cls)) ele.className += " " + cls;
660
}
661
 
662
function removeClass(ele, cls) {
663
    if (hasClass(ele, cls)) {
664
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
665
        ele.className = ele.className.replace(reg, ' ');
666
    }
667
}
668
 
669
function toggleClass(ele, cls1, cls2){
670
    if(hasClass(ele, cls1)){
671
        replaceClass(ele, cls1, cls2);
672
    }else if(hasClass(ele, cls2)){
673
        replaceClass(ele, cls2, cls1);
674
    }else{
675
        addClass(ele, cls1);
676
    }
677
}
678
 
679
// Highlight combobox if selection is zero
680
// Returns true:  None-zero selection
681
// Returns false: Invalid element or item-0 selected
682
function checkSeletion(el)
683
{
684
   if (el ) {
685
     if ( el.selectedIndex == 0) {
686
        addClass(el, 'form_error');
687
     } else {
688
        removeClass(el, 'form_error');
689
        return true;
690
     }
691
   }
692
   return false;
693
}
694
 
695
function getElementsByClassName(classname, node)  {
696
    if(!node) node = document.getElementsByTagName("body")[0];
697
    var a = [];
698
    var re = new RegExp('\\b' + classname + '\\b');
699
    var els = node.getElementsByTagName("*");
700
    for(var i=0,j=els.length; i<j; i++)
701
        if(re.test(els[i].className))a.push(els[i]);
702
    return a;
703
}
704
 
705
function setCookie(c_name,value,exdays)
706
{
707
  var exdate=new Date();
708
  exdate.setDate(exdate.getDate() + exdays);
709
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
710
  document.cookie=c_name + "=" + c_value;
711
}
712
 
713
function getCookie(c_name)
714
{
715
  var c_value = document.cookie;
716
  var c_start = c_value.indexOf(" " + c_name + "=");
717
  if (c_start == -1)
718
  {
719
    c_start = c_value.indexOf(c_name + "=");
720
  }
721
  if (c_start == -1)
722
  {
723
    c_value = null;
724
  }
725
  else
726
  {
727
    c_start = c_value.indexOf("=", c_start) + 1;
728
    var c_end = c_value.indexOf(";", c_start);
729
    if (c_end == -1)
730
    {
731
      c_end = c_value.length;
732
    }
733
  c_value = unescape(c_value.substring(c_start,c_end));
734
}
735
return c_value;
736
}
737
 
119 ghuddy 738
//-->