chiro-canto/public/scripts/script.js

79 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2021-03-28 20:40:17 +02:00
/* SHOW ELEMENT AFTER PAGE IS SCROLLED 100px */
var win = window,
docEl = document.documentElement,
$nav = document.getElementsByTagName('nav')[0];
win.onscroll = function() {
var sTop = (this.pageYOffset || docEl.scrollTop) - (docEl.clientTop || 0);
if (sTop > 100) {
$nav.classList.add("dark-theme");
} else {
$nav.classList.remove("dark-theme");
}
};
// /*
// * Link preview in nav bar
// */
// nav = document.getElementsByTagName('nav')[0];
// navItems = nav.children[0].children;
// for (navItem of navItems) {
// console.log(navItem);
// navItem.addEventListener('mouseover', function() {
// displayPreview(this);
// });
// navItem.addEventListener('mouseleave', function() {
// hidePreview();
// })
// }
2021-03-28 20:40:17 +02:00
// let iframe = document.createElement('iframe');
// iframe.style.display = "none";
// nav.appendChild(iframe);
2021-03-28 20:40:17 +02:00
// function displayPreview(navItem) {
// let url = navItem.href;
// // console.log(url);
// iframe.src = url;
// iframe.id = "previewFrame";
// iframe.style.width = "600px";
// iframe.style.height = "600px";
// iframe.style.display = "block";
// iframe.style.position = "fixed";
// var x = event.clientX;
// // var y = event.clientY;
// iframe.style.top = 5 + 'em';
// iframe.style.left = (x - 50) + 'px';
// }
2021-03-28 20:40:17 +02:00
// function hidePreview() {
// iframe.style.display = "none";
2021-04-09 14:29:00 +02:00
// }
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("collapsed");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
function clipboard_copy() {
/* Get the text field */
var copyText = document.getElementById("guano");
var r = document.createRange();
r.selectNode(copyText);
window.getSelection().removeAllRanges();
window.getSelection().addRange(r);
document.execCommand('copy');
window.getSelection().removeAllRanges();
}