SMMP/test/client/lib-min.js

7 lines
1.7 KiB
JavaScript

var Chip;
(function(){Chip=function(){this.pins=[];this.pin={};for(var a=0;a<arguments.length;a++)parseInt(arguments[a])==arguments[a]&&(this.pins.push(parseInt(arguments[a])),this.pin[parseInt(arguments[a])]=0)};Chip.prototype={pin:this.pin,pins:this.pins};Chip.prototype.setPin=function(a,b){if(parseInt(a)==a&&this.pin.hasOwnProperty(a)){if("boolean"==typeof b)b=b?255:0;else if(b!=parseInt(b)||0>b||255<b)return;b=parseInt(b);this.pin[a]=b}};Chip.prototype.setPins=function(a){for(var b=0;b<this.pins.length;b++)this.setPin(this.pin[this.pins[b]],a[b])};
Chip.prototype.getPin=function(a){if(parseInt(a)==a&&this.pin.hasOwnProperty(a))return this.pin[a]};Chip.prototype.getPins=function(){for(var a=[],b=0;b<this.pins.length;b++)a.push(this.getPin(this.pins[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.apply=function(){this.container.style.background="rgb("+this.chip.pin[0]+","+this.chip.pin[1]+","+this.chip.pin[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.apply=function(){this.chip.pin[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]))}})();