home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 February / CMCD0205.ISO / Software / Freeware / Comunicatii / slimbrow / sbsetup.exe / ExtractAutoLoginData.js < prev    next >
Text File  |  2003-06-18  |  2KB  |  89 lines

  1. ExtractAutoLoginData();
  2. function ExtractAutoLoginData()
  3. {
  4.     var topBody = top.document.body;
  5.     topBody.sbalData="";
  6.     topBody.sbalFormIndex=-1;
  7.     WalkFrames("top" );
  8. }
  9.  
  10. function WalkFrames(path)
  11. {
  12.     var vWindow=eval(path);
  13.     if (ExtractAutoLoginFromWindow(path)) return true;
  14.     for(var i=0; i<vWindow.frames.length; i++ )
  15.     {
  16.         if (WalkFrames(path+".frames["+i+"]")) return true;    
  17.     }
  18.     return false;
  19. }
  20.  
  21. function ExtractAutoLoginFromWindow(FramePath)
  22. {
  23.     var curDoc = eval( FramePath + ".document" );
  24.     var topBody = top.document.body;
  25.  
  26.     var activeForm=curDoc.activeElement.form;
  27.     if (activeForm==null)
  28.     {
  29.         activeForm=curDoc.forms[0];
  30.         if (activeForm==null) return false;
  31.     }
  32.     var sbalData="",sbalPass="",sbalFormIndex=-1;
  33.     var bFound=false;
  34.     for(var i=0;i<activeForm.elements.length;i++)
  35.     {
  36.         var elem=activeForm.elements[i];
  37.         var t=elem.type;
  38.         if (elem.name==null || elem.name=="") continue;
  39.         var en=elem.name;
  40.         var tn=elem.tagName.toLowerCase();
  41.         s="";
  42.         if (tn=="input")
  43.         {
  44.             if (t=="text") 
  45.             {
  46.                 s=en+"="+elem.value;
  47.                 if (elem.value!="") bFound=true;
  48.             }
  49.             else if (t=="checkbox" || t=="radio") 
  50.             {
  51.                 if (elem.checked) s=en+"="+elem.value;
  52.                 else if (t=="checkbox") s=en+"=";
  53.             }
  54.             else if (t=="password") 
  55.             {
  56.                 s=en+"=$sbpswd:"+elem.value;
  57.                 if (elem.value!="") bFound=true;
  58.             }
  59.         }
  60.         else if (tn=="select")
  61.         {
  62.             s="";
  63.             for (var j=0;j<elem.options.length;j++)
  64.             {
  65.                 var opt=elem.options[j];
  66.                 if (opt.selected) 
  67.                 {
  68.                     if (s!="") s=s+"&";
  69.                     if (opt.value!="") s=s+en+"="+opt.value;
  70.                     else s=en+"="+opt.text;
  71.                 }
  72.             }
  73.         }
  74.         if (s=="") continue;
  75.         if (sbalData=="") sbalData=s;
  76.         else sbalData=sbalData+"&"+s;
  77.     }
  78.     for(i=0;i<curDoc.forms.length;i++)
  79.     {
  80.         if (curDoc.forms[i]==activeForm) sbalFormIndex=i;
  81.     }
  82.     if (!bFound) return false;
  83.     topBody.sbalData="FramePath=" + FramePath + "&" + sbalData;
  84.     topBody.sbalFormIndex=sbalFormIndex;
  85.     return true;
  86. }
  87.  
  88.  
  89.