Refactored modal.js, to reduce code duplication, and to add helper
functions for common tasks.
Refactored the file structure for the entire web client scripts part.