Skip to content

Instantly share code, notes, and snippets.

@HBehrens
Created May 11, 2021 22:48
Show Gist options
  • Save HBehrens/da8fe906ef5f183a9739ae7b0e9135b1 to your computer and use it in GitHub Desktop.
Save HBehrens/da8fe906ef5f183a9739ae7b0e9135b1 to your computer and use it in GitHub Desktop.
<textarea id="input" placeholder="Paste text with issue ids with the pattern MFLT-1234" rows="10"
style="display: block; width:100%"></textarea>
<a id="link" href="">Click me</a>
<script>
const textArea = document.getElementById("input");
const linkElement = document.getElementById("link");
function updateLink() {
const issueMatches = [...textArea.value.matchAll((/\bMFLT-\d+/g))];
const issueStrings = issueMatches.map(m => '' + m);
const issues = [...new Set(issueStrings)];
linkElement.innerText = `Open YouTrack Search for ${issues.length} issue(s)`;
const issueList = issues.join(',');
const searchTerms = ["issue id:", "aggregate Is duplicated by:", "aggregate Duplicates:"].map((s) => s + issueList)
linkElement.href = `https://memfault.myjetbrains.com/youtrack/issues/MFLT?q=${encodeURI(searchTerms.join(' or '))}`;
return true;
}
// yes, wasteful – but the easiest way to keep Link in sync
setInterval(updateLink, 500);
textArea.focus();
updateLink();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment