Moved main JS code to a resource file.