Add randomize button. It needs more work (see #4)

parent 55c7c866
......@@ -106,3 +106,15 @@ window.onload = function() {
let hash = window.location.hash || '#step1';
document.querySelector('nav > a[href="' + hash + '"]').click();
}
let randomElement = function(selector) {
let elems = document.querySelectorAll(selector);
return elems[Math.round(Math.random() * elems.length)];
}
document.getElementById('randomize').onclick = function(e) {
randomElement('input[name="bg-color"]').click();
randomElement('input[name="fg-color"]').click();
randomElement('input[name="font"]').click();
draw();
}
......@@ -19,7 +19,7 @@
</nav>
<div id="inputs">
<div>
<button id="randomize">CHOISIR AU HASARD</button>
<button id="randomize">CHOISIR AU HASARD <span class="fa fa-random"></span></button>
</div>
<div id="step1">
<h2>Choisissez la couleur de fond</h2>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment