79 lines
2.1 KiB
JavaScript
Executable File
79 lines
2.1 KiB
JavaScript
Executable File
/* 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();
|
|
// })
|
|
// }
|
|
|
|
// let iframe = document.createElement('iframe');
|
|
// iframe.style.display = "none";
|
|
// nav.appendChild(iframe);
|
|
|
|
// 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';
|
|
// }
|
|
|
|
// function hidePreview() {
|
|
// iframe.style.display = "none";
|
|
// }
|
|
|
|
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();
|
|
} |