minmod
This commit is contained in:
parent
6d7b42b998
commit
7c3d79e4ec
|
@ -180,12 +180,12 @@
|
||||||
if( !is_array($autotyped) ){
|
if( !is_array($autotyped) ){
|
||||||
|
|
||||||
/* (1) Si Numérique Entier -> INT */
|
/* (1) Si Numérique Entier -> INT */
|
||||||
if( is_numeric($autotyped) && intval($autotyped) == $autotyped )
|
if( preg_match('/^(0|([1-9][0-9]*))$/i', $autotyped) )
|
||||||
return intval($autotyped);
|
return intval($autotyped);
|
||||||
|
|
||||||
/* (2) Si Numérique Décimal -> FLOAT */
|
/* (2) Si Numérique Décimal -> FLOAT */
|
||||||
else if( is_numeric($autotyped) && floatval($autotyped) == $autotyped )
|
else if( preg_match('/^(0|(?:[1-9][0-9]*))[\.\,]([0-9]+)$/i', $autotyped, $m) )
|
||||||
return floatval($autotyped);
|
return floatval("${m[1]}.${m[2]}");
|
||||||
|
|
||||||
/* (3) Sinon on retourne la même chose */
|
/* (3) Sinon on retourne la même chose */
|
||||||
else
|
else
|
||||||
|
@ -195,12 +195,21 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
// Pour chaque valeur, on applique récursivement
|
/* (1) Pour chaque valeur, on applique récursivement */
|
||||||
foreach($autotyped as $k=>$v)
|
foreach($autotyped as $k=>$v){
|
||||||
|
|
||||||
|
// Si on met '_nomColonne', on ne le traite pas
|
||||||
|
if( is_string($k) && $k[0] == '_' ) continue;
|
||||||
|
|
||||||
$autotyped[$k] = self::autotype($v);
|
$autotyped[$k] = self::autotype($v);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] On retourne le résultat auto-typé
|
||||||
|
=========================================================*/
|
||||||
return $autotyped;
|
return $autotyped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -453,10 +453,10 @@
|
||||||
/* [N] Retourne les données
|
/* [N] Retourne les données
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return [
|
return [
|
||||||
'actions' => $sorted_actions,
|
'actions' => Database::autotype( $sorted_actions ),
|
||||||
'states' => $globalStates,
|
'states' => Database::autotype( $globalStates ),
|
||||||
'chips' => $chips,
|
'chips' => Database::autotype( $chips ),
|
||||||
'permissions' => $indexed_permissions
|
'permissions' => Database::autotype( $indexed_permissions )
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,25 +363,12 @@
|
||||||
for( var a in Object.keys(ACTIONS[COUNT]) ){
|
for( var a in Object.keys(ACTIONS[COUNT]) ){
|
||||||
|
|
||||||
/* (3) On vérifie que l'utilisateur a la permissions d'effectuer l'action */
|
/* (3) On vérifie que l'utilisateur a la permissions d'effectuer l'action */
|
||||||
var hasPermission = false;
|
var hasPermission = PERMISSIONS.hasOwnProperty(CARD) && PERMISSIONS[CARD].indexOf(ACTIONS[COUNT][a].id_action) > -1;
|
||||||
|
console.log( CARD, PERMISSIONS[CARD], ACTIONS[COUNT][a].id_action, hasPermission);
|
||||||
// On vérifie parmis toutes les permissions de cette CARTE
|
|
||||||
if( PERMISSIONS.hasOwnProperty(CARD) )
|
|
||||||
for( var i = 0 ; i < PERMISSIONS[CARD].length ; i++ )
|
|
||||||
if( PERMISSIONS[CARD][i] == ACTIONS[COUNT][a].id_action ){
|
|
||||||
hasPermission = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si on a pas la permission, on quitte
|
|
||||||
if( !hasPermission ) return;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log( CARD, PERMISSIONS[CARD], ACTIONS[COUNT][a].id_action);
|
|
||||||
|
|
||||||
// Si pas la permission, on fait rien
|
// Si pas la permission, on fait rien
|
||||||
if( !hasPermission ) break;
|
if( !hasPermission ) continue;
|
||||||
|
|
||||||
|
|
||||||
/* (4) Si la condition est correcte, On applique la modification de l'état */
|
/* (4) Si la condition est correcte, On applique la modification de l'état */
|
||||||
if( previous(ACTIONS[COUNT][a].previous, STATE) ){
|
if( previous(ACTIONS[COUNT][a].previous, STATE) ){
|
||||||
|
|
|
@ -5,4 +5,4 @@ a};Board.prototype.set=function(a,b){if(!(parseInt(a)!=a||a>this.maxPin)&&this.p
|
||||||
b=parseInt(b);this.values[a].set(b)}};Chip.prototype.setPins=function(a){for(var b=0;b<this.pins.length;b++)this.setPin(b,a[b])};Chip.prototype.getPin=function(a){return parseInt(a)!=a||this.pins.length<=a?!1:this.values[a].get()};Chip.prototype.getPins=function(){for(var a=[],b=0;b<this.pins.length;b++)a[b]=this.getPin(b);return a}})();var LedInterface;
|
b=parseInt(b);this.values[a].set(b)}};Chip.prototype.setPins=function(a){for(var b=0;b<this.pins.length;b++)this.setPin(b,a[b])};Chip.prototype.getPin=function(a){return parseInt(a)!=a||this.pins.length<=a?!1:this.values[a].get()};Chip.prototype.getPins=function(){for(var a=[],b=0;b<this.pins.length;b++)a[b]=this.getPin(b);return a}})();var LedInterface;
|
||||||
(function(){LedInterface=function(a,b){a instanceof Chip&&b instanceof Element&&(this.chip=a,this.container=b)};LedInterface.prototype={chip:this.chip,container:this.container};LedInterface.prototype.update=function(){this.container.style.backgroundColor="rgb("+this.chip.getPin(0)+","+this.chip.getPin(1)+","+this.chip.getPin(2)+")"}})();var RelayInterface;
|
(function(){LedInterface=function(a,b){a instanceof Chip&&b instanceof Element&&(this.chip=a,this.container=b)};LedInterface.prototype={chip:this.chip,container:this.container};LedInterface.prototype.update=function(){this.container.style.backgroundColor="rgb("+this.chip.getPin(0)+","+this.chip.getPin(1)+","+this.chip.getPin(2)+")"}})();var RelayInterface;
|
||||||
(function(){RelayInterface=function(a,b){a instanceof Chip&&b instanceof Element&&(this.chip=a,this.container=b)};RelayInterface.prototype={chip:this.chip,container:this.container};RelayInterface.prototype.update=function(){1<this.chip.getPin(0)?this.container.addClass("active"):this.container.remClass("active")}})();var previous,action;
|
(function(){RelayInterface=function(a,b){a instanceof Chip&&b instanceof Element&&(this.chip=a,this.container=b)};RelayInterface.prototype={chip:this.chip,container:this.container};RelayInterface.prototype.update=function(){1<this.chip.getPin(0)?this.container.addClass("active"):this.container.remClass("active")}})();var previous,action;
|
||||||
(function(){previous=function(a,b){a=a.toLowerCase();for(var c=0;c<a.length;c++)if("x"!=a[c]&&a[c]!=b[c])return!1;return!0};action=function(a,b){a=a.toLowerCase();for(var c=0;c<a.length;c++)"x"!=a[c]&&(b[c]=parseInt(a[c]))}})();
|
(function(){previous=function(a,b){console.warn(a);a=a.toLowerCase();for(var c=0;c<a.length;c++)if("x"!=a[c]&&a[c]!=b[c])return!1;return!0};action=function(a,b){a=a.toLowerCase();for(var c=0;c<a.length;c++)"x"!=a[c]&&(b[c]=parseInt(a[c]))}})();
|
||||||
|
|
|
@ -363,6 +363,7 @@ var action;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
previous = function(previous, state){
|
previous = function(previous, state){
|
||||||
|
console.warn(previous);
|
||||||
previous = previous.toLowerCase();
|
previous = previous.toLowerCase();
|
||||||
|
|
||||||
for( var i = 0 ; i < previous.length ; i++ )
|
for( var i = 0 ; i < previous.length ; i++ )
|
||||||
|
|
Loading…
Reference in New Issue