Fixed flipped array

master
sigonasr2 2 years ago
parent deb56c2e0d
commit b54bbd9994
  1. 14
      inventory_monitor.js

@ -16,14 +16,16 @@ function update(){
item=line.split(" ")
itemID=item[1]
itemAmt=item[0]
itemHQ=item[2]
//console.log(itemID+" x"+itemAmt+" "+(itemHQ?"":"HQ"))
hq=(item[2]!==undefined)?item[2].replace("\r",""):""
itemHQ=hq==="0"?false:true
//console.log(itemID+" x"+itemAmt+" "+(itemHQ))
if(firstLoad){
finalData=[{"id":itemID,"amt":itemAmt,"hq":Boolean(itemHQ)},...finalData]
finalData=[...finalData,{"id":Number(itemID),"amt":Number(itemAmt),"hq":itemHQ}]
}else
if (finalData[i]!==undefined){
if (finalData[i].id!==itemID||finalData[i].amt!==itemAmt||finalData[i].hq!==Boolean(itemHQ)){
finalData[i]={"id":itemID,"amt":itemAmt,"hq":Boolean(itemHQ)}
if (finalData[i]!==undefined&&(Number.isInteger(finalData[i].id)^Number.isInteger(itemID))){
if (finalData[i].id!=Number(itemID)||finalData[i].amt!==Number(itemAmt)||finalData[i].hq!==Boolean(itemHQ)){
console.log(JSON.stringify(finalData[i])+" !== "+JSON.stringify({"id":Number(itemID),"amt":Number(itemAmt),"hq":Boolean(itemHQ)}))
finalData[i]={"id":Number(itemID),"amt":Number(itemAmt),"hq":Boolean(itemHQ)}
changed=true;
}
}

Loading…
Cancel
Save