This repository has been archived by the owner on Sep 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
167 lines (152 loc) · 7.69 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Bowling Tracker">
<meta name="author" content="graboskyc">
<title>Bowling Tracker</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/album.css" rel="stylesheet">
<link href="css/bowling.css" rel="stylesheet">
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
</head>
<body>
<header>
<div class="navbar navbar-dark bg-dark shadow-sm">
<div class="container d-flex justify-content-between" id="div_nav">
</div>
</div>
</header>
<section class="jumbotron text-center" style="background: url(assets/jumbotron.JPG); background-repeat: no-repeat; background-position: center center; background-size: cover;">
<div class="container">
<h1 class="jumbotron-heading" style="color:#ffffff;font-size:60px;font-weight: bold;">Bowling Tracker</h1>
</div>
</section>
<div class="album text-muted">
<div class="bodyctr">
<h2 class="nameform"><i class="fa fa-fw fa-user" aria-hidden="true"></i> Player: <input type="text" id="txt_player" value="" class="nameform" style="width:250px;" /></h2>
<h2 class="nameform"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Team: <input type="text" id="txt_team" value="" class="nameform" style="width:250px;" /></h2>
<h2 class="nameform"><i class="fa fa-fw fa-map-marker" aria-hidden="true"></i> Location: <input type="text" id="txt_location" value="" class="nameform" style="width:250px;" /></h2>
<h2 class="nameform"><i class="fa fa-fw fa-trophy" aria-hidden="true"></i> Game: <input type="text" id="txt_gamenum" value="1" class="nameform" style="width:40px;" /> <button type="button" class="btn btn-info" onclick="nextGame()"><i class="fa fa-forward" aria-hidden="true"></i> Next Game</button></h2>
<h2 class="nameform"><i class="fa fa-fw fa-calendar" aria-hidden="true"></i> Date: <input type="text" id="txt_date" class="nameform" style="width:250px;" /> </h2>
<div class="row" id="mainctr">
</div>
</div>
<div id="jsontosend"></div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
<script src="https://s3.amazonaws.com/stitch-sdks/js/bundles/4.0.13/stitch.js"></script>
<script src="js/bowling.js"></script>
<script src="js/helpers.js"></script>
<script src="js/secrets.js"></script>
<script>
//GLOBALS
var framesArr = [];
var runningTotal = 0;
function nextGame() {
$('#txt_gamenum').val($('#txt_gamenum').val()*1+1);
$('.scorebox').val('');
$('.bowlingtotalscore').text('0');
$('.framescore').text('0');
}
function buildJson() {
if($('#txt_player').val().length < 3) {
alert("You must provide your name!");
} else {
var r = confirm("Save record?");
if(r) {
var i = 1;
var obj = {};
obj.name = $('#txt_player').val();
obj.game = $('#txt_gamenum').val()*1;
obj.played_on =$ ('#txt_date').val();
obj.team = $('#txt_team').val();
obj.location = $('#txt_location').val();
obj.frames = [];
while (i < 11) {
var frame = {};
frame.split = false;
frame.spare = false;
var f = 'frame'+i;
// is a split
if ($('input[data-frame="'+f+'"][data-ball="split"').val().length != 0) { frame.split=true;}
frame.b1 = correctFrameNum($('input[data-frame="'+f+'"][data-ball="ball1"').val());
if(frame.b1 != 10) {
frame.b2 = correctFrameNum($('input[data-frame="'+f+'"][data-ball="ball2"').val());
if (frame.b2 == "/") {
frame.b2 = 10 - frame.b1*1 ;
frame.spare = true;
}
}
if(i==10) {
frame.b2 = correctFrameNum($('input[data-frame="'+f+'"][data-ball="ball2"').val());
frame.b3 = correctFrameNum($('input[data-frame="'+f+'"][data-ball="ball3"').val());
frame.b3spare = false;
if (frame.b3 == "/") {
frame.b3 = 10 - frame.b1*1 ;
frame.b3spare = true;
}
}
obj.frames.push(frame);
i = i + 1;
}
obj.total = $('.bowlingtotalscore').text()*1;
$('#jsontosend').text(JSON.stringify(obj));
var url = SECRETSTITCHURL+JSON.stringify(obj);
$.get( url )
.done(function() {alert("Saved!");})
.fail(function() { alert("Error Saving!");})
.error(function() {alert("Error saving!");});
}
}
}
$(document).ready(function () {
var i = 1;
var w = 1;
wp = "33";
var d = new Date();
$('#txt_date').val(d.yyyymmdd());
while (i < 11) {
if(i==10) { w = 2; wp = "25"; }
apStr = '<div class="col-sm-'+w+' bowlingcellouter bowlingborder frame'+i+'"> \
<div>Frame '+i+'</div>\
<div class="bowlinginnerscore issplit frame'+i+'" style="width:'+wp+'%;"><input type="text" class="scorebox" data-frame="frame'+i+'" data-ball="split" /></div> \
<div class="bowlinginnerscore bowlingborder ballone frame'+i+'" style="width:'+wp+'%;"><input type="text" class="scorebox" data-frame="frame'+i+'" data-ball="ball1" /></div>\
<div class="bowlinginnerscore bowlingborder balltwo frame'+i+'" style="width:'+wp+'%;"><input type="text" class="scorebox" data-frame="frame'+i+'" data-ball="ball2" /></div>';
if(i==10) {
apStr = apStr +'<div class="bowlinginnerscore bowlingborder ballthree frame'+i+'" style="width:'+wp+'%;"><input type="text" class="scorebox" data-frame="frame'+i+'" data-ball="ball3" /></div>';
}
apStr = apStr + '<div class="framescore framescoreformat frame'+i+'">0</div> \
</div>';
$('#mainctr').append(apStr);
i = i+1;
}
$('#mainctr').append('<div class="col-sm-1 bowlingcellouter bowlingborder"> \
<div class="bowlingtotalscore bowlingtotalscoreformat">0</div> \
<button type="button" class="btn btn-success btn-lg" onclick="buildJson()"><i class="fa fa-floppy-o" aria-hidden="true"></i> Record</button>\
</div>');
$("input.scorebox").change(function() {
updateTotal();
});
var url = window.self.location.href;
var kvp = url.split("#!");
if(kvp.length==2) {
var p = getPlayer();
$('#txt_player').val(p);
$('title').text( p + ' Score Entry');
}
});
</script>
</body>
</html>