* SusiDNS:
- Reduce displayed entries from 300 to 100 - Add ability to go forward or back - Make textareas bigger - Clean up file names - Clarify messages about filter and search
This commit is contained in:
@ -37,11 +37,13 @@ import java.util.Properties;
|
||||
public class AddressbookBean
|
||||
{
|
||||
private String book, action, serial, lastSerial, filter, search, hostname, destination;
|
||||
private int beginIndex, endIndex;
|
||||
private Properties properties, addressbook;
|
||||
private int trClass;
|
||||
private LinkedList deletionMarks;
|
||||
private static Comparator sorter;
|
||||
|
||||
private static final int DISPLAY_SIZE=100;
|
||||
|
||||
static {
|
||||
sorter = new AddressByNameSorter();
|
||||
}
|
||||
@ -74,6 +76,8 @@ public class AddressbookBean
|
||||
{
|
||||
properties = new Properties();
|
||||
deletionMarks = new LinkedList();
|
||||
beginIndex = 0;
|
||||
endIndex = DISPLAY_SIZE - 1;
|
||||
}
|
||||
private long configLastLoaded = 0;
|
||||
private static final String PRIVATE_BOOK = "private_addressbook";
|
||||
@ -106,6 +110,8 @@ public class AddressbookBean
|
||||
{
|
||||
loadConfig();
|
||||
String filename = properties.getProperty( getBook() + "_addressbook" );
|
||||
if (filename.startsWith("../"))
|
||||
return filename.substring(3);
|
||||
return ConfigBean.addressbookPrefix + filename;
|
||||
}
|
||||
private Object[] entries;
|
||||
@ -174,17 +180,45 @@ public class AddressbookBean
|
||||
}
|
||||
list.addLast( new AddressBean( name, destination ) );
|
||||
}
|
||||
// Format a message about filtered addressbook size, and the number of displayed entries
|
||||
if( filter != null && filter.length() > 0 )
|
||||
message = "Filtered l";
|
||||
else
|
||||
message = "L";
|
||||
message += "ist contains " + list.size() + " entries";
|
||||
if (list.size() > 300) message += ", displaying the first 300."; else message += ".";
|
||||
|
||||
Object array[] = list.toArray();
|
||||
Arrays.sort( array, sorter );
|
||||
entries = array;
|
||||
|
||||
// Format a message about filtered addressbook size, and the number of displayed entries
|
||||
// addressbook.jsp catches the case where the whole book is empty.
|
||||
String filterArg = "";
|
||||
if( search != null && search.length() > 0 ) {
|
||||
message = "Search ";
|
||||
}
|
||||
if( filter != null && filter.length() > 0 ) {
|
||||
if( search != null && search.length() > 0 )
|
||||
message += "within ";
|
||||
message += "Filtered list ";
|
||||
filterArg = "&filter=" + filter;
|
||||
}
|
||||
if (entries.length == 0) {
|
||||
message += "- no matches";
|
||||
} else if (getBeginInt() == 0 && getEndInt() == entries.length - 1) {
|
||||
if (message.length() == 0)
|
||||
message = "Addressbook ";
|
||||
message += "contains " + entries.length + " entries";
|
||||
} else {
|
||||
if (getBeginInt() > 0) {
|
||||
int newBegin = Math.max(0, getBeginInt() - DISPLAY_SIZE);
|
||||
int newEnd = Math.max(0, getBeginInt() - 1);
|
||||
message += "<a href=\"addressbook.jsp?book=" + getBook() + filterArg +
|
||||
"&begin=" + newBegin + "&end=" + newEnd + "\">" + newBegin +
|
||||
'-' + newEnd + "</a> | ";
|
||||
}
|
||||
message += "Showing " + getBegin() + '-' + getEnd() + " of " + entries.length;
|
||||
if (getEndInt() < entries.length - 1) {
|
||||
int newBegin = Math.min(entries.length - 1, getEndInt() + 1);
|
||||
int newEnd = Math.min(entries.length, getEndInt() + DISPLAY_SIZE);
|
||||
message += " | <a href=\"addressbook.jsp?book=" + getBook() + filterArg +
|
||||
"&begin=" + newBegin + "&end=" + newEnd + "\">" + newBegin +
|
||||
'-' + newEnd + "</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
|
||||
@ -302,4 +336,26 @@ public class AddressbookBean
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
private int getBeginInt() {
|
||||
return Math.max(0, Math.min(entries.length - 1, beginIndex));
|
||||
}
|
||||
public String getBegin() {
|
||||
return "" + getBeginInt();
|
||||
}
|
||||
public void setBegin(String s) {
|
||||
try {
|
||||
beginIndex = Integer.parseInt(s);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
private int getEndInt() {
|
||||
return Math.max(0, Math.max(getBeginInt(), Math.min(entries.length - 1, endIndex)));
|
||||
}
|
||||
public String getEnd() {
|
||||
return "" + getEndInt();
|
||||
}
|
||||
public void setEnd(String s) {
|
||||
try {
|
||||
endIndex = Integer.parseInt(s);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,10 @@
|
||||
|
||||
<div id="navi">
|
||||
<p>addressbooks
|
||||
<a href="addressbook.jsp?book=master">master</a> |
|
||||
<a href="addressbook.jsp?book=router">router</a> |
|
||||
<a href="addressbook.jsp?book=published">published</a> |
|
||||
<a href="addressbook.jsp?book=private">private</a> *
|
||||
<a href="addressbook.jsp?book=master&filter=none&begin=0&end=99">master</a> |
|
||||
<a href="addressbook.jsp?book=router&filter=none&begin=0&end=99">router</a> |
|
||||
<a href="addressbook.jsp?book=published&filter=none&begin=0&end=99">published</a> |
|
||||
<a href="addressbook.jsp?book=private&filter=none&begin=0&end=99">private</a> *
|
||||
<a href="subscriptions.jsp">subscriptions</a> *
|
||||
<a href="config.jsp">configuration</a> *
|
||||
<a href="index.jsp">overview</a>
|
||||
@ -64,42 +64,46 @@
|
||||
|
||||
<span>${book.loadBookMessages}</span>
|
||||
|
||||
<c:if test="${book.notEmpty}">
|
||||
<div id="filter">
|
||||
<p>Filter: <a href="addressbook.jsp?filter=a">a</a>
|
||||
<a href="addressbook.jsp?filter=b">b</a>
|
||||
<a href="addressbook.jsp?filter=c">c</a>
|
||||
<a href="addressbook.jsp?filter=d">d</a>
|
||||
<a href="addressbook.jsp?filter=e">e</a>
|
||||
<a href="addressbook.jsp?filter=f">f</a>
|
||||
<a href="addressbook.jsp?filter=g">g</a>
|
||||
<a href="addressbook.jsp?filter=h">h</a>
|
||||
<a href="addressbook.jsp?filter=i">i</a>
|
||||
<a href="addressbook.jsp?filter=j">j</a>
|
||||
<a href="addressbook.jsp?filter=k">k</a>
|
||||
<a href="addressbook.jsp?filter=l">l</a>
|
||||
<a href="addressbook.jsp?filter=m">m</a>
|
||||
<a href="addressbook.jsp?filter=n">n</a>
|
||||
<a href="addressbook.jsp?filter=o">o</a>
|
||||
<a href="addressbook.jsp?filter=p">p</a>
|
||||
<a href="addressbook.jsp?filter=q">q</a>
|
||||
<a href="addressbook.jsp?filter=r">r</a>
|
||||
<a href="addressbook.jsp?filter=s">s</a>
|
||||
<a href="addressbook.jsp?filter=t">t</a>
|
||||
<a href="addressbook.jsp?filter=u">u</a>
|
||||
<a href="addressbook.jsp?filter=v">v</a>
|
||||
<a href="addressbook.jsp?filter=w">w</a>
|
||||
<a href="addressbook.jsp?filter=x">x</a>
|
||||
<a href="addressbook.jsp?filter=y">y</a>
|
||||
<a href="addressbook.jsp?filter=z">z</a>
|
||||
<a href="addressbook.jsp?filter=0-9">0-9</a>
|
||||
<a href="addressbook.jsp?filter=none">all</a></p>
|
||||
<p>Filter:
|
||||
<a href="addressbook.jsp?filter=a&begin=0&end=99">a</a>
|
||||
<a href="addressbook.jsp?filter=b&begin=0&end=99">b</a>
|
||||
<a href="addressbook.jsp?filter=c&begin=0&end=99">c</a>
|
||||
<a href="addressbook.jsp?filter=d&begin=0&end=99">d</a>
|
||||
<a href="addressbook.jsp?filter=e&begin=0&end=99">e</a>
|
||||
<a href="addressbook.jsp?filter=f&begin=0&end=99">f</a>
|
||||
<a href="addressbook.jsp?filter=g&begin=0&end=99">g</a>
|
||||
<a href="addressbook.jsp?filter=h&begin=0&end=99">h</a>
|
||||
<a href="addressbook.jsp?filter=i&begin=0&end=99">i</a>
|
||||
<a href="addressbook.jsp?filter=j&begin=0&end=99">j</a>
|
||||
<a href="addressbook.jsp?filter=k&begin=0&end=99">k</a>
|
||||
<a href="addressbook.jsp?filter=l&begin=0&end=99">l</a>
|
||||
<a href="addressbook.jsp?filter=m&begin=0&end=99">m</a>
|
||||
<a href="addressbook.jsp?filter=n&begin=0&end=99">n</a>
|
||||
<a href="addressbook.jsp?filter=o&begin=0&end=99">o</a>
|
||||
<a href="addressbook.jsp?filter=p&begin=0&end=99">p</a>
|
||||
<a href="addressbook.jsp?filter=q&begin=0&end=99">q</a>
|
||||
<a href="addressbook.jsp?filter=r&begin=0&end=99">r</a>
|
||||
<a href="addressbook.jsp?filter=s&begin=0&end=99">s</a>
|
||||
<a href="addressbook.jsp?filter=t&begin=0&end=99">t</a>
|
||||
<a href="addressbook.jsp?filter=u&begin=0&end=99">u</a>
|
||||
<a href="addressbook.jsp?filter=v&begin=0&end=99">v</a>
|
||||
<a href="addressbook.jsp?filter=w&begin=0&end=99">w</a>
|
||||
<a href="addressbook.jsp?filter=x&begin=0&end=99">x</a>
|
||||
<a href="addressbook.jsp?filter=y&begin=0&end=99">y</a>
|
||||
<a href="addressbook.jsp?filter=z&begin=0&end=99">z</a>
|
||||
<a href="addressbook.jsp?filter=0-9&begin=0&end=99">0-9</a>
|
||||
<a href="addressbook.jsp?filter=none&begin=0&end=99">all</a></p>
|
||||
<c:if test="${book.hasFilter}">
|
||||
<p>Current filter: ${book.filter}
|
||||
(<a href="addressbook.jsp?filter=none">clear filter</a>)</p>
|
||||
(<a href="addressbook.jsp?filter=none&begin=0&end=99">clear filter</a>)</p>
|
||||
</c:if>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="addressbook.jsp">
|
||||
<input type="hidden" name="begin" value="0"/>
|
||||
<input type="hidden" name="end" value="99"/>
|
||||
<div id="search">
|
||||
<table><tr>
|
||||
<td class="search">Search: <input type="text" name="search" value="${book.search}" size="20" /></td>
|
||||
@ -109,9 +113,12 @@
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</c:if>
|
||||
|
||||
<form method="POST" action="addressbook.jsp">
|
||||
<input type="hidden" name="serial" value="${book.serial}"/>
|
||||
<input type="hidden" name="begin" value="0"/>
|
||||
<input type="hidden" name="end" value="99"/>
|
||||
|
||||
<c:if test="${book.notEmpty}">
|
||||
|
||||
@ -127,8 +134,8 @@
|
||||
<th>Name</th>
|
||||
<th>Destination</th>
|
||||
</tr>
|
||||
<!-- limit iterator to 300, or "Form too large" may result on submit -->
|
||||
<c:forEach items="${book.entries}" var="addr" begin="0" end="299">
|
||||
<!-- limit iterator, or "Form too large" may result on submit, and is a huge web page if we don't -->
|
||||
<c:forEach items="${book.entries}" var="addr" begin="${book.begin}" end="${book.end}">
|
||||
<tr class="list${book.trClass}">
|
||||
<c:if test="${book.master || book.router || book.published || book.private}">
|
||||
<td class="checkbox"><input type="checkbox" name="checked" value="${addr.name}" alt="Mark for deletion"></td>
|
||||
@ -136,7 +143,7 @@
|
||||
<td class="names"><a href="http://${addr.name}/">${addr.name}</a> -
|
||||
<span class="addrhlpr"><a href="http://${addr.name}/?i2paddresshelper=${addr.destination}">(addrhlpr)</a></span>
|
||||
</td>
|
||||
<td class="destinations"><textarea rows="1" cols="20" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td>
|
||||
<td class="destinations"><textarea rows="1" cols="40" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
@ -160,8 +167,9 @@
|
||||
<div id="add">
|
||||
<p class="add">
|
||||
<h3>Add new destination:</h3>
|
||||
Hostname: <input type="text" name="hostname" value="${book.hostname}" size="20">
|
||||
Destination: <textarea name="destination" rows="1" cols="20" wrap="off" >${book.destination}</textarea><br/>
|
||||
<b>Hostname:</b> <input type="text" name="hostname" value="${book.hostname}" size="20">
|
||||
<b>Destination:</b> <textarea name="destination" rows="1" cols="40" wrap="off" >${book.destination}</textarea><br/>
|
||||
</p><p>
|
||||
<input type="image" name="action" value="add" src="images/add.png" alt="Add destination" />
|
||||
</p>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user