Browse files

add javascript to inject

  • Loading branch information...
1 parent 2d352af commit d7d365faf1d12321af7f552798c863a7766cfa4e @jlongster committed Feb 17, 2011
Showing with 42 additions and 0 deletions.
  1. +42 −0 branches.js
View
42 branches.js
@@ -0,0 +1,42 @@
+
+// the "branches" variable is assumed to be set
+
+function show_branches() {
+ var host = window.location.hostname;
+ var splitat = host.indexOf('.');
+ var branch = host.substring(0, splitat);
+ var domain = host.substring(splitat+1);
+
+ function remake_url(domain) {
+ var loc = window.location;
+
+ if(loc.port != 80) {
+ domain += ':' + loc.port;
+ }
+
+ return loc.protocol + '//' + domain + loc.pathname + loc.search;
+ }
+
+
+ if(window.branches && window.jQuery) {
+ var el = $('<div class="_branches"></div>');
+
+ el.append('Current branch: ' + branch);
+
+ for(var i=0; i<branches.length; i++) {
+ el.append('<div><a href="' + remake_url(branches[i] + '.' + domain) + '">' + branches[i] + '</a></div>');
+ }
+
+ el.hide();
+ el.css({ position: 'fixed',
+ top: 0,
+ right: 0,
+ padding: '30px',
+ margin: '15px',
+ backgroundColor: '#00FF00' });
+ $('body').prepend(el);
+ el.fadeIn(1500);
+ }
+}
+
+setTimeout(show_branches, 1000);

0 comments on commit d7d365f

Please sign in to comment.