Mise en place du client virtuel (simulation)
This commit is contained in:
parent
d6431f381f
commit
0f4270eecc
|
@ -1,2 +1,2 @@
|
|||
function $(a){var b=document.querySelectorAll("#"+a);a=document.querySelectorAll("."+a);return 0<b.length?b[0]:a[0]}Element.prototype.getData=function(a){return"undefined"==typeof this.dataset?!1:this.dataset.hasOwnProperty(a)?this.dataset[a]:!1};Element.prototype.addClass=function(a){var b=this.className.split(" ");-1<b.indexOf(a)||(b.push(a),this.className=b.join(" ").trim())};
|
||||
Element.prototype.remClass=function(a){var b=this.className.split(" ");a=b.indexOf(a);-1!=a&&(b=b.slice(0,a).concat(b.slice(a+1)),this.className=b.join(" ").trim())};NodeList.prototype.indexOf=HTMLCollection.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};Element.prototype.anim=function(a,b){var c=this;c.addClass(a);setTimeout(function(){c.remClass(a)},b)};var format_code=new formatChecker(null,"HH-HH-HH-HH",{H:"[0-9A-F]"});
|
||||
Element.prototype.remClass=function(a){var b=this.className.split(" ");a=b.indexOf(a);-1!=a&&(b=b.slice(0,a).concat(b.slice(a+1)),this.className=b.join(" ").trim())};NodeList.prototype.indexOf=HTMLCollection.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};Element.prototype.anim=function(a,b){var c=this;c.addClass(a);setTimeout(function(){c.remClass(a)},b)};var format_code;try{format_code=new formatChecker(null,"HH-HH-HH-HH",{H:"[0-9A-F]"})}catch(a){console.warn(a)};
|
||||
|
|
|
@ -110,4 +110,10 @@ Element.prototype.anim = function(className, timeout){
|
|||
/* DEFINITION DES FORMATS UTILES POUR INPUT-CHECKER
|
||||
*
|
||||
*/
|
||||
var format_code = new formatChecker(null, 'HH-HH-HH-HH', { 'H' : '[0-9A-F]'} )
|
||||
var format_code;
|
||||
|
||||
try{
|
||||
format_code = new formatChecker(null, 'HH-HH-HH-HH', { 'H' : '[0-9A-F]'} );
|
||||
}catch(e){
|
||||
console.warn(e);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
$_SESSION['history'] = [];
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Virtual Client</title>
|
||||
|
||||
|
||||
<script type='text/javascript' src='/js/lib/reset.js' ></script> <!-- Corrections Javascript natif (ajouts) -->
|
||||
<script type='text/javascript' src='/js/lib/api.js' ></script> <!-- Gestion des transactions avec le serveur -->
|
||||
<script type='text/javascript' src='/js/lib/page-manager.js' ></script> <!-- Gestion réseau/chargement/liens/URL -->
|
||||
<script type='text/javascript' src='/js/lib/form-deflater.js' ></script> <!-- Gestion des formulaires (Object) -->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type='text' data-name='user-code' placeholder='Code RFID utilisateur'><br><br>
|
||||
|
||||
<br><br>
|
||||
|
||||
<input type='button' data-name='start-stop' value='Start/Stop'><br><br>
|
||||
<input type='button' data-name='signal' value='Signaler' ><br><br>
|
||||
<input type='button' data-name='lock' value='Bloquer' ><br><br>
|
||||
<input type='button' data-name='unlock' value='Débloquer' ><br><br>
|
||||
<input type='button' data-name='sync' value='Synchroniser'><br><br>
|
||||
|
||||
<br><br>
|
||||
<span id='status-box'></span><br><br>
|
||||
<hr>
|
||||
<span id='history-box'></span><br><br>
|
||||
|
||||
|
||||
<script type='text/javascript'>
|
||||
/* (0) Initialisation des éléments du DOM */
|
||||
var tCode = document.querySelector('input[data-name="user-code"]');
|
||||
|
||||
var bStartStop = document.querySelector('input[data-name="start-stop"]');
|
||||
var bSignal = document.querySelector('input[data-name="signal"]');
|
||||
var bLock = document.querySelector('input[data-name="lock"]');
|
||||
var bUnlock = document.querySelector('input[data-name="unlock"]');
|
||||
var bSync = document.querySelector('input[data-name="sync"]');
|
||||
|
||||
var sBox = document.querySelector('#status-box');
|
||||
var hBox = document.querySelector('#history-box');
|
||||
|
||||
var FD = new FormDeflater(document.body, ['input'], ['data-name']);
|
||||
|
||||
var selfApi = new APIClass('/test/clientBackground.php');
|
||||
var remoteApi = new APIClass('/api/');
|
||||
|
||||
var state = false;
|
||||
var locked = false;
|
||||
var signaled = false;
|
||||
|
||||
/* (1) Gestion du StartStop */
|
||||
bStartStop.addEventListener('click', function(e){
|
||||
if( locked ) return;
|
||||
|
||||
var data = FD.deflate();
|
||||
|
||||
var req = {
|
||||
'code' : data['user-code'],
|
||||
'action' : state ? 'stop' : 'start'
|
||||
};
|
||||
|
||||
state = !state;
|
||||
|
||||
selfApi.send(req, function(res){
|
||||
hBox.innerHTML = res.data;
|
||||
});
|
||||
|
||||
sBox.innerHTML = '- bloqué : '+locked+'<br> - signalé : '+signaled+'<br> - en marche : '+state;
|
||||
|
||||
}, false);
|
||||
|
||||
/* (2) Gestion du Signalement */
|
||||
bSignal.addEventListener('click', function(e){
|
||||
if( locked || signaled ) return;
|
||||
|
||||
var data = FD.deflate();
|
||||
|
||||
var req = {
|
||||
'code' : data['user-code'],
|
||||
'action' : 'signal'
|
||||
};
|
||||
|
||||
selfApi.send(req, function(res){
|
||||
hBox.innerHTML = res.data;
|
||||
});
|
||||
|
||||
signaled = true;
|
||||
|
||||
sBox.innerHTML = '- bloqué : '+locked+'<br> - signalé : '+signaled+'<br> - en marche : '+state;
|
||||
|
||||
}, false);
|
||||
|
||||
/* (3) Gestion du blocage */
|
||||
bLock.addEventListener('click', function(e){
|
||||
if( locked ) return;
|
||||
|
||||
var data = FD.deflate();
|
||||
|
||||
var req = {
|
||||
'code' : data['user-code'],
|
||||
'action' : 'lock'
|
||||
};
|
||||
|
||||
selfApi.send(req, function(res){
|
||||
hBox.innerHTML = res.data;
|
||||
});
|
||||
|
||||
locked = true;
|
||||
state = false;
|
||||
signaled = false;
|
||||
|
||||
sBox.innerHTML = '- bloqué : '+locked+'<br> - signalé : '+signaled+'<br> - en marche : '+state;
|
||||
|
||||
}, false);
|
||||
|
||||
/* (4) Gestion du déblocage */
|
||||
bUnlock.addEventListener('click', function(e){
|
||||
if( !locked && !signaled ) return;
|
||||
|
||||
|
||||
var data = FD.deflate();
|
||||
|
||||
var req = {
|
||||
'code' : data['user-code'],
|
||||
'action' : 'unlock'
|
||||
};
|
||||
|
||||
selfApi.send(req, function(res){
|
||||
hBox.innerHTML = res.data;
|
||||
});
|
||||
|
||||
locked = false;
|
||||
state = false;
|
||||
signaled = false;
|
||||
|
||||
sBox.innerHTML = '- bloqué : '+locked+'<br> - signalé : '+signaled+'<br> - en marche : '+state;
|
||||
|
||||
}, false);
|
||||
|
||||
/* (5) Gestion de la synchro */
|
||||
bSync.addEventListener('click', function(e){
|
||||
|
||||
}, false);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<?php session_start();
|
||||
|
||||
|
||||
|
||||
|
||||
/* [1] Gestion de l'enregistrement
|
||||
=========================================================*/
|
||||
if( isset($_POST['code']) && isset($_POST['action']) ){
|
||||
|
||||
array_push($_SESSION['history'],[
|
||||
json_decode( $_POST['code'], true ),
|
||||
json_decode( $_POST['action'], true )
|
||||
]);
|
||||
|
||||
$data = '';
|
||||
|
||||
foreach($_SESSION['history'] as $h=>$entry)
|
||||
$data .= "<span>".$entry[0]." - ".$entry[1]."</span><br>";
|
||||
|
||||
|
||||
echo json_encode( [
|
||||
'ModuleError' => 0,
|
||||
'data' => $data
|
||||
] );
|
||||
|
||||
}
|
||||
?>
|
|
@ -7,7 +7,7 @@
|
|||
<meta name='Content-Type' content='text/html; charset=utf-8'>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='author' content='Adrien MARQUÈS alias {xdrm};'>
|
||||
<meta name='desctiption' content="Système de gestion des véhicules pour STEF.">
|
||||
<meta name='desctiption' content="Système de gestion d'authentification pour parcs de véhicules ou autres systèmes fermés.">
|
||||
|
||||
<!-- Dépendences CSS -->
|
||||
<link type='text/css' rel='stylesheet' href='/css/reset/min.css' /> <!-- Reset du css natif des browsers -->
|
||||
|
|
Loading…
Reference in New Issue