reverting back to version 1.11, new changes broke single signon

This commit is contained in:
morse%netscape.com 2000-02-01 08:08:06 +00:00
parent 620faed348
commit f4077f3663
2 changed files with 168 additions and 166 deletions

View File

@ -1,84 +1,68 @@
function commonDialogOnLoad()
{
dump("commonDialogOnLoad \n");
doSetOKCancel( commonDialogOnOK, commonDialogOnCancel, commonDialogOnButton2, commonDialogOnButton3 );
dump("commonDialogOnLoad \n");
doSetOKCancel( commonDialogOnOK, commonDialogOnCancel, commonDialogOnButton2, commonDialogOnButton3 );
param = window.arguments[0].QueryInterface( Components.interfaces.nsIDialogParamBlock );
if( !param )
dump( " error getting param block interface\n" );
var messageText = param.GetString( 0 );
var messageFragment;
// dump("message: "+ msg +"\n");
//SetElementText("info.txt", msg );
{
var messageFragment;
// Let the caller use "\n" to cause breaks
// Translate these into <br> tags
var messageParent = document.getElementById("info.txt");
var done = false;
while (!done)
{
breakIndex = messageText.indexOf('\n');
if (breakIndex == 0) {
// Ignore break at the first character
messageText = messageText.slice(1);
dump("Found break at begining\n");
messageFragment = "";
}
else if (breakIndex > 0) {
// The fragment up to the break
messageFragment = messageText.slice(0, breakIndex);
// Chop off fragment we just found from remaining string
messageText = messageText.slice(breakIndex+1);
}
else {
// "\n" not found. We're done
done = true;
messageFragment = messageText;
}
messageNode = document.createTextNode(messageFragment);
if (messageNode)
messageParent.appendChild(messageNode);
// This is needed when the default namespace of the document is XUL
breakNode = document.createElementWithNameSpace("BR", "http://www.w3.org/TR/REC-html40");
if (breakNode)
messageParent.appendChild(breakNode);
}
// Let the caller use "\n" to cause breaks
// Translate these into <br> tags
var messageParent = (document.getElementById("info.txt"));
done = false;
while (!done) {
breakIndex = messageText.indexOf('\n');
if (breakIndex == 0) {
// Ignore break at the first character
messageText = messageText.slice(1);
dump("Found break at begining\n");
messageFragment = "";
} else if (breakIndex > 0) {
// The fragment up to the break
messageFragment = messageText.slice(0, breakIndex);
// set a bold header message
// Chop off fragment we just found from remaining string
messageText = messageText.slice(breakIndex+1);
} else {
// "\n" not found. We're done
done = true;
messageFragment = messageText;
}
messageNode = document.createTextNode(messageFragment);
if (messageNode)
messageParent.appendChild(messageNode);
// This is needed when the default namespace of the document is XUL
breakNode = document.createElementWithNameSpace("BR", "http://www.w3.org/TR/REC-html40");
if (breakNode)
messageParent.appendChild(breakNode);
}
}
var msg = param.GetString( 3 );
// dump("title message: "+ msg +"\n");
SetElementText("info.header", msg );
// set the window title
var windowTitle = param.GetString( 12 );
window.title = windowTitle;
// set the icon. hm.. this is potentially unskinnable.
var iconURL = param.GetString( 2 );
// hack around the unskinnable code by looking into the url and attempting to get something meaningful from it:
var fileTag = iconURL.substring( ( iconURL.lastIndexOf("/") + 1 ), iconURL.lastIndexOf(".") ); // BAD BAD HACKERY EVIL ICK WRONG BAD
switch ( fileTag )
{
case "alert-icon":
var iconClass = "alert-icon";
break;
case "error-icon":
var iconClass = "error-icon";
break;
case "question-icon":
var iconClass = "question-icon";
break;
case "message-icon":
default:
var iconClass = "message-icon";
break;
}
var element = document.getElementById("icon");
var iconURL = param.GetString(2 );
var element = document.getElementById("info.icon");
if( element )
element.setAttribute( "class", iconClass );
element.src = iconURL;
else
dump("couldn't find icon element \n");
// Set button names
var buttonText = param.GetString( 8 );
if ( buttonText != "" )
{
// dump( "Setting OK Button to "+buttonText+"\n");
var okButton = document.getElementById("ok");
okButton.setAttribute("value", buttonText);
}
@ -86,92 +70,126 @@ function commonDialogOnLoad()
buttonText = param.GetString( 9 );
if ( buttonText != "" )
{
// dump( "Setting Cancel Button to"+buttonText+"\n");
var cancelButton = document.getElementById("cancel");
cancelButton.setAttribute( "value",buttonText);
}
// Adjust number buttons
var numButtons = param.GetInt( 2 );
if ( numButtons == 1 ) ;
if ( numButtons == 1 )
{
}
switch ( numButtons )
{
case 4:
var button = document.getElementById("Button3");
button.setAttribute("style", "display:inline;");
var buttonText = param.GetString( 11 );
button.setAttribute( "value",buttonText);
{
var button = document.getElementById("Button3");
button.setAttribute("style", "display:inline;");
var buttonText = param.GetString( 11 );
button.setAttribute( "value",buttonText);
}
case 3:
var button = document.getElementById("Button2");
button.setAttribute("style", "display:inline;");
var buttonText = param.GetString( 10 );
button.setAttribute( "value",buttonText);
{
var button = document.getElementById("Button2");
button.setAttribute("style", "display:inline;");
var buttonText = param.GetString( 10 );
button.setAttribute( "value",buttonText);
}
break;
case 1:
var element = document.getElementById("cancel");
if ( element )
{
// dump( "hide button \n" );
element.setAttribute("style", "display:none;" );
}
else
{
// dump( "couldn't find button \n");
}
break;
default:
break;
}
// Set the Checkbox
// dump(" set checkbox \n");
var checkMsg = param.GetString( 1 );
// dump("check box msg is "+ checkMsg +"\n");
if ( checkMsg != "" )
{
var checkMsgElement = document.getElementById("checkboxLabel");
SetElementText( "checkboxLabel", checkMsg );
var prompt = (document.getElementById("checkboxLabel"));
if ( prompt )
{
// dump(" setting message \n" );
prompt.childNodes[1].nodeValue = checkMsg;
}
var checkValue = param.GetInt( 1 );
var element=document.getElementById("checkbox" );
var checkbool = checkValue > 0 ? true : false;
element.checked = checkbool;
}
else {
else
{
// dump("not visibile \n");
var element = document.getElementById("checkboxLabel");
element.setAttribute("style","display: none;" );
}
// handle the edit fields
// dump("set editfields \n");
var numEditfields = param.GetInt( 3 );
switch( numEditfields )
{
case 2:
var element = document.getElementById("dialog.password2");
element.value = param.GetString( 7 );
var editMsg = param.GetString( 5 );
if (editMsg)
if (editMsg) {
SetElementText("password2.text", editMsg );
}
var editfield1Password = param.GetInt( 4 );
if ( editfield1Password == 1 ) {
if ( editfield1Password == 1 )
{
var element = document.getElementById("dialog.password1");
element.value = param.GetString( 6 );
var editMsg1 = param.GetString( 4 );
if (editMsg1)
if (editMsg1) {
SetElementText("password1.text", editMsg1 );
}
// dump("hiding loginEditField");
var element = document.getElementById("loginEditField");
element.setAttribute("style","display: none;" );
var element = document.getElementById("dialog.password1");
element.focus();
}
else {
}
else
{
var element = document.getElementById("dialog.loginname");
element.value = param.GetString( 6 );
var editMsg1 = param.GetString( 4 );
if (editMsg1)
if (editMsg1) {
SetElementText("login.text", editMsg1 );
}
// dump("hiding password1EditField");
var element = document.getElementById("password1EditField");
element.setAttribute("style","display: none;" );
var element = document.getElementById("dialog.loginname");
element.focus();
}
}
break;
case 1:
var editfield1Password = param.GetInt( 4 );
if ( editfield1Password == 1 ) {
if ( editfield1Password == 1 )
{
var element = document.getElementById("dialog.password1");
element.value = param.GetString( 6 );
@ -182,38 +200,41 @@ function commonDialogOnLoad()
// Now hide the meaningless text
var element = document.getElementById("password1.text");
element.setAttribute("style", "display:none;" );
// dump("hiding loginEditField and password2EditField");
var element = document.getElementById("loginEditField");
element.setAttribute("style","display: none;" );
var element = document.getElementById("password2EditField");
element.setAttribute("style","display: none;" );
var element = document.getElementById("dialog.password1");
// dump("give keyboard focus to password edit field \n");
element.focus();
}
else {
}
else
{
var element = document.getElementById("dialog.loginname");
element.value = param.GetString( 6 );
var editMsg1 = param.GetString( 4 );
if (editMsg1)
if (editMsg1) {
SetElementText("login.text", editMsg1 );
}
// Now hide the meaningless text
var element = document.getElementById("login.text");
element.setAttribute("style", "display:none;" );
// dump("hiding password1EditField and password2EditField");
var element = document.getElementById("password1EditField");
element.setAttribute("style","display: none;" );
var element = document.getElementById("password2EditField");
element.setAttribute("style","display: none;" );
var element = document.getElementById("dialog.loginname");
// dump("give keyboard focus to password edit field \n");
element.focus();
}
break;
case 0:
var element = document.getElementById("loginEditField");
element.setAttribute("style", "display:none;" );
var element = document.getElementById("password1EditField");
element.setAttribute("style","display: none;" );
var element = document.getElementById("password2EditField");
element.setAttribute("style","display: none;" );
// dump("hiding all editfields \n");
var element = document.getElementById("editFields");
element.setAttribute("style","display: none;" );
break;
}
@ -230,56 +251,55 @@ function commonDialogOnLoad()
function onCheckboxClick()
{
param.SetInt( 1, (param.GetInt( 1 ) ? 0 : 1 ));
// dump("setting checkbox to "+ element.checked+"\n");
}
// set the text on a text container
function SetElementText( elementID, text )
{
var element = document.getElementById( elementID );
while( element.hasChildNodes() )
element.removeChild( element.firstChild );
var text = document.createTextNode( text );
element.appendChild( text );
// dump("setting "+elementID+" to "+text +"\n");
var element = document.getElementById(elementID);
if( element )
element.childNodes[0].nodeValue = text;
else
dump("couldn't find element \n");
}
// set an attribute on an element
function SetElementAttribute( elementID, attribute, value )
{
var element = document.getElementById( elementID );
element.setAttribute( attribute, value );
}
function commonDialogOnOK()
{
// dump("commonDialogOnOK \n");
param.SetInt(0, 0 );
var element1, element2;
var numEditfields = param.GetInt( 3 );
if (numEditfields == 2) {
var editfield1Password = param.GetInt( 4 );
if ( editfield1Password == 1 )
if ( editfield1Password == 1 ) {
element1 = document.getElementById("dialog.password1");
else
} else {
element1 = document.getElementById("dialog.loginname");
}
param.SetString( 6, element1.value );
element2 = document.getElementById("dialog.password2");
param.SetString( 7, element2.value );
}
else if (numEditfields == 1) {
// dump(" login name - "+ element1.value+ "\n");
// dump(" password - "+ element2.value+ "\n");
} else if (numEditfields == 1) {
var editfield1Password = param.GetInt( 4 );
if ( editfield1Password == 1 ) {
element1 = document.getElementById("dialog.password1");
param.SetString( 6, element1.value );
}
else {
} else {
element1 = document.getElementById("dialog.loginname");
param.SetString( 6, element1.value );
}
// dump(" login name - "+ element2.value+ "\n");
}
return true;
}
function commonDialogOnCancel()
{
// dump("commonDialogOnCancel \n");
param.SetInt(0, 1 );
return true;
}

View File

@ -1,74 +1,56 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/commonDialog.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://global/locale/commonDialog.dtd">
<window
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="max-width: 400px;"
align="vertical"
onload="commonDialogOnLoad()"
class="dialog">
<html:script language="JavaScript" src="chrome://global/content/commonDialog.js" />
<html:script language="JavaScript" src="chrome://global/content/commonDialog.js" />
<keyset id="keyset"/>
<keyset id="keyset"/>
<box id="wrapper" style="min-width: 260px;">
<box class="icon" align="vertical">
<box>
<spring flex="1"/>
<html:div>
<titledbutton id="icon" class="message-icon plain"/>
</html:div>
<spring flex="1"/>
</box>
<spring flex="1"/>
</box>
<box align="vertical" id="content" flex="100%">
<html:div id="info.header">&header.label;</html:div>
<html:div id="info.txt"/>
<html:table id="editFields" cellpadding="0" cellspacing="0" style="width: 100%;">
<html:tr id="loginEditField">
<html:td id="login.text">
<html:label for="dialog.loginname">&editfield0.label;</html:label>
</html:td>
<html:td style="width: 100%">
<html:input accesskey="u" tabindex="0" type="text" id="dialog.loginname" flex="100%" style="width: 100%;"/>
</html:td>
</html:tr>
<html:tr id="password1EditField">
<html:td id="password1.text">
<html:label for="dialog.password1">&editfield2.label;</html:label>
</html:td>
<html:td>
<html:input accesskey="p" tabindex="1" type="password" id="dialog.password1" style="width: 100%"/>
</html:td>
</html:tr>
<html:tr id="password2EditField">
<html:td id="password2.text">
<html:label for="dialog.password2">&editfield2.label;</html:label>
</html:td>
<html:td>
<html:input accesskey="p" tabindex="1" type="password" id="dialog.password2" style="width: 100%"/>
</html:td>
</html:tr>
<html:tr id="checkboxLabel">
<html:td/>
<html:td>
<html:label for="checkbox" onclick="onCheckboxClick();">
<html:input type="checkbox" id="checkbox" />
&checkbox.label;
</html:label>
</html:td>
</html:tr>
</html:table>
<box align="horizontal" flex="100%" style="width: 36em;">
<html:div style="width: 40px; margin: 5px;">
<html:img id="info.icon" src="chrome://global/skin/message-icon.gif" width="32" height="32" border="0"/>
</html:div>
<box align="vertical" flex="100%">
<html:div id="info.header" style="margin-left:2em; margin-right:2em; margin-top:5px; font-size: 110%; font-weight: bold;">
&header.label;
</html:div>
<html:div id="info.txt" style="margin-left:2em; margin-right:2em; margin-top:5px;" flex="100%">
</html:div>
</box>
</box>
<html:div class="separator" align="horizontal"/>
<box id="editFields" align="vertical" >
<box align="horizontal" id="loginEditField" >
<html:div style="min-width: 6em;" id="login.text">&editfield0.label;</html:div>
<html:input accesskey="u" tabindex="0" type="text" id="dialog.loginname" flex="100%"/>
</box>
<box align="horizontal" id ="password1EditField">
<html:div style="min-width: 6em;" id="password1.text">&editfield1.label;</html:div>
<html:input accesskey="p" tabindex="1" type="password" id="dialog.password1" flex="100%"/>
</box>
<box align="horizontal" id ="password2EditField">
<html:div style="min-width: 6em;" id="password2.text">&editfield2.label;</html:div>
<html:input accesskey="p" tabindex="1" type="password" id="dialog.password2" flex="100%"/>
</box>
</box>
<html:label id="checkboxLabel" onclick="onCheckboxClick()" >
<html:input type="checkbox" id="checkbox" />
&checkbox.label;
</html:label>
<box id="okCancelButtons"/>
</window>