diff options
| Commit | 70ec859dee61a77ac813c1bf1e6f8d928fd1c2b2 (patch) | |
|---|---|---|
| Author | 2025-10-05 20:55:26 +0300 | |
| Committer | 2025-10-05 20:55:26 +0300 | |
| Files | caab85ac5fc69b488f2213b946583a09f41fbd59 /src | |
| syndamia.com-70ec859dee61a77ac813c1bf1e6f8d928fd1c2b2.tar syndamia.com-70ec859dee61a77ac813c1bf1e6f8d928fd1c2b2.tar.gz syndamia.com-70ec859dee61a77ac813c1bf1e6f8d928fd1c2b2.zip | ||
| Parent | 7e77973c9d8594ee2f36a18b53f5d78d797a6686 (diff) | |
fix(teachihng/upp-2025/w02): Load styles like any normal stylesheet
The old approach using JS would cause CORS policy errors. Since the
stylesheet is disabled by default, it won't ever be downloaded, unless
you're on a machine_table page. But even if you try, it will fail
because of the relative path, making sure you almost never download it.
2 files changed, 82 insertions, 83 deletions
| -rw-r--r-- | src/teaching/upp-2025/week02/machine_table.css | 80 | ||||
| -rw-r--r-- | src/teaching/upp-2025/week02/machine_table.js | 85 |
diff --git a/src/teaching/upp-2025/week02/machine_table.css b/src/teaching/upp-2025/week02/machine_table.css new file mode 100644 index 0000000..fee8577 --- /dev/null +++ b/src/teaching/upp-2025/week02/machine_table.css @@ -0,0 +1,80 @@ +/* Reset */ +#worksheet table, +#worksheet tr, +#worksheet th, +#worksheet td { + background-color: initial; + border: initial; + padding: 0.1em; +} + +/* General styling */ +#worksheet th { + font-weight: normal; +} +#worksheet { + color: black; + background-color: white; + margin: 1em auto; + + /* Thanks https://stackoverflow.com/a/4407335/12036073 */ + + -webkit-touch-callout: none; /* iOS Safari */ + -webkit-user-select: none; /* Safari */ + -khtml-user-select: none; /* Konqueror HTML */ + -moz-user-select: none; /* Old versions of Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; +} + +#worksheet button { + border-radius: 0; + border-width: 2px; + width: 100%; +} +#worksheet button:hover, +#worksheet input[type="radio"]:hover, +#worksheet input[type="radio"] ~ label:hover { + cursor: pointer; +} + +/* Borders and colors */ +#worksheet td, #worksheet th { + border: 1px solid #c0c0c0; +} +#worksheet tr:first-of-type th, +#worksheet td:first-child, #worksheet th:first-child +{ + border-color: #6a6a6a; + background-color: #f1f1f1; +} +#worksheet tr:first-of-type th { + border-top: none; +} +#worksheet td:first-child, #worksheet th:first-child { + border-left: none; +} + +/* Spacing */ +#worksheet th:first-child { + min-width: 2.82em; + padding: 0.3em 0; +} +#worksheet td { + min-width: 8em; + padding: 0.3em 0.2em; +} + +#worksheet button { + margin: calc(-0.3em + 4px) 0; + padding: 0.2em; +} + +/* Execution */ +.selected { + background-color: yellow !important; +} +.error { + background-color: red !important; +} + diff --git a/src/teaching/upp-2025/week02/machine_table.js b/src/teaching/upp-2025/week02/machine_table.js index ec67ff8..99a0255 100644 --- a/src/teaching/upp-2025/week02/machine_table.js +++ b/src/teaching/upp-2025/week02/machine_table.js @@ -1,88 +1,7 @@ // Style // -var machineStyles = document.createElement("style"); -machineStyles.textContent = ` - /* Reset */ - #worksheet table, - #worksheet tr, - #worksheet th, - #worksheet td { - background-color: initial; - border: initial; - padding: 0.1em; - } - - /* General styling */ - #worksheet th { - font-weight: normal; - } - #worksheet { - color: black; - background-color: white; - margin: 1em auto; - - /* Thanks https://stackoverflow.com/a/4407335/12036073 */ - - -webkit-touch-callout: none; /* iOS Safari */ - -webkit-user-select: none; /* Safari */ - -khtml-user-select: none; /* Konqueror HTML */ - -moz-user-select: none; /* Old versions of Firefox */ - -ms-user-select: none; /* Internet Explorer/Edge */ - user-select: none; - } - - #worksheet button { - border-radius: 0; - border-width: 2px; - width: 100%; - } - #worksheet button:hover, - #worksheet input[type="radio"]:hover, - #worksheet input[type="radio"] ~ label:hover { - cursor: pointer; - } - - /* Borders and colors */ - #worksheet td, #worksheet th { - border: 1px solid #c0c0c0; - } - #worksheet tr:first-of-type th, - #worksheet td:first-child, #worksheet th:first-child - { - border-color: #6a6a6a; - background-color: #f1f1f1; - } - #worksheet tr:first-of-type th { - border-top: none; - } - #worksheet td:first-child, #worksheet th:first-child { - border-left: none; - } - - /* Spacing */ - #worksheet th:first-child { - min-width: 2.82em; - padding: 0.3em 0; - } - #worksheet td { - min-width: 8em; - padding: 0.3em 0.2em; - } - - #worksheet button { - margin: calc(-0.3em + 4px) 0; - padding: 0.2em; - } - - /* Execution */ - .selected { - background-color: yellow !important; - } - .error { - background-color: red !important; - } -`; -document.head.appendChild(machineStyles); +const machineStyles = document.getElementById("upp2025_w02"); +machineStyles.disabled = false; // Execution // |