Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit 18138e9

Browse files
author
matthew
committed
[svn] Fix accidentally broken (stupid if braces) insert, and use tempParams to avoid fouling the object.
--HG-- branch : ProveIt
1 parent ed0b2fc commit 18138e9

File tree

2 files changed

+46
-26
lines changed

2 files changed

+46
-26
lines changed

content/test.js

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,12 @@ com.elclab.proveit = {
597597

598598
insertRef : function(ref, full)
599599
{
600-
//com.elclab.proveit.log("Entering insertRef.")
600+
com.elclab.proveit.log("Entering insertRef.");
601601
var txtarea = com.elclab.proveit.getMWEditBox();
602602
if(!txtarea)
603+
{
603604
return false;
605+
}
604606
var sel = com.elclab.proveit.getInsertionText(ref, full);
605607

606608
// var start = top.window.content.document
@@ -641,10 +643,12 @@ com.elclab.proveit = {
641643
* location of the cursor in the document.
642644
*/
643645
insertSelectedRef : function() {
644-
//com.elclab.proveit.log("Entering insert.");
646+
com.elclab.proveit.log("Entering insertSelectedRef.");
645647
if (com.elclab.proveit.getRefbox().selectedItem) {
646648
if(com.elclab.proveit.currentrefs == [])
647-
//com.elclab.proveit.log("currentrefs is undefined.");
649+
{
650+
com.elclab.proveit.log("currentrefs is undefined.");
651+
}
648652
//var sel = com.elclab.proveit.getSidebarDoc().getElementById('display').value;
649653
/*else
650654
com.elclab.proveit.log("currentrefs: " + com.elclab.proveit.currentrefs);*/
@@ -832,12 +836,15 @@ com.elclab.proveit = {
832836
for (var i = 0; i < list.length; i++) {
833837
if (list[i]) {
834838
// com.elclab.proveit.log(item + ":" + list[item].id);
835-
var node = list[i].id;
836-
com.elclab.proveit.log("item: " + i);
837-
com.elclab.proveit.log("node: " + node);
838-
delete(com.elclab.proveit.currentrefs[name].params[node]);
839-
//var paramName = com.elclab.proveit.getSidebarDoc().getElementById(node + "namec").value;
839+
//var node = list[i].id;
840+
//com.elclab.proveit.log("item: " + i);
840841
var paramName = list[i].childNodes[0].value;
842+
//com.elclab.proveit.log("node: " + node);
843+
844+
//delete(com.elclab.proveit.currentrefs[name].params[node]);
845+
delete(com.elclab.proveit.currentrefs[name].params[paramName]);
846+
847+
//var paramName = com.elclab.proveit.getSidebarDoc().getElementById(node + "namec").value;
841848
com.elclab.proveit.log("paramName: " + paramName);
842849
//var paramVal = com.elclab.proveit.getSidebarDoc().getElementById(node + "value").value;
843850
var paramVal = list[i].childNodes[2].value;
@@ -1014,7 +1021,7 @@ com.elclab.proveit = {
10141021
com.elclab.proveit.log("Entering updateEditPopup.")
10151022
var box = com.elclab.proveit.getSidebarDoc().getElementById("editlist");
10161023
var size = box.childNodes.length;
1017-
com.elclab.proveit.log("Before size: " + size);
1024+
//com.elclab.proveit.log("Before size: " + size);
10181025
//for (var i = 0; i < size; i++) {
10191026
while(box.childNodes.length > 0) // Above apparently can get into race condition.
10201027
{
@@ -1026,12 +1033,12 @@ com.elclab.proveit = {
10261033
}
10271034

10281035
size = box.childNodes.length;
1029-
com.elclab.proveit.log("After size: " + size);
1036+
//com.elclab.proveit.log("After size: " + size);
10301037

10311038

10321039
//var name = com.elclab.proveit.getRef().selectedItem.id;
10331040
var name = com.elclab.proveit.curRefItem.id;
1034-
com.elclab.proveit.log("name: " + name);
1041+
//com.elclab.proveit.log("name: " + name);
10351042

10361043
var current = com.elclab.proveit.currentrefs[name];
10371044

@@ -1056,29 +1063,37 @@ com.elclab.proveit = {
10561063
{
10571064
refNameValue.value = "";
10581065
}
1066+
1067+
// Don't contaminate actual object with junk params.
1068+
var tempParams = {};
1069+
for(e in current.params)
1070+
{
1071+
tempParams[e] = current.params[e];
1072+
}
1073+
10591074
// Add default params with blank values.
10601075
var defaults = current.getDefaultParams();
10611076
for(var i = 0; i < defaults.length; i++)
10621077
{
1063-
if(!current.params[defaults[i]])
1078+
if(!tempParams[defaults[i]])
10641079
{
1065-
com.elclab.proveit.log("Setting default blank parameter: defaults[i] = " + defaults[i]);
1066-
current.params[defaults[i]] = "";
1080+
//com.elclab.proveit.log("Setting default blank parameter: defaults[i] = " + defaults[i]);
1081+
tempParams[defaults[i]] = "";
10671082
}
10681083
}
10691084

10701085
var required = current.getRequiredParams();
10711086

10721087
var paramNames = new Array();
10731088
//First run through just to get names.
1074-
com.elclab.proveit.log("Adding params to array.");
1075-
for(item in current.params)
1089+
//com.elclab.proveit.log("Adding params to array.");
1090+
for(item in tempParams)
10761091
{
1077-
com.elclab.proveit.log(item);
1092+
//com.elclab.proveit.log(item);
10781093
paramNames.push(item);
10791094
}
10801095

1081-
com.elclab.proveit.log("Done adding params to array.");
1096+
//com.elclab.proveit.log("Done adding params to array.");
10821097

10831098
var sorter = current.getSorter();
10841099
if(sorter)
@@ -1096,18 +1111,18 @@ com.elclab.proveit = {
10961111
*/
10971112

10981113
size = box.childNodes.length;
1099-
com.elclab.proveit.log("Before size: " + size);
1114+
//com.elclab.proveit.log("Before size: " + size);
11001115

11011116
for(var i = 0; i < paramNames.length; i++) {
1102-
//com.elclab.proveit.log("Calling addEditPopupRow on current.params." + item);
1103-
com.elclab.proveit.log("i: " + i + ", paramNames[i]: " + paramNames[i]);
1104-
com.elclab.proveit.addEditPopupRow(current.params, paramNames[i], required[paramNames[i]], true);
1117+
//com.elclab.proveit.log("Calling addEditPopupRow on tempParams." + item);
1118+
//com.elclab.proveit.log("i: " + i + ", paramNames[i]: " + paramNames[i]);
1119+
com.elclab.proveit.addEditPopupRow(tempParams, paramNames[i], required[paramNames[i]], true);
11051120
}
11061121

1107-
size = box.childNodes.length;
1108-
com.elclab.proveit.log("After size: " + size);
1122+
//size = box.childNodes.length;
1123+
//com.elclab.proveit.log("After size: " + size);
11091124

1110-
com.elclab.proveit.log("Leaving updateEditPopup");
1125+
//com.elclab.proveit.log("Leaving updateEditPopup");
11111126
},
11121127

11131128
/**
@@ -1119,10 +1134,13 @@ com.elclab.proveit = {
11191134
*/
11201135
addEditPopupRow : function(list, item, req, fieldType)
11211136
{
1137+
/*
11221138
com.elclab.proveit.log("Entering addEditPopupRow.");
11231139
com.elclab.proveit.log("item: " + item);
11241140
com.elclab.proveit.log("req: " + req);
11251141
com.elclab.proveit.log("fieldType: " + fieldType);
1142+
*/
1143+
11261144
/*
11271145
if (item != "type" && item != "toString" && item != "orig"
11281146
&& item != "save") {
@@ -1133,10 +1151,12 @@ com.elclab.proveit = {
11331151
var left = newline.childNodes[0];
11341152
var right = newline.childNodes[2];
11351153
//newline.id = "" + item;
1154+
/*
11361155
com.elclab.proveit.log("About to set id of hbox to: " + item);
11371156
com.elclab.proveit.log("Checking for already existing item. Should be null: "
11381157
+ com.elclab.proveit.getSidebarDoc().getElementById(item));
11391158
newline.id = item;
1159+
*/
11401160
newline.hidden = false;
11411161
com.elclab.proveit.getSidebarDoc().getElementById("editlist").appendChild(newline);
11421162

install.rdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<Description about="urn:mozilla:install-manifest">
77
<em:name>ProveIt</em:name>
8-
<em:version>1.0.626</em:version>
8+
<em:version>1.0.630</em:version>
99
<em:description>A Extension to facilitate the insertion of citation tags in Wikipedia.</em:description>
1010
<em:creator>Christopher Jordan and Matthew Flaschen</em:creator>
1111
<em:id>ProveIt@somedomain.com</em:id>

0 commit comments

Comments
 (0)