Created
June 24, 2014 19:54
-
-
Save johnjones4/d5bead1895151e9d31b0 to your computer and use it in GitHub Desktop.
This script forces GitLab's front end to build the entire Git history for a project, then update necessary images, and finally rewrite the page with just the graph so it is suitable for printing.
This file contains 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
(function() { | |
var $graphWrapper = $('.network-graph'); | |
var lastScrollTop = 0; | |
$graphWrapper.scrollTop(0); | |
var dropInImages = function() { | |
const replaceShots = [ | |
{ // Sam | |
'old': '/uploads/user/avatar/5/superman-logo-013.png', | |
'newimg': 'http://localhost:9090/small_sam.png' | |
}, | |
{ // John | |
'old': 'http://www.gravatar.com/avatar/a289396a38e2b9457243a16e500d7f73?s=20&d=mm', | |
'newimg': 'http://localhost:9090/small_john.png' | |
}, | |
{ // John | |
'old': 'http://www.gravatar.com/avatar/65f5ee1ec8f4636c6e8dae712d8d6a55?s=20&d=mm', | |
'newimg': 'http://localhost:9090/small_john.png' | |
}, | |
{ // Chris | |
'old': 'http://www.gravatar.com/avatar/ccee736221ce91fd8bc78ac81b59f03c?s=20&d=mm', | |
'newimg': 'http://localhost:9090/small_chris.png' | |
}, | |
{ // Sean | |
'old': 'http://www.gravatar.com/avatar/c17897aa15eda9299917492ea5701ccb?s=20&d=mm', | |
'newimg': 'http://localhost:9090/small_sean.png' | |
} | |
]; | |
$('.network-graph image').each(function() { | |
var $image = $(this); | |
var url = $image.attr('href'); | |
replaceShots.forEach(function(object) { | |
if (url == object.old) { | |
$image.attr('href',object.newimg); | |
} | |
}); | |
}); | |
} | |
var finalize = function() { | |
var svg = $('.network-graph').html(); | |
svg = svg.replace('xmlns="http://www.w3.org/2000/svg"','xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"'); | |
document.write(svg); | |
document.title = 'Git History'; | |
} | |
var scrollDown = function() { | |
lastScrollTop = $graphWrapper.scrollTop(); | |
$graphWrapper.scrollTop(lastScrollTop + 300); | |
if ($graphWrapper.scrollTop() > lastScrollTop) { | |
setTimeout(scrollDown,500); | |
} else { | |
dropInImages(); | |
setTimeout(finalize,1000); | |
} | |
} | |
scrollDown(); | |
return true; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment