|
|
@ -2917,6 +2917,27 @@ function deSelect() { |
|
|
|
|
|
|
|
|
|
|
|
function selectRange($list, $select, $from) { |
|
|
|
function selectRange($list, $select, $from) { |
|
|
|
$list.removeClass('active'); |
|
|
|
$list.removeClass('active'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// add hashchange to permalink
|
|
|
|
|
|
|
|
const $issue = $('a.ref-in-new-issue'); |
|
|
|
|
|
|
|
const $copyPermalink = $('a.copy-line-permalink'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($issue.length === 0 || $copyPermalink.length === 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateIssueHref = function(anchor) { |
|
|
|
|
|
|
|
let href = $issue.attr('href'); |
|
|
|
|
|
|
|
href = `${href.replace(/%23L\d+$|%23L\d+-L\d+$/, '')}%23${anchor}`; |
|
|
|
|
|
|
|
$issue.attr('href', href); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateCopyPermalinkHref = function(anchor) { |
|
|
|
|
|
|
|
let link = $copyPermalink.attr('data-clipboard-text'); |
|
|
|
|
|
|
|
link = `${link.replace(/#L\d+$|#L\d+-L\d+$/, '')}#${anchor}`; |
|
|
|
|
|
|
|
$copyPermalink.attr('data-clipboard-text', link); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if ($from) { |
|
|
|
if ($from) { |
|
|
|
let a = parseInt($select.attr('rel').substr(1)); |
|
|
|
let a = parseInt($select.attr('rel').substr(1)); |
|
|
|
let b = parseInt($from.attr('rel').substr(1)); |
|
|
|
let b = parseInt($from.attr('rel').substr(1)); |
|
|
@ -2934,38 +2955,16 @@ function selectRange($list, $select, $from) { |
|
|
|
$list.filter(classes.join(',')).addClass('active'); |
|
|
|
$list.filter(classes.join(',')).addClass('active'); |
|
|
|
changeHash(`#L${a}-L${b}`); |
|
|
|
changeHash(`#L${a}-L${b}`); |
|
|
|
|
|
|
|
|
|
|
|
// add hashchange to permalink
|
|
|
|
updateIssueHref(`L${a}-L${b}`); |
|
|
|
const $issue = $('a.ref-in-new-issue'); |
|
|
|
updateCopyPermalinkHref(`L${a}-L${b}`); |
|
|
|
|
|
|
|
|
|
|
|
if ($issue.length === 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const matched = $issue.attr('href').match(/%23L\d+$|%23L\d+-L\d+$/); |
|
|
|
|
|
|
|
if (matched) { |
|
|
|
|
|
|
|
$issue.attr('href', $issue.attr('href').replace($issue.attr('href').substr(matched.index), `%23L${a}-L${b}`)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$issue.attr('href', `${$issue.attr('href')}%23L${a}-L${b}`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$select.addClass('active'); |
|
|
|
$select.addClass('active'); |
|
|
|
changeHash(`#${$select.attr('rel')}`); |
|
|
|
changeHash(`#${$select.attr('rel')}`); |
|
|
|
|
|
|
|
|
|
|
|
// add hashchange to permalink
|
|
|
|
updateIssueHref($select.attr('rel')); |
|
|
|
const $issue = $('a.ref-in-new-issue'); |
|
|
|
updateCopyPermalinkHref($select.attr('rel')); |
|
|
|
|
|
|
|
|
|
|
|
if ($issue.length === 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const matched = $issue.attr('href').match(/%23L\d+$|%23L\d+-L\d+$/); |
|
|
|
|
|
|
|
if (matched) { |
|
|
|
|
|
|
|
$issue.attr('href', $issue.attr('href').replace($issue.attr('href').substr(matched.index), `%23${$select.attr('rel')}`)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$issue.attr('href', `${$issue.attr('href')}%23${$select.attr('rel')}`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$(() => { |
|
|
|
$(() => { |
|
|
|