Last active
October 25, 2016 16:14
-
-
Save JanBe/26025df4283d7a5e0ced to your computer and use it in GitHub Desktop.
Some improvements for GitHub's pull request view (using https://github.com/defunkt/dotjs)
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
$(function() { | |
addProgressBar = function() { | |
checked = $('.discussion-timeline input:checkbox:checked.task-list-item-checkbox').length | |
total = $('.discussion-timeline .task-list-item-checkbox').length | |
progress = (checked / total) * 100.0 | |
bar = '<div class="discussion-sidebar-item progress">' | |
bar += '<h3 class="discussion-sidebar-heading">Progress</h3>' | |
bar += '<span class="progress-bar">' | |
bar += '<span class="progress" style="width: ' + progress + '%">' | |
bar += ' ' | |
bar += '</span>' | |
bar += '</span>' | |
bar += checked + '/' + total | |
bar += '</div>' | |
$('.discussion-sidebar').append(bar); | |
} | |
addDiffToggle = function() { | |
toggle = '<div class="discussion-sidebar-item toggle-outdated-diffs">'; | |
toggle += '<a href="#" class="show-outdated-diffs" style="color: #777; font-weight: bold;">'; | |
toggle += '<span class="octicon octicon-unfold"/>'; | |
toggle += ' Show outdated diffs'; | |
toggle += '</a>'; | |
toggle += '<a href="#" class="hide-outdated-diffs" style="display: none; font-weight: bold;">'; | |
toggle += '<span class="octicon octicon-fold"/>'; | |
toggle += ' Hide outdated diffs'; | |
toggle += '</a>'; | |
toggle += '</div>'; | |
$('.discussion-sidebar').append(toggle); | |
} | |
if(document.URL.match(/\/pull\//)) { | |
addProgressBar(); | |
addDiffToggle(); | |
} | |
$('.toggle-outdated-diffs').on('click', '.show-outdated-diffs', function() { | |
$('.outdated-diff-comment-container .discussion-item-body').show(); | |
$('.discussion-item-toggle-closed').hide(); | |
$('.discussion-item-toggle-open').show(); | |
$('.show-outdated-diffs').hide(); | |
$('.hide-outdated-diffs').show(); | |
return false; | |
}); | |
$('.toggle-outdated-diffs').on('click', '.hide-outdated-diffs', function() { | |
$('.outdated-diff-comment-container .discussion-item-body').hide(); | |
$('.discussion-item-toggle-closed').show(); | |
$('.discussion-item-toggle-open').hide(); | |
$('.hide-outdated-diffs').hide(); | |
$('.show-outdated-diffs').show(); | |
return false; | |
}); | |
}); |
Verwendungshinweis: Man muss nach Laden der PR-Übersicht einmal die Seite neu laden, da Github auf PJAX setzt und wir hier nicht die richtigen PJAX-Callbacks benutzen.
How this JS can be connected to GitHub? Maybe there is UserScripts.org version of it?
Zwei Änderungen, damit das Script wieder funktioniert:
Aus Zeile 38:
$('.outdated-diff-comment-container .discussion-item-body').show();
mache:
$('.discussion-item-body .outdated-comment').addClass('open');
Und aus Zeile 47:
$('.outdated-diff-comment-container .discussion-item-body').hide();
mache:
$('.discussion-item-body .outdated-comment').removeClass('open');
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Der Scope von Progress-Zähler beinhaltet auch das Diff. Daher: