pjs/profile/Acctidl/am2a.xul

176 строки
4.5 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="pm.css" type="text/css"?>
<window
width="640"
height="480"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:div flex="100%">
<html:script>
var Account = Components.classes["component://netscape/profile/Account-services"].createInstance();
Account = Account.QueryInterface(Components.interfaces.nsIAccountServices);
dump("Account = " + Account + "\n");
nameGlobal = new Array();
nameArray = new Array();
var count = 0;
var dataCount = 0;
function TestMe()
{
var field1 = document.getElementById('phone');
SetPhonebookValue(field1.id,field1.value);
var field2 = document.getElementById('loginname');
SetPhonebookValue(field2.id,field2.value);
var field3 = document.getElementById('loginpass');
SetPhonebookValue(field3.id,field3.value);
var field4 = document.getElementById('passagain');
SetPhonebookValue(field4.id,field4.value);
var sel = document.getElementById("x");
var ind = sel.selectedIndex;
var opt = document.getElementById(ind);
SetPhonebookValue("filename",opt.label);
SetPhonebookValue("ncivalue","1");
// var field8 = document.getElementById('callwait');
// if (field8.value ==TRUE)
// SetPhonebookValue(field8.id,field8.value);
// var field9 = document.getElementById('tone');
// SetPhonebookValue(field9.id,field9.value);
Finish();
}
function SetPhonebookValue(name, value)
{
dump("Inside SetPhonebookValue\n");
var found = false;
for (i = 0; i !=dataCount; i++) {
if (nameArray[i] == name) {
dump("Name exists: "+nameGlobal[i]+"\n");
nameGlobal[i] = name+"="+value+"%";
dump("New values: "+name+" "+value+"\n");
found = true;
break;
}
}
if (!found) {
dump("Name does not exist\n");
nameGlobal[dataCount] = name+"="+value+"%";
dump("Name Value: "+name+" "+value+"\n");
nameArray[dataCount] = name;
dataCount++;
}
}
function Finish()
{
var data = "";
var i = 0;
dump("before for loop\n");
for (i = 0; i !=dataCount; i++) {
data = data+nameGlobal[i];
}
dump("DATA IS: "+data+"\n");
Account.SetDialerConfig(data);
dump ("this is before getting account \n");
}
function loadElements()
{
Account.LoadValues();
var SiteList = "";
SiteList = Account.GetSiteName();
dump ("this is after getting SiteList \n");
SiteList = SiteList.split(",");
dump("Got SiteList of '" + SiteList + "'\n");
var PhoneList = "";
PhoneList = Account.GetPhone();
dump ("this is after getting PhoneList \n");
PhoneList = PhoneList.split(",");
dump("Got PhoneList of '" + PhoneList + "'\n");
for (var i=0; i &lt; SiteList.length; i++)
{
var tempval = SiteList[i];
var tempval = tempval.split("^");
pvals = tempval[0];
plabel = tempval [1];
pvalue = PhoneList[i];
addOptions(pvals,i+1,plabel,pvalue);
}
}
// -------------------------------------------- begin Hack for OnLoad handling
setTimeout("loadElements()", 0);
// -------------------------------------------- end Hack for OnLoad handling
function addOptions(oname,iname,plabel,pvalue)
{
var sel = document.getElementById("x");
dump( "sel="+sel+"\n" );
var elem = document.createElement( "html:option" );
dump( "elem="+elem+"\n" );
elem.id = iname;
elem.label=plabel;
elem.value=pvalue;
dump ("elem id label value ="+elem.id+" "+elem.label+" "+elem.value+"\n");
var text = document.createTextNode( oname );
dump( "text="+text+"\n" );
var rc = elem.appendChild( text );
dump( "rc="+rc+"\n" );
var newsel = sel.appendChild( elem );
dump( "newsel="+newsel+"\n" );
}
function SelectCity()
{
var sel = document.getElementById("x");
var ind = sel.selectedIndex;
var opt = document.getElementById(ind);
var phonel = document.getElementById("phone");
phonel.value = opt.value;
var filel = document.getElementById("filename");
filel.value = opt.label;
}
</html:script>
<html:select id="x">
<html:option> </html:option>
</html:select>
<html:br/>
<titledbutton value="SelectCity" class="push" onclick="SelectCity();"/>
<html:br/>
Phone <html:input type="text" id="phone"/> This information will not be given to anyone else.<html:br/><html:br/>
FileName<html:input type="text" id="filename"/> <html:br/><html:br/>
Login Name<html:input type="text" id="loginname"/> <html:br/><html:br/>
Password<html:input type="text" id="loginpass"/>
Enter Again<html:input type="text" id="passagain"/><html:br/><html:br/>
<titledbutton value="Create Account" class="push" onclick="TestMe();"/>
</html:div>
</window>