Subversion Repositories DevTools

Rev

Rev 5596 | 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() {
385
  var pb = MM_findObj('ProgressBar');
386
  if ( pb )
387
    pb.style.visibility='hidden';
388
}
389
 
119 ghuddy 390
function isChecked(boxName, buttonId) {
391
  var formButton = document.getElementById(buttonId);
392
  var boxes = document.getElementsByName(boxName);
393
  var btnChecked = false;
394
  if (formButton) {
395
    for (var i = 0; i < boxes.length; i++) {
396
      if (boxes[i].checked) {
397
        btnChecked = true;
398
      }
399
    }
121 hknight 400
 
119 ghuddy 401
    if (btnChecked) {
402
      formButton.disabled = false;
403
      formButton.style.color="";
404
    }
405
    else {
406
      formButton.disabled = true;
407
      formButton.style.color="silver";
408
    }
409
  }
410
}
411
 
412
function DisplaySPAN(show) {
129 ghuddy 413
   if (show) {
414
      MM_findObj("spanHideDetails").style.display = "block";
415
      MM_findObj("spanPkgInfo").style.display = "block";
416
      MM_findObj("spanShowDetails").style.display = "none";
417
   } else {
418
      MM_findObj("spanHideDetails").style.display = "none";
419
      MM_findObj("spanPkgInfo").style.display = "none";
420
      MM_findObj("spanShowDetails").style.display = "block";
421
   }
119 ghuddy 422
}
423
 
424
function ToggleDisplay () {
4388 dpurdie 425
   var i, args, div_name, el
129 ghuddy 426
   args=ToggleDisplay.arguments;
427
   for (i=0; i<(args.length); i+=1) {
428
      div_name=args[i];
4388 dpurdie 429
      el = MM_findObj(div_name);
430
      if (el) { 
431
        if ( el.style.display == 'block' ) {
432
           el.style.display = 'none';
433
        } else {
434
           el.style.display = 'block';
435
        }
436
     }
129 ghuddy 437
   }
119 ghuddy 438
}
439
 
440
function Visible () {
121 hknight 441
 
129 ghuddy 442
   var i, args, div_name, visibility
443
   args=Visible.arguments;
444
   for (i=0; i<(args.length); i+=2) {
445
      div_name=args[i];
446
      visibility=args[i+1]
447
      MM_findObj(div_name).style.display = visibility;
121 hknight 448
 
129 ghuddy 449
   }
119 ghuddy 450
}
451
 
452
function DisplayObjects () {
129 ghuddy 453
   var i, args, div_name
454
   args=DisplayObjects.arguments;
455
   for (i=0; i<(args.length); i+=1) {
456
      div_name=args[i];
457
      MM_findObj(div_name).style.display = 'block';
458
   }
119 ghuddy 459
}
460
 
121 hknight 461
function GetCookieVal (offset) {
129 ghuddy 462
   var endstr = document.cookie.indexOf (";", offset);
463
   if (endstr == -1) { endstr = document.cookie.length; }
464
   return unescape(document.cookie.substring(offset, endstr));
119 ghuddy 465
}
466
 
467
 
121 hknight 468
function GetCookie (name) {
129 ghuddy 469
   var arg = name + "=";
470
   var alen = arg.length;
471
   var clen = document.cookie.length;
472
   var i = 0;
119 ghuddy 473
 
129 ghuddy 474
   while (i < clen) {
475
      var j = i + alen;
476
      if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);
477
      i = document.cookie.indexOf(" ", i) + 1;
478
      if (i == 0) break;
479
   }
119 ghuddy 480
 
129 ghuddy 481
   return null;
119 ghuddy 482
}
483
 
484
function go_submit( formname, actionname )
485
{
129 ghuddy 486
   formname.action.value = actionname;
487
   formname.submit();
119 ghuddy 488
}
489
 
490
function ExpandAll()
491
{
129 ghuddy 492
   var elem
121 hknight 493
 
129 ghuddy 494
   if (document.all)
495
   {
496
      // Run this for IE
497
      elem = document.all;
498
   } else {
499
      // Run this for other browsers
500
      elem = document.getElementsByTagName('div');
501
   }
121 hknight 502
 
129 ghuddy 503
   for (i in elem)
504
   {
505
      if (elem[i].id)
506
      {
507
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
508
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
509
      }
510
   }
121 hknight 511
 
119 ghuddy 512
}
513
 
514
function CollapseAll()
515
{
129 ghuddy 516
   var elem
121 hknight 517
 
129 ghuddy 518
   if (document.all)
519
   {
520
      // Run this for IE
521
      elem = document.all;
522
   } else {
523
      // Run this for other browsers
524
      elem = document.getElementsByTagName('div');
525
   }
121 hknight 526
 
129 ghuddy 527
   for (i in elem)
528
   {
529
      if (elem[i].id)
530
      {
531
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
532
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
533
      }
534
   }
121 hknight 535
 
119 ghuddy 536
}
537
 
538
 
539
function height()
121 hknight 540
{
129 ghuddy 541
   if( typeof( window.innerWidth ) == 'number' )
542
   {
543
      h = window.innerHeight;
544
   }
545
   else if(document.documentElement&&(document.documentElement.clientHeight ))
546
   {
547
      h = document.documentElement.clientHeight;
548
   }
549
   else if( document.body &&   ( document.body.clientWidth || document.body.clientHeight ) )
550
   {
551
      h = document.body.clientHeight;
552
   }
121 hknight 553
 
129 ghuddy 554
   var e = document.getElementById("LayerDescription");
121 hknight 555
 
129 ghuddy 556
   if (navigator.userAgent.indexOf('Internet Explorer'))
557
   {
558
      e.style.height = h - 350 + "px";
559
      e.style.overflow = "auto";
560
   }
561
   else
562
   {
563
      // This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
564
      e.style.minHeight= h - 350 + "px";
565
      e.style.overflow = "auto";
566
   }
119 ghuddy 567
}
568
 
121 hknight 569
//////////////////////////////////////////////////////////////////////////////////////////////////
570
//
3959 dpurdie 571
// MM_ValidateVersion(versionBase, versionExt, isAutobuild isPatch)
572
// Should NOT be used externally. Use MM_validateForm to access this function
121 hknight 573
//
574
//    versionBase   eg 1.2.3
3959 dpurdie 575
//    versionExt    eg .cr
121 hknight 576
//    isAutobuild   true or false
133 ghuddy 577
//    isPatch       true or false
121 hknight 578
//
579
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
580
//
581
//////////////////////////////////////////////////////////////////////////////////////////////////
3959 dpurdie 582
function MM_ValidateVersion(versionBase, versionExt, isAutobuild, isPatch)
121 hknight 583
{
133 ghuddy 584
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
585
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
586
   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 587
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
588
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
5791 dpurdie 589
   var re_cots_ver_format_end = /\.\d{4,}$/;    // Must have a patch build number. ie: .nnnn or .
590
 
3959 dpurdie 591
   var isCots = versionExt == ".cots" || versionExt == ".tool";
121 hknight 592
 
3959 dpurdie 593
   if (!isAutobuild) {
594
      if ( versionBase.length == 0 ) {
595
         return " is of zero length";
596
      } else if ( !isCots) {
597
         if ( isPatch ) {
598
            if ( !re_patch_ver_format.test(versionBase) ) {
599
               return " is not of form (integer).(integer).(integer).p(integer)";
133 ghuddy 600
            }
3959 dpurdie 601
         } else {
602
            if ( !re_std_ver_format.test(versionBase) ) {
603
               return " is not of form (integer).(integer).(integer)";
133 ghuddy 604
            }
605
         }
3959 dpurdie 606
      } else if (isCots) {
607
         var extName = versionExt.toUpperCase().substr(1);
608
 
609
         if ( !re_cots_ver_format.test(versionBase) ) {
610
            return " " + extName + " package must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed";
129 ghuddy 611
         }
121 hknight 612
 
3959 dpurdie 613
         if ( re_cots_ver_format_exc1.test(versionBase) ) {
614
            return " " + extName + " package cannot contain two adjacent special characters (underscore/dash/dot)";
129 ghuddy 615
         }
121 hknight 616
 
3959 dpurdie 617
         if ( !re_cots_ver_format_exc2.test(versionBase) ) {
618
            return " " + extName + " package must contain one or more alphanumeric characters";
129 ghuddy 619
         }
5791 dpurdie 620
 
621
         if ( !re_cots_ver_format_end.test(versionBase) ) {
622
		    return " " + extName + " package must end with a patchBuild number (ie: .0000)";
623
         }
129 ghuddy 624
      }
625
   }
121 hknight 626
 
129 ghuddy 627
   // everything ok - no error
628
   return "";
121 hknight 629
}
630
 
631
 
3959 dpurdie 632
// Manipulate the class list for a given element
633
function hasClass(ele, cls) {
634
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
635
}
121 hknight 636
 
3959 dpurdie 637
function addClass(ele, cls) {
638
    if (!this.hasClass(ele, cls)) ele.className += " " + cls;
639
}
640
 
641
function removeClass(ele, cls) {
642
    if (hasClass(ele, cls)) {
643
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
644
        ele.className = ele.className.replace(reg, ' ');
645
    }
646
}
647
 
648
function toggleClass(ele, cls1, cls2){
649
    if(hasClass(ele, cls1)){
650
        replaceClass(ele, cls1, cls2);
651
    }else if(hasClass(ele, cls2)){
652
        replaceClass(ele, cls2, cls1);
653
    }else{
654
        addClass(ele, cls1);
655
    }
656
}
657
 
658
// Highlight combobox if selection is zero
659
// Returns true:  None-zero selection
660
// Returns false: Invalid element or item-0 selected
661
function checkSeletion(el)
662
{
663
   if (el ) {
664
     if ( el.selectedIndex == 0) {
665
        addClass(el, 'form_error');
666
     } else {
667
        removeClass(el, 'form_error');
668
        return true;
669
     }
670
   }
671
   return false;
672
}
673
 
674
function getElementsByClassName(classname, node)  {
675
    if(!node) node = document.getElementsByTagName("body")[0];
676
    var a = [];
677
    var re = new RegExp('\\b' + classname + '\\b');
678
    var els = node.getElementsByTagName("*");
679
    for(var i=0,j=els.length; i<j; i++)
680
        if(re.test(els[i].className))a.push(els[i]);
681
    return a;
682
}
683
 
684
function setCookie(c_name,value,exdays)
685
{
686
  var exdate=new Date();
687
  exdate.setDate(exdate.getDate() + exdays);
688
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
689
  document.cookie=c_name + "=" + c_value;
690
}
691
 
692
function getCookie(c_name)
693
{
694
  var c_value = document.cookie;
695
  var c_start = c_value.indexOf(" " + c_name + "=");
696
  if (c_start == -1)
697
  {
698
    c_start = c_value.indexOf(c_name + "=");
699
  }
700
  if (c_start == -1)
701
  {
702
    c_value = null;
703
  }
704
  else
705
  {
706
    c_start = c_value.indexOf("=", c_start) + 1;
707
    var c_end = c_value.indexOf(";", c_start);
708
    if (c_end == -1)
709
    {
710
      c_end = c_value.length;
711
    }
712
  c_value = unescape(c_value.substring(c_start,c_end));
713
}
714
return c_value;
715
}
716
 
119 ghuddy 717
//-->