Author: zothar
Date: 2006-11-05 14:57:35 +0000 (Sun, 05 Nov 2006)
New Revision: 10824
Modified:
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/NodeClientCore.java
Log:
FProxy use of Javascript is now optional and off by default.
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-11-05 03:56:35 UTC (rev 10823)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-11-05 14:57:35 UTC (rev 10824)
@@ -77,6 +77,7 @@
}
final boolean advancedEnabled = node.isAdvancedDarknetEnabled();
+ final boolean fProxyJavascriptEnabled =
node.isFProxyJavascriptEnabled();
/* gather connection statistics */
PeerNodeStatus[] peerNodeStatuses = node.getPeerNodeStatuses();
@@ -285,35 +286,37 @@
// END OVERVIEW TABLE
// BEGIN PEER TABLE
- StringBuffer jsBuf = new StringBuffer();
- // FIXME: There's probably some icky Javascript in here
(this is the first thing that worked for me); feel free to fix up to Javascript
guru standards
- jsBuf.append( " function peerNoteChange() {\n" );
- jsBuf.append( " var theobj =
document.getElementById( \"action\" );\n" );
- jsBuf.append( " var length =
theobj.options.length;\n" );
- jsBuf.append( " for (var i = 0; i < length; i++)
{\n" );
- jsBuf.append( " if(theobj.options[i] ==
\"update_notes\") {\n" );
- jsBuf.append( " theobj.options[i].select =
true;\n" );
- jsBuf.append( " } else {\n" );
- jsBuf.append( " theobj.options[i].select =
false;\n" );
- jsBuf.append( " }\n" );
- jsBuf.append( " }\n" );
- jsBuf.append( " theobj.value=\"update_notes\";\n" );
- //jsBuf.append( " document.getElementById(
\"peersForm\" ).submit();\n" );
- jsBuf.append( " document.getElementById(
\"peersForm\" ).doAction.click();\n" );
- jsBuf.append( " }\n" );
- jsBuf.append( " function peerNoteBlur() {\n" );
- jsBuf.append( " var theobj =
document.getElementById( \"action\" );\n" );
- jsBuf.append( " var length =
theobj.options.length;\n" );
- jsBuf.append( " for (var i = 0; i < length; i++)
{\n" );
- jsBuf.append( " if(theobj.options[i] ==
\"update_notes\") {\n" );
- jsBuf.append( " theobj.options[i].select =
true;\n" );
- jsBuf.append( " } else {\n" );
- jsBuf.append( " theobj.options[i].select =
false;\n" );
- jsBuf.append( " }\n" );
- jsBuf.append( " }\n" );
- jsBuf.append( " theobj.value=\"update_notes\";\n" );
- jsBuf.append( " }\n" );
- contentNode.addChild("script", "type",
"text/javascript").addChild("%", jsBuf.toString());
+ if(fProxyJavascriptEnabled) {
+ StringBuffer jsBuf = new StringBuffer();
+ // FIXME: There's probably some icky Javascript
in here (this is the first thing that worked for me); feel free to fix up to
Javascript guru standards
+ jsBuf.append( " function peerNoteChange() {\n"
);
+ jsBuf.append( " var theobj =
document.getElementById( \"action\" );\n" );
+ jsBuf.append( " var length =
theobj.options.length;\n" );
+ jsBuf.append( " for (var i = 0; i < length;
i++) {\n" );
+ jsBuf.append( " if(theobj.options[i] ==
\"update_notes\") {\n" );
+ jsBuf.append( " theobj.options[i].select
= true;\n" );
+ jsBuf.append( " } else {\n" );
+ jsBuf.append( " theobj.options[i].select
= false;\n" );
+ jsBuf.append( " }\n" );
+ jsBuf.append( " }\n" );
+ jsBuf.append( "
theobj.value=\"update_notes\";\n" );
+ //jsBuf.append( " document.getElementById(
\"peersForm\" ).submit();\n" );
+ jsBuf.append( " document.getElementById(
\"peersForm\" ).doAction.click();\n" );
+ jsBuf.append( " }\n" );
+ jsBuf.append( " function peerNoteBlur() {\n" );
+ jsBuf.append( " var theobj =
document.getElementById( \"action\" );\n" );
+ jsBuf.append( " var length =
theobj.options.length;\n" );
+ jsBuf.append( " for (var i = 0; i < length;
i++) {\n" );
+ jsBuf.append( " if(theobj.options[i] ==
\"update_notes\") {\n" );
+ jsBuf.append( " theobj.options[i].select
= true;\n" );
+ jsBuf.append( " } else {\n" );
+ jsBuf.append( " theobj.options[i].select
= false;\n" );
+ jsBuf.append( " }\n" );
+ jsBuf.append( " }\n" );
+ jsBuf.append( "
theobj.value=\"update_notes\";\n" );
+ jsBuf.append( " }\n" );
+ contentNode.addChild("script", "type",
"text/javascript").addChild("%", jsBuf.toString());
+ }
HTMLNode peerTableInfobox = contentNode.addChild("div",
"class", "infobox infobox-normal");
HTMLNode peerTableInfoboxHeader =
peerTableInfobox.addChild("div", "class", "infobox-header");
peerTableInfoboxHeader.addChild("#", "My peers");
@@ -424,7 +427,11 @@
}
// private darknet node comment note
column
- peerRow.addChild("td", "class",
"peer-private-darknet-comment-note").addChild("input", new String[] { "type",
"name", "size", "maxlength", "onBlur", "onChange", "value" }, new String[] {
"text", "peerPrivateNote_" + peerNodeStatus.hashCode(), "16", "250",
"peerNoteBlur();", "peerNoteChange();",
peerNodeStatus.getPrivateDarknetCommentNote() });
+ if(fProxyJavascriptEnabled) {
+ peerRow.addChild("td", "class",
"peer-private-darknet-comment-note").addChild("input", new String[] { "type",
"name", "size", "maxlength", "onBlur", "onChange", "value" }, new String[] {
"text", "peerPrivateNote_" + peerNodeStatus.hashCode(), "16", "250",
"peerNoteBlur();", "peerNoteChange();",
peerNodeStatus.getPrivateDarknetCommentNote() });
+ } else {
+ peerRow.addChild("td", "class",
"peer-private-darknet-comment-note").addChild("input", new String[] { "type",
"name", "size", "maxlength", "value" }, new String[] { "text",
"peerPrivateNote_" + peerNodeStatus.hashCode(), "16", "250",
peerNodeStatus.getPrivateDarknetCommentNote() });
+ }
if(advancedEnabled) {
// percent of time connected
column
Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2006-11-05 03:56:35 UTC (rev 10823)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2006-11-05 14:57:35 UTC (rev 10824)
@@ -53,6 +53,7 @@
private String cssName;
private Thread myThread;
private boolean advancedDarknetEnabled;
+ private boolean fProxyJavascriptEnabled;
private final PageMaker pageMaker;
static boolean isPanicButtonToBeShown;
@@ -160,13 +161,33 @@
}
}
+ private static class FProxyJavascriptEnabledCallback implements
BooleanCallback {
+
+ private final SimpleToadletServer ts;
+
+ FProxyJavascriptEnabledCallback(SimpleToadletServer ts){
+ this.ts = ts;
+ }
+
+ public boolean get() {
+ return ts.isFProxyJavascriptEnabled();
+ }
+
+ public void set(boolean val) throws InvalidConfigValueException
{
+ if(val == get()) return;
+ ts.enableFProxyJavascript(val);
+ }
+ }
+
/**
* Create a SimpleToadletServer, using the settings from the SubConfig
(the fproxy.*
* config).
*/
public SimpleToadletServer(SubConfig fproxyConfig, NodeClientCore core)
throws IOException, InvalidConfigValueException {
+
+ int configItemOrder = 0;
- fproxyConfig.register("enabled", true, 1, true, true, "Enable
FProxy?", "Whether to enable FProxy and related HTTP services",
+ fproxyConfig.register("enabled", true, configItemOrder++, true,
true, "Enable FProxy?", "Whether to enable FProxy and related HTTP services",
new FProxyEnabledCallback());
boolean enabled = fproxyConfig.getBoolean("enabled");
@@ -212,17 +233,19 @@
}
}
- fproxyConfig.register("port", DEFAULT_FPROXY_PORT, 2, true,
false, "FProxy port number", "FProxy port number",
+ fproxyConfig.register("port", DEFAULT_FPROXY_PORT,
configItemOrder++, true, false, "FProxy port number", "FProxy port number",
new FProxyPortCallback());
- fproxyConfig.register("bindTo", "127.0.0.1", 2, true, false,
"IP address to bind to", "IP address to bind to",
+ fproxyConfig.register("bindTo", "127.0.0.1", configItemOrder++,
true, false, "IP address to bind to", "IP address to bind to",
new FProxyBindtoCallback());
- fproxyConfig.register("allowedHosts",
"127.0.0.1,0:0:0:0:0:0:0:1", 2, true, false, "Allowed hosts", "Hostnames or IP
addresses that are allowed to connect to FProxy. May be a comma-separated list
of hostnames, single IPs and even CIDR masked IPs like 192.168.0.0/24",
+ fproxyConfig.register("allowedHosts",
"127.0.0.1,0:0:0:0:0:0:0:1", configItemOrder++, true, false, "Allowed hosts",
"Hostnames or IP addresses that are allowed to connect to FProxy. May be a
comma-separated list of hostnames, single IPs and even CIDR masked IPs like
192.168.0.0/24",
new FProxyAllowedHostsCallback());
- fproxyConfig.register("css", "clean", 1, false, false, "CSS
Name", "Name of the CSS FProxy should use "+themes.toString(),
+ fproxyConfig.register("css", "clean", configItemOrder++, false,
false, "CSS Name", "Name of the CSS FProxy should use "+themes.toString(),
new FProxyCSSNameCallback());
- fproxyConfig.register("advancedDarknetEnabled", false, 1,
false, false, "Enable Advanced Darknet?", "Whether to show or not informations
meant for advanced users/devs. This setting should be turned to false in most
cases.",
+ fproxyConfig.register("advancedDarknetEnabled", false,
configItemOrder++, false, false, "Enable Advanced Darknet?", "Whether to show
or not informations meant for advanced users/devs. This setting should be
turned to false in most cases.",
new FProxyAdvancedDarknetEnabledCallback(this));
- fproxyConfig.register("showPanicButton", false, 1, true, true,
"Show the panic button?", "Whether to show or not the panic button on the
/queue/ page.",
+ fproxyConfig.register("javascriptEnabled", false,
configItemOrder++, false, false, "Enable FProxy use of Javascript?", "Whether
or not FProxy should use Javascript \"helpers\". This setting should be turned
to false in most cases.",
+ new FProxyJavascriptEnabledCallback(this));
+ fproxyConfig.register("showPanicButton", false,
configItemOrder++, true, true, "Show the panic button?", "Whether to show or
not the panic button on the /queue/ page.",
new BooleanCallback(){
public boolean get(){
return
SimpleToadletServer.isPanicButtonToBeShown;
@@ -386,4 +409,12 @@
public synchronized void enableAdvancedDarknet(boolean b){
advancedDarknetEnabled = b;
}
+
+ public synchronized boolean isFProxyJavascriptEnabled() {
+ return this.fProxyJavascriptEnabled;
+ }
+
+ public synchronized void enableFProxyJavascript(boolean b){
+ fProxyJavascriptEnabled = b;
+ }
}
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-11-05 03:56:35 UTC (rev
10823)
+++ trunk/freenet/src/freenet/node/Node.java 2006-11-05 14:57:35 UTC (rev
10824)
@@ -3107,6 +3107,10 @@
return clientCore.isAdvancedDarknetEnabled();
}
+ public boolean isFProxyJavascriptEnabled() {
+ return clientCore.isFProxyJavascriptEnabled();
+ }
+
// FIXME convert these kind of threads to Checkpointed's and implement
a handler
// using the PacketSender/Ticker. Would save a few threads.
Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java 2006-11-05 03:56:35 UTC
(rev 10823)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java 2006-11-05 14:57:35 UTC
(rev 10824)
@@ -757,6 +757,11 @@
getToadletContainer().isAdvancedDarknetEnabled();
}
+ public boolean isFProxyJavascriptEnabled() {
+ return (getToadletContainer() != null) &&
+ getToadletContainer().isFProxyJavascriptEnabled();
+ }
+
public String getMyName() {
return node.getMyName();
}