Spaces:
Running
Running
aepstar
commited on
Commit
·
69e1f32
1
Parent(s):
3f85c7b
copy index.html to workdir
Browse files- index.html +439 -0
index.html
ADDED
@@ -0,0 +1,439 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
3 |
+
|
4 |
+
<meta charset="utf-8">
|
5 |
+
<meta name="generator" content="quarto-1.3.433">
|
6 |
+
|
7 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
8 |
+
|
9 |
+
<meta name="author" content="Aep Hidayatuloh">
|
10 |
+
|
11 |
+
<title>Codewars Challenge 2024 Using R and RStudio</title>
|
12 |
+
<style>
|
13 |
+
code{white-space: pre-wrap;}
|
14 |
+
span.smallcaps{font-variant: small-caps;}
|
15 |
+
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
16 |
+
div.column{flex: auto; overflow-x: auto;}
|
17 |
+
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
18 |
+
ul.task-list{list-style: none;}
|
19 |
+
ul.task-list li input[type="checkbox"] {
|
20 |
+
width: 0.8em;
|
21 |
+
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
22 |
+
vertical-align: middle;
|
23 |
+
}
|
24 |
+
</style>
|
25 |
+
|
26 |
+
|
27 |
+
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
28 |
+
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
29 |
+
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
30 |
+
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
31 |
+
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
32 |
+
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
33 |
+
<meta name="quarto:offset" content="./">
|
34 |
+
<link href="./intro.html" rel="next">
|
35 |
+
<script src="site_libs/quarto-html/quarto.js"></script>
|
36 |
+
<script src="site_libs/quarto-html/popper.min.js"></script>
|
37 |
+
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
38 |
+
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
39 |
+
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
40 |
+
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
41 |
+
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
42 |
+
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
43 |
+
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
44 |
+
<script id="quarto-search-options" type="application/json">{
|
45 |
+
"location": "sidebar",
|
46 |
+
"copy-button": false,
|
47 |
+
"collapse-after": 3,
|
48 |
+
"panel-placement": "start",
|
49 |
+
"type": "textbox",
|
50 |
+
"limit": 20,
|
51 |
+
"language": {
|
52 |
+
"search-no-results-text": "No results",
|
53 |
+
"search-matching-documents-text": "matching documents",
|
54 |
+
"search-copy-link-title": "Copy link to search",
|
55 |
+
"search-hide-matches-text": "Hide additional matches",
|
56 |
+
"search-more-match-text": "more match in this document",
|
57 |
+
"search-more-matches-text": "more matches in this document",
|
58 |
+
"search-clear-button-title": "Clear",
|
59 |
+
"search-detached-cancel-button-title": "Cancel",
|
60 |
+
"search-submit-button-title": "Submit",
|
61 |
+
"search-label": "Search"
|
62 |
+
}
|
63 |
+
}</script>
|
64 |
+
|
65 |
+
|
66 |
+
</head>
|
67 |
+
|
68 |
+
<body class="nav-sidebar floating">
|
69 |
+
|
70 |
+
<div id="quarto-search-results"></div>
|
71 |
+
<header id="quarto-header" class="headroom fixed-top">
|
72 |
+
<nav class="quarto-secondary-nav">
|
73 |
+
<div class="container-fluid d-flex">
|
74 |
+
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
75 |
+
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
76 |
+
</button>
|
77 |
+
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./index.html">Preface</a></li></ol></nav>
|
78 |
+
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
79 |
+
</a>
|
80 |
+
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
81 |
+
<i class="bi bi-search"></i>
|
82 |
+
</button>
|
83 |
+
</div>
|
84 |
+
</nav>
|
85 |
+
</header>
|
86 |
+
<!-- content -->
|
87 |
+
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
88 |
+
<!-- sidebar -->
|
89 |
+
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
90 |
+
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
91 |
+
<div class="sidebar-title mb-0 py-0">
|
92 |
+
<a href="./">Codewars Challenge 2024 Using R and RStudio</a>
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
<div class="mt-2 flex-shrink-0 align-items-center">
|
96 |
+
<div class="sidebar-search">
|
97 |
+
<div id="quarto-search" class="" title="Search"></div>
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
<div class="sidebar-menu-container">
|
101 |
+
<ul class="list-unstyled mt-1">
|
102 |
+
<li class="sidebar-item">
|
103 |
+
<div class="sidebar-item-container">
|
104 |
+
<a href="./index.html" class="sidebar-item-text sidebar-link active">
|
105 |
+
<span class="menu-text">Preface</span></a>
|
106 |
+
</div>
|
107 |
+
</li>
|
108 |
+
<li class="sidebar-item">
|
109 |
+
<div class="sidebar-item-container">
|
110 |
+
<a href="./intro.html" class="sidebar-item-text sidebar-link">
|
111 |
+
<span class="menu-text">Introduction</span></a>
|
112 |
+
</div>
|
113 |
+
</li>
|
114 |
+
<li class="sidebar-item">
|
115 |
+
<div class="sidebar-item-container">
|
116 |
+
<a href="./001-reducegrow.html" class="sidebar-item-text sidebar-link">
|
117 |
+
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
118 |
+
</div>
|
119 |
+
</li>
|
120 |
+
<li class="sidebar-item">
|
121 |
+
<div class="sidebar-item-container">
|
122 |
+
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
123 |
+
<span class="menu-text">References</span></a>
|
124 |
+
</div>
|
125 |
+
</li>
|
126 |
+
</ul>
|
127 |
+
</div>
|
128 |
+
</nav>
|
129 |
+
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
130 |
+
<!-- margin-sidebar -->
|
131 |
+
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
132 |
+
<nav id="TOC" role="doc-toc" class="toc-active">
|
133 |
+
<h2 id="toc-title">Table of contents</h2>
|
134 |
+
|
135 |
+
<ul>
|
136 |
+
<li><a href="#preface" id="toc-preface" class="nav-link active" data-scroll-target="#preface">Preface</a>
|
137 |
+
<ul class="collapse">
|
138 |
+
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by">Supported by</a></li>
|
139 |
+
</ul></li>
|
140 |
+
</ul>
|
141 |
+
</nav>
|
142 |
+
</div>
|
143 |
+
<!-- main -->
|
144 |
+
<main class="content" id="quarto-document-content">
|
145 |
+
|
146 |
+
<header id="title-block-header" class="quarto-title-block default">
|
147 |
+
<div class="quarto-title">
|
148 |
+
<h1 class="title">Codewars Challenge 2024 Using R and RStudio</h1>
|
149 |
+
</div>
|
150 |
+
|
151 |
+
|
152 |
+
|
153 |
+
<div class="quarto-title-meta">
|
154 |
+
|
155 |
+
<div>
|
156 |
+
<div class="quarto-title-meta-heading">Author</div>
|
157 |
+
<div class="quarto-title-meta-contents">
|
158 |
+
<p>Aep Hidayatuloh </p>
|
159 |
+
</div>
|
160 |
+
</div>
|
161 |
+
|
162 |
+
<div>
|
163 |
+
<div class="quarto-title-meta-heading">Published</div>
|
164 |
+
<div class="quarto-title-meta-contents">
|
165 |
+
<p class="date">Last Updated on 31 January, 2024</p>
|
166 |
+
</div>
|
167 |
+
</div>
|
168 |
+
|
169 |
+
|
170 |
+
</div>
|
171 |
+
|
172 |
+
|
173 |
+
</header>
|
174 |
+
|
175 |
+
<section id="preface" class="level1 unnumbered">
|
176 |
+
<h1 class="unnumbered">Preface</h1>
|
177 |
+
<p>Buku ini adalah catatan penyelesaian dalam mengerjakan tantangan-tantangan logika dan pemrograman Codewars menggunakan R dan RStudio selama tahun 2024.</p>
|
178 |
+
<p>Hal ini terisnpirasi dari kegiatan di YouTube nya Pak Sandhika Galih WPU.</p>
|
179 |
+
<section id="supported-by" class="level2">
|
180 |
+
<h2 class="anchored" data-anchor-id="supported-by">Supported by</h2>
|
181 |
+
<div class="quarto-figure quarto-figure-center">
|
182 |
+
<figure class="figure">
|
183 |
+
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
184 |
+
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
185 |
+
</figure>
|
186 |
+
</div>
|
187 |
+
|
188 |
+
|
189 |
+
</section>
|
190 |
+
</section>
|
191 |
+
|
192 |
+
</main> <!-- /main -->
|
193 |
+
<script id="quarto-html-after-body" type="application/javascript">
|
194 |
+
window.document.addEventListener("DOMContentLoaded", function (event) {
|
195 |
+
const toggleBodyColorMode = (bsSheetEl) => {
|
196 |
+
const mode = bsSheetEl.getAttribute("data-mode");
|
197 |
+
const bodyEl = window.document.querySelector("body");
|
198 |
+
if (mode === "dark") {
|
199 |
+
bodyEl.classList.add("quarto-dark");
|
200 |
+
bodyEl.classList.remove("quarto-light");
|
201 |
+
} else {
|
202 |
+
bodyEl.classList.add("quarto-light");
|
203 |
+
bodyEl.classList.remove("quarto-dark");
|
204 |
+
}
|
205 |
+
}
|
206 |
+
const toggleBodyColorPrimary = () => {
|
207 |
+
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
208 |
+
if (bsSheetEl) {
|
209 |
+
toggleBodyColorMode(bsSheetEl);
|
210 |
+
}
|
211 |
+
}
|
212 |
+
toggleBodyColorPrimary();
|
213 |
+
const icon = "";
|
214 |
+
const anchorJS = new window.AnchorJS();
|
215 |
+
anchorJS.options = {
|
216 |
+
placement: 'right',
|
217 |
+
icon: icon
|
218 |
+
};
|
219 |
+
anchorJS.add('.anchored');
|
220 |
+
const isCodeAnnotation = (el) => {
|
221 |
+
for (const clz of el.classList) {
|
222 |
+
if (clz.startsWith('code-annotation-')) {
|
223 |
+
return true;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
return false;
|
227 |
+
}
|
228 |
+
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
229 |
+
text: function(trigger) {
|
230 |
+
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
231 |
+
for (const childEl of codeEl.children) {
|
232 |
+
if (isCodeAnnotation(childEl)) {
|
233 |
+
childEl.remove();
|
234 |
+
}
|
235 |
+
}
|
236 |
+
return codeEl.innerText;
|
237 |
+
}
|
238 |
+
});
|
239 |
+
clipboard.on('success', function(e) {
|
240 |
+
// button target
|
241 |
+
const button = e.trigger;
|
242 |
+
// don't keep focus
|
243 |
+
button.blur();
|
244 |
+
// flash "checked"
|
245 |
+
button.classList.add('code-copy-button-checked');
|
246 |
+
var currentTitle = button.getAttribute("title");
|
247 |
+
button.setAttribute("title", "Copied!");
|
248 |
+
let tooltip;
|
249 |
+
if (window.bootstrap) {
|
250 |
+
button.setAttribute("data-bs-toggle", "tooltip");
|
251 |
+
button.setAttribute("data-bs-placement", "left");
|
252 |
+
button.setAttribute("data-bs-title", "Copied!");
|
253 |
+
tooltip = new bootstrap.Tooltip(button,
|
254 |
+
{ trigger: "manual",
|
255 |
+
customClass: "code-copy-button-tooltip",
|
256 |
+
offset: [0, -8]});
|
257 |
+
tooltip.show();
|
258 |
+
}
|
259 |
+
setTimeout(function() {
|
260 |
+
if (tooltip) {
|
261 |
+
tooltip.hide();
|
262 |
+
button.removeAttribute("data-bs-title");
|
263 |
+
button.removeAttribute("data-bs-toggle");
|
264 |
+
button.removeAttribute("data-bs-placement");
|
265 |
+
}
|
266 |
+
button.setAttribute("title", currentTitle);
|
267 |
+
button.classList.remove('code-copy-button-checked');
|
268 |
+
}, 1000);
|
269 |
+
// clear code selection
|
270 |
+
e.clearSelection();
|
271 |
+
});
|
272 |
+
function tippyHover(el, contentFn) {
|
273 |
+
const config = {
|
274 |
+
allowHTML: true,
|
275 |
+
content: contentFn,
|
276 |
+
maxWidth: 500,
|
277 |
+
delay: 100,
|
278 |
+
arrow: false,
|
279 |
+
appendTo: function(el) {
|
280 |
+
return el.parentElement;
|
281 |
+
},
|
282 |
+
interactive: true,
|
283 |
+
interactiveBorder: 10,
|
284 |
+
theme: 'quarto',
|
285 |
+
placement: 'bottom-start'
|
286 |
+
};
|
287 |
+
window.tippy(el, config);
|
288 |
+
}
|
289 |
+
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
290 |
+
for (var i=0; i<noterefs.length; i++) {
|
291 |
+
const ref = noterefs[i];
|
292 |
+
tippyHover(ref, function() {
|
293 |
+
// use id or data attribute instead here
|
294 |
+
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
295 |
+
try { href = new URL(href).hash; } catch {}
|
296 |
+
const id = href.replace(/^#\/?/, "");
|
297 |
+
const note = window.document.getElementById(id);
|
298 |
+
return note.innerHTML;
|
299 |
+
});
|
300 |
+
}
|
301 |
+
let selectedAnnoteEl;
|
302 |
+
const selectorForAnnotation = ( cell, annotation) => {
|
303 |
+
let cellAttr = 'data-code-cell="' + cell + '"';
|
304 |
+
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
305 |
+
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
306 |
+
return selector;
|
307 |
+
}
|
308 |
+
const selectCodeLines = (annoteEl) => {
|
309 |
+
const doc = window.document;
|
310 |
+
const targetCell = annoteEl.getAttribute("data-target-cell");
|
311 |
+
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
312 |
+
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
313 |
+
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
314 |
+
const lineIds = lines.map((line) => {
|
315 |
+
return targetCell + "-" + line;
|
316 |
+
})
|
317 |
+
let top = null;
|
318 |
+
let height = null;
|
319 |
+
let parent = null;
|
320 |
+
if (lineIds.length > 0) {
|
321 |
+
//compute the position of the single el (top and bottom and make a div)
|
322 |
+
const el = window.document.getElementById(lineIds[0]);
|
323 |
+
top = el.offsetTop;
|
324 |
+
height = el.offsetHeight;
|
325 |
+
parent = el.parentElement.parentElement;
|
326 |
+
if (lineIds.length > 1) {
|
327 |
+
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
328 |
+
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
329 |
+
height = bottom - top;
|
330 |
+
}
|
331 |
+
if (top !== null && height !== null && parent !== null) {
|
332 |
+
// cook up a div (if necessary) and position it
|
333 |
+
let div = window.document.getElementById("code-annotation-line-highlight");
|
334 |
+
if (div === null) {
|
335 |
+
div = window.document.createElement("div");
|
336 |
+
div.setAttribute("id", "code-annotation-line-highlight");
|
337 |
+
div.style.position = 'absolute';
|
338 |
+
parent.appendChild(div);
|
339 |
+
}
|
340 |
+
div.style.top = top - 2 + "px";
|
341 |
+
div.style.height = height + 4 + "px";
|
342 |
+
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
343 |
+
if (gutterDiv === null) {
|
344 |
+
gutterDiv = window.document.createElement("div");
|
345 |
+
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
346 |
+
gutterDiv.style.position = 'absolute';
|
347 |
+
const codeCell = window.document.getElementById(targetCell);
|
348 |
+
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
349 |
+
gutter.appendChild(gutterDiv);
|
350 |
+
}
|
351 |
+
gutterDiv.style.top = top - 2 + "px";
|
352 |
+
gutterDiv.style.height = height + 4 + "px";
|
353 |
+
}
|
354 |
+
selectedAnnoteEl = annoteEl;
|
355 |
+
}
|
356 |
+
};
|
357 |
+
const unselectCodeLines = () => {
|
358 |
+
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
359 |
+
elementsIds.forEach((elId) => {
|
360 |
+
const div = window.document.getElementById(elId);
|
361 |
+
if (div) {
|
362 |
+
div.remove();
|
363 |
+
}
|
364 |
+
});
|
365 |
+
selectedAnnoteEl = undefined;
|
366 |
+
};
|
367 |
+
// Attach click handler to the DT
|
368 |
+
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
369 |
+
for (const annoteDlNode of annoteDls) {
|
370 |
+
annoteDlNode.addEventListener('click', (event) => {
|
371 |
+
const clickedEl = event.target;
|
372 |
+
if (clickedEl !== selectedAnnoteEl) {
|
373 |
+
unselectCodeLines();
|
374 |
+
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
375 |
+
if (activeEl) {
|
376 |
+
activeEl.classList.remove('code-annotation-active');
|
377 |
+
}
|
378 |
+
selectCodeLines(clickedEl);
|
379 |
+
clickedEl.classList.add('code-annotation-active');
|
380 |
+
} else {
|
381 |
+
// Unselect the line
|
382 |
+
unselectCodeLines();
|
383 |
+
clickedEl.classList.remove('code-annotation-active');
|
384 |
+
}
|
385 |
+
});
|
386 |
+
}
|
387 |
+
const findCites = (el) => {
|
388 |
+
const parentEl = el.parentElement;
|
389 |
+
if (parentEl) {
|
390 |
+
const cites = parentEl.dataset.cites;
|
391 |
+
if (cites) {
|
392 |
+
return {
|
393 |
+
el,
|
394 |
+
cites: cites.split(' ')
|
395 |
+
};
|
396 |
+
} else {
|
397 |
+
return findCites(el.parentElement)
|
398 |
+
}
|
399 |
+
} else {
|
400 |
+
return undefined;
|
401 |
+
}
|
402 |
+
};
|
403 |
+
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
404 |
+
for (var i=0; i<bibliorefs.length; i++) {
|
405 |
+
const ref = bibliorefs[i];
|
406 |
+
const citeInfo = findCites(ref);
|
407 |
+
if (citeInfo) {
|
408 |
+
tippyHover(citeInfo.el, function() {
|
409 |
+
var popup = window.document.createElement('div');
|
410 |
+
citeInfo.cites.forEach(function(cite) {
|
411 |
+
var citeDiv = window.document.createElement('div');
|
412 |
+
citeDiv.classList.add('hanging-indent');
|
413 |
+
citeDiv.classList.add('csl-entry');
|
414 |
+
var biblioDiv = window.document.getElementById('ref-' + cite);
|
415 |
+
if (biblioDiv) {
|
416 |
+
citeDiv.innerHTML = biblioDiv.innerHTML;
|
417 |
+
}
|
418 |
+
popup.appendChild(citeDiv);
|
419 |
+
});
|
420 |
+
return popup.innerHTML;
|
421 |
+
});
|
422 |
+
}
|
423 |
+
}
|
424 |
+
});
|
425 |
+
</script>
|
426 |
+
<nav class="page-navigation">
|
427 |
+
<div class="nav-page nav-page-previous">
|
428 |
+
</div>
|
429 |
+
<div class="nav-page nav-page-next">
|
430 |
+
<a href="./intro.html" class="pagination-link">
|
431 |
+
<span class="nav-page-text">Introduction</span> <i class="bi bi-arrow-right-short"></i>
|
432 |
+
</a>
|
433 |
+
</div>
|
434 |
+
</nav>
|
435 |
+
</div> <!-- /content -->
|
436 |
+
|
437 |
+
|
438 |
+
|
439 |
+
</body></html>
|