Subversion Repositories DevTools

Rev

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