I'm working on an IDE as a side project using NW.js and I need to detect if there's any changes to my project tree when focused.
I'm using JQuery's .each check if the files in the project folder have changed since being focused.
Here's what I have for window focused function.
win.on("focus", function() {
var stringArray = [];
listFiles = fs.readdirSync(__dirname + "/content/project");
console.log("checking if there's any changes");
$.each($("[data-nme]"), function() {
stringArray.push(this.textContent);
});
var array1 = listFiles;
var array2 = JSON.stringify(stringArray);
console.log(array1);
console.log(array2);
if (array1.toString() != array2.toString()) {
console.log("there's been a change");
}
});
When I debug I get the following result.
I don't understand why it says there's a difference with the array when it's the exact same.
if (array1.toString() != array2.toString()) {
console.log("there's been a change");
}