home *** CD-ROM | disk | FTP | other *** search
/ PC User 2008 February / Australian_PC_User_2008-02.iso / software / brows / files / Slim / sbsetup.exe / biscripts / ExtractAutoLoginData.js < prev    next >
Encoding:
Text File  |  2007-07-15  |  2.0 KB  |  98 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;
  24.     try
  25.     {
  26.         curDoc = eval( FramePath + ".document" );
  27.     }
  28.     catch (e)
  29.     {
  30.         return false;
  31.     }
  32.     var topBody = top.document.body;
  33.  
  34.     var activeForm=curDoc.activeElement.form;
  35.     if (activeForm==null)
  36.     {
  37.         activeForm=curDoc.forms[0];
  38.         if (activeForm==null) return false;
  39.     }
  40.     var sbalData="",sbalPass="",sbalFormIndex=-1;
  41.     var bFound=false;
  42.     for(var i=0;i<activeForm.elements.length;i++)
  43.     {
  44.         var elem=activeForm.elements[i];
  45.         var t=elem.type;
  46.         var en=elem.name;
  47.         if (en=="" || en==null) en=elem.id;
  48.         if (en==null || en=="") continue;
  49.         var tn=elem.tagName.toLowerCase();
  50.         var s="";
  51.         if (tn=="input")
  52.         {
  53.             if (t=="text") 
  54.             {
  55.                 s=en+"="+elem.value;
  56.                 if (elem.value!="") bFound=true;
  57.             }
  58.             else if (t=="checkbox" || t=="radio") 
  59.             {
  60.                 if (elem.checked) s=en+"="+elem.value;
  61.                 else if (t=="checkbox") s=en+"=";
  62.             }
  63.             else if (t=="password") 
  64.             {
  65.                 s=en+"=$sbpswd:"+elem.value;
  66.                 if (elem.value!="") bFound=true;
  67.             }
  68.         }
  69.         else if (tn=="select")
  70.         {
  71.             s="";
  72.             for (var j=0;j<elem.options.length;j++)
  73.             {
  74.                 var opt=elem.options[j];
  75.                 if (opt.selected) 
  76.                 {
  77.                     if (s!="") s=s+"&";
  78.                     if (opt.value!="") s=s+en+"="+opt.value;
  79.                     else s=en+"="+opt.text;
  80.                 }
  81.             }
  82.         }
  83.         if (s=="") continue;
  84.         if (sbalData=="") sbalData=s;
  85.         else sbalData=sbalData+"&"+s;
  86.     }
  87.     for(i=0;i<curDoc.forms.length;i++)
  88.     {
  89.         if (curDoc.forms[i]==activeForm) sbalFormIndex=i;
  90.     }
  91.     if (!bFound) return false;
  92.     topBody.sbalData="FramePath=" + FramePath + "&" + sbalData;
  93.     topBody.sbalFormIndex=sbalFormIndex;
  94.     return true;
  95. }
  96.  
  97.  
  98.