Skip to content

Commit

Permalink
Added a countdown on the home page
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulay committed Jun 13, 2011
1 parent cda8dea commit f241a16
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 19 deletions.
5 changes: 4 additions & 1 deletion app/controllers/Home.java
@@ -1,9 +1,11 @@
package controllers;

import java.util.Date;
import java.util.List;

import models.Person;
import models.PersonAndTimeSlot;
import org.joda.time.DateMidnight;
import play.mvc.Controller;
import play.mvc.With;

Expand All @@ -13,7 +15,8 @@ public class Home extends Controller {
public static void index() {
List<Person> freePersons = Person.getAllPerson(PersonAndTimeSlot.TimeSlotStatus.AVAILABLE);
List<Person> onCallPersons = Person.getAllPerson(PersonAndTimeSlot.TimeSlotStatus.ON_CALL);
render(freePersons, onCallPersons);
long timeToNextChange = (new DateMidnight().plusDays(1).toDate().getTime() - new Date().getTime()) / 1000;
render(freePersons, onCallPersons, timeToNextChange);
}

public static void deletePerson(long id) {
Expand Down
59 changes: 41 additions & 18 deletions app/views/Home/index.html
@@ -1,21 +1,44 @@
#{extends 'main.html' /}
#{set title:'Home page - Summary' /}
#{set 'moreScripts'}
<script src="@{'/public/javascripts/countdown.js'}" type="text/javascript" charset="utf-8"></script>
#{/set}
#{set 'moreStyles'}
<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/home.css'}"/>
#{/set}


#{if freePersons}
<h1><span>List of currently free employees</span></h1>
<ul>
#{list freePersons}
<li>${_.firstName} ${_.lastName}</li>
#{/list}
</ul>
#{/if}

#{if onCallPersons}
<h1><span>List of currently on call employees</span></h1>
<ul>
#{list onCallPersons}
<li>${_.firstName} ${_.lastName}</li>
#{/list}
</ul>
#{/if}
<table class="home-table">
<tbody>
<tr>
<td>
#{if freePersons}
<h1><span>List of currently free employees</span></h1>
<ul>
#{list freePersons}
<li>${_.firstName} ${_.lastName}</li>
#{/list}
</ul>
#{/if}
</td>
<td rowspan="2">
<div style="text-align:right">Next change in</div>
<div id="countdown_time"></div>
<script type="text/javascript">
jsCountdown.init(${timeToNextChange}, 'countdown_time');
</script>
</td>
</tr>
<tr>
<td>
#{if onCallPersons}
<h1><span>List of currently on call employees</span></h1>
<ul>
#{list onCallPersons}
<li>${_.firstName} ${_.lastName}</li>
#{/list}
</ul>
#{/if}
</td>
</tr>
</tbody>
</table>

0 comments on commit f241a16

Please sign in to comment.