(function(){ Legend={}; NUM_COLS=4; NUM_TDS_PER_COL=3; function newTr(_1){ var td; var tr=document.createElement("tr"); for(var i=0;i=_6.numTds){ newTr(_6); } i%=(NUM_COLS*NUM_TDS_PER_COL); return _6.tr.childNodes[i]; } Legend=function(_8,_9){ this.emon=_9; this.sources={}; this.numSources=0; this.nextTd=0; this.numTds=0; this.table=document.getElementById(_8); this.addEntry(false,"use",".power","Power used"); this.addEntry(false,"gen",".power","Power generated"); this.addEntry(false,"use",".energy","Energy from grid"); this.addEntry(false,"gen",".energy","Energy to grid"); var _a=this; _9.setCallback("sourcesChanged",function(_b){ _a.update(_b); }); }; Legend.prototype.addEntry=function(_c,_d,_e,_f){ var _10=this; var td=nextTd(this); if(_c){ var _12=document.createElement("input"); _12.type="checkbox"; if(_f){ _12.defaultChecked="true"; } _12.onclick=function(){ _10.emon.setVisibility(_e,this.checked); _10.emon.refresh(); }; td.appendChild(_12); } var td=nextTd(this); td.className="sym"; var sym=this.emon.legendSym(_d,_e); td.appendChild(sym.g); var td=nextTd(this); td.className="desc right_border"; if(_f){ td.innerHTML=_f; }else{ td.innerHTML=(_e+" gen./"+" used"); } }; Legend.prototype.addSource=function(src){ this.sources[src]=true; this.addEntry(true,"all",src); }; Legend.prototype.update=function(_15){ for(var i=0;i<_15.length;++i){ var src=_15[i]; if(EG_NON_RENEWABLE_PATTERN.exec(src)){ continue; } if(!this.sources[src]){ this.addSource(src); } } }; })();