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