|
@ -6,7 +6,6 @@ const repoName = path.split('/')[2]; |
|
|
const isDashboard = () => location.pathname === '/' || /(^\/(dashboard))/.test(location.pathname) || /(^\/(orgs)\/)(\w|-)+\/(dashboard)/.test(location.pathname); |
|
|
const isDashboard = () => location.pathname === '/' || /(^\/(dashboard))/.test(location.pathname) || /(^\/(orgs)\/)(\w|-)+\/(dashboard)/.test(location.pathname); |
|
|
const isRepo = () => /^\/[^/]+\/[^/]+/.test(location.pathname); |
|
|
const isRepo = () => /^\/[^/]+\/[^/]+/.test(location.pathname); |
|
|
const isRepoRoot = () => location.pathname.replace(/\/$/, '') === `/${ownerName}/${repoName}` || /(\/tree\/)(\w|\d|\.)+(\/$|$)/.test(location.href); |
|
|
const isRepoRoot = () => location.pathname.replace(/\/$/, '') === `/${ownerName}/${repoName}` || /(\/tree\/)(\w|\d|\.)+(\/$|$)/.test(location.href); |
|
|
const isCompare = () => /^\/[^/]+\/[^/]+\/compare/.test(location.pathname); |
|
|
|
|
|
const isPR = () => /^\/[^/]+\/[^/]+\/pull\/\d+/.test(location.pathname) || /^\/[^/]+\/[^/]+\/pull\/\d+\/commits\/[0-9a-f]{5,40}/.test(location.pathname); |
|
|
const isPR = () => /^\/[^/]+\/[^/]+\/pull\/\d+/.test(location.pathname) || /^\/[^/]+\/[^/]+\/pull\/\d+\/commits\/[0-9a-f]{5,40}/.test(location.pathname); |
|
|
const isCommit = () => /^\/[^/]+\/[^/]+\/commit\/[0-9a-f]{5,40}/.test(location.pathname) || /^\/[^/]+\/[^/]+\/pull\/\d+\/commits\/[0-9a-f]{5,40}/.test(location.pathname); |
|
|
const isCommit = () => /^\/[^/]+\/[^/]+\/commit\/[0-9a-f]{5,40}/.test(location.pathname) || /^\/[^/]+\/[^/]+\/pull\/\d+\/commits\/[0-9a-f]{5,40}/.test(location.pathname); |
|
|
const isIssue = () => /^\/[^/]+\/[^/]+\/issues\/\d+$/.test(location.pathname); |
|
|
const isIssue = () => /^\/[^/]+\/[^/]+\/issues\/\d+$/.test(location.pathname); |
|
@ -33,41 +32,6 @@ function linkifyBranchRefs() { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function addMinimizeMaximize() { |
|
|
|
|
|
if ($('#toc .refined-github-btn-group').length) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const buttonGroup = $('<div>').addClass('btn-group right refined-github-btn-group'); |
|
|
|
|
|
const buttonHideAll = $('<a>').addClass('btn btn-sm').text('Minimize All').attr('id', 'hide_all'); |
|
|
|
|
|
const buttonShowAll = $('<a>').addClass('btn btn-sm').text('Maximize All').attr('id', 'show_all'); |
|
|
|
|
|
|
|
|
|
|
|
buttonHideAll.on('click', e => { |
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
$('.file-header').parent().addClass('refined-github-minimized'); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
buttonShowAll.on('click', e => { |
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
$('.file-header').parent().removeClass('refined-github-minimized'); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
buttonGroup |
|
|
|
|
|
.append(buttonHideAll) |
|
|
|
|
|
.append(buttonShowAll) |
|
|
|
|
|
.insertAfter('#toc .btn-group'); |
|
|
|
|
|
|
|
|
|
|
|
$('.file-header .file-actions').on('click', e => { |
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$('.file-header').on('click', e => { |
|
|
|
|
|
$(e.target).closest('.js-details-container').toggleClass('refined-github-minimized'); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function commentIsUseless(type, el) { |
|
|
function commentIsUseless(type, el) { |
|
|
if (uselessContent[type].text.includes(el.innerText)) { |
|
|
if (uselessContent[type].text.includes(el.innerText)) { |
|
|
return true; |
|
|
return true; |
|
@ -284,12 +248,13 @@ function addPatchDiffLinks() { |
|
|
// Prompt user to confirm erasing a comment with the Cancel button
|
|
|
// Prompt user to confirm erasing a comment with the Cancel button
|
|
|
$(document).on('click', event => { |
|
|
$(document).on('click', event => { |
|
|
// Check event.target instead of using a delegate, because Sprint doesn't support them
|
|
|
// Check event.target instead of using a delegate, because Sprint doesn't support them
|
|
|
if (!event.target.classList.contains('js-hide-inline-comment-form')) { |
|
|
const $target = $(event.target); |
|
|
|
|
|
if (!$target.hasClass('js-hide-inline-comment-form')) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Do not prompt if textarea is empty
|
|
|
// Do not prompt if textarea is empty
|
|
|
const text = $(event.target).closest('.js-inline-comment-form').find('.js-comment-field').val(); |
|
|
const text = $target.closest('.js-inline-comment-form').find('.js-comment-field').val(); |
|
|
if (text.length === 0) { |
|
|
if (text.length === 0) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -300,6 +265,17 @@ $(document).on('click', event => { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Collapse file diffs when clicking the file header
|
|
|
|
|
|
$(document).on('click', event => { |
|
|
|
|
|
// Check event.target instead of using a delegate, because Sprint doesn't support them
|
|
|
|
|
|
const $target = $(event.target); |
|
|
|
|
|
if (!($target.closest('.file-header').length > 0 && $target.closest('.file-actions').length === 0)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$target.closest('.js-details-container').toggleClass('refined-github-minimized'); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => { |
|
|
document.addEventListener('DOMContentLoaded', () => { |
|
|
const username = getUsername(); |
|
|
const username = getUsername(); |
|
|
|
|
|
|
|
@ -335,10 +311,6 @@ document.addEventListener('DOMContentLoaded', () => { |
|
|
linkifyIssuesInTitles(); |
|
|
linkifyIssuesInTitles(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isPR() || isCommit() || isCompare()) { |
|
|
|
|
|
addMinimizeMaximize(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isBlame()) { |
|
|
if (isBlame()) { |
|
|
addBlameParentLinks(); |
|
|
addBlameParentLinks(); |
|
|
} |
|
|
} |
|
|