Skip to content

Commit

Permalink
Next page buttons #619 err fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ollie64 committed Sep 16, 2015
1 parent 6cd0ff8 commit bad9fd2
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions celos-ui/src/main/java/com/collective/celos/ui/UIServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,16 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws Ser
}

static ScheduledTime getDisplayTime(String timeStr) {
final ScheduledTime now = ScheduledTime.now();
if (timeStr == null) {
return ScheduledTime.now();
return now;
} else {
return new ScheduledTime(timeStr);
final ScheduledTime time = new ScheduledTime(timeStr);
if (time.compareTo(now) > 0) {
return time;
} else {
return now;
}
}
}

Expand Down Expand Up @@ -155,12 +161,20 @@ private static Tag makeBody(UIConfiguration conf) {

private static Tag makePaginationButtons(UIConfiguration conf) {
List<Tag> contents = new ArrayList<>();
String tParam1 = TIME_PARAM + "=" + (conf.getTimeParam().plusMinutes(conf.getZoomLevelMinutes()));
String tParam2 = TIME_PARAM + "=" + (conf.getTimeParam().minusMinutes(conf.getZoomLevelMinutes()));
final int minutes = conf.getZoomLevelMinutes();
final int pos = Arrays.binarySearch(ZOOM_LEVEL_MINUTES, conf.getZoomLevelMinutes());
int window;
if (pos == ZOOM_LEVEL_MINUTES.length - 1) {
window = minutes * 8;
} else {
window = ZOOM_LEVEL_MINUTES[pos+1] / 2;
}
String tParam1 = TIME_PARAM + "=" + (conf.getTimeParam().plusMinutes(window));
String tParam2 = TIME_PARAM + "=" + (conf.getTimeParam().minusMinutes(window));
String urlPart = "/ui?" + ZOOM_PARAM + "=" + conf.getZoomLevelMinutes();
contents.add(a("< Prev page").withHref(urlPart + "&" + ZOOM_PARAM + "=" + tParam2));
contents.add(a("< Prev page").withHref(urlPart + "&" + tParam2));
contents.add(strong(" | "));
contents.add(a("Next page >").withHref(urlPart + "&" + ZOOM_PARAM + "=" + tParam1));
contents.add(a("Next page >").withHref(urlPart + "&" + tParam1));
return div().with(contents).withClass("bigButtons");
}

Expand Down

0 comments on commit bad9fd2

Please sign in to comment.