Friday, January 20, 2023

bookmarkable/link-based random order list shuffler (php + stateless)

I made up a trivial list shuffler so that my zoom-based scrum standup could avoid the awkwardness of figuring out "who goes next".

You can bookmark the page, e.g. https://kirk.is/tools/shuffle/?items=Alice%0D%0ABob%0D%0ACarlos and everytime you reload it will get a new shuffle. 

(I do like that paradigm of putting everything in a link so I don't have to store anything in server or on browser, and putting everything in a textarea so that I don't have to build much UI, and the content can be copy and pasted freely - same idea I used for my quick poll and pill tracking sheet generator but here it's even cleaner since I don't have to make up a format, just items separated by returns)

PHP remains the simplest, lowest-friction way for me to make and deploy something like this in like 10 minutes, borrowing from my own html boilerplate and my no-warnings cgi param functions

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>bookmarkable random list order shuffler</title>
<style>
body {
    background-color: white;
    color: black;
    font-family: sans-serif;    
}
.content {
    width: 800px;
    margin: auto;
}
textarea {
    height:100px;   
    width:400px;
}
</style>
</head>
<body>
  <div class="content">
        <h1>bookmarkable random list order shuffler</h1>
        <?
            $rawitems = trim(getval("items"));            
            if($rawitems != '') {
                $items = explode("\n",$rawitems);
                shuffle($items);
                echo "<ol>";
                foreach($items as $item) {
                    echo "<li>".htmlspecialchars($item);
                }
            }
            echo "</ol>";
        ?>
        <p>
        Trivial random order list shuffler. Add one item per line, and hit the button. You
        can then bookmark the resulting page to get a new order each time.
        </p>
        <p>
        Great for deciding order at team standup meetings!
        </p>
        <form method="GET">
            <textarea name="items"><?echo htmlspecialchars($rawitems) ?></textarea>
            <br>
            <button>Shuffle</button>
        </form>        
  </div>
</body>
</html>
<? 
 function getval($key, $default = ''){
    return isset($_GET[$key]) ? $_GET[$key] : $default;    
 }
?>

(Incidentally that code textaarea is a nice freebie I get from using Freeforamatter.com's HTML Escape - that's weirdly convenient, better than times in the past where I put in code that breaks my blog template.)

No comments:

Post a Comment