gecko-dev/extensions/wallet/editor/WalletEditor.html

537 lines
16 KiB
HTML
Raw Normal View History

<html>
<head bgcolor='#cccccc'>
<title>Wallet</title>
<script>
1999-06-19 21:08:33 +00:00
/* for xpconnect */
var walleteditor =
Components.classes
["component://netscape/walleteditor/walleteditor-world"].createInstance();
walleteditor = walleteditor.QueryInterface(Components.interfaces.nsIWalletEditor);
dump("walleteditor = " + walleteditor + "\n");
function get()
{
return walleteditor.GetValue();
}
function set(value)
{
walleteditor.SetValue(value, window);
}
/* end of xpconnect stuff */
1999-07-14 15:04:25 +00:00
title_frame = 0;
schema_frame = 1;
value_frame = 2;
synonym_frame = 3;
button_frame = 4;
1999-06-19 21:08:33 +00:00
var schemas = [];
var schemasLength;
var values = [];
var valuesLength;
var strings = [];
var stringsLength;
var currentSchema=0;
var currentValue=0;
var currentSynonym=0;
var BREAK;
function generateOutput(button) {
var output = button + BREAK;
for (i=0; i!=schemasLength; i++) {
for (j=schemas[i]; j!=schemas[i+1]; j++) {
for (k=values[j]; k!=values[j+1]; k++) {
1999-06-19 21:08:33 +00:00
output += strings[k] + BREAK;
}
}
}
set(output);
}
function parseInput() {
var input;
input = get();
/* following is for going to wallet editor from URL line */
if (input.length == 0) {
input = "+name.first+steve++";
}
BREAK = input[0];
flushTables();
strings = input.split(BREAK);
stringsLength = strings.length;
j = 0;
for (i=1; i!=stringsLength; i++) {
if (strings[i] != "") {
if(strings[i-1] == "") {
values[j++] = i;
valuesLength++;
}
1999-06-19 21:08:33 +00:00
}
}
values[j] = stringsLength;
j = 0;
for (i=0; i!=valuesLength; i++) {
1999-06-19 21:08:33 +00:00
if (i == 0 || (strings[values[i]] != strings[values[i-1]])) {
schemas[j++] = i;
schemasLength++;
}
}
schemas[j] = valuesLength;
}
function dumpStrings() {
/* for debugging purposes */
for (i=0; i!=schemasLength; i++) {
1999-06-19 21:08:33 +00:00
alert(i+" "+schemas[i]+" "+values[schemas[i]]+" "+strings[values[schemas[i]]]);
for (j=schemas[i]; j!=schemas[i+1]; j++) {
1999-06-19 21:08:33 +00:00
alert(" " + strings[values[j]+1]);
for (k=values[j]+2; k!=values[j+1]-1; k++) {
1999-06-19 21:08:33 +00:00
alert("....." + strings[k]);
}
}
}
}
function dumpRawStrings() {
/* for debugging purposes */
alert("Schemas follow");
for (i=0; i!=schemasLength; i++) {
1999-06-19 21:08:33 +00:00
alert("{" + schemas[i] + "}");
}
alert("Values follow");
for (i=0; i!=valuesLength; i++) {
1999-06-19 21:08:33 +00:00
alert("{" + values[i] + "}");
}
alert("Strings follow");
for (i=0; i!=stringsLength; i++) {
1999-06-19 21:08:33 +00:00
alert("{" + strings[i] + "}");
}
}
function lostFocus() {
1999-07-14 15:04:25 +00:00
schemalist = top.frames[schema_frame].document.schema.schemalist;
valuelist = top.frames[value_frame].document.value.valuelist;
synonymlist = top.frames[synonym_frame].document.synonym.synonymlist;
1999-06-19 21:08:33 +00:00
if (!(schemalist.selectedIndex>=0)) {
1999-06-19 21:08:33 +00:00
currentSchema = 0;
currentValue = 0;
currentSynonym = 0;
loadMain();
return;
} else if (schemalist.selectedIndex != currentSchema) {
currentSchema = schemalist.selectedIndex;
currentValue = 0;
currentSynonym = 0;
loadMain();
return;
}
if (!(valuelist.selectedIndex>=0)) {
1999-06-19 21:08:33 +00:00
currentValue = 0;
currentSynonym = 0;
loadMain();
return;
} else if (valuelist.selectedIndex != currentValue) {
currentValue = valuelist.selectedIndex;
currentSynonym = 0;
loadMain();
return;
}
if (!(synonymlist.selectedIndex>=0)) {
1999-06-19 21:08:33 +00:00
currentSynonym = 0;
loadMain();
return;
} else if (synonymlist.selectedIndex != currentSynonym) {
currentSynonym = synonymlist.selectedIndex;
loadMain();
return;
}
}
function flushTables() {
strings[0] = "";
strings[1] = "";
values[0] = 0;
values[1] = 2;
schemas[0] = 0;
schemas[1] = 0;
schemasLength = 0;
valuesLength = 0;
stringsLength = 0;
currentSchema = 0;
currentValue = 0;
currentSynonym = 0;
}
function deleteSchema0() {
if (schemasLength == 1) {
flushTables();
return;
}
currentValue = 0;
numberOfValues = schemas[currentSchema+1] - schemas[currentSchema];
for (i=0; i!=numberOfValues; i++) {
1999-06-19 21:08:33 +00:00
deleteValue0();
}
deleteString(values[schemas[currentSchema]]+1); /* delete blank line */
deleteString(values[schemas[currentSchema]]); /* delete name of schema */
schemasLength--;
for (i=currentSchema; i!=schemasLength; i++) {
1999-06-19 21:08:33 +00:00
schemas[i] = schemas[i+1];
}
}
function deleteValue0() {
valueToDelete = schemas[currentSchema]+currentValue;
currentSynonym = 0;
while (!(values[valueToDelete]+2 >= values[valueToDelete+1]-1)) {
1999-06-19 21:08:33 +00:00
deleteSynonym0();
}
if ((schemas[currentSchema+1] - schemas[currentSchema]) == 1) {
if(strings[values[valueToDelete]+1] != "") {
deleteString(values[valueToDelete]+1);
}
return;
}
while(strings[values[valueToDelete]] != "") {
deleteString(values[valueToDelete]);
}
deleteString(values[valueToDelete]);
valuesLength--;
for (i=valueToDelete; i!=valuesLength; i++) {
1999-06-19 21:08:33 +00:00
values[i] = values[i+1];
}
for (i=0; i!==schemasLength; i++) {
1999-06-19 21:08:33 +00:00
if (schemas[i] > valueToDelete) {
schemas[i]--;
}
}
}
function deleteSynonym0() {
stringToDelete = values[schemas[currentSchema]+currentValue]+2+currentSynonym;
deleteString(stringToDelete);
}
function addSchema0() {
1999-07-14 15:04:25 +00:00
text = top.frames[schema_frame].document.schema.newSchema;
1999-06-19 21:08:33 +00:00
schemaIndex = 0;
while (!(strings[values[schemas[schemaIndex]]] >= text.value)) {
1999-06-19 21:08:33 +00:00
schemaIndex++;
}
schemasLength++;
for (i=schemasLength; i>schemaIndex; i--) {
schemas[i] = schemas[i-1]+1;
}
valueIndex = schemas[schemaIndex];
valuesLength++;
for (i=valuesLength; i>valueIndex; i--) {
values[i] = values[i-1];
}
stringIndex = values[valueIndex];
if (stringIndex == stringsLength) {
stringIndex--;
}
addString(stringIndex, text.value);
addString(stringIndex+1, "");
schemas[schemaIndex] = valueIndex;
values[valueIndex] = stringIndex;
}
function addValue0() {
1999-07-14 15:04:25 +00:00
text = top.frames[value_frame].document.value.newValue;
1999-06-19 21:08:33 +00:00
stringIndex = values[schemas[currentSchema]+currentValue];
if(strings[values[schemas[currentSchema]+currentValue]+1]=="") {
addString(values[schemas[currentSchema]+currentValue]+1, text.value);
return;
}
addString(stringIndex, strings[values[schemas[currentSchema]]]);
addString(stringIndex+1, text.value);
addString(stringIndex+2, "");
valuesLength++;
for (i=valuesLength; i>schemas[currentSchema]+currentValue; i--) {
values[i] = values[i-1];
}
values[schemas[currentSchema]+currentValue] = stringIndex;
for (i=currentSchema+1; i!==schemasLength; i++) {
1999-06-19 21:08:33 +00:00
schemas[i]++;
}
}
function addSynonym0() {
1999-07-14 15:04:25 +00:00
text = top.frames[synonym_frame].document.synonym.newSynonym;
1999-06-19 21:08:33 +00:00
addString(values[schemas[currentSchema]+currentValue]+2, text.value);
}
function deleteString(stringToDelete) {
stringsLength--;
for (i=stringToDelete; i!=stringsLength; i++) {
1999-06-19 21:08:33 +00:00
strings[i] = strings[i+1];
}
for (i=0; i!==valuesLength; i++) {
1999-06-19 21:08:33 +00:00
if (values[i] > stringToDelete) {
values[i]--;
}
}
}
function addString(stringToAdd, text) {
stringsLength++;
for (i=stringsLength; i>stringToAdd; i--) {
strings[i] = strings[i-1];
}
strings[stringToAdd] = text;
for (i=0; i!==valuesLength; i++) {
1999-06-19 21:08:33 +00:00
if (values[i] >= stringToAdd) {
values[i]++;
}
}
}
function addSchema() {
addSchema0();
loadMain();
}
function addValue() {
addValue0();
loadMain();
}
function addSynonym() {
addSynonym0();
loadMain();
}
function deleteSchema() {
deleteSchema0();
loadMain();
}
function deleteValue() {
deleteValue0();
loadMain();
}
function deleteSynonym() {
deleteSynonym0();
loadMain();
}
function loadMain() {
1999-07-14 15:04:25 +00:00
/* create the title */
top.frames[title_frame].document.open();
top.frames[title_frame].document.write(
"<body bgcolor='#cccccc' name='schema'>" +
"<h3><center><b>Manage Personal Data</b></center></h3>" +
"</body>"
1999-06-19 21:08:33 +00:00
);
1999-07-14 15:04:25 +00:00
top.frames[title_frame].document.close();
1999-06-19 21:08:33 +00:00
/* create the schema list */
1999-07-14 15:04:25 +00:00
top.frames[schema_frame].document.open();
top.frames[schema_frame].document.write(
"<body bgcolor='#cccccc' name='schema'>" +
"<b>Field Names:</b><br>" +
"<form name='schema'>" +
"<table border='0' width='50%' bgcolor='#cccccc'>" +
"<tr>" +
"<td>" +
// "<select name='schemalist' size='10' onchange='top.lostFocus();'>"
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<select name='schemalist' size='10' onchange=\"setTimeout('top.lostFocus();',0)\">"
1999-06-19 21:08:33 +00:00
);
for (i=0; i!=schemasLength; i++) {
1999-06-19 21:08:33 +00:00
if (i == currentSchema) {
selected = " selected='selected'";
1999-06-19 21:08:33 +00:00
} else {
selected = "";
}
1999-07-14 15:04:25 +00:00
top.frames[schema_frame].document.write(
"<option" + selected + ">" + strings[values[schemas[i]]] + "</option>"
1999-06-19 21:08:33 +00:00
);
}
1999-07-14 15:04:25 +00:00
top.frames[schema_frame].document.write(
"</select>" +
"</td>" +
"</tr>" +
"<tr>" +
"<td>" +
// "<button onclick='parent.deleteSchema();'>Remove</button>" +
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.deleteSchema();',0)\">Remove</button>" +
"</td>" +
"<td>" +
// "<button onclick='parent.addSchema();'>Add New...</button>" +
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.addSchema();',0)\">Add New...</button>" +
"<br/>" +
"<input type='text' size='8' name='newSchema'>" +
"</td>" +
"</tr>" +
"</table>" +
"</form>" +
"</body>"
1999-06-19 21:08:33 +00:00
);
1999-07-14 15:04:25 +00:00
top.frames[schema_frame].document.close();
1999-06-19 21:08:33 +00:00
/* create the value list */
1999-07-14 15:04:25 +00:00
top.frames[value_frame].document.open();
top.frames[value_frame].document.write(
"<body bgcolor='#cccccc' name='schema'>" +
"<b>Entries for field:</b><br>" +
"<form name=value>" +
"<table border='0' width='50%' bgcolor='#cccccc'>" +
"<tr>" +
"<td>" +
// "<select name='valuelist' size='5' onchange='top.lostFocus();'>"
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<select name='valuelist' size='5' onchange=\"setTimeout('top.lostFocus();',0)\">"
1999-06-19 21:08:33 +00:00
);
for (i=schemas[currentSchema]; i!=schemas[currentSchema+1]; i++) {
1999-06-19 21:08:33 +00:00
if ((i-schemas[currentSchema]) == currentValue) {
selected = " selected='selected'";
1999-06-19 21:08:33 +00:00
} else {
selected = "";
}
if (strings[values[i]+1] != "") {
1999-07-14 15:04:25 +00:00
top.frames[value_frame].document.write(
"<option" + selected + ">" + strings[values[i]+1] + "</option>"
1999-06-19 21:08:33 +00:00
);
}
}
1999-07-14 15:04:25 +00:00
top.frames[value_frame].document.write(
"</select>" +
"</td>" +
"<td>" +
// "<button onclick='parent.deleteValue();'>Remove</button>" +
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.deleteValue();',0)\">Remove</button>" +
"<br/>" +
"<br/>" +
// "<button onclick='parent.addValue();'>Add New...</button>" +
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.addValue();',0)\">Add New...</button>" +
"<input type='text' size='8' name='newValue'>" +
"</td>" +
"</tr>" +
"</table>" +
"</form>" +
"</body>"
1999-06-19 21:08:33 +00:00
);
1999-07-14 15:04:25 +00:00
top.frames[value_frame].document.close();
1999-06-19 21:08:33 +00:00
/* create the synonym list */
1999-07-14 15:04:25 +00:00
top.frames[synonym_frame].document.open();
top.frames[synonym_frame].document.write(
"<body bgcolor='#cccccc' name='schema'>" +
"<b>Entries that mean the same:</b><br>" +
"<form name=synonym>" +
"<table border='0' width='50%' bgcolor='#cccccc'>" +
"<tr>" +
"<td>" +
// "<select name='synonymlist' size='3' onchange='top.lostFocus();'>"
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<select name='synonymlist' size='3' onchange=\"setTimeout('top.lostFocus();',0)\">"
1999-06-19 21:08:33 +00:00
);
for (i=values[schemas[currentSchema]+currentValue]+2; i!=values[schemas[currentSchema]+1]-1; i++) {
1999-06-19 21:08:33 +00:00
if ((i-(values[schemas[currentSchema]+currentValue]+2)) == currentSynonym) {
selected = " selected='selected'";
1999-06-19 21:08:33 +00:00
} else {
selected = "";
}
1999-07-14 15:04:25 +00:00
top.frames[synonym_frame].document.write(
"<option" + selected + ">" + strings[i] + "</option>"
1999-06-19 21:08:33 +00:00
);
}
1999-07-14 15:04:25 +00:00
top.frames[synonym_frame].document.write(
"</select>" +
"</td>" +
"<td>" +
// "<button onclick='parent.deleteSynonymSchema();'>Remove</button>" +
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.deleteSynonym();',0)\">Remove</button>" +
"<br/>" +
"<br/>" +
// "<button onclick='parent.addSynonym();'>Add New...</button>" +
1999-06-19 21:08:33 +00:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.addSynonym();',0)\">Add New...</button>" +
"<input type='text' size='8' name='newSynonym'>" +
"</td>" +
"</tr>" +
"</table>" +
"</form>" +
"</body>"
1999-07-14 15:04:25 +00:00
);
top.frames[synonym_frame].document.close();
/* create the buttons */
top.frames[button_frame].document.open();
top.frames[button_frame].document.write(
"<body bgcolor='#cccccc' name='schema'>" +
"<hr/>" +
"<form name=button>" +
"<div align='right'>" +
"<button onclick='parent.generateOutput(this.value);'>OK</button>" +
1999-07-14 15:04:25 +00:00
" &nbsp;&nbsp;" +
"<button onclick='parent.generateOutput(this.value);'>Cancel</button>" +
"</div>" +
"</form>" +
"</body>"
1999-06-19 21:08:33 +00:00
);
1999-07-14 15:04:25 +00:00
top.frames[button_frame].document.close();
1999-06-19 21:08:33 +00:00
}
function loadFrames() {
parseInput();
loadMain();
}
</script>
</head>
<frameset rows="44,*,56" frameborder="no" border="0" bordercolor="#cccccc" onload="loadFrames();">
<frame src="about:blank" frameborder="no" id="title_frame" bordercolor="#cccccc" scrolling="no"/>
<frameset cols="200,200" bordercolor="#cccccc">
<frame src="about:blank" id="schema_frame" frameborder="no" bordercolor="#cccccc" scrolling="auto"/>
<frameset rows="52%,48%" bordercolor="#cccccc">
<frame src="about:blank" id="value_frame" frameborder="no" bordercolor="#cccccc" scrolling="auto"/>
<frame src="about:blank" id="synonym_frame" frameborder="no" bordercolor="#cccccc" scrolling="auto"/>
</frameset>
</frameset>
<frame src="about:blank" id="button_frame" scrolling="no"/>
</frameset>
<noframes>
<body> <p> </p> </body>
</noframes>
</html>