Simulate an input() dialog box
The built-in function
input() is blocking: the script
execution stops until the user enters a value. It is implemented with the
prompt(), which opens a
dialog box that can't be customized.
it's impossible to override
input() with a function that would
open a dialog box made of HTML elements (an INPUT tag, "Ok" and "Cancel"
buttons) and stop execution until the user clicks on one of the buttons; the
actions to execute when a value has been entered must be defined in a callback
In this example, we use a generic function
handles the entry of an integer value in an INPUT tag. It loops until the
value is a valid integer literal.The comments in the source code explain the
interface of this function.