Skip to content
Snippets Groups Projects
Commit 64e1f62e authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Add a "pick random artists" button

parent 57451541
Branches
No related tags found
1 merge request!14Resolve "Add a "pick random artists" button"
This commit is part of merge request !14. Comments created here will be created in the context of that merge request.
/* pick some random artists */
function pickRandomArtists() {
var pickedArtistsCount = 6 + Math.floor(Math.random() * 6);
var artistElements = document.getElementsByClassName("checkbox-artist");
for (var i = 0; i < pickedArtistsCount; i++) {
var random = Math.floor(Math.random() * artistElements.length);
artistElements[random].click();
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<link rel="icon" type="image/png" href="img/favicon.png"/> <link rel="icon" type="image/png" href="img/favicon.png"/>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" media="all" /> <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/styles.css" type="text/css" media="all" /> <link rel="stylesheet" href="css/styles.css" type="text/css" media="all" />
<script src="js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script> <script src="js/scripts.js"></script>
</head> </head>
...@@ -62,7 +61,7 @@ ...@@ -62,7 +61,7 @@
<div class="custom-control custom-checkbox"> <div class="custom-control custom-checkbox">
<input <input
type="checkbox" type="checkbox"
class="custom-control-input" class="custom-control-input checkbox-artist"
id="check-top-artist-<?php echo $artist->id; ?>" id="check-top-artist-<?php echo $artist->id; ?>"
name="selected-artist[]" name="selected-artist[]"
value="<?php echo $artist->id; ?>" value="<?php echo $artist->id; ?>"
...@@ -92,7 +91,10 @@ ...@@ -92,7 +91,10 @@
</label> </label>
</div> </div>
<div class="col-md-4 col-sm-12"> <div class="col-md-4 col-sm-12">
<button name="generate-playlist-top-artists" type="submit" class="btn btn-secondary float-end">🎶 Generate!</button> <div class="btn-group float-end" role="group" aria-label="Action buttons">
<button name="pick-random-artist" type="button" class="btn btn-secondary" onclick="pickRandomArtists()">🎲 Pick random artists</button>
<button name="generate-playlist-top-artists" type="submit" class="btn btn-primary float-end">🎶 Generate!</button>
</div>
</div> </div>
</div> </div>
</form> </form>
...@@ -145,6 +147,7 @@ ...@@ -145,6 +147,7 @@
</div> </div>
<script src="js/bootstrap.min.js"></script>
</body> </body>
</html> </html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment