Created
April 27, 2010 22:25
-
-
Save banterability/381427 to your computer and use it in GitHub Desktop.
Bookmarklet to switch between production & development environments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:var%20h=location.href,a="www.scpr.org",b="localhost:8000";function%20s(){if(h.search(a)!=-1)z();else%20if(h.search(b)!=-1)y();else%20return%20false}function%20x(c){location.href=c}function%20y(){x(h.replace(b,a))}function%20z(){x(h.replace(a,b))}s(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: | |
var current_url = location.href; | |
var production_url = "www.scpr.org"; | |
var development_url = "localhost:8000"; | |
function site_detect() { | |
if (current_url.search(production_url) != -1) { | |
production_to_development(); | |
} else if (current_url.search(development_url) != -1) { | |
development_to_production(); | |
} else { | |
return false; | |
} | |
} | |
function redirect(new_url) { | |
location.href = new_url; | |
} | |
function development_to_production() { | |
redirect(current_url.replace(development_url, production_url)) | |
} | |
function production_to_development() { | |
redirect(current_url.replace(production_url, development_url)) | |
} | |
site_detect(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment