Fix a JavaScript regression encapsulating the problematic part into an if.
Other minor changes:
- dedicate a variable for the confirmation messages to improve i18n in the future (but also to avoid 80 characters and make lint happy)
- replace confirm with window.confirm (to make lint happy)