Skip to content

Commit 27a7807

Browse files
updated book details
1 parent edb01e6 commit 27a7807

40 files changed

+311
-615
lines changed

404.html

Lines changed: 6 additions & 18 deletions
Large diffs are not rendered by default.

ayu-highlight.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
88
overflow-x: auto;
99
background: #191f26;
1010
color: #e6e1cf;
11-
padding: 0.5em;
1211
}
1312

1413
.hljs-comment,

book.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,12 @@ function playground_text(playground) {
108108

109109
let text = playground_text(code_block);
110110
let classes = code_block.querySelector('code').classList;
111-
let has_2018 = classes.contains("edition2018");
112-
let edition = has_2018 ? "2018" : "2015";
113-
111+
let edition = "2015";
112+
if(classes.contains("edition2018")) {
113+
edition = "2018";
114+
} else if(classes.contains("edition2021")) {
115+
edition = "2021";
116+
}
114117
var params = {
115118
version: "stable",
116119
optimize: "0",
@@ -133,7 +136,15 @@ function playground_text(playground) {
133136
body: JSON.stringify(params)
134137
})
135138
.then(response => response.json())
136-
.then(response => result_block.innerText = response.result)
139+
.then(response => {
140+
if (response.result.trim() === '') {
141+
result_block.innerText = "No output";
142+
result_block.classList.add("result-no-output");
143+
} else {
144+
result_block.innerText = response.result;
145+
result_block.classList.remove("result-no-output");
146+
}
147+
})
137148
.catch(error => result_block.innerText = "Playground Communication: " + error.message);
138149
}
139150

@@ -151,12 +162,13 @@ function playground_text(playground) {
151162
if (window.ace) {
152163
// language-rust class needs to be removed for editable
153164
// blocks or highlightjs will capture events
154-
Array
155-
.from(document.querySelectorAll('code.editable'))
165+
code_nodes
166+
.filter(function (node) {return node.classList.contains("editable"); })
156167
.forEach(function (block) { block.classList.remove('language-rust'); });
157168

158169
Array
159-
.from(document.querySelectorAll('code:not(.editable)'))
170+
code_nodes
171+
.filter(function (node) {return !node.classList.contains("editable"); })
160172
.forEach(function (block) { hljs.highlightBlock(block); });
161173
} else {
162174
code_nodes.forEach(function (block) { hljs.highlightBlock(block); });
@@ -359,7 +371,14 @@ function playground_text(playground) {
359371
});
360372

361373
themePopup.addEventListener('click', function (e) {
362-
var theme = e.target.id || e.target.parentElement.id;
374+
var theme;
375+
if (e.target.className === "theme") {
376+
theme = e.target.id;
377+
} else if (e.target.parentElement.className === "theme") {
378+
theme = e.target.parentElement.id;
379+
} else {
380+
return;
381+
}
363382
set_theme(theme);
364383
});
365384

buy.html

Lines changed: 6 additions & 18 deletions
Large diffs are not rendered by default.

calculator/calc_bash_func.html

Lines changed: 9 additions & 21 deletions
Large diffs are not rendered by default.

calculator/calc_py_cli.html

Lines changed: 9 additions & 21 deletions
Large diffs are not rendered by default.

calculator/calculator.html

Lines changed: 6 additions & 18 deletions
Large diffs are not rendered by default.

calculator/exercises.html

Lines changed: 7 additions & 19 deletions
Large diffs are not rendered by default.

cover.html

Lines changed: 6 additions & 18 deletions
Large diffs are not rendered by default.

css/chrome.css

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,63 @@ pre {
208208
pre > .buttons {
209209
position: absolute;
210210
z-index: 100;
211-
right: 5px;
212-
top: 5px;
211+
right: 0px;
212+
top: 2px;
213+
margin: 0px;
214+
padding: 2px 0px;
213215

214216
color: var(--sidebar-fg);
215217
cursor: pointer;
218+
visibility: hidden;
219+
opacity: 0;
220+
transition: visibility 0.1s linear, opacity 0.1s linear;
221+
}
222+
pre:hover > .buttons {
223+
visibility: visible;
224+
opacity: 1
216225
}
217226
pre > .buttons :hover {
218227
color: var(--sidebar-active);
228+
border-color: var(--icons-hover);
229+
background-color: var(--theme-hover);
219230
}
220231
pre > .buttons i {
221232
margin-left: 8px;
222233
}
223234
pre > .buttons button {
224-
color: inherit;
225-
background: transparent;
226-
border: none;
227235
cursor: inherit;
236+
margin: 0px 5px;
237+
padding: 3px 5px;
238+
font-size: 14px;
239+
240+
border-style: solid;
241+
border-width: 1px;
242+
border-radius: 4px;
243+
border-color: var(--icons);
244+
background-color: var(--theme-popup-bg);
245+
transition: 100ms;
246+
transition-property: color,border-color,background-color;
247+
color: var(--icons);
228248
}
249+
@media (pointer: coarse) {
250+
pre > .buttons button {
251+
/* On mobile, make it easier to tap buttons. */
252+
padding: 0.3rem 1rem;
253+
}
254+
}
255+
pre > code {
256+
padding: 1rem;
257+
}
258+
259+
/* FIXME: ACE editors overlap their buttons because ACE does absolute
260+
positioning within the code block which breaks padding. The only solution I
261+
can think of is to move the padding to the outer pre tag (or insert a div
262+
wrapper), but that would require fixing a whole bunch of CSS rules.
263+
*/
264+
.hljs.ace_editor {
265+
padding: 0rem 0rem;
266+
}
267+
229268
pre > .result {
230269
margin-top: 10px;
231270
}

0 commit comments

Comments
 (0)