it might be sensible to refactor this file so that this script block is a file in the public/js dir