You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
2 years ago
|
const fs = require('fs');
|
||
|
|
||
|
console.log("Hello!")
|
||
|
|
||
|
finalData=[]
|
||
|
firstLoad=true
|
||
|
|
||
|
function update(){
|
||
|
changed=false
|
||
|
fs.readFile("C:\\Users\\sigon\\Documents\\memory",
|
||
|
(err,data)=>{
|
||
|
var fileContents = data.toString().split("\n");
|
||
|
for (i=0;i<fileContents.length;i++){
|
||
|
line=fileContents[i]
|
||
|
item=line.split(" ")
|
||
|
itemID=item[1]
|
||
|
itemAmt=item[0]
|
||
|
itemHQ=item[2]
|
||
|
//console.log(itemID+" x"+itemAmt+" "+(itemHQ?"":"HQ"))
|
||
|
if(firstLoad){
|
||
|
finalData=[{"id":itemID,"amt":itemAmt,"hq":itemHQ},...finalData]
|
||
|
}else
|
||
|
if (finalData[i]!==undefined){
|
||
|
if (finalData[i].id!==itemID||finalData[i].amt!==itemAmt||finalData[i].hq!==itemHQ){
|
||
|
finalData[i]={"id":itemID,"amt":itemAmt,"hq":itemHQ}
|
||
|
changed=true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (changed){
|
||
|
console.log("Changes occurred...")
|
||
|
}
|
||
|
firstLoad=false
|
||
|
setTimeout(update,1000)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
update()
|