Skip to content

Instantly share code, notes, and snippets.

@dergachev
Last active January 2, 2016 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dergachev/8291018 to your computer and use it in GitHub Desktop.
Save dergachev/8291018 to your computer and use it in GitHub Desktop.
Side-By-Side Diff Bookmarklet

Side-By-Side Diff Bookmarklet

Currently hardcodes these domain pairs, tweak it for your use-case:

var urls = {prod: "http://www.mcgill.ca/study/2013-2014", dev: "http://amir-dev.tree.ewdev.ca"}; 

Activating the bookmarklet once on either site displays the same page side-by-side with its complement, as follows:

Activating the bookmarklet a second time redirects to the complementary page.

I use this bookmarklet as a http://backtick.io/ command, but you can simply paste the code into a bookmarklet.

var urls = {prod: "http://www.mcgill.ca/study/2013-2014", dev: "http://amir-dev.tree.ewdev.ca"};
var thisURL = window.location.href;
var otherURL = window.location.host.match(/mcgill.ca$/) ?
thisURL.replace(urls.prod, urls.dev) :
thisURL.replace(urls.dev, urls.prod);
if(!jQuery('body').hasClass('courseCal-split')) {
jQuery('body').addClass('courseCal-split').empty();
jQuery('<iframe/>').attr({width:'50%', height: '100%', src: thisURL}).appendTo('body');
jQuery('<iframe/>').attr({width:'50%', height: '100%', src: otherURL}).appendTo('body');
} else {
//on double click, simply redirect
window.location.href = otherURL;
}
{
"name": "SWAP-COURSECAL",
"description": "Swaps domains: mcgill.ca/study/2013-14 and amir-dev.tree.ewdev.ca"
}
@dergachev
Copy link
Author

javascript:var urls = {prod: "http://www.mcgill.ca/study/2013-2014", dev: "http://amir-dev.tree.ewdev.ca"}; 
var thisURL = window.location.href;
var otherURL = window.location.host.match(/mcgill.ca$/) ? 
  thisURL.replace(urls.prod, urls.dev) : 
  thisURL.replace(urls.dev, urls.prod);
if(!jQuery('body').hasClass('courseCal-split')) {
  jQuery('body').addClass('courseCal-split').empty();
  jQuery('<iframe/>').attr({width:'50%', height: '100%', src: thisURL}).appendTo('body');
  jQuery('<iframe/>').attr({width:'50%', height: '100%', src: otherURL}).appendTo('body');
} else {
  window.location.href = otherURL;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment