Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Added number of books
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-van-Woudenberg committed Apr 24, 2024
1 parent 4233f1d commit 7c47dac
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions book/_static/books.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
.slider {
display: block;
margin-bottom: 10px;
width: 100%; /* Add this line to set the width of the sliders to 100% */
width: 100%;
}
.slider-container {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-columns: repeat(6, 1fr);
grid-gap: 10px;
width: 100%; /* Add this line to set the width of the sliders to 100% */
width: 100%;
}
</style>
</head>
Expand All @@ -39,6 +39,7 @@
var x = [];
for (var i = 1; i <= 12; i++) {
x.push(document.getElementById("x_" + i).value);
document.getElementById("x_" + i + "_value").textContent = x[i-1] + " books"; // Update the value display with the unit "books"
}

var output = document.getElementById("outputContainer");
Expand Down Expand Up @@ -80,15 +81,19 @@
slider.value = 0;
slider.step = 1;
slider.id = "x_" + i;
slider.oninput = eval; // Trigger evaluation function on slider value change
slider.classList.add("slider"); // Add the "slider" class to the slider element
slider.oninput = eval;
slider.classList.add("slider");
var label = document.createElement("label");
label.innerHTML = routes[i-1]; // Set the label text to the corresponding route
label.setAttribute("for", "x_" + i); // Associate the label with the slider
label.innerHTML = routes[i-1];
label.setAttribute("for", "x_" + i);

var valueDisplay = document.createElement("span"); // Create a span element for value display
valueDisplay.id = "x_" + i + "_value"; // Set the id for value display
valueDisplay.textContent = slider.value + " books"; // Set the initial value with the unit "books"

sliderContainer.appendChild(label);
sliderContainer.appendChild(slider);

sliderContainer.appendChild(valueDisplay); // Append the value display element
}

var outputContainer = document.getElementById("outputContainer");
Expand Down

0 comments on commit 7c47dac

Please sign in to comment.