[freenet-cvs] r11271 - trunk/freenet/src/freenet/clients/http

toad at freenetproject.org toad at freenetproject.org
Wed Dec 6 16:33:21 UTC 2006


Author: toad
Date: 2006-12-06 16:33:18 +0000 (Wed, 06 Dec 2006)
New Revision: 11271

Modified:
   trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
Log:
Tidy up a bit

Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java	2006-12-06 10:43:42 UTC (rev 11270)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java	2006-12-06 16:33:18 UTC (rev 11271)
@@ -364,20 +364,20 @@
 				HTMLNode peerTable = peerForm.addChild("table", "class", "darknet_connections");
 				HTMLNode peerTableHeaderRow = peerTable.addChild("tr");
 				peerTableHeaderRow.addChild("th");
-				peerTableHeaderRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=status" : "?sortBy=status&reversed")).addChild("#", "Status");
-				peerTableHeaderRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=name" : "?sortBy=name&reversed")).addChild("span", new String[] { "title", "style" }, new String[] { "The node's name. Click on the name link to send the node a N2NTM (Node To Node Text Message)", "border-bottom: 1px dotted; cursor: help;" }, "Name");
+				peerTableHeaderRow.addChild("th").addChild("a", "href", sortString(isReversed, "status")).addChild("#", "Status");
+				peerTableHeaderRow.addChild("th").addChild("a", "href", sortString(isReversed, "name")).addChild("span", new String[] { "title", "style" }, new String[] { "The node's name. Click on the name link to send the node a N2NTM (Node To Node Text Message)", "border-bottom: 1px dotted; cursor: help;" }, "Name");
 				if (advancedEnabled) {
-					peerTableHeaderRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=address" : "?sortBy=address&reversed")).addChild("span", new String[] { "title", "style" }, new String[] { "The node's network address as IP:Port", "border-bottom: 1px dotted; cursor: help;" }, "Address");
+					peerTableHeaderRow.addChild("th").addChild("a", "href", sortString(isReversed, "address")).addChild("span", new String[] { "title", "style" }, new String[] { "The node's network address as IP:Port", "border-bottom: 1px dotted; cursor: help;" }, "Address");
 				}
-				peerTableHeaderRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=version" : "?sortBy=version&reversed")).addChild("#", "Version");
+				peerTableHeaderRow.addChild("th").addChild("a", "href", sortString(isReversed, "version")).addChild("#", "Version");
 				if (advancedEnabled) {
-					peerTableHeaderRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=location" : "?sortBy=location&reversed")).addChild("#", "Location");
+					peerTableHeaderRow.addChild("th").addChild("a", "href", sortString(isReversed, "location")).addChild("#", "Location");
 					peerTableHeaderRow.addChild("th").addChild("span", new String[] { "title", "style" }, new String[] { "Other node busy? Display: Percentage of time the node is overloaded, Current wait time remaining (0=not overloaded)/total/last overload reason", "border-bottom: 1px dotted; cursor: help;" }, "Backoff");
 
 					peerTableHeaderRow.addChild("th").addChild("span", new String[] { "title", "style" }, new String[] { "Probability of the node rejecting a request due to overload or causing a timeout.", "border-bottom: 1px dotted; cursor: help;" }, "Overload Probability");
 				}
 				peerTableHeaderRow.addChild("th").addChild("span", new String[] { "title", "style" }, new String[] { "How long since the node was connected or last seen", "border-bottom: 1px dotted; cursor: help;" }, "Connected\u00a0/\u00a0Idle");
-				peerTableHeaderRow.addChild("th").addChild("a", "href", (isReversed ? "?sortBy=privnote" : "?sortBy=privnote&reversed")).addChild("span", new String[] { "title", "style" }, new String[] { "A private note concerning this peer", "border-bottom: 1px dotted; cursor: help;" }, "Private Note");
+				peerTableHeaderRow.addChild("th").addChild("a", "href", sortString(isReversed, "privnote")).addChild("span", new String[] { "title", "style" }, new String[] { "A private note concerning this peer", "border-bottom: 1px dotted; cursor: help;" }, "Private Note");
 
 				if(advancedEnabled) {
 					peerTableHeaderRow.addChild("th", "%\u00a0Time Routable");
@@ -595,6 +595,10 @@
 		this.writeReply(ctx, 200, "text/html", "OK", pageBuffer.toString());
 	}
 	
+	private String sortString(boolean isReversed, String type) {
+		return (isReversed ? ("?sortBy="+type) : ("?sortBy="+type+"&reversed"));
+	}
+
 	public void handlePost(URI uri, Bucket data, ToadletContext ctx) throws ToadletContextClosedException, IOException, RedirectException {
 		if(data.size() > 1024*1024) {
 			this.writeReply(ctx, 400, "text/plain", "Too big", "Too much data, darknet toadlet limited to 1MB");




More information about the cvs mailing list