-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathddrsch_script.html
72 lines (55 loc) · 2.51 KB
/
ddrsch_script.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
<script>
// Chapter name
const currentChapterFile = window.location.pathname.split('/').pop().replace('.html', '');
//Deffining urls
const originalURL = "https://github.com/hadley/adv-r";
const translationURL = "https://github.com/davidrsch/adv-res";
//Deffining texts
const edit_text = "Editar esta página";
const issue_text = "Informar de un problema"
//Deffining git_i
const git_i = '<div><i class="bi bi-github"></i></div>';
// Adding TOC if not exist
const sidebarmargin = document.getElementById('quarto-margin-sidebar');
const buscar_TOC = document.getElementById('TOC');
if (!buscar_TOC) {
const crear_TOC = document.createElement('nav');
crear_TOC.id = 'TOC';
crear_TOC.role = "doc-toc";
crear_TOC.class = "toc-active";
sidebarmargin.appendChild(crear_TOC);
}
// Adding original github actions
const TOC = document.getElementById('TOC');
const originalga = document.createElement('h2');
originalga.textContent = "Original";
originalga.style["border-top"] = "1px solid #ccc";
originalga.style["padding-top"] = "0.5rem";
const toc_act_O = document.createElement('div');
toc_act_O.className = 'toc-actions';
toc_act_O.id = 'toc-act-O';
const act_link_O = document.createElement('div');
act_link_O.className='action-links';
act_link_O.id='act-link-O';
const edit_issue_O ='<p><a href="'+originalURL+'/edit/master/'+currentChapterFile+'.Rmd" class="toc-action">'+edit_text+'</p><p><a href="'+originalURL+'/issues/new" class="toc-action">'+issue_text+'</p>';
TOC.appendChild(originalga);
TOC.appendChild(toc_act_O);
toc_act_O.innerHTML += git_i;
toc_act_O.appendChild(act_link_O);
act_link_O.innerHTML += edit_issue_O;
// Adding translation github actions
const translationga = document.createElement('h2');
translationga.textContent = "Traducción";
const toc_act_T = document.createElement('div');
toc_act_T.className = 'toc-actions';
toc_act_T.id = 'toc-act-T';
const act_link_T = document.createElement('div');
act_link_T.className='action-links';
act_link_T.id='act-link-T';
const edit_issue_T ='<p><a href="'+translationURL+'/edit/main/'+currentChapterFile+'.qmd" class="toc-action">'+edit_text+'</p><p><a href="'+translationURL+'/issues/new" class="toc-action">'+issue_text+'</p>';
TOC.appendChild(translationga);
TOC.appendChild(toc_act_T);
toc_act_T.innerHTML += git_i;
toc_act_T.appendChild(act_link_T);
act_link_T.innerHTML += edit_issue_T;
</script>