Last active
April 20, 2022 18:15
-
-
Save apexskier/3c20bb2842f7938d95f87a47aade4ef0 to your computer and use it in GitHub Desktop.
Shuffle people quick filters in our Jira board
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
(() => { | |
// https://stackoverflow.com/a/2450976/2178159 | |
// Fisher-Yates | |
function shuffle(array) { | |
var currentIndex = array.length, temporaryValue, randomIndex; | |
// While there remain elements to shuffle... | |
while (0 !== currentIndex) { | |
// Pick a remaining element... | |
randomIndex = Math.floor(Math.random() * currentIndex); | |
currentIndex -= 1; | |
// And swap it with the current element. | |
temporaryValue = array[currentIndex]; | |
array[currentIndex] = array[randomIndex]; | |
array[randomIndex] = temporaryValue; | |
} | |
return array; | |
} | |
// This has been updated for jira cloud. See prior commit for old jira | |
const buttons = Array.from(document.querySelectorAll("#ASSIGNEE + div > div")); | |
const parents = buttons.map(b => { | |
const p = b.parentElement; | |
p.removeChild(b); | |
return p; | |
}); | |
shuffle(buttons); | |
parents.forEach((p, i) => { | |
p.appendChild(buttons[i]); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment