-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsconnect-health-tutorial.html
504 lines (478 loc) · 24.5 KB
/
rsconnect-health-tutorial.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.3.353">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Posit Connect Health Startup Tutorial</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
</style>
<script src="rsconnect-health-tutorial_files/libs/clipboard/clipboard.min.js"></script>
<script src="rsconnect-health-tutorial_files/libs/quarto-html/quarto.js"></script>
<script src="rsconnect-health-tutorial_files/libs/quarto-html/popper.min.js"></script>
<script src="rsconnect-health-tutorial_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="rsconnect-health-tutorial_files/libs/quarto-html/anchor.min.js"></script>
<link href="rsconnect-health-tutorial_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="rsconnect-health-tutorial_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="rsconnect-health-tutorial_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="rsconnect-health-tutorial_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="rsconnect-health-tutorial_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
</head>
<body>
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#background" id="toc-background" class="nav-link active" data-scroll-target="#background">Background</a></li>
<li><a href="#best-practices" id="toc-best-practices" class="nav-link" data-scroll-target="#best-practices">Best Practices</a></li>
<li><a href="#request-access-to-soteria" id="toc-request-access-to-soteria" class="nav-link" data-scroll-target="#request-access-to-soteria">Request Access to Soteria</a>
<ul class="collapse">
<li><a href="#download-and-set-up-cisco-vpn" id="toc-download-and-set-up-cisco-vpn" class="nav-link" data-scroll-target="#download-and-set-up-cisco-vpn">Download and Set up Cisco VPN</a></li>
<li><a href="#connect-to-soteria-vpn" id="toc-connect-to-soteria-vpn" class="nav-link" data-scroll-target="#connect-to-soteria-vpn">Connect to Soteria VPN</a></li>
</ul></li>
<li><a href="#posit-connect-health" id="toc-posit-connect-health" class="nav-link" data-scroll-target="#posit-connect-health">Posit Connect Health</a>
<ul class="collapse">
<li><a href="#system-requirements" id="toc-system-requirements" class="nav-link" data-scroll-target="#system-requirements">System Requirements</a></li>
<li><a href="#installation-dependencies" id="toc-installation-dependencies" class="nav-link" data-scroll-target="#installation-dependencies">Installation Dependencies</a>
<ul class="collapse">
<li><a href="#r-and-r-studio" id="toc-r-and-r-studio" class="nav-link" data-scroll-target="#r-and-r-studio">R and R Studio</a></li>
</ul></li>
<li><a href="#establishing-an-posit-connect-account" id="toc-establishing-an-posit-connect-account" class="nav-link" data-scroll-target="#establishing-an-posit-connect-account">Establishing an Posit Connect account</a></li>
<li><a href="#connecting-rstudio-to-posit-connect" id="toc-connecting-rstudio-to-posit-connect" class="nav-link" data-scroll-target="#connecting-rstudio-to-posit-connect">Connecting RStudio to Posit Connect</a></li>
<li><a href="#publishing-to-posit-connect" id="toc-publishing-to-posit-connect" class="nav-link" data-scroll-target="#publishing-to-posit-connect">Publishing to Posit Connect</a></li>
<li><a href="#references-and-further-information" id="toc-references-and-further-information" class="nav-link" data-scroll-target="#references-and-further-information">References and Further Information</a></li>
</ul></li>
</ul>
</nav>
</div>
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Posit Connect Health Startup Tutorial</h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<p><img src="images/cover.png" class="img-fluid" width="349"></p>
<section id="background" class="level1">
<h1>Background</h1>
<p>Posit Connect (formerly known as RStudio Connect) is a tool that allows for organizational sharing of items published from RStudio such as <a href="https://shiny.rstudio.com/">Shiny apps</a>, interactive graphs and reporting documents (such as this one created with <a href="https://quarto.org/">Quarto</a>). This document is intended to walk RStudio users through the process of establishing an Posit Connect account, connecting to Posit Connect from RStudio, and publishing a document to Posit Connect.</p>
</section>
<section id="best-practices" class="level1">
<h1>Best Practices</h1>
<details>
<summary>
Here are some best practices
</summary>
<p>
</p><ul>
<li>
Never publish screenshots of data, code, or outputs.
</li>
<li>
To prevent accidental publication to other servers do not download data to local devices unless otherwise instructed,
</li>
<li>
Choose the correct publishing location - viz.soteria.arizona.edu
</li>
<li>
If available, do not select the “Anyone - no login required” under the Posit Connect sharing permissions.
</li>
<li>
Do not copy your API code to an insecure location.
</li>
</ul>
<p></p>
</details>
<p>To access Posit Connect Health however, you will first need to have access to the Soteria enclave.</p>
</section>
<section id="request-access-to-soteria" class="level1">
<h1>Request Access to Soteria</h1>
<ol type="1">
<li>Establish a primary PI or sponsoring faculty member and have them indicate that you are a team member on Soteria.</li>
<li>Open <a href="https://soteria.arizona.edu/" class="uri">https://soteria.arizona.edu/</a> and click <strong>Request Access</strong>.</li>
</ol>
<p><img src="images/SoteriaAccess1.png" class="img-fluid" width="532"></p>
<ol start="3" type="1">
<li>Fill out the form with your user and project information. Once submitted you will receive an automated email indicating completion of the request.</li>
<li>Once approved, you will receive a secondary automated email, UA Soteria Access Request Approved indicating required trainings. Log into Edge Learning (<a href="https://edgelearning.arizona.edu/" class="uri">https://edgelearning.arizona.edu/</a>) to sign up and complete all of the required trainings.</li>
</ol>
<section id="download-and-set-up-cisco-vpn" class="level2">
<h2 class="anchored" data-anchor-id="download-and-set-up-cisco-vpn">Download and Set up Cisco VPN</h2>
<ol type="1">
<li>Download the VPN software by following the link (<a href="https://vpn.arizona.edu/+CSCOE+/logon.html#form_title_text" class="uri">https://vpn.arizona.edu/+CSCOE+/logon.html#form_title_text</a>) . You will be prompted to log in. Use the default connections. Enter your NetID, Password and NetID +Method (ex: “push”).</li>
</ol>
<p><img src="images/Cisco1.png" class="img-fluid" width="334"></p>
<ol start="2" type="1">
<li>Follow the prompts to download and install Cisco AnyConnect VPN.</li>
</ol>
<p><img src="images/CiscoDown1.png" class="img-fluid" width="168"></p>
<p><img src="images/CiscoDown2.png" class="img-fluid" width="4143"></p>
<div class="tabset-margin-container"></div><div class="panel-tabset">
<ul class="nav nav-tabs" role="tablist"><li class="nav-item" role="presentation"><a class="nav-link active" id="tabset-1-1-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-1" role="tab" aria-controls="tabset-1-1" aria-selected="true" href="">Mac</a></li><li class="nav-item" role="presentation"><a class="nav-link" id="tabset-1-2-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-2" role="tab" aria-controls="tabset-1-2" aria-selected="false" href="">Windows</a></li></ul>
<div class="tab-content">
<div id="tabset-1-1" class="tab-pane active" role="tabpanel" aria-labelledby="tabset-1-1-tab">
<p><img src="images/CiscoDown3.png" class="img-fluid"></p>
</div>
<div id="tabset-1-2" class="tab-pane" role="tabpanel" aria-labelledby="tabset-1-2-tab">
<p><img src="images/CiscoDown3.2.png" class="img-fluid" width="3302"></p>
</div>
</div>
</div>
<ol start="2" type="1">
<li>Open Cisco AnyConnect VPN on your desktop.</li>
<li>The first connection must be to: vpn.arizona.edu. Type into the pop-up and click <strong>connect</strong>.</li>
</ol>
<p><img src="images/Cisco2.png" class="img-fluid" width="334"></p>
<ol start="5" type="1">
<li>Sign in as before, using the default group. Enter your NetID, Password and NetID +Method (ex: “push”).</li>
</ol>
<p><img src="images/Cisco3.png" class="img-fluid" width="334"></p>
<ol start="6" type="1">
<li>Click <strong>Disconnect</strong></li>
</ol>
<p><img src="images/Cisco4.png" class="img-fluid" width="334"></p>
<p>You are now ready to connect to your Soteria VPN.</p>
</section>
<section id="connect-to-soteria-vpn" class="level2">
<h2 class="anchored" data-anchor-id="connect-to-soteria-vpn">Connect to Soteria VPN</h2>
<ol type="1">
<li>If it does not auto-populate, connect to the Soteria VPN using: vpn.arizona.edu/soteria. Again, enter your NetID, Password and NetID +Method (ex: “push”) to sign in.</li>
</ol>
<p><img src="images/SoteriaVPN1.png" class="img-fluid" width="334"></p>
<ol start="2" type="1">
<li>Accept the pop-up notification. The Cisco Icon in the system tray (bottom right) of your desktop, will now display a lock, indicating a successful connection.</li>
</ol>
<hr>
</section>
</section>
<section id="posit-connect-health" class="level1">
<h1>Posit Connect Health</h1>
<section id="system-requirements" class="level2">
<h2 class="anchored" data-anchor-id="system-requirements">System Requirements</h2>
<p>Posit Connect is supported on multiple operating systems and browsers. For a full list see documentation found <a href="https://posit.co/about/platform-support/">here</a> to ensure full machine compatibility.</p>
</section>
<section id="installation-dependencies" class="level2">
<h2 class="anchored" data-anchor-id="installation-dependencies">Installation Dependencies</h2>
<section id="r-and-r-studio" class="level3">
<h3 class="anchored" data-anchor-id="r-and-r-studio">R and R Studio</h3>
<p>You will need a current, working version of R and RStudio to publish on Posit Connect. This website gives step by step instructions: <a href="https://www.dataquest.io/blog/installing-r-on-your-computer/" class="uri">https://www.dataquest.io/blog/installing-r-on-your-computer/</a></p>
</section>
</section>
<section id="establishing-an-posit-connect-account" class="level2">
<h2 class="anchored" data-anchor-id="establishing-an-posit-connect-account">Establishing an Posit Connect account</h2>
<p>Follow the steps below to begin your publishing journey with Posit Connect Health:</p>
<ol type="1">
<li>Request account access by navigating to the following <a href="https://datascience.arizona.edu/analytics-powerhouse/rstudio-connect">link</a> and finding the Request Access button near the bottom of the page.</li>
</ol>
<p><img src="images/ReqAccess.png" class="img-fluid"></p>
<ol start="2" type="1">
<li><p>You will be taken to a survey form to request access. Along with name and contact information, be prepared to supply a copy of published work, such as a Shiny app or GitHub code, and the name of an advisor for approval.</p></li>
<li><p>Once your request has been approved, navigate to <a href="https://viz.soteria.arizona.edu" class="uri">https://viz.soteria.arizona.edu</a> and sign in with your organizational email if you are not automatically signed in. You will see the main navigational screen of Posit Connect.</p></li>
</ol>
<p><img src="images/ReqAccess2.png" class="img-fluid"></p>
<p>The main navigation is at the top of the screen:</p>
<ul>
<li><p><strong>Content</strong> shows all content you have access to (yours and shared)</p></li>
<li><p><strong>People</strong> shows collaborators within your network</p></li>
<li><p><strong>Documentation</strong> provides further instructional material for use of Posit Connect.</p></li>
</ul>
<p><img src="images/RSConnect_Header.png" class="img-fluid"></p>
</section>
<section id="connecting-rstudio-to-posit-connect" class="level2">
<h2 class="anchored" data-anchor-id="connecting-rstudio-to-posit-connect">Connecting RStudio to Posit Connect</h2>
<p>Follow the steps below to connect RStudio with Posit Connect:</p>
<ol type="1">
<li>Open R Studio. Select <strong>Tools</strong> > <strong>Global Options</strong>:</li>
</ol>
<p><img src="images/RStudio_Tools.png" class="img-fluid"></p>
<ol start="2" type="1">
<li>On the pop up, navigate to <strong>Publishing</strong>, then click <strong>Connect</strong> on the right-hand side:</li>
</ol>
<p><img src="images/RStudioPublishing.png" class="img-fluid" width="562"></p>
<ol start="3" type="1">
<li>Click <strong>Posit Connect</strong>. Paste in the URL of the Posit Connect server (example: <a href="https://viz.datascience.arizona.edu" class="uri">https://viz.datascience.arizona.edu</a>) then click <strong>Next</strong>.</li>
</ol>
<p><img src="images/RStudioConnAcc.png" class="img-fluid" width="562"></p>
<ol start="4" type="1">
<li>A window should pop up in your browser. If not, follow the prompts in RStudio to open the window. Click <strong>Connect</strong> in the window. You will receive a notification if the connection was successful. The browser window can be closed.</li>
</ol>
<p><img src="images/ConnToR.png" class="img-fluid"></p>
<ol start="5" type="1">
<li>In RStudio the popup should now have the option to connect account. Click Connect Account. The URL will now be visible in the parent menu. Click <strong>OK</strong> to save the changes.</li>
</ol>
<p><img src="images/AccntVerify.png" class="img-fluid" width="562"></p>
</section>
<section id="publishing-to-posit-connect" class="level2">
<h2 class="anchored" data-anchor-id="publishing-to-posit-connect">Publishing to Posit Connect</h2>
<ol type="1">
<li>Once your content is created, click the blue <strong>Publish</strong> button (exists in multiple locations):</li>
</ol>
<p><img src="images/Publish1.png" class="img-fluid"></p>
<ol start="2" type="1">
<li>The publishing window should auto populate with your information. Ensure all information is correct and click <strong>Publish</strong>.</li>
</ol>
<p><img src="images/Publish2.png" class="img-fluid" width="562"></p>
<ol start="3" type="1">
<li>🎉 You are now published! Your browser window will automatically open the app. Click <strong>Documentation</strong> to view instructional material regarding Posit Connect publishing options.</li>
</ol>
<p><img src="images/Publish3.png" class="img-fluid"></p>
</section>
<section id="references-and-further-information" class="level2">
<h2 class="anchored" data-anchor-id="references-and-further-information">References and Further Information</h2>
<blockquote class="blockquote">
<p>Duitman, Ryan. Red Machine VPN Tutorial. <a href="https://arizona.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=6410e385-300c-4bfa-98d7-aea701705a99" class="uri">https://arizona.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=6410e385-300c-4bfa-98d7-aea701705a99</a></p>
<p>Data Science Institute. 2023. RStudio Connect. <a href="https://datascience.arizona.edu/analytics-powerhouse/rstudio-connect" class="uri">https://datascience.arizona.edu/analytics-powerhouse/rstudio-connect</a></p>
<p>Posit Software. 2023. Posit Documentation. <a href="https://docs.posit.co" class="uri">https://docs.posit.co</a></p>
<p>University of Arizona. 2021. UA Virtual Private Network (VPN). <a href="https://uarizona.service-now.com/sp?id=sc_cat_item&sys_id=8ab35af01bb830507947edf1604bcb90" class="uri">https://uarizona.service-now.com/sp?id=sc_cat_item&sys_id=8ab35af01bb830507947edf1604bcb90</a></p>
</blockquote>
</section>
</section>
</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const isCodeAnnotation = (el) => {
for (const clz of el.classList) {
if (clz.startsWith('code-annotation-')) {
return true;
}
}
return false;
}
const clipboard = new window.ClipboardJS('.code-copy-button', {
text: function(trigger) {
const codeEl = trigger.previousElementSibling.cloneNode(true);
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
}
return codeEl.innerText;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
let tooltip;
if (window.bootstrap) {
button.setAttribute("data-bs-toggle", "tooltip");
button.setAttribute("data-bs-placement", "left");
button.setAttribute("data-bs-title", "Copied!");
tooltip = new bootstrap.Tooltip(button,
{ trigger: "manual",
customClass: "code-copy-button-tooltip",
offset: [0, -8]});
tooltip.show();
}
setTimeout(function() {
if (tooltip) {
tooltip.hide();
button.removeAttribute("data-bs-title");
button.removeAttribute("data-bs-toggle");
button.removeAttribute("data-bs-placement");
}
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
function tippyHover(el, contentFn) {
const config = {
allowHTML: true,
content: contentFn,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start'
};
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
return note.innerHTML;
});
}
let selectedAnnoteEl;
const selectorForAnnotation = ( cell, annotation) => {
let cellAttr = 'data-code-cell="' + cell + '"';
let lineAttr = 'data-code-annotation="' + annotation + '"';
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
return selector;
}
const selectCodeLines = (annoteEl) => {
const doc = window.document;
const targetCell = annoteEl.getAttribute("data-target-cell");
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
const lineIds = lines.map((line) => {
return targetCell + "-" + line;
})
let top = null;
let height = null;
let parent = null;
if (lineIds.length > 0) {
//compute the position of the single el (top and bottom and make a div)
const el = window.document.getElementById(lineIds[0]);
top = el.offsetTop;
height = el.offsetHeight;
parent = el.parentElement.parentElement;
if (lineIds.length > 1) {
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
height = bottom - top;
}
if (top !== null && height !== null && parent !== null) {
// cook up a div (if necessary) and position it
let div = window.document.getElementById("code-annotation-line-highlight");
if (div === null) {
div = window.document.createElement("div");
div.setAttribute("id", "code-annotation-line-highlight");
div.style.position = 'absolute';
parent.appendChild(div);
}
div.style.top = top - 2 + "px";
div.style.height = height + 4 + "px";
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
if (gutterDiv === null) {
gutterDiv = window.document.createElement("div");
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
gutterDiv.style.position = 'absolute';
const codeCell = window.document.getElementById(targetCell);
const gutter = codeCell.querySelector('.code-annotation-gutter');
gutter.appendChild(gutterDiv);
}
gutterDiv.style.top = top - 2 + "px";
gutterDiv.style.height = height + 4 + "px";
}
selectedAnnoteEl = annoteEl;
}
};
const unselectCodeLines = () => {
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
elementsIds.forEach((elId) => {
const div = window.document.getElementById(elId);
if (div) {
div.remove();
}
});
selectedAnnoteEl = undefined;
};
// Attach click handler to the DT
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
for (const annoteDlNode of annoteDls) {
annoteDlNode.addEventListener('click', (event) => {
const clickedEl = event.target;
if (clickedEl !== selectedAnnoteEl) {
unselectCodeLines();
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
if (activeEl) {
activeEl.classList.remove('code-annotation-active');
}
selectCodeLines(clickedEl);
clickedEl.classList.add('code-annotation-active');
} else {
// Unselect the line
unselectCodeLines();
clickedEl.classList.remove('code-annotation-active');
}
});
}
const findCites = (el) => {
const parentEl = el.parentElement;
if (parentEl) {
const cites = parentEl.dataset.cites;
if (cites) {
return {
el,
cites: cites.split(' ')
};
} else {
return findCites(el.parentElement)
}
} else {
return undefined;
}
};
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const citeInfo = findCites(ref);
if (citeInfo) {
tippyHover(citeInfo.el, function() {
var popup = window.document.createElement('div');
citeInfo.cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
}
});
</script>
</div> <!-- /content -->
</body></html>