mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-24 16:42:36 +02:00
This reverts commit e2cad7da8d85b3d7d783f064b6d4db5b6e7d9580. Fixes #2105, #2104.
This commit is contained in:
parent
13d69007d4
commit
8e668cdadd
@ -48,9 +48,6 @@ urlcolor = "red"
|
|||||||
curly-quotes = true
|
curly-quotes = true
|
||||||
additional-js = [
|
additional-js = [
|
||||||
"theme/speaker-notes.js",
|
"theme/speaker-notes.js",
|
||||||
"theme/redbox.js",
|
|
||||||
"theme/save-playgrounds.js",
|
|
||||||
"theme/instructor-menu.js",
|
|
||||||
]
|
]
|
||||||
additional-css = [
|
additional-css = [
|
||||||
"theme/css/svgbob.css",
|
"theme/css/svgbob.css",
|
||||||
|
@ -24,10 +24,10 @@
|
|||||||
instructorMenu.title = "Utilities for course instructors";
|
instructorMenu.title = "Utilities for course instructors";
|
||||||
instructorMenu.innerHTML =
|
instructorMenu.innerHTML =
|
||||||
'<i class="fa fa-ellipsis-v" aria-hidden="true"></i>';
|
'<i class="fa fa-ellipsis-v" aria-hidden="true"></i>';
|
||||||
redBoxButton.innerHTML = "Toggle aspect-ratio box";
|
redBoxButton.innerHTML = "aspect-ratio box";
|
||||||
redBoxButton.title =
|
redBoxButton.title =
|
||||||
"Outline the area that fits on one screen while teaching the course.";
|
"Outline the area that fits on one screen while teaching the course.";
|
||||||
playgroundStateButton.innerHTML = "Reset all playgrounds";
|
playgroundStateButton.innerHTML = "reset all playgrounds";
|
||||||
playgroundStateButton.title =
|
playgroundStateButton.title =
|
||||||
"Reset code in all playgrounds to its original value.";
|
"Reset code in all playgrounds to its original value.";
|
||||||
|
|
||||||
|
@ -1,54 +1,41 @@
|
|||||||
(function savePlaygrounds() {
|
(function savePlaygrounds() {
|
||||||
function setCodeToPlayground() {
|
function setCodeToPlayground() {
|
||||||
Array.from(document.querySelectorAll(".playground")).forEach(function (
|
var codes = JSON.parse(
|
||||||
pre_block,
|
localStorage.getItem(`${window.location.href}₹code`)
|
||||||
index
|
);
|
||||||
) {
|
if (codes) {
|
||||||
let code_block = pre_block.querySelector("code");
|
var i = 0;
|
||||||
let editor = window.ace.edit(code_block);
|
Array.from(document.querySelectorAll(".playground")).forEach(function (
|
||||||
code = JSON.parse(
|
pre_block
|
||||||
localStorage.getItem(`${window.location.href}₹${index}`)
|
) {
|
||||||
);
|
let code_block = pre_block.querySelector("code");
|
||||||
if (code) {
|
let editor = window.ace.edit(code_block);
|
||||||
editor.setValue(code);
|
editor.setValue(codes[i]);
|
||||||
editor.clearSelection();
|
editor.clearSelection();
|
||||||
}
|
i += 1;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function getCodeFromPlayground() {
|
function getCodeFromPlayground() {
|
||||||
|
var codes = [];
|
||||||
Array.from(document.querySelectorAll(".playground")).forEach(function (
|
Array.from(document.querySelectorAll(".playground")).forEach(function (
|
||||||
pre_block,
|
pre_block
|
||||||
index
|
|
||||||
) {
|
) {
|
||||||
let code_block = pre_block.querySelector("code");
|
let code_block = pre_block.querySelector("code");
|
||||||
let editor = window.ace.edit(code_block);
|
let editor = window.ace.edit(code_block);
|
||||||
editor.session.on("change", function () {
|
let code = editor.getValue();
|
||||||
let code = editor.getValue();
|
codes.push(code);
|
||||||
localStorage.setItem(
|
|
||||||
`${window.location.href}₹${index}`,
|
|
||||||
JSON.stringify(code)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
localStorage.setItem(`${window.location.href}₹code`, JSON.stringify(codes));
|
||||||
}
|
}
|
||||||
setCodeToPlayground();
|
setCodeToPlayground();
|
||||||
getCodeFromPlayground();
|
addEventListener("pagehide", getCodeFromPlayground);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function resetPlaygroundsClicked() {
|
function resetPlaygroundsClicked() {
|
||||||
Array.from(document.querySelectorAll(".playground")).forEach(function (
|
|
||||||
pre_block,
|
|
||||||
index
|
|
||||||
) {
|
|
||||||
let code_block = pre_block.querySelector("code");
|
|
||||||
let editor = window.ace.edit(code_block);
|
|
||||||
editor.setValue(editor.originalCode);
|
|
||||||
editor.clearSelection();
|
|
||||||
});
|
|
||||||
|
|
||||||
let keys = [];
|
let keys = [];
|
||||||
for (var i = 0, len = localStorage.length; i < len; i++) {
|
for (var i = 0, len = localStorage.length; i < len; i++) {
|
||||||
if (localStorage.key(i).includes("₹")) {
|
if (localStorage.key(i).includes("₹code")) {
|
||||||
keys.push(localStorage.key(i));
|
keys.push(localStorage.key(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user