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

@ -47,6 +47,10 @@ img[alt="XMR Logo"] {
display: inline ;
}
#rand {
color: lightgreen;
}
@media (prefers-color-scheme: light) {
body {
background: white ;
@ -64,6 +68,9 @@ img[alt="XMR Logo"] {
code {
color: forestgreen ;
}
#rand {
color: green;
}
}
@media print {

View File

@ -1 +1 @@
<li><a href="$URL">$TITLE</a></li>
<li><a class="entrylink" href="$URL">$TITLE</a></li>

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>

View File

@ -1,2 +1,4 @@
<h2>Recipes</h2>
<ul id=artlist>
<a id=rand oncontextmenu="return false"></a>
<br>