counter and copy-to-clipboard button added to classes code

This commit is contained in:
s416422 2020-03-10 15:37:05 +01:00
parent 494aaedf3e
commit a68a2f7069
3 changed files with 35 additions and 5 deletions

View File

@ -6893,6 +6893,19 @@ a.close.disabled {
.classes-name-indicator { .classes-name-indicator {
width: 100%; width: 100%;
} }
.classes-code-div {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
padding: auto;
}
#classes_code_input, #classes_code_input:focus {
text-align: center;
background-color: transparent;
border: none;
}
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.carousel-control-prev, .carousel-control-prev,

View File

@ -62,10 +62,17 @@ $(document).ready(function(){
$('#group-select').on('change', function() { $('#group-select').on('change', function() {
$(location).attr('href', $(this).val()) $(location).attr('href', $(this).val())
}); });
const classes_code = $('#classes-code'); const classes_code_div = $('#classes-code-div');
if(classes_code){ if(classes_code_div){
$('#copy-btn').on('click', function () {
const copyText = $('#classes_code_input');
copyText.select();
document.execCommand("copy");
alert("Skopiowano: " + copyText.val());
copyText.blur();
});
setTimeout(function(){ setTimeout(function(){
classes_code.remove() classes_code_div.remove()
}, 30000); }, 30000);
} }

View File

@ -12,7 +12,11 @@
<button type="button" class="checkout-button end-button add-mn-btn"> Dodaj studenta ręcznie</button> <button type="button" class="checkout-button end-button add-mn-btn"> Dodaj studenta ręcznie</button>
</div> </div>
<div id="refresh"></div> <div id="refresh"></div>
<p class="code-p" id="classes-code"><b>Kod:</b> <span id="classes_code_input">{{ $classes_code }}</span></p> <div class="classes-code-div code-p" id="classes-code-div">
<p class="m-0" id="classes-code"><b>Kod weryfikacyjny:</b></p>
<input type="text" id="classes_code_input" value="{{ $classes_code }}">
<button type="button" id="copy-btn" class="btn btn-primary" title="Kopiuj do schowka"><i class="fa fa-clone"></i> Kopiuj <span id="copy-counter">(30) &raquo;</span> </button>
</div>
<div class="code-p"> Stan połączenia z serwerem legitymacji: <span id="status" style="color:green"> połączony</span></div> <div class="code-p"> Stan połączenia z serwerem legitymacji: <span id="status" style="color:green"> połączony</span></div>
<h1 class="main-text main-seat-text">Przyłóż legitymację do czytnika</h1> <h1 class="main-text main-seat-text">Przyłóż legitymację do czytnika</h1>
@ -47,7 +51,7 @@
</div> </div>
<script> <script>
var classes_code_input = $('#classes_code_input').html(); var classes_code_input = $('#classes_code_input').val();
const client = new WebSocket('wss://atcheck.projektstudencki.pl/wss', classes_code_input); const client = new WebSocket('wss://atcheck.projektstudencki.pl/wss', classes_code_input);
client.onclose = function(event) { client.onclose = function(event) {
@ -66,6 +70,12 @@
} }
} }
var counter = 30;
setInterval(function() {
counter--;
$('#copy-counter').html('(' + counter + ') &raquo;');
}, 1000);
</script> </script>
</div> </div>
@endsection @endsection