Skip to content

Instantly share code, notes, and snippets.

@JanBe
Last active October 25, 2016 16:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JanBe/26025df4283d7a5e0ced to your computer and use it in GitHub Desktop.
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)
$(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 += '&nbsp;'
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;
});
});
@JanBe
Copy link
Author

JanBe commented Sep 9, 2014

Features:

  • Adds a toggle to show/hide all outdated diffs
  • Adds a progress bar for todos (including todos in comments)

@ChristianPeters
Copy link

Der Scope von Progress-Zähler beinhaltet auch das Diff. Daher:

    checked = $('.discussion-timeline input:checkbox:checked.task-list-item-checkbox').length
    total = $('.discussion-timeline .task-list-item-checkbox').length

@ChristianPeters
Copy link

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.

@aik099
Copy link

aik099 commented Jan 21, 2015

How this JS can be connected to GitHub? Maybe there is UserScripts.org version of it?

@rastersysteme
Copy link

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