-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
596 lines (485 loc) · 20.2 KB
/
index.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/bootstrap.css" media="screen"/>
<link rel="stylesheet" href="css/bootstrap-responsive.css"/>
<link rel="stylesheet" href="css/style.css"/>
<link rel="stylesheet" href="img/glyphicons-halflings.png"/>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<!-- <script type="text/javascript" src="jquery.carouFredSel-6.2.0.js"></script> -->
<!-- <script type="text/javascript" src="js/validation.js"></script> -->
<style>
.btn{
color: blue;
}
.show{
font-weight: thick;
color: blue;
}
.show:hover{
text-decoration: none;
color: black;
font-size: 115%;
font-weight: thick;
}
.box{
background: rgba(0,0,0,0.2);
padding: 10px 0px;
text-align: center;
margin-top: 10px;
border-radius: 5px;
}
.box h3, .box h4, .box p, .box a{
padding-left: 6px;
}
.what1, .side, .three{
text-align: left;
}
.newsletter{
background: #ffcc99;
}
.carousel-indicators {
right: 42px;
}
.carousel-control.left{
margin-left: 91px;
}
.windowpane{
margin-top: 60px;
}
.maintext{
background-image: url("img/beer.jpg");
height: 600px;
}
.hero-unit{
padding: 0;
}
.control-group{
display: inline-block;
width: 400px;
}
.control-label{
display: inline-block;
}
.controls{
display: inline-block;
}
.input-prepend{
margin-bottom: 4px;
}
.maintext a{
margin-left: 350px;
}
.alert-error{
background-color: #cc6666;
color: #660000;
margin-top: 330px;
text-align: center;
}
.maintext h1, .maintext h3, .maintext p{
color: white;
text-align: center;
}
.maintext p{
width: 580px;
line-height: 25px;
}
tbody, .schedule{
text-align: center;
background-image: url("img/beer_side.jpg");
}
.gameschedule{
background-image: url("img/beer-side.jpg");
}
.games{
width: 335px;
background: rgba(0,0,0,0.14);
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Bootstrap Exercise</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<form class="navbar-form pull-right">
<input class="span2" type="text" placeholder="Email">
<input class="span2" type="password" placeholder="Password">
<button type="submit" class="btn">Sign in</button>
</form>
</div><!--/.nav-collapse -->
</div>
</div>
</div> <!--navbar-->
<div class="container windowpane">
<div class="hero-unit">
<div class="row">
<div class="span12 maintext">
<h1>Beer League Baseball!</h1>
<h3>There's No Crying in Baseball!....But there is BEER!!!</h3>
<a href="#myModal" role="button" class="btn" id="launch" data-toggle="modal">SIGN UP TODAY</a>
<div class="alert alert-error">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>HURRY!</strong> Registration will close very soon!
</div>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
<h3 id="myModalLabel">Team Registration Form</h3>
</div>
<form class="form-horizontal commentForm" id="signup">
<fieldset>
<legend>Registraion</legend>
<label>Team Name</label>
<input type="text" id="teamName" name = "teamName" placeholder="Team Name" value="">
<label>Manager Name</label>
<input id="mgrFirst" name = "mgrFirst" type="text" placeholder="First Name" value="">
<input id="mgrLast" name = "mgrLast" type="text" placeholder="Last Name" value="">
<label>Manager Phone Number</label>
<input type="text" id="phone" name = "phone"placeholder="Phone Number" value="">
<label>Manager Zip Code</label>
<input type="text" id="zip" name = "zip"placeholder="Zip Code" value="">
<label>Sponsor</label>
<input type="text" id="sponsor" name = "sponsor" placeholder="Team Sponsor" value=""></br>
<!-- <INPUT TYPE="button" button id= "registerTeam" NAME="button" Value="Submit" onClick="registerTeam(this.form)"> -->
<button id ="registerTeam" button type="button" name="button" class="btn">Register Team</button>
<div id="registerTeam"></div>
</form>
</div>
<div id="teamdisplay"></div>
</div>
</div>
</div>
<!-- <div class="row">
<div class="span12 box what1">
<div class="image_carousel">
<div id="foo1">
<img src="img/logo1.jpg" alt="basketball" width="225" height="140" />
<img src="img/logo2.jpg" alt="beachtree" width="225" height="140" />
<img src="img/logo3.jpg" alt="cupcackes" width="225" height="140" />
<img src="img/logo4.jpg" alt="hangmat" width="225" height="140" />
<img src="img/logo5.jpg" alt="new york" width="225" height="140" />
<img src="img/logo6.jpg" alt="new york" width="225" height="140" />
</div>
<div class="clearfix"></div>
</div>
</div>
</div> -->
<div class="row">
<!---Start Team List -->
<div class="span8 box three">
<table class="table table-striped" id="standings">
<tr>
<th>Team</th>
<th>Wins</th>
<th>Losses</th>
<th>Win %</th>
</tr>
<tr>
<td id ="team1">Team 1</td>
<td>0</td>
<td>0</td>
<td>.000</td>
</tr>
<tr>
<td id ="team2">Team 2</td>
<td>0</td>
<td>0</td>
<td>.000</td>
</tr>
<tr>
<td id= "team3">Team 3</td>
<td>0</td>
<td>0</td>
<td>.000</td>
</tr>
<tr>
<td id = "team4">Team 4</td>
<td>0</td>
<td>0</td>
<td>.000</td>
</tr>
<tr>
<td id = "team5">Team 5</td>
<td>0</td>
<td>0</td>
<td>.000</td>
</tr>
<tr>
<td id = "team6">Team 6</td>
<td>0</td>
<td>0</td>
<td>.000</td>
</tr>
<tr>
<td id ="team7">Team 7</td>
<td>0</td>
<td>0</td>
<td>.000</td>
</tr>
<tr>
<td id="team8">Team 8</td>
<td>0</td>
<td>0</td>
<td>.000</td>
</tr>
</table>
<p><a class="btn" id="startSeason">Start Season</a></p>
<p><a class="btn" id="sortStandings">Update Standings</a></p>
</div>
<!-------End Team List -->
<div class="row">
<div class="span6 box">
<div id="gameschedule" class="tab-pane hero-unit gameschedule">
<h3>Schedule</h3>
<p class="matchups">Who's Playing Who?</p>
<table class="table table-striped" id="scheduleTable">
</table>
</div> <!-- End Schedule Tab -->
</div>
</div>
<div class="row">
<div class="span12 box newsletter">
<h4>Sign up for our newsletter</h4>
<div class="control-group">
<label class="control-label" for="inputIcon">Email address</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-envelope"></i></span>
<input class="span2" id="inputIcon" type="text">
</div>
</div>
</div>
</div>
</div>
<footer>
<p>© Company 2013</p>
</footer>
</div>
<script>
$(document).ready(function(){
//form validation
//$(".commentForm").validate();
var allTeams = new Array (); //declaring array for all teams in league
$('#registerTeam').click(function() {
var team = { };
team.teamName = $("#teamName").val();
team.mgrFirst = $("#mgrFirst").val();
team.mgrLast = $("#mgrLast").val();
team.phone = $("#phone").val();
team.zip = $("#zip").val();
team.sponsor = $("#sponsor").val();
team.wins = 0;
team.losses = 0;
console.log(team);
$.ajax({
url: "/backliftapp/team",
type: "post",
dataType: "JSON",
data:team, // this line is the objcet name that i am sending to the server//
success: function(data){
console.log(data);
allTeams.push(data);
},
error: function(){
console.log("There was an error");
}
}); //end of ajax "post"
//resets form after each time register is clicked
$("#signup")[0].reset();
}); //end click
function listTeams(){
$.ajax({
url: "/backliftapp/team",
type: "GET",
success: function(data) {
var i=1;
$.each(data,function() {
$("#team" +i).html("<a rel='popover' class='show'>" + this.teamName +"</a>"+"<p class='more'><br>"+
"<strong>Manager: </strong>" + this.mgrFirst + " " + this.mgrLast + "<br>" +
"<strong>Phone: </strong>" + this.phone + "<br>" +
"<strong>Sponsor: </strong>" + this.sponsor + "<br></p>"); i=i+1;
console.log(this);
}); //end each loop
//calling teamPopover..has to be after loop but before close of success function to work properly
teamPopover();
}, //end success function
error: function(){
console.log("There was an error");
} //end error function
}) //end ajax get
} //end listTeams functionality
// start Delete Team
//use this code to delete teams that have been entered - replace id number above with id number from ajax data file
$.ajax({
type: "DELETE",
url: "backliftapp/team/8ac752dd-0846-45a9-9722-f2643815bc6a",
success: function(data) {
console.log("Deleted!");
} //end success function
}); //end ajax DELETE
listTeams();//calling listTeams
function teamPopover() {
$('.more').hide();
$('.show').click(
function () {
$(this).next('.more').toggle();
});
}//end teamPopover
// functionality of using the right schedule for the # of teams in league and populting schedule with actual team names
// event listener is #startSeason button on click
$('#startSeason').click(function(){
$.ajax({
url: '/backliftapp/team',
type: "GET",
dataType: 'json',
success: function(data) {
allTeams = data;
populateSchedule(data);
}//end success
});//end Ajax get
});//end startSeason click
//declaring schedule variables
var sched4 = [
[ [1, 4], [2, 3] ],
[ [1, 3], [2, 4] ],
[ [1, 2], [3, 4] ]
];
var sched6 = [
[ [1, 6], [2, 5], [3, 4] ],
[ [1, 5], [4, 6], [2, 3] ],
[ [1, 4], [3, 5], [2, 6] ],
[ [1, 3], [2, 4], [5, 6] ],
[ [1, 2], [3, 6], [4, 5] ],
];
var sched8 = [
[ [1, 8], [2, 7], [3, 6], [4, 5] ],
[ [1, 7], [6, 8], [2, 5], [3, 4] ],
[ [1, 6], [5, 7], [4, 8], [2, 3] ],
[ [1, 5], [4, 6], [3, 7], [2, 8] ],
[ [1, 4], [3, 5], [2, 6], [7, 8] ],
[ [1, 3], [2, 4], [5, 8], [6, 7] ],
[ [1, 2], [3, 8], [4, 7], [5, 6] ],
];//end schedule variables
// Note: (d) is from ajax "data", set equal to allTeams array in "get" above
function populateSchedule (d) {
if (d.length < 4) {
alert('Must have at least 4 teams to continue!');
}
else if (d.length === 4) {
var s = sched4;
} else if (d.length === 5 || d.length === 6) {
var s = sched6;
} else{
var s = sched8;
} //end schedule conditional based on # of teams
//d-allTeams s-schedule w-weeks g-games
for (w = 0 ; w < s.length ; w++) {
//if statement for even # of teams
if (d.length%2 === 0){
$('#scheduleTable').append("<tbody id='week" + w + "'class='tablehead'><tr><th>Week " + [w + 1] + "</th><th>Score" + "</th></tr></tbody>");
for (g = 0 ; g < s[w].length; g++) {
//setting values of home and away teams with teamName from allTeams(AKA "d")
var awayTeam = d[s[w][g][0]-1].teamName
var homeTeam = d[s[w][g][1]-1].teamName
//awayScore = $(".score-visitor").val();
//homeScore = 0;
$("#week" + w).append("<div class='schedule'><tr><td>" + awayTeam + " vs. " + homeTeam + "</td><td class='inputScore' data-awayName='"+ awayTeam +"' data-homeName='"+ homeTeam +"'><input type='num' size='2' maxlength='2' class='score-field score-visitor' />-<input type='num' size='2' maxlength='2' class='score-field score-home'/></td><td class='enterscore'><a class='enterscore btn' id='" + w + "' href=''>Enter Score</a></td></tr></div>")
}//end games loop
} //end if statement for even # of teams
else{
var teamwithBye = d[s[w][0][1]-2].teamName
$('#scheduleTable').append("<tbody id='week" + w + "'class='tablehead'><tr><th>Week " + [w + 1] + "<br/>" +teamwithBye + " have a Bye</th><th>Score" + "</th><th class='enterscore hidden-btn'>Update</th></tr></tbody>")
for (g = 1 ; g < s[w].length; g++) {
var awayTeam = d[s[w][g][0]-2].teamName
var homeTeam = d[s[w][g][1]-2].teamName
//awayScore = 0;
//homeScore = 0;
$("#week" + w).append("<tr><td>" + awayTeam + " vs. " + homeTeam + "</td><td class='inputScore' data-awayName='"+ awayTeam +"' data-homeName='"+ homeTeam +"'><input type='num' size='2' maxlength='2' class='score-field score-visitor' /><input type='num' size='2' maxlength='2' class='score-field score-home'/></td><td class='enterscore'><a class='enterscore btn'>Enter Score</a></td></tr>")
}//end games(g) loop
} // end ELSE loop for BYE WEEKS if odd # of teams in league
}// end week(w) loop
//start score input function
//declaring array for all teams in league
var allScores = new Array ();
$('a.btn').click(function(ev){
ev.preventDefault();
var week = $(this).attr("id");
var scoreVisitor = $(this).parent().prev().find('.score-visitor').val();
var scoreHome = $(this).parent().prev().find('.score-home').val();
//var nameHome = $(this).homeTeam;
var nameHome = $(this).parent().prev().data('homename');
var nameAway = $(this).parent().prev().data('awayname');
console.log(scoreVisitor);
console.log(scoreHome);
console.log(nameAway);
console.log(nameHome);
//calling function to add wins or losses to correct team
//addResults();
// start ajax to save scores
/*$.ajax({
type: 'POST',
url: 'backliftapp/scores',
dataType: "JSON",
data: {
"game": s[w],
"scoreHome": (".score-home").val();
"scoreAway": (".score-visitor").val;
}
success: function(data){
allScores.push(data);
};
});///end AJAX post */
}); //end score input click function
///// start of ajax put to add to .wins and .losses of teams based on scores
///// Can't get values pulled out from home and away teams because they're not being
///// assigned using the allTeams array. AKA scores and teams have no relationship right now.
///// tried moving function up into schedule loop, but the loop is already finished so it
///// will always use the home and away teams from the very last game of the "season".
function addResults(){
if(scoreVisitor > scoreHome){
$.ajax({
url: '/backliftapp/team',
type: "PUT",
dataType: 'json',
success: function(data) {
allTeams = data;
// start Pseudo Code
// if(awayscore > homescore),
// then add 1 to the wins value in allTeams array for correct team,
// else (add 1 to losses of that team);
}//end success
});//end Ajax get
} //end if
} //end addResults
}// end populateSchedule
}); // end document.ready
</script>
</body>
</html>