The http://localhost:8888 part of this can be changed to 
location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: '')
That way it will work in any context without needing to be modified.