@@ -19,55 +19,84 @@ limitations under the License.
19
19
<html lang =" en" >
20
20
<head >
21
21
<title >Tabs VS Spaces</title >
22
- <link rel =" stylesheet" type =" text/css" href =" css/index.css" >
22
+ <link rel =" stylesheet"
23
+ href =" https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" >
24
+ <script src =" https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js" ></script >
23
25
</head >
24
26
<body >
25
- <div id =" main" >
26
- <aside > </aside >
27
- <article >
28
- <div id =" title" >
29
- <h1 class =" tabs" >TABS</h1 >
30
- <p >vs</p >
31
- <h1 class =" spaces" >SPACES</h1 >
32
- </div >
33
- <div id =" tally" >
34
- <p id =" tabs-tally" >Tabs: <%= request. getAttribute(" tabVoteCt" ) % > </p >
35
- <p id =" spaces-tally" >Spaces: <%= request. getAttribute(" spaceVoteCt" ) % > </p >
36
- <p id =" winner" >Currently <b ><%= request. getAttribute(" winningTeam" ) % > </b > is winning by <%= request. getAttribute(" voteDiff" ) % > votes</p >
27
+ <nav >
28
+ <div class =" nav-wrapper" >
29
+ <a href =" #" class =" brand-logo center" >Tabs vs. Spaces</a >
30
+ </div >
31
+ </nav >
32
+
33
+ <%
34
+ String tabsWinning = " " ;
35
+ if (request. getAttribute(" winningTeam" ) == " TABS" ) {
36
+ tabsWinning = " green lighten-4" ;
37
+ }
38
+ String spacesWinning = " " ;
39
+ if (request. getAttribute(" winningTeam" ) == " SPACES" ) {
40
+ spacesWinning = " green lighten-4" ;
41
+ }
42
+ % >
43
+ <div class =" section" >
44
+ <div class =" row center" >
45
+ <div class =" col s6 m5 offset-m1" >
46
+ <div class =" card-panel <%= tabsWinning % >" >
47
+ <h3 >Tabs</h3 >
48
+ <h3 ><%= request. getAttribute(" tabVoteCt" ) % > </h3 >
37
49
</div >
38
- <div id =" history" >
39
- <%
40
- List<String > votesTeam = (List<String > ) request. getAttribute(" votesTeam" );
41
- List<Timestamp > votesTs = (List<Timestamp > ) request. getAttribute(" votesTs" );
42
- for (int i = 0 ; i < votesTeam. size(); i+= 1 ) { % >
43
- <div ><%= votesTeam. get(i) % > received vote at <%= votesTs. get(i) % > . </div >
44
- <% } % >
50
+ </div >
51
+ <div class =" col s6 m5" >
52
+ <div class =" card-panel <%= spacesWinning % >" >
53
+ <h3 >Spaces</h3 >
54
+ <h3 ><%= request. getAttribute(" spaceVoteCt" ) % > </h3 >
45
55
</div >
46
- <button id =" voteTabs" type =" button" >Vote for tabs!</button >
47
- <button id =" voteSpaces" type =" button" >Vote for spaces!</button >
48
- </article >
49
- <aside > </aside >
56
+ </div >
50
57
</div >
58
+ </div >
59
+ <div class =" section center" >
60
+ <h4 >Currently, <%= request. getAttribute(" winningTeam" ) % > is winning by
61
+ <%= request. getAttribute(" voteDiff" ) % > votes</h4 >
62
+ <h4 >Vote for your favorite:</h4 >
63
+ <button id =" voteTabs" class =" btn" >tabs</button >
64
+ <button id =" voteSpaces" class =" btn" >spaces</button >
65
+ </div >
66
+
67
+ <ul class =" collection with-header" >
68
+ <li class =" collection-header" ><h4 >Votes</h4 ></li >
69
+ <%
70
+ List<String > votesTeam = (List<String > ) request. getAttribute(" votesTeam" );
71
+ List<Timestamp > votesTs = (List<Timestamp > ) request. getAttribute(" votesTs" );
72
+ for (int i = 0 ; i < votesTeam. size(); i += 1 ) { % >
73
+ <li class =" collection-item" ><div ><%= votesTeam. get(i) % > received vote at <%= votesTs. get(i) % > </div ></li >
74
+ <% } % >
75
+ </ul >
51
76
</body >
52
77
<footer >
53
78
<script >
54
- function vote (team ){
79
+ function vote (team ) {
55
80
var xhr = new XMLHttpRequest ();
56
- xhr .onreadystatechange = function () {
81
+ xhr .onreadystatechange = function () {
57
82
var msg = " " ;
58
- if (this .readyState == 4 ){
59
- if (! window .alert (this .responseText )){
83
+ if (this .readyState == 4 ) {
84
+ if (! window .alert (this .responseText )) {
60
85
window .location .reload ();
61
86
}
62
87
}
63
88
};
64
- xhr .open (" POST" ," /" , true );
89
+ xhr .open (" POST" , " /" , true );
65
90
xhr .setRequestHeader (" Content-Type" , " application/x-www-form-urlencoded" );
66
- xhr .send (" team=" + team);
91
+ xhr .send (" team=" + team);
67
92
}
68
93
69
- document .getElementById (" voteTabs" ).addEventListener (" click" , function () { vote (" tabs" ); });
70
- document .getElementById (" voteSpaces" ).addEventListener (" click" , function () { vote (" spaces" ); });
94
+ document .getElementById (" voteTabs" ).addEventListener (" click" , function () {
95
+ vote (" tabs" );
96
+ });
97
+ document .getElementById (" voteSpaces" ).addEventListener (" click" , function () {
98
+ vote (" spaces" );
99
+ });
71
100
</script >
72
101
</footer >
73
102
</html >
0 commit comments