After looking around the Internet for a simple way of blocking a script to wait for an event, I found that the general approach is to use setTimeout and recursively (though it is not recursive) call a method until a condition is met. This is my implementation of a JavaScript waitForCondition meth more