home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 February
/
PCWorld_2005-02_cd.bin
/
komunikace
/
slim
/
sbsetup.exe
/
ExtractAutoLoginData.js
< prev
next >
Wrap
Text File
|
2003-06-18
|
2KB
|
89 lines
ExtractAutoLoginData();
function ExtractAutoLoginData()
{
var topBody = top.document.body;
topBody.sbalData="";
topBody.sbalFormIndex=-1;
WalkFrames("top" );
}
function WalkFrames(path)
{
var vWindow=eval(path);
if (ExtractAutoLoginFromWindow(path)) return true;
for(var i=0; i<vWindow.frames.length; i++ )
{
if (WalkFrames(path+".frames["+i+"]")) return true;
}
return false;
}
function ExtractAutoLoginFromWindow(FramePath)
{
var curDoc = eval( FramePath + ".document" );
var topBody = top.document.body;
var activeForm=curDoc.activeElement.form;
if (activeForm==null)
{
activeForm=curDoc.forms[0];
if (activeForm==null) return false;
}
var sbalData="",sbalPass="",sbalFormIndex=-1;
var bFound=false;
for(var i=0;i<activeForm.elements.length;i++)
{
var elem=activeForm.elements[i];
var t=elem.type;
if (elem.name==null || elem.name=="") continue;
var en=elem.name;
var tn=elem.tagName.toLowerCase();
s="";
if (tn=="input")
{
if (t=="text")
{
s=en+"="+elem.value;
if (elem.value!="") bFound=true;
}
else if (t=="checkbox" || t=="radio")
{
if (elem.checked) s=en+"="+elem.value;
else if (t=="checkbox") s=en+"=";
}
else if (t=="password")
{
s=en+"=$sbpswd:"+elem.value;
if (elem.value!="") bFound=true;
}
}
else if (tn=="select")
{
s="";
for (var j=0;j<elem.options.length;j++)
{
var opt=elem.options[j];
if (opt.selected)
{
if (s!="") s=s+"&";
if (opt.value!="") s=s+en+"="+opt.value;
else s=en+"="+opt.text;
}
}
}
if (s=="") continue;
if (sbalData=="") sbalData=s;
else sbalData=sbalData+"&"+s;
}
for(i=0;i<curDoc.forms.length;i++)
{
if (curDoc.forms[i]==activeForm) sbalFormIndex=i;
}
if (!bFound) return false;
topBody.sbalData="FramePath=" + FramePath + "&" + sbalData;
topBody.sbalFormIndex=sbalFormIndex;
return true;
}