Rev 8 | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(document).ready(function() {
$("a[href^='#']").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
});
});
function openPage(pageName, elmnt) {
var i, tablinks;
// Show spinner
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>';
// Get and display snippet from server
getPage(pageName);
// Remove the background color of all nav-links/buttons
tablinks = document.getElementsByClassName("nav-link");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].style.backgroundColor = "";
}
// Scroll to top
topFunction();
// Change color for active button
elmnt.style.backgroundColor = "#5e5e5e";
}
function initIframes() {
var iframeDefer = document.getElementsByTagName('iframe');
for (var i = 0; i < iframeDefer.length; i++) {
if (iframeDefer[i].getAttribute('data-src')) {
iframeDefer[i].setAttribute('src', iframeDefer[i].getAttribute('data-src'));
}
}
}
window.onload = initIframes;
jQuery(document).on('copy', function(e) {
var sel = window.getSelection();
var copyFooter = "<br /><br /> Source: <a href='" + document.location.href + "'>" + document.location.href + "</a>";
var copyHolder = $('<div>', {html: sel+copyFooter, style: {position: 'absolute', left: '-99999px'}});
$('body').append(copyHolder);
sel.selectAllChildren( copyHolder[0] );
window.setTimeout(function() {
copyHolder.remove();
},0);
}
);
function getPage(pageName) {
$.post("getpage.php",
{
page: pageName
},
function(data, status) {
if (status == "success") {
document.getElementById("content").innerHTML = data;
$("a[href^='#']").click(function(event){
event.preventDefault();
var pos = $(this.hash).parent().parent().offset().top - $("#topNav").outerHeight();
window.location.hash = "" + $(this).attr("href");
$('html,body').animate({scrollTop:pos}, 500, 'swing');
});
initIframes();
handleCollabsible();
}
}
);
}
// collapsible content
function handleCollabsible() {
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight){
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + "px";
}
});
}
}
// Read url parameter or get the element with id="defaultOpen", and click on it
var parameterValue = null;
var parameterPage = window.location.search.match(/(\?|&)page\=([^&]*)/);
if (parameterPage !== null) {
parameterValue = decodeURIComponent(parameterPage[2]);
document.getElementById(parameterValue + "Open").click();
} else {
document.getElementById("defaultOpen").click();
}
// Floating Top Navigation Button:
mybutton = document.getElementById("topBtn");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = document.documentElement.scrollTop = 0;
}