Client Virtuel : gestion du passage de carte opérationnel

This commit is contained in:
xdrm-brackets 2016-07-18 15:44:43 +02:00
parent 79e3bf6a75
commit 854add1046
2 changed files with 62 additions and 3 deletions

View File

@ -86,6 +86,12 @@
top: calc( 50% - 3em/2 );
}
#machine-box > #r1.active,
#machine-box > #r2.active{
color: #18eea9;
}
#card-stack{
position: absolute;
top: 50%;
@ -123,6 +129,11 @@
color: #000;
}
#card-stack > .card.active{
background: #aaa;
color: #000;
}
#card-stack > input{
display: inline-block;
position: relative;
@ -232,7 +243,6 @@
var api = new APIClass('/api/');
api.send({path: 'machineDefault/init'}, function(response){
console.log(response);
SYSTEM = {
action: response.actions,
state: response.states
@ -243,7 +253,7 @@
=========================================================*/
/* (1) Gestion de mise à jour de la led en fonction de l'état
---------------------------------------------------------*/
function updateLed(){
function updateChips(){
/* (1) Si machine bloquée */
if( STATE.locked ){
STATE.started = false;
@ -265,6 +275,11 @@
}else
led.style.background = '#000';
if( STATE.started == true )
r1.addClass('active');
else
r1.remClass('active');
}
@ -282,14 +297,59 @@
if( e.target.className == 'card' ){
lastCard = card;
card = e.target.innerHTML;
var allCards = document.querySelectorAll('#card-stack .card');
for( var i = 0 ; i < allCards.length ; i++ )
allCards[i].remClass('active');
e.target.addClass('active');
}
}, false);
card = document.querySelector('#card-stack .card').innerHTML;
document.querySelector('#card-stack .card').addClass('active');
/* [4] Passage de carte
=========================================================*/
var PRESSED = false;
var INTERVAL = null;
var COUNT = 0;
/* (0) Routine de comptage de temps
---------------------------------------------------------*/
function countRoutine(){
COUNT++;
if( COUNT == 1 )
STATE.started = !STATE.started;
if( COUNT == 2 )
STATE.signaled = true;
if( COUNT == 3 )
STATE.locked = true;
updateChips();
}
/* (1) Appui carte
---------------------------------------------------------*/
pass.addEventListener('mousedown', function(e){
PRESSED = true;
COUNT = 0;
countRoutine();
INTERVAL = setInterval( countRoutine, 1000 );
}, false);
/* (2) Levé carte
---------------------------------------------------------*/
document.body.addEventListener('mouseup', function(e){
if( PRESSED == true ){
PRESSED = false;
clearInterval(INTERVAL);
}
}, false);
</script>
</body>

View File

@ -39,7 +39,6 @@
<?php
debug();
$post = [];
foreach($_POST as $k=>$v)