diff --git a/test/client/interface.php b/test/client/interface.php index ef4efc1..6675582 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -254,12 +254,16 @@ var board = new Board(50); var chip = { - led: new LedInterface( new Chip(1, 2, 3), led ), - r1: new RelayInterface( new Chip(4), r1 ), - r2: new RelayInterface( new Chip(5), r2 ) + led: new LedInterface( new Chip('serial', [1, 2, 3]), led ), + r1: new RelayInterface( new Chip('serial', [4]), r1 ), + r2: new RelayInterface( new Chip('serial', [5]), r2 ) }; - board.plug( chip.led ) + var chipList = Object.keys(chip); + + // Branchement des puces + for( var i = 0 ; i < chipList.length ; i++ ) + board.plug( chip[chipList[i]] ); /* [1] Fonctions diff --git a/test/client/lib.js b/test/client/lib.js index 54f508f..79c1acd 100644 --- a/test/client/lib.js +++ b/test/client/lib.js @@ -78,7 +78,7 @@ var Board; /* [2] Branchement + on lie l'interface =========================================================*/ - for( var i = 0 ; i < chipInterface.chip.pins.length ; i++ ){ + for( i = 0 ; i < chipInterface.chip.pins.length ; i++ ){ this.pins[i] = chipInterface.chip.values[i]; this.listener[i] = chipInterface; } @@ -166,7 +166,7 @@ var Chip; this.pins = pins; this.values = []; - for( var i = 0 ; i < this.pins.length ; i++ ) + for( i = 0 ; i < this.pins.length ; i++ ) this.values[i] = new Pin(0); }; @@ -336,10 +336,8 @@ var RelayInterface; * */ RelayInterface.prototype.update = function(){ - if( this.chip.pin[0] ) - this.container.addClass('active'); - else - this.container.remClass('active'); + if( this.chip.pin[0] ) this.container.addClass('active'); + else this.container.remClass('active'); };