Last active
May 11, 2021 23:06
-
-
Save HBehrens/27103ca96bda5b50b935545aba64e24c to your computer and use it in GitHub Desktop.
Search for Memfault YouTrack Issues in text and create Search Link
This file contains 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
<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
Don't use https://bl.ocks.org/HBehrens/27103ca96bda5b50b935545aba64e24c as they could read what you paste into the form