35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
var menu = document.getElementById("menu");
|
|
|
|
var menuBtn = document.getElementById("menuBtn");
|
|
var closeMenu = document.getElementById("closeMenu");
|
|
menuBtn.onclick = function () {
|
|
menu.classList.add("showMenu");
|
|
};
|
|
closeMenu.onclick = function () {
|
|
menu.classList.remove("showMenu");
|
|
};
|
|
|
|
var searchModal = document.getElementById("searchModal");
|
|
var searchBtn = document.getElementById("searchBtn");
|
|
var searchClose = document.getElementById("searchClose");
|
|
searchBtn.onclick = function () {
|
|
searchModal.classList.add("active");
|
|
};
|
|
searchClose.onclick = function () {
|
|
searchModal.classList.remove("active");
|
|
};
|
|
// =============================================
|
|
const copyListener = (e) => {
|
|
const range = window.getSelection().getRangeAt(0),
|
|
rangeContents = range.cloneContents(),
|
|
pageLink = `Orient Link: ${document.location.href}`,
|
|
helper = document.createElement("div");
|
|
|
|
helper.appendChild(rangeContents);
|
|
|
|
event.clipboardData.setData("text/plain", `${helper.innerText}\n${pageLink}`);
|
|
event.clipboardData.setData("text/html", `${helper.innerHTML}<br>${pageLink}`);
|
|
event.preventDefault();
|
|
};
|
|
document.addEventListener("copy", copyListener);
|