From 4a599c9fd3fcb3a5d5d8c81d5191b7e1bae4ad5d Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 18 Jul 2016 15:44:43 +0200 Subject: [PATCH] =?UTF-8?q?Client=20Virtuel=20:=20gestion=20du=20passage?= =?UTF-8?q?=20de=20carte=20op=C3=A9rationnel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/client/interface.php | 64 +++++++++++++++++++++++++++++++++++++-- view/machines.php | 1 - 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/test/client/interface.php b/test/client/interface.php index 134d36b..df11074 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -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); diff --git a/view/machines.php b/view/machines.php index e5b2f49..db45cc5 100755 --- a/view/machines.php +++ b/view/machines.php @@ -39,7 +39,6 @@ $v)