-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertscore.php
More file actions
executable file
·160 lines (146 loc) · 7.23 KB
/
insertscore.php
File metadata and controls
executable file
·160 lines (146 loc) · 7.23 KB
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
<?php
require_once('php/config.php');
require_once('php/Teams.php');
require_once('php/Team.php');
require_once('php/Score.php');
pg_connect('host=' . Config::$HOST . ' dbname=' . Config::$DATABASE . ' user=' . Config::$USER . ' password=' . Config::$PASSWORD . '');
$teams = Teams::findAll();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Puntentelling <?= Config::$ORGANISATION; ?></title>
<link rel="stylesheet" href="stylesheet/bootstrap.min.css">
<link rel="stylesheet" href="stylesheet/style.css">
</head>
<body>
<div class="container">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="/">Puntentelling</a>
<ul class="nav">
<li><a href="team.php">Ploegen beheren</a></li>
<li class="active"><a href="insertscore.php">Punten invoeren</a></li>
<li><a href="viewscore.php">Punten bekijken</a></li>
<li><a href="endscore.php">Eindstand</a></li>
<li><a href="export.php">Export</a></li>
</ul>
</div>
</div>
</div>
<header class="subhead">
<h1>Puntentelling <?= Config::$ORGANISATION; ?></h1>
</header>
<ul class="nav nav-tabs" id="tab">
<?php if (Config::$HASSEPARATION): ?>
<li><a href="#separation" data-toggle="tab">Schifting</a></li>
<?php endif; ?>
<?php foreach(Config::$ROUNDS as $num => $round): ?>
<li><a href="#round<?= $num; ?>" data-toggle="tab"><?= $round; ?></a></li>
<?php endforeach; ?>
</ul>
<div class="tab-content" id="tab-content">
<?php if (Config::$HASSEPARATION): ?>
<div id="separation" class="tab-pane fade in form-horizontal">
<?php foreach($teams as $team): ?>
<div class="control-group">
<label class="control-label" for="name"><?= $team->getName(); ?> (<?= $team->getNumber(); ?>)</label>
<div class="controls">
<input type="text" class="input-small sepHour"> uur <input type="text" class="input-small sepMinute"> minutes <input type="text" class="input-small sepSec"> seconden
<input type="text" data-team="<?= $team->getId(); ?>" data-round="separation" class="input-xlarge roundScore hide" value="<?= $team->getScore('separation'); ?>">
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php foreach(Config::$ROUNDS as $num => $round): ?>
<div id="round<?= $num; ?>" class="tab-pane fade in form-horizontal">
<?php foreach($teams as $team): ?>
<div class="control-group">
<label class="control-label" for="name"><?= $team->getName(); ?> (<?= $team->getNumber(); ?>)</label>
<div class="controls">
<input type="text" data-team="<?= $team->getId(); ?>" data-round="<?= $num; ?>" class="input-xlarge roundScore" value="<?= $team->getScore($num); ?>">
</div>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
</div>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
var updateTimeValue = function (wrapper) {
var hours = parseInt(wrapper.find('.sepHour').val(), 10) || 0;
var minutes = parseInt(wrapper.find('.sepMinute').val(), 10) || 0;
var seconds = parseInt(wrapper.find('.sepSec').val(), 10) || 0;
var total = wrapper.find('.roundScore');
total.val(hours * 60 * 60 + minutes * 60 + seconds).blur();
};
var loadTimeValue = function (wrapper) {
var total = parseInt(wrapper.find('.roundScore').val(), 10) || 0;
var seconds = total % 60;
var minutes = ((total - seconds) / 60 ) % (60);
var hours = (total - minutes * 60 - seconds) / (60 * 60);
wrapper.find('.sepHour').val(hours);
wrapper.find('.sepMinute').val(minutes);
wrapper.find('.sepSec').val(seconds);
};
$(document).ready(function () {
$('#separation .controls').each(function () {
loadTimeValue($(this));
});
$('#tab li:first').addClass('active');
$('#tab-content .tab-pane:first').addClass('active');
$('.sepHour').keyup(function (e) {
if (e.keyCode == 13) {
var next = $(this).parent().find('.sepMinute');
next.focus().select();
}
}).blur(function () {
updateTimeValue($(this).parent());
});
$('.sepMinute').keyup(function (e) {
if (e.keyCode == 13) {
var next = $(this).parent().find('.sepSec');
next.focus().select();
}
}).blur(function () {
updateTimeValue($(this).parent());
});
$('.sepSec').keyup(function (e) {
if (e.keyCode == 13) {
var next = $(this).parent().parent().next().find('.sepHour');
next.focus().select();
}
}).blur(function () {
updateTimeValue($(this).parent());
});
$('.roundScore').keyup(function (e) {
if (e.keyCode == 13) {
var next = $(this).parent().parent().next().find('.roundScore');
next.focus().select();
if (next.find('.roundScore').length == 0)
$(this).blur();
}
}).blur(function () {
var field = $(this);
$.ajax({
url: 'php/savescore.php',
type: 'post',
data: {team: $(this).data('team'), round: $(this).data('round'), score: $(this).val()},
dataType: 'json',
success: function (data) {
field.parent().parent().addClass('success');
},
error: function () {
field.parent().parent().addClass('error');
}
});
});
});
</script>
</body>
</html>