is there a way to watch for file changes in the browser?
the workflow would be:
1) the user open the file
2) the webapp write the file
3) a locally installed app read the file and write some changes
4) the webapp read the last change
5) eventually go to step 2 again
This should be done in the browser.
At the moment I have a button that the user have to press multiple times, but:
1) I would prefer this to be done automatically, without clicking 2) Chrome caches the files, so further changes are not read.
What is the best way to do this?
Here's what I'm doing now:
https://codepen.io/muaddibber/pen/OZJgYQ
window.onload = function() {
var fileInput = document.getElementById('fileInput');
var fileDisplayArea = document.getElementById('fileDisplayArea');
fileInput.addEventListener('change', function(e) {
var file = fileInput.files[0];
var textType = /text.*/;
if (file.type.match(textType)) {
var reader = new FileReader();
reader.onload = function(e) {
fileDisplayArea.innerText = reader.result;
}
reader.readAsText(file);
} else {
fileDisplayArea.innerText = "File not supported!"
}
});
}
I open a file, prova.txt, and it works.
Then I locally edit the file and reopen it: it doesn't change, chrome still shows the old version.