mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-27 20:58:41 +02:00
createSolutions
This commit is contained in:
parent
6ade0b002d
commit
16d1beff00
@ -13,7 +13,9 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
let notes = document.querySelector("details");
|
const details = new Array(...document.querySelectorAll("details"));
|
||||||
|
let notes = details.find(details => details.getAttribute("solution") === null);
|
||||||
|
const solutions = details.filter(details => details.getAttribute("solution") !== null);
|
||||||
// Create an unattached DOM node for the code below.
|
// Create an unattached DOM node for the code below.
|
||||||
if (!notes) {
|
if (!notes) {
|
||||||
notes = document.createElement("details");
|
notes = document.createElement("details");
|
||||||
@ -47,7 +49,7 @@
|
|||||||
break;
|
break;
|
||||||
case "inline-open":
|
case "inline-open":
|
||||||
popIn.classList.add("hidden");
|
popIn.classList.add("hidden");
|
||||||
notes.open = true;
|
notes.open = notes.getAttribute("solution") === null;
|
||||||
notes.classList.remove("hidden");
|
notes.classList.remove("hidden");
|
||||||
break;
|
break;
|
||||||
case "inline-closed":
|
case "inline-closed":
|
||||||
@ -87,15 +89,15 @@
|
|||||||
});
|
});
|
||||||
document.querySelector(".left-buttons").append(popIn);
|
document.querySelector(".left-buttons").append(popIn);
|
||||||
|
|
||||||
// Create speaker notes.
|
const createSpeakerNotes = () => {
|
||||||
notes.addEventListener("toggle", (event) => {
|
notes.addEventListener("toggle", (event) => {
|
||||||
setState(notes.open ? "inline-open" : "inline-closed");
|
setState(notes.open ? "inline-open" : "inline-closed");
|
||||||
});
|
});
|
||||||
|
|
||||||
let summary = document.createElement("summary");
|
const summary = document.createElement("summary");
|
||||||
notes.insertBefore(summary, notes.firstChild);
|
notes.insertBefore(summary, notes.firstChild);
|
||||||
|
|
||||||
let h4 = document.createElement("h4");
|
const h4 = document.createElement("h4");
|
||||||
h4.setAttribute("id", "speaker-notes");
|
h4.setAttribute("id", "speaker-notes");
|
||||||
h4.append("Speaker Notes");
|
h4.append("Speaker Notes");
|
||||||
h4.addEventListener("click", (event) => {
|
h4.addEventListener("click", (event) => {
|
||||||
@ -104,6 +106,21 @@
|
|||||||
window.location.hash = "#speaker-notes";
|
window.location.hash = "#speaker-notes";
|
||||||
});
|
});
|
||||||
summary.append(h4);
|
summary.append(h4);
|
||||||
|
};
|
||||||
|
|
||||||
|
const createSolutions = () => {
|
||||||
|
for(const solution of solutions) {
|
||||||
|
const summary = document.createElement("summary");
|
||||||
|
solution.insertBefore(summary, solution.firstChild);
|
||||||
|
|
||||||
|
const h4 = document.createElement("h4");
|
||||||
|
h4.append("Solution");
|
||||||
|
summary.append(h4);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
createSpeakerNotes();
|
||||||
|
createSolutions();
|
||||||
|
|
||||||
// Create pop-out button.
|
// Create pop-out button.
|
||||||
let popOutLocation = new URL(window.location.href);
|
let popOutLocation = new URL(window.location.href);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user