Verified Commit 0508c054 authored by Thibaut Broggi's avatar Thibaut Broggi
Browse files

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

parent 55c7c866
...@@ -106,3 +106,15 @@ window.onload = function() { ...@@ -106,3 +106,15 @@ window.onload = function() {
let hash = window.location.hash || '#step1'; let hash = window.location.hash || '#step1';
document.querySelector('nav > a[href="' + hash + '"]').click(); 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 @@ ...@@ -19,7 +19,7 @@
</nav> </nav>
<div id="inputs"> <div id="inputs">
<div> <div>
<button id="randomize">CHOISIR AU HASARD</button> <button id="randomize">CHOISIR AU HASARD <span class="fa fa-random"></span></button>
</div> </div>
<div id="step1"> <div id="step1">
<h2>Choisissez la couleur de fond</h2> <h2>Choisissez la couleur de fond</h2>
......
Supports Markdown
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