-
Notifications
You must be signed in to change notification settings - Fork 10
/
index-templates-js.js
43 lines (36 loc) · 1.17 KB
/
index-templates-js.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$(document).ready(function() {
var oldestClients = clientRetriever.getOldestClients(5);
var bestClients = clientRetriever.getBestClients(5);
var clients = clientRetriever.getClients();
var onSelectHome = function() {
$(".panel-heading").html("Welcome");
$(".panel-body").html("<p>There are " + clients.length + " clients.</p>");
};
$("#home-btn").click(onSelectHome);
var clientsTemplate = _.template(
"<ul><li>" +
"<%_.forEach(clients, function (client,index) {%>" +
"<%if (index>0) {%>" +
"</li><li>" +
"<%}%>" +
"<%=transformations.getContactNameIdAndType(client)%>" +
"<%})%>" +
"</li></ul>");
$("#oldest-clients-btn").click(function() {
$(".panel-heading").html("Top 5 oldest clients with name, id and type");
var displayContent = clientsTemplate({
clients: oldestClients
});
$(".panel-body").html(
displayContent);
});
$("#best-clients-btn").click(function() {
$(".panel-heading").html("Top 5 best clients with name, id and type");
var displayContent = clientsTemplate({
clients: bestClients
});
$(".panel-body").html(
displayContent);
});
onSelectHome();
});