add random recipe link

This commit is contained in:
dvhar
2021-03-30 20:56:44 -05:00
parent 7d05044a2d
commit f42c51179d
4 changed files with 24 additions and 1 deletions

View File

@@ -1 +1,15 @@
</ul>
<script>
var entries = document.getElementsByClassName('entrylink');
var randlink = document.getElementById('rand');
function setbutton() {
let rand = entries[Math.floor(Math.random() * entries.length)];
randlink.innerHTML = 'Random: ' + rand.innerHTML;
randlink.href = rand.href;
}
setbutton();
randlink.onmouseup = function(e){
if (e.which != 1)
setTimeout(setbutton, 10);
}
</script>