-
Notifications
You must be signed in to change notification settings - Fork 1
/
after_body.html
108 lines (90 loc) · 3.2 KB
/
after_body.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
<script src="https://cdn.jsdelivr.net/npm/@xiee/utils/js/external-link.min.js" defer></script>
<script>
$(function(){
$(".note").addClass("alert alert-warning");
});
$(function(){
$(".tip").addClass("alert alert-success");
});
$(function(){
$(".def").addClass("alert alert-info");
});
$(function(){
$(".eg").addClass("alert alert-secondary");
});
$(function(){
$(".col-lg-3").addClass("col-lg-2").removeClass("col-lg-3");
});
$(function(){
$(".col-lg-7").addClass("col-lg-8").removeClass("col-lg-7");
});
</script>
<!-- https://stackoverflow.com/a/37839683/25278020 -->
<script>
$(document).ready(function() {
$chunks = $('.fold');
$chunks.each(function () {
// add button to source code chunks
if ( $(this).hasClass('s') ) {
$('pre.r', this).prepend("<div class=\"showopt\">Show Source</div><br style=\"line-height:22px;\"/>");
$('pre.r', this).children('code').attr('class', 'folded');
}
// add button to output chunks
if ( $(this).hasClass('o') ) {
$('pre:not(.r)', this).has('code').prepend("<div class=\"showopt\">Show Output</div><br style=\"line-height:22px;\"/>");
$('pre:not(.r)', this).children('code:not(r)').addClass('folded');
// add button to plots
$(this).find('img').wrap('<pre class=\"plot\"></pre>');
$('pre.plot', this).prepend("<div class=\"showopt\">Show Plot</div><br style=\"line-height:22px;\"/>");
$('pre.plot', this).children('img').addClass('folded');
}
});
// hide all chunks when document is loaded
$('.folded').css('display', 'none')
// function to toggle the visibility
$('.showopt').click(function() {
var label = $(this).html();
if (label.indexOf("Show") >= 0) {
$(this).html(label.replace("Show", "Hide"));
} else {
$(this).html(label.replace("Hide", "Show"));
}
$(this).siblings('code, img').slideToggle('fast', 'swing');
});
});
</script>
<!-- https://www.tutorialrepublic.com/faq/how-to-change-href-attribute-of-a-hyperlink-using-jquery.php-->
<script>
$(document).ready(function(){
$("a.anchorjs-link").each(function(){
var oldUrl = $(this).attr("href"); // Get current url
var newUrl = oldUrl.replace(/^#(\d+-)+/,"#"); // Create new url
$(this).attr("href", "#" + $(this).closest("div").attr("id")); // Set href value
$(this).attr("title", location.protocol + "//" + location.host + location.pathname + $(this).attr("href")); // Set title value
});
});
</script>
<!-- https://stackoverflow.com/a/10415599/25278020 -->
<script>
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
// element added to DOM
var hasClass = [].some.call(mutation.addedNodes, function(el) {
return el.classList.contains('bs-popover-top')
});
if (hasClass) {
$("div.bs-popover-top a").each(function(){
$(this).attr("target", "_blank");
});
}
}
});
});
var config = {
attributes: true,
childList: true,
characterData: true
};
observer.observe(document.body, config);
</script>