So I'm building a rather complex (from my standpoint) client-sided web-app in Javascript.
What the program does basically is take a (rather huge) set of string data from the user, take a list of keywords from the user, perform a search and return an array of true/false.
Very plainly it works that way :
var userData = ["lorem ipsum", "dolor sit amet", " consectetur adipisicing"];
var userKeywords = ["et","or"];
var isMatch = false;
for (var x in userData){
var y = 0;
while (y<userKeywords.length && !isMatch){
isMatch = (userData[x].match(userKeywords[y]) !== null)? true : false;
y++;
}
}
// That would return [true, true, true]
(that was just to give you the main idea)
Because I'm dealing with rather big quantities of data (50K ++) and keywords (~50) my program can run for a couple minutes. Whilst we know not to panic and wait when a huge program is running, my users won't...
So I wanted to give them some feedback on the execution of the program while it is running like a basic progress bar would, but I couldn't find how.
I know I could calculate the length of the task I'm asking my program to do, then increment a counter and post the result into the DOM - but wouldn't it be a problem to access the DOM in a loop ?
var userData = ["lorem ipsum", "dolor sit amet", " consectetur adipisicing"];
var userKeywords = ["et","or"];
var isMatch = false;
var myTask = userData.length * userKeywords.length ;
var myCounter = 0;
for (var x in userData){
var y = 0;
while (y<userKeywords.length && !isMatch){
isMatch = (userData[x].match(userKeywords[y]) !== null)? true : false;
y++;
myCounter++;
console.log("Ran " + myCounter + " calculations out of " + myTask);
}
}
So, how can I give feedback to my user on the execution of the program ? Thanks!