You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-15 22:00:26 +02:00
Saving playground code state (#1917)
The embedded Playground's code reset when you navigate between slides. This has caused problems: if people navigate away from a slide to look something up, they've suddenly lost their work.
This commit is contained in:
committed by
GitHub
parent
6b3eb83bff
commit
b7a6e3b46d
@ -11,28 +11,19 @@
|
||||
var parentElement = document.body; // Change this to your desired parent element
|
||||
// Append the new div to the parent element
|
||||
parentElement.insertBefore(newDiv, parentElement.firstChild);
|
||||
// Create the button element
|
||||
var hideShowButton = document.createElement("button");
|
||||
hideShowButton.innerHTML = '<i class="fa fa-square-o"></i>';
|
||||
hideShowButton.className = "icon-button";
|
||||
hideShowButton.type = "button";
|
||||
hideShowButton.title =
|
||||
"Outline the area that fits on one screen while teaching the course.";
|
||||
hideShowButton.id = "Dev";
|
||||
var navbarButtons = document.getElementsByClassName("left-buttons");
|
||||
navbarButtons[0].insertBefore(hideShowButton, navbarButtons.firstChild);
|
||||
//Default hiding the redbox
|
||||
document.getElementById("aspect-ratio-helper").style.display = "none";
|
||||
//Add Event listener to button to perform on click action.
|
||||
hideShowButton.addEventListener("click", function () {
|
||||
if (
|
||||
document.getElementById("aspect-ratio-helper").style.display === "none"
|
||||
) {
|
||||
document.getElementById("aspect-ratio-helper").style.display = "block";
|
||||
hideShowButton.innerHTML = '<i class="fa fa-square"></i>';
|
||||
} else {
|
||||
document.getElementById("aspect-ratio-helper").style.display = "none";
|
||||
hideShowButton.innerHTML = '<i class="fa fa-square-o"></i>';
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
//Create a function to button to perform on click action.
|
||||
function redboxButtonClicked() {
|
||||
var hideShowButton = document.getElementById("redbox");
|
||||
if (document.getElementById("aspect-ratio-helper").style.display === "none") {
|
||||
document.getElementById("aspect-ratio-helper").style.display = "block";
|
||||
hideShowButton.innerHTML = "aspect-ratio box";
|
||||
} else {
|
||||
document.getElementById("aspect-ratio-helper").style.display = "none";
|
||||
hideShowButton.innerHTML = "aspect-ratio box";
|
||||
}
|
||||
}
|
||||
window.redboxButtonClicked = redboxButtonClicked;
|
||||
|
Reference in New Issue
Block a user