Commit 1d768fd2 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Coloring scorecards option is now remembered using HTML5 local storage

parent 671118ff
num = (s) -> if s == '' or isNaN(parseInt(s)) then 0 else parseInt(s) num = (s) -> if s == '' or isNaN(parseInt(s)) then 0 else parseInt(s)
$ -> $ ->
$('.match').each -> $('.match-editable').each ->
table = $(@) table = $(@)
match_total = table.find('.match-total') match_total = table.find('.match-total')
match_avg = table.find('.match-avg') match_avg = table.find('.match-avg')
...@@ -45,7 +45,6 @@ $ -> ...@@ -45,7 +45,6 @@ $ ->
cell = $(@).closest('td') cell = $(@).closest('td')
cls = cell.attr('class').replace(/\s*val-\d+\s*/, '') cls = cell.attr('class').replace(/\s*val-\d+\s*/, '')
console.log cell.attr('class'), cls
cell.attr('class', cls).addClass('val-' + $(@).val()) cell.attr('class', cls).addClass('val-' + $(@).val())
inputs.filter('[value=""]:first').focus() inputs.filter('[value=""]:first').focus()
...@@ -62,3 +61,13 @@ $ -> ...@@ -62,3 +61,13 @@ $ ->
$('#toggle-colored').on 'click', -> $('#toggle-colored').on 'click', ->
$(@).toggleClass('active').blur() $(@).toggleClass('active').blur()
$('#match').toggleClass('colored') $('#match').toggleClass('colored')
if $('#match').hasClass('colored') and window.hasOwnProperty('localStorage')
localStorage.setItem('colored-scores', true)
console.log localStorage.getItem('colored-scores')
else
localStorage.removeItem('colored-scores')
if window.hasOwnProperty('localStorage') and localStorage.getItem('colored-scores')
$('#match').addClass('colored')
$('#toggle-colored').addClass('active')
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
<form method="post" action="match/{$match->id}/scores"> <form method="post" action="match/{$match->id}/scores">
<table id="match" class="table table-bordered table-condensed match {$match->discipline}"> <table id="match" class="table table-bordered table-condensed match
{$match->discipline} match-editable">
<thead> <thead>
<tr> <tr>
<th class="separator"></th> <th class="separator"></th>
......
...@@ -99,10 +99,5 @@ ...@@ -99,10 +99,5 @@
{/block} {/block}
{block scripts} {block scripts}
<script type="text/javascript"> <script src="js/scores.js"></script>
$('#toggle-colored').click(function() {
$(this).toggleClass('active').blur();
$('#match').toggleClass('colored');
});
</script>
{/block} {/block}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment