I would want to separate these two logical points into different functions.  One has one use-case (distributed server is offline), the other has two, and both are admin-only.  So I suggest to wrap in separate functions, and call them inside +$(function() {} in the appropriate pages.