Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
archery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
archery
Commits
18ad13ac
Commit
18ad13ac
authored
Jul 24, 2017
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use HTML data attribute to record scores, cleaner & probably faster code
parent
9f298a6c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
18 deletions
+24
-18
coffee/scores.coffee
coffee/scores.coffee
+8
-3
sass/main.sass
sass/main.sass
+8
-7
templates/match/scores.latte
templates/match/scores.latte
+4
-4
templates/match/view.latte
templates/match/view.latte
+4
-4
No files found.
coffee/scores.coffee
View file @
18ad13ac
...
@@ -30,12 +30,16 @@ if table.classList.contains 'match-editable'
...
@@ -30,12 +30,16 @@ if table.classList.contains 'match-editable'
subtotal
=
0
subtotal
=
0
subtotal
+=
scores
[
dirty_row
*
w
+
col
]
for
col
in
[
0
...
w
]
subtotal
+=
scores
[
dirty_row
*
w
+
col
]
for
col
in
[
0
...
w
]
sub
(
dirty_row
).
innerHTML
=
subtotal
rowsub
=
sub
dirty_row
rowsub
.
innerHTML
=
subtotal
rowsub
.
dataset
.
score
=
Math
.
floor
(
subtotal
/
w
)
total
=
if
dirty_row
then
num
tot
(
dirty_row
-
1
).
innerHTML
else
0
total
=
if
dirty_row
then
num
tot
(
dirty_row
-
1
).
innerHTML
else
0
for
row
in
[
dirty_row
...
h
]
for
row
in
[
dirty_row
...
h
]
total
+=
num
sub
(
row
).
innerHTML
total
+=
num
sub
(
row
).
innerHTML
tot
(
row
).
innerHTML
=
total
rowtot
=
tot
row
rowtot
.
innerHTML
=
total
rowtot
.
dataset
.
score
=
Math
.
floor
(
total
/
((
row
+
1
)
*
w
))
match_total
.
innerHTML
=
total
match_total
.
innerHTML
=
total
match_avg
.
innerHTML
=
Math
.
round
(
total
/ inputs.length * 10) /
10
match_avg
.
innerHTML
=
Math
.
round
(
total
/ inputs.length * 10) /
10
...
@@ -47,7 +51,7 @@ if table.classList.contains 'match-editable'
...
@@ -47,7 +51,7 @@ if table.classList.contains 'match-editable'
cb
=
->
cb
=
->
value
=
num
@
.
value
value
=
num
@
.
value
if
set_score
col
,
row
,
value
if
set_score
col
,
row
,
value
cell
.
className
=
cell
.
className
.
replace
/val-\d+/
,
'val-'
+
value
cell
.
dataset
.
score
=
value
if
value
!=
10
if
value
!=
10
@
.
nextElementSibling
.
value
=
0
@
.
nextElementSibling
.
value
=
0
@
.
parentNode
.
querySelector
(
'.cross-popup'
)
@
.
parentNode
.
querySelector
(
'.cross-popup'
)
...
@@ -82,6 +86,7 @@ if table.classList.contains 'match-editable'
...
@@ -82,6 +86,7 @@ if table.classList.contains 'match-editable'
localStorage
.
setItem
'hide-total-scores'
,
true
localStorage
.
setItem
'hide-total-scores'
,
true
else
else
localStorage
.
removeItem
'hide-total-scores'
localStorage
.
removeItem
'hide-total-scores'
render
0
# notes area grows automatically with each added line
# notes area grows automatically with each added line
if
notes
=
document
.
getElementById
(
'notes'
)
if
notes
=
document
.
getElementById
(
'notes'
)
...
...
sass/main.sass
View file @
18ad13ac
...
@@ -67,25 +67,26 @@ $lg-width: 1200px
...
@@ -67,25 +67,26 @@ $lg-width: 1200px
$white
:
#F2F2F2
$white
:
#F2F2F2
&
.colored
&
.colored
.val-10
,
.val-9
td
[
data-score
=
"10"
],
td
[
data-score
=
"9"
]
background-color
:
$yellow
background-color
:
$yellow
.val-8
,
.val-7
td
[
data-score
=
"8"
],
td
[
data-score
=
"7"
]
background-color
:
$red
background-color
:
$red
.val-6
,
.val-5
td
[
data-score
=
"6"
],
td
[
data-score
=
"5"
]
background-color
:
$blue
background-color
:
$blue
.val-4
,
.val-3
td
[
data-score
=
"4"
],
td
[
data-score
=
"3"
]
background-color
:
$black
background-color
:
$black
color
:
white
color
:
white
.val-2
,
.val-1
td
[
data-score
=
"2"
],
td
[
data-score
=
"1"
]
background-color
:
$white
background-color
:
$white
&
.hide-total-scores
&
.hide-total-scores
.row-total
,
.total
,
.match-avg
,
.match-total
.row-total
,
.total
,
.match-avg
,
.match-total
color
:
#fff
background-color
:
white
!
important
color
:
white
.popup-container
.popup-container
position
:
relative
position
:
relative
...
@@ -109,7 +110,7 @@ $lg-width: 1200px
...
@@ -109,7 +110,7 @@ $lg-width: 1200px
border-left-color
:
rgb
(
51
,
51
,
51
)
border-left-color
:
rgb
(
51
,
51
,
51
)
display
:
block
display
:
block
.val-10
:hover
.cross-popup
td
[
data-score
=
"10"
]
:hover
.cross-popup
display
:
block
display
:
block
&
.match-editable
.cross-popup
&
.match-editable
.cross-popup
...
...
templates/match/scores.latte
View file @
18ad13ac
...
@@ -32,8 +32,8 @@
...
@@ -32,8 +32,8 @@
<tbody>
<tbody>
<tr n:foreach="$rows as $i => $row">
<tr n:foreach="$rows as $i => $row">
<th class="separator">{$i + 1}</th>
<th class="separator">{$i + 1}</th>
<td n:foreach="$row as $j => $arrow"
<td n:foreach="$row as $j => $arrow"
data-score="{$arrow}"
class="
val-{$arrow}
{$j == $match->arrows - 1 ? separator}">
class="{$j == $match->arrows - 1 ? separator}">
<input type="number" name="scores[]" min="0" max="10"
<input type="number" name="scores[]" min="0" max="10"
value="{$arrow ? $arrow}">
value="{$arrow ? $arrow}">
<input type="hidden" name="crosses[]"
<input type="hidden" name="crosses[]"
...
@@ -43,8 +43,8 @@
...
@@ -43,8 +43,8 @@
title="{_'Inner 10?'}">×</div>
title="{_'Inner 10?'}">×</div>
</div>
</div>
</td>
</td>
<td class="row-total"
>{$sum = array_sum($row)
}</td>
<td class="row-total"
data-score="{floor(($sum = array_sum($row)) / $match->arrows)}">{$sum
}</td>
<td class="total"
>{$total = $total + $sum
}</td>
<td class="total"
data-score="{floor(($total = $total + $sum) / ($match->arrows * ($i + 1)))}">{$total
}</td>
</tr>
</tr>
</tbody>
</tbody>
<tbody>
<tbody>
...
...
templates/match/view.latte
View file @
18ad13ac
...
@@ -43,15 +43,15 @@
...
@@ -43,15 +43,15 @@
<tbody>
<tbody>
<tr n:foreach="$rows as $i => $row">
<tr n:foreach="$rows as $i => $row">
<th class="separator">{$i + 1}</th>
<th class="separator">{$i + 1}</th>
<td n:foreach="$row as $j => $arrow"
<td n:foreach="$row as $j => $arrow"
data-score="{$arrow}"
class="
val-{$arrow}
{$j == $match->arrows - 1 ? separator}">
class="{$j == $match->arrows - 1 ? separator}">
<input type="text" disabled value="{$arrow}">
<input type="text" disabled value="{$arrow}">
<div n:if="$crosses[$i][$j]" class="popup-container">
<div n:if="$crosses[$i][$j]" class="popup-container">
<div class="cross-popup enabled" title="{_'Inner 10?'}">×</div>
<div class="cross-popup enabled" title="{_'Inner 10?'}">×</div>
</div>
</div>
</td>
</td>
<td class="
val-
{floor(($sum = array_sum($row)) / $match->arrows)}">{$sum}</td>
<td class="
row-total" data-score="
{floor(($sum = array_sum($row)) / $match->arrows)}">{$sum}</td>
<td class="
val-
{floor(($total = $total + $sum) / ($match->arrows * ($i + 1)))}">{$total}</td>
<td class="
total" data-score="
{floor(($total = $total + $sum) / ($match->arrows * ($i + 1)))}">{$total}</td>
</tr>
</tr>
</tbody>
</tbody>
<tbody>
<tbody>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment