I am already using this piece of code to update a codebox in the page with the data retrieved using dyntask.php.
<script type="text/javascript">
if(typeof(EventSource)!=="undefined") {
var eSource = new EventSource("dyntasks.php");
eSource.onmessage = function(event, previous) {
document.getElementById("serverData").innerHTML = event.data;
};
}
</script>
The data collected using dyntask.php are extracted from a text file.
2018-05-10 14:02:01: starting task 99333
2018-05-10 14:02:03: task 99333 completed
2018-04-13 15:13:44: triggered tasks
2018-05-10 14:05:52: starting task 99334
2018-05-10 14:05:57: task 99334 completed
2018-05-10 14:11:01: starting hidden task 99335
2018-05-10 14:11:07: hidden task 99335 completed
updating...
The last row of the text file is always "updating...". What I need to do is to check continuously for the content of the row before the last one
- the check should start every time the keyword "starting" is present in the row
- when the keywork is found the script should start checking for the presence of the word "completed"
- when the word "completed" is found the script should refresh the whole page
I don't know Javascript more than what is needed in order to create this little script. I have no clues about how to do it but I'm sure there are people out there able to add just TWO lines in the script to make it work as expected.
Can you please provide me with some help?