hide random link when no js

This commit is contained in:
dvhar 2021-03-30 21:20:26 -05:00
parent f42c51179d
commit 95004f566f
3 changed files with 4 additions and 2 deletions

View File

@ -49,6 +49,7 @@ img[alt="XMR Logo"] {
#rand { #rand {
color: lightgreen; color: lightgreen;
display: none;
} }
@media (prefers-color-scheme: light) { @media (prefers-color-scheme: light) {
@ -70,6 +71,7 @@ img[alt="XMR Logo"] {
} }
#rand { #rand {
color: green; color: green;
display: none;
} }
} }

View File

@ -2,9 +2,10 @@
<script> <script>
var entries = document.getElementsByClassName('entrylink'); var entries = document.getElementsByClassName('entrylink');
var randlink = document.getElementById('rand'); var randlink = document.getElementById('rand');
randlink.style.display = 'revert';
function setbutton() { function setbutton() {
let rand = entries[Math.floor(Math.random() * entries.length)]; let rand = entries[Math.floor(Math.random() * entries.length)];
randlink.innerHTML = 'Random: ' + rand.innerHTML; randlink.innerHTML = 'Random: ' + rand.innerHTML + '<br>';
randlink.href = rand.href; randlink.href = rand.href;
} }
setbutton(); setbutton();

View File

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