pjs/extensions/wallet/editor/WalletEditor.html

584 строки
18 KiB
HTML
Исходник Обычный вид История

<html>
<head bgcolor='#cccccc'>
<title>Wallet</title>
<script>
1999-06-20 01:08:33 +04:00
/* for xpconnect */
var walleteditor =
Components.classes
["component://netscape/walleteditor/walleteditor-world"].createInstance();
walleteditor = walleteditor.QueryInterface(Components.interfaces.nsIWalletEditor);
function get()
{
return walleteditor.GetValue();
}
function set(value)
{
walleteditor.SetValue(value, window);
}
/* end of xpconnect stuff */
1999-07-14 19:04:25 +04:00
title_frame = 0;
schema_frame = 1;
value_frame = 2;
synonym_frame = 3;
button_frame = 4;
1999-06-20 01:08:33 +04: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) {
1999-08-18 09:44:45 +04:00
var i, j, k;
1999-06-20 01:08:33 +04:00
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-20 01:08:33 +04:00
output += strings[k] + BREAK;
}
}
}
set(output);
}
function parseInput() {
var input;
1999-08-18 09:44:45 +04:00
var i, j;
1999-06-20 01:08:33 +04:00
input = get();
1999-08-04 00:37:18 +04:00
/* check for user supplying invalid database key */
1999-06-20 01:08:33 +04:00
if (input.length == 0) {
1999-08-04 00:37:18 +04:00
flushTables();
BREAK = '+';
return false;
1999-06-20 01:08:33 +04:00
}
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-20 01:08:33 +04:00
}
}
values[j] = stringsLength;
j = 0;
for (i=0; !(i>=valuesLength); i++) {
1999-06-20 01:08:33 +04:00
if (i == 0 || (strings[values[i]] != strings[values[i-1]])) {
schemas[j++] = i;
schemasLength++;
}
}
schemas[j] = valuesLength;
1999-08-04 00:37:18 +04:00
return true;
1999-06-20 01:08:33 +04:00
}
function dumpStrings() {
/* for debugging purposes */
1999-08-18 09:44:45 +04:00
var i, j, k;
for (i=0; !(i>=schemasLength); i++) {
1999-08-18 09:44:45 +04:00
dump("<<"+i+" "+schemas[i]+" "+values[schemas[i]]+" "+strings[values[schemas[i]]] +">>\n");
for (j=schemas[i]; !(j>=schemas[i+1]); j++) {
1999-08-18 09:44:45 +04:00
dump("<< " + strings[values[j]+1] +">>\n");
for (k=values[j]+2; !(k>=values[j+1]-1); k++) {
1999-08-18 09:44:45 +04:00
dump("<<....." + strings[k] +">>\n");
1999-06-20 01:08:33 +04:00
}
}
}
1999-08-18 09:44:45 +04:00
dump("\n");
1999-06-20 01:08:33 +04:00
}
function dumpRawStrings() {
/* for debugging purposes */
1999-08-18 09:44:45 +04:00
var i;
dump("Schemas follow\n");
for (i=0; !(i>=schemasLength); i++) {
1999-08-18 09:44:45 +04:00
dump("{" + schemas[i] + "}");
1999-06-20 01:08:33 +04:00
}
1999-08-18 09:44:45 +04:00
dump("[" + schemas[schemasLength] + "]");
dump("\nValues follow\n");
for (i=0; !(i>=valuesLength); i++) {
1999-08-18 09:44:45 +04:00
dump("{" + values[i] + "}");
1999-06-20 01:08:33 +04:00
}
1999-08-18 09:44:45 +04:00
dump("[" + values[valuesLength] + "]");
dump("\nStrings follow\n");
for (i=0; !(i>=stringsLength); i++) {
1999-08-18 09:44:45 +04:00
dump("{" + strings[i] + "}");
1999-06-20 01:08:33 +04:00
}
1999-08-18 09:44:45 +04:00
dump("\n");
1999-06-20 01:08:33 +04:00
}
function lostFocus() {
1999-07-14 19:04:25 +04: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-20 01:08:33 +04:00
if (!(schemalist.selectedIndex>=0)) {
1999-06-20 01:08:33 +04: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-20 01:08:33 +04: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-20 01:08:33 +04: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() {
1999-08-18 09:44:45 +04:00
var i;
1999-06-20 01:08:33 +04:00
if (schemasLength == 1) {
flushTables();
return;
}
currentValue = 0;
numberOfValues = schemas[currentSchema+1] - schemas[currentSchema];
for (i=0; !(i>=numberOfValues); i++) {
1999-06-20 01:08:33 +04:00
deleteValue0();
}
deleteString(values[schemas[currentSchema]]+1); /* delete blank line */
deleteString(values[schemas[currentSchema]]); /* delete name of schema */
1999-08-18 09:44:45 +04:00
valuesLength--;
for (i=schemas[currentSchema]; !(i>valuesLength); i++) {
values[i] = values[i+1];
}
for (i=0; !(i>schemasLength); i++) {
if (schemas[i] > valueToDelete) {
schemas[i]--;
}
}
1999-06-20 01:08:33 +04:00
schemasLength--;
1999-08-18 09:44:45 +04:00
for (i=currentSchema; !(i>schemasLength); i++) {
1999-06-20 01:08:33 +04:00
schemas[i] = schemas[i+1];
}
}
function deleteValue0() {
1999-08-18 09:44:45 +04:00
var i;
1999-06-20 01:08:33 +04:00
valueToDelete = schemas[currentSchema]+currentValue;
currentSynonym = 0;
while (!(values[valueToDelete]+2 >= values[valueToDelete+1]-1)) {
1999-06-20 01:08:33 +04: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--;
1999-08-18 09:44:45 +04:00
for (i=valueToDelete; !(i>valuesLength); i++) {
1999-06-20 01:08:33 +04:00
values[i] = values[i+1];
}
1999-08-18 09:44:45 +04:00
for (i=0; !(i>schemasLength); i++) {
1999-06-20 01:08:33 +04:00
if (schemas[i] > valueToDelete) {
schemas[i]--;
}
}
}
function deleteSynonym0() {
stringToDelete = values[schemas[currentSchema]+currentValue]+2+currentSynonym;
deleteString(stringToDelete);
}
function addSchema0() {
1999-08-18 09:44:45 +04:00
var i;
1999-07-14 19:04:25 +04:00
text = top.frames[schema_frame].document.schema.newSchema;
1999-09-03 01:37:24 +04:00
if (text.value == "") {
return;
}
1999-06-20 01:08:33 +04:00
schemaIndex = 0;
while ((schemaIndex<schemasLength) &&!(strings[values[schemas[schemaIndex]]] >= text.value)) {
1999-06-20 01:08:33 +04: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-08-18 09:44:45 +04:00
var i;
1999-07-14 19:04:25 +04:00
text = top.frames[value_frame].document.value.newValue;
1999-09-03 01:37:24 +04:00
if (text.value == "") {
return;
}
1999-06-20 01:08:33 +04: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-20 01:08:33 +04:00
schemas[i]++;
}
}
function addSynonym0() {
1999-07-14 19:04:25 +04:00
text = top.frames[synonym_frame].document.synonym.newSynonym;
1999-09-03 01:37:24 +04:00
if (text.value == "") {
return;
}
1999-06-20 01:08:33 +04:00
addString(values[schemas[currentSchema]+currentValue]+2, text.value);
}
function deleteString(stringToDelete) {
1999-08-18 09:44:45 +04:00
var i;
1999-06-20 01:08:33 +04:00
stringsLength--;
for (i=stringToDelete; !(i>=stringsLength); i++) {
1999-06-20 01:08:33 +04:00
strings[i] = strings[i+1];
}
for (i=0; !(i>valuesLength); i++) {
1999-06-20 01:08:33 +04:00
if (values[i] > stringToDelete) {
values[i]--;
}
}
}
function addString(stringToAdd, text) {
1999-08-18 09:44:45 +04:00
var i;
1999-06-20 01:08:33 +04:00
stringsLength++;
for (i=stringsLength; i>stringToAdd; i--) {
strings[i] = strings[i-1];
}
strings[stringToAdd] = text;
for (i=0; !(i>valuesLength); i++) {
1999-06-20 01:08:33 +04:00
if (values[i] >= stringToAdd) {
values[i]++;
}
}
}
function addSchema() {
addSchema0();
loadMain();
}
function addValue() {
if (schemasLength != 0) {
addValue0();
loadMain();
}
1999-06-20 01:08:33 +04:00
}
function addSynonym() {
if (schemasLength != 0) {
addSynonym0();
loadMain();
}
1999-06-20 01:08:33 +04:00
}
function deleteSchema() {
deleteSchema0();
loadMain();
}
function deleteValue() {
deleteValue0();
loadMain();
}
function deleteSynonym() {
deleteSynonym0();
loadMain();
}
function loadMain() {
1999-07-14 19:04:25 +04: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-20 01:08:33 +04:00
);
1999-07-14 19:04:25 +04:00
top.frames[title_frame].document.close();
1999-06-20 01:08:33 +04:00
/* create the schema list */
1999-07-14 19:04:25 +04: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-20 01:08:33 +04:00
// (bug 3317 workaround)
"<select name='schemalist' size='10' onchange=\"setTimeout('top.lostFocus();',0)\">"
1999-06-20 01:08:33 +04:00
);
for (i=0; !(i>=schemasLength); i++) {
1999-06-20 01:08:33 +04:00
if (i == currentSchema) {
selected = " selected='selected'";
1999-06-20 01:08:33 +04:00
} else {
selected = "";
}
1999-07-14 19:04:25 +04:00
top.frames[schema_frame].document.write(
"<option" + selected + ">" + strings[values[schemas[i]]] + "</option>"
1999-06-20 01:08:33 +04:00
);
}
1999-07-14 19:04:25 +04:00
top.frames[schema_frame].document.write(
"</select>" +
"</td>" +
"</tr>" +
"<tr>" +
"<td>" +
// "<button onclick='parent.deleteSchema();'>Remove</button>" +
1999-06-20 01:08:33 +04:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.deleteSchema();',0)\">Remove</button>" +
"</td>" +
1999-09-03 01:37:24 +04:00
"</tr>" +
"<tr>" +
"<td>" +
1999-09-03 01:37:24 +04:00
"<nobr>" +
"<input type='text' size='8' name='newSchema'>" +
// "<button onclick='parent.addSchema();'>Add</button>" +
1999-06-20 01:08:33 +04:00
// (bug 3317 workaround)
1999-09-03 01:37:24 +04:00
"<button onclick=\"setTimeout('parent.addSchema();',0)\">Add</button>" +
"</nobr>" +
"</td>" +
"</tr>" +
"</table>" +
"</form>" +
"</body>"
1999-06-20 01:08:33 +04:00
);
1999-07-14 19:04:25 +04:00
top.frames[schema_frame].document.close();
1999-06-20 01:08:33 +04:00
/* create the value list */
1999-07-14 19:04:25 +04: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-20 01:08:33 +04:00
// (bug 3317 workaround)
"<select name='valuelist' size='5' onchange=\"setTimeout('top.lostFocus();',0)\">"
1999-06-20 01:08:33 +04:00
);
for (i=schemas[currentSchema]; !(i>=schemas[currentSchema+1]); i++) {
1999-06-20 01:08:33 +04:00
if ((i-schemas[currentSchema]) == currentValue) {
selected = " selected='selected'";
1999-06-20 01:08:33 +04:00
} else {
selected = "";
}
if (strings[values[i]+1] != "") {
1999-07-14 19:04:25 +04:00
top.frames[value_frame].document.write(
"<option" + selected + ">" + strings[values[i]+1] + "</option>"
1999-06-20 01:08:33 +04:00
);
}
}
1999-07-14 19:04:25 +04:00
top.frames[value_frame].document.write(
"</select>" +
"</td>" +
"<td>" +
// "<button onclick='parent.deleteValue();'>Remove</button>" +
1999-06-20 01:08:33 +04:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.deleteValue();',0)\">Remove</button>" +
"<br/>" +
1999-09-03 01:37:24 +04:00
"<nobr>" +
"<input type='text' size='8' name='newValue'>" +
// "<button onclick='parent.addValue();'>Add</button>" +
1999-06-20 01:08:33 +04:00
// (bug 3317 workaround)
1999-09-03 01:37:24 +04:00
"<button onclick=\"setTimeout('parent.addValue();',0)\">Add</button>" +
"</nobr>" +
"</td>" +
"</tr>" +
"</table>" +
"</form>" +
"</body>"
1999-06-20 01:08:33 +04:00
);
1999-07-14 19:04:25 +04:00
top.frames[value_frame].document.close();
1999-06-20 01:08:33 +04:00
/* create the synonym list */
1999-07-14 19:04:25 +04:00
top.frames[synonym_frame].document.open();
top.frames[synonym_frame].document.write(
"<body bgcolor='#cccccc' name='schema'>" +
1999-09-03 01:37:24 +04:00
"<b>Entries that mean the same as the above:</b><br>" +
"<form name=synonym>" +
"<table border='0' width='50%' bgcolor='#cccccc'>" +
"<tr>" +
"<td>" +
// "<select name='synonymlist' size='3' onchange='top.lostFocus();'>"
1999-06-20 01:08:33 +04:00
// (bug 3317 workaround)
"<select name='synonymlist' size='3' onchange=\"setTimeout('top.lostFocus();',0)\">"
1999-06-20 01:08:33 +04:00
);
for (i=values[schemas[currentSchema]+currentValue]+2; !(i>=values[schemas[currentSchema]+1]-1); i++) {
1999-06-20 01:08:33 +04:00
if ((i-(values[schemas[currentSchema]+currentValue]+2)) == currentSynonym) {
selected = " selected='selected'";
1999-06-20 01:08:33 +04:00
} else {
selected = "";
}
1999-07-14 19:04:25 +04:00
top.frames[synonym_frame].document.write(
"<option" + selected + ">" + strings[i] + "</option>"
1999-06-20 01:08:33 +04:00
);
}
1999-07-14 19:04:25 +04:00
top.frames[synonym_frame].document.write(
"</select>" +
"</td>" +
"<td>" +
// "<button onclick='parent.deleteSynonymSchema();'>Remove</button>" +
1999-06-20 01:08:33 +04:00
// (bug 3317 workaround)
"<button onclick=\"setTimeout('parent.deleteSynonym();',0)\">Remove</button>" +
"<br/>" +
1999-09-03 01:37:24 +04:00
"<nobr>" +
"<input type='text' size='8' name='newSynonym'>" +
// "<button onclick='parent.addSynonym();'>Add</button>" +
1999-06-20 01:08:33 +04:00
// (bug 3317 workaround)
1999-09-03 01:37:24 +04:00
"<button onclick=\"setTimeout('parent.addSynonym();',0)\">Add</button>" +
"</nobr>" +
"</td>" +
"</tr>" +
"</table>" +
"</form>" +
"</body>"
1999-07-14 19:04:25 +04: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'>" +
1999-08-11 01:24:32 +04:00
"<button value='OK' onclick='parent.generateOutput(this.value);'>OK</button>" +
1999-07-14 19:04:25 +04:00
" &nbsp;&nbsp;" +
1999-08-11 01:24:32 +04:00
"<button value='Cancel' onclick='parent.generateOutput(this.value);'>Cancel</button>" +
"</div>" +
"</form>" +
"</body>"
1999-06-20 01:08:33 +04:00
);
1999-07-14 19:04:25 +04:00
top.frames[button_frame].document.close();
1999-06-20 01:08:33 +04:00
}
function loadFrames() {
1999-08-04 00:37:18 +04:00
if (!parseInput()) {
setTimeout('parent.generateOutput("Cancel")',0);
} else {
loadMain();
}
1999-06-20 01:08:33 +04:00
}
</script>
</head>
1999-09-03 01:37:24 +04:00
<frameset rows="15,115,30" frameborder="no" border="0" bordercolor="#cccccc" onload="loadFrames();">
<frame src="about:blank" frameborder="no" id="title_frame" bordercolor="#cccccc" scrolling="no"/>
1999-09-03 01:37:24 +04:00
<frameset cols="100,200" bordercolor="#cccccc">
<frame src="about:blank" id="schema_frame" frameborder="no bordercolor="#cccccc" scrolling="auto"/>
<frameset rows="53%,47%" 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>