8 |
- |
1 |
$(document).ready(function() {
|
|
|
2 |
|
|
|
3 |
$("a[href^='#']").click(function(event){
|
|
|
4 |
event.preventDefault();
|
|
|
5 |
$('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
|
|
|
6 |
});
|
|
|
7 |
});
|
|
|
8 |
|
5 |
- |
9 |
function openPage(pageName, elmnt) {
|
6 |
- |
10 |
var i, tablinks;
|
5 |
- |
11 |
|
8 |
- |
12 |
// Show spinner
|
|
|
13 |
document.getElementById("content").innerHTML = '<div class="d-flex justify-content-center p-5"><div class="spinner-border"><span class="sr-only">Loading...</span></div></div>';
|
|
|
14 |
|
|
|
15 |
// Get and display snippet from server
|
6 |
- |
16 |
getPage(pageName);
|
|
|
17 |
|
5 |
- |
18 |
// Remove the background color of all nav-links/buttons
|
|
|
19 |
tablinks = document.getElementsByClassName("nav-link");
|
|
|
20 |
for (i = 0; i < tablinks.length; i++) {
|
|
|
21 |
tablinks[i].style.backgroundColor = "";
|
|
|
22 |
}
|
|
|
23 |
|
8 |
- |
24 |
// Scroll to top
|
|
|
25 |
topFunction();
|
5 |
- |
26 |
|
|
|
27 |
// Change color for active button
|
10 |
- |
28 |
elmnt.style.backgroundColor = "#5e5e5e";
|
5 |
- |
29 |
}
|
|
|
30 |
|
|
|
31 |
function initIframes() {
|
|
|
32 |
var iframeDefer = document.getElementsByTagName('iframe');
|
|
|
33 |
for (var i = 0; i < iframeDefer.length; i++) {
|
|
|
34 |
if (iframeDefer[i].getAttribute('data-src')) {
|
|
|
35 |
iframeDefer[i].setAttribute('src', iframeDefer[i].getAttribute('data-src'));
|
|
|
36 |
}
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
window.onload = initIframes;
|
|
|
40 |
|
|
|
41 |
jQuery(document).on('copy', function(e) {
|
|
|
42 |
var sel = window.getSelection();
|
|
|
43 |
var copyFooter = "<br /><br /> Source: <a href='" + document.location.href + "'>" + document.location.href + "</a>";
|
|
|
44 |
var copyHolder = $('<div>', {html: sel+copyFooter, style: {position: 'absolute', left: '-99999px'}});
|
|
|
45 |
$('body').append(copyHolder);
|
|
|
46 |
sel.selectAllChildren( copyHolder[0] );
|
|
|
47 |
window.setTimeout(function() {
|
|
|
48 |
copyHolder.remove();
|
|
|
49 |
},0);
|
|
|
50 |
}
|
|
|
51 |
);
|
6 |
- |
52 |
|
|
|
53 |
function getPage(pageName) {
|
|
|
54 |
$.post("getpage.php",
|
|
|
55 |
{
|
|
|
56 |
page: pageName
|
|
|
57 |
},
|
|
|
58 |
function(data, status) {
|
|
|
59 |
if (status == "success") {
|
|
|
60 |
document.getElementById("content").innerHTML = data;
|
8 |
- |
61 |
$("a[href^='#']").click(function(event){
|
|
|
62 |
event.preventDefault();
|
|
|
63 |
var pos = $(this.hash).parent().parent().offset().top - $("#topNav").outerHeight();
|
|
|
64 |
window.location.hash = "" + $(this).attr("href");
|
|
|
65 |
$('html,body').animate({scrollTop:pos}, 500, 'swing');
|
|
|
66 |
});
|
6 |
- |
67 |
initIframes();
|
8 |
- |
68 |
handleCollabsible();
|
6 |
- |
69 |
}
|
|
|
70 |
}
|
|
|
71 |
);
|
|
|
72 |
}
|
|
|
73 |
|
8 |
- |
74 |
// collapsible content
|
|
|
75 |
function handleCollabsible() {
|
|
|
76 |
var coll = document.getElementsByClassName("collapsible");
|
|
|
77 |
var i;
|
6 |
- |
78 |
|
8 |
- |
79 |
for (i = 0; i < coll.length; i++) {
|
|
|
80 |
coll[i].addEventListener("click", function() {
|
|
|
81 |
this.classList.toggle("active");
|
|
|
82 |
var content = this.nextElementSibling;
|
|
|
83 |
if (content.style.maxHeight){
|
|
|
84 |
content.style.maxHeight = null;
|
|
|
85 |
} else {
|
|
|
86 |
content.style.maxHeight = content.scrollHeight + "px";
|
|
|
87 |
}
|
|
|
88 |
});
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
|
6 |
- |
92 |
// Read url parameter or get the element with id="defaultOpen", and click on it
|
|
|
93 |
var parameterValue = null;
|
|
|
94 |
var parameterPage = window.location.search.match(/(\?|&)page\=([^&]*)/);
|
|
|
95 |
if (parameterPage !== null) {
|
|
|
96 |
parameterValue = decodeURIComponent(parameterPage[2]);
|
|
|
97 |
document.getElementById(parameterValue + "Open").click();
|
|
|
98 |
} else {
|
|
|
99 |
document.getElementById("defaultOpen").click();
|
8 |
- |
100 |
}
|
|
|
101 |
|
|
|
102 |
// Floating Top Navigation Button:
|
|
|
103 |
mybutton = document.getElementById("topBtn");
|
|
|
104 |
|
|
|
105 |
window.onscroll = function() {scrollFunction()};
|
|
|
106 |
|
|
|
107 |
function scrollFunction() {
|
|
|
108 |
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
|
|
|
109 |
mybutton.style.display = "block";
|
|
|
110 |
} else {
|
|
|
111 |
mybutton.style.display = "none";
|
|
|
112 |
}
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
function topFunction() {
|
|
|
116 |
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
6 |
- |
117 |
}
|