Compare commits

..

No commits in common. "7a2ad274843ccf053cb51819eda1ac4d220d23d7" and "f9082d4d3eba2f567d9c2019aec5e49180684bb3" have entirely different histories.

1 changed files with 15 additions and 61 deletions

View File

@ -3,7 +3,6 @@
<head>
<title>blackout engine</title>
<script src="/html2canvas.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<style>
@ -38,10 +37,6 @@
background-color: black;
}
.grey {
background-color: grey;
}
.hidden {
display: none;
}
@ -64,30 +59,14 @@
#paper span {
cursor: help;
/* hack for the image download. without this, thin white artifacting at span margins */
margin-left:-1px;
}
@media (max-width:400px) {
.centering {
display: block;
width: 100%;
margin: 0px;
}
#paper span:hover {
background-color: white;
}
@media (hover: hover) {
#paper span:hover {
background-color: white;
/* hack for the image download. without this, thin white artifacting at span margins */
margin-left:-1px;
}
#paper span.black:hover {
background-color: grey;
/* hack for the image download. without this, thin white artifacting at span margins */
margin-left:-1px;
}
#paper span.black:hover {
background-color: grey;
}
#aboutToggle {
@ -125,7 +104,9 @@
<center>
<p>
<button id="copyText">copy text to clipboard</button>
<button id="downloadImage">download as image</button>
</p>
<p>
<button id="copyImage" class="hidden">copy image to clipboard</button>
</p>
<p>
<a id="aboutToggle" href="">ABOUT</a>
@ -149,54 +130,27 @@
</div>
</center>
<script>
document.querySelectorAll("#paper span").forEach(span => {
span.addEventListener("click", () => span.classList.toggle("black"));
span.addEventListener("touchstart", (e) => {
e.preventDefault();
span.classList.add("grey");
});
span.addEventListener("touchend", (e) => {
e.preventDefault();
span.classList.remove("grey");
span.classList.toggle("black");
});
span.addEventListener("touchcancel", (e) => {
e.preventDefault();
span.classList.remove("grey");
});
});
document.querySelectorAll("#paper span").forEach(span =>
span.onclick = () => span.classList.toggle("black"));
document.querySelector("#aboutToggle").onclick = (e) => {
e.preventDefault();
document.querySelector("#about").classList.toggle("hidden");
}
const downloadImgButton = document.querySelector("#downloadImage");
downloadImgButton.addEventListener("animationend", () => downloadImgButton.classList.remove("rainbow"), false);
downloadImgButton.addEventListener("click", () => {
const copyImgButton = document.querySelector("#copyImage");
copyImgButton.addEventListener("animationend", () => copyImgButton.classList.remove("rainbow"), false);
copyImgButton.onclick = () => {
html2canvas(document.querySelector("#paper")).then((canvas) => {
canvas.toBlob((blob) => {
/*
// can't use this because ff doesn't have support by default for clipboard.write()
let data = [new ClipboardItem({ [blob.type]: blob })];
navigator.clipboard.write(data).then(() => {
copyImgButton.classList.add("rainbow");
}, console.log);
*/
const downloadUrl = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = downloadUrl;
a.download = "blackout.png";
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(downloadUrl);
});
});
});
}
const copyTextButton = document.querySelector("#copyText");
copyTextButton.addEventListener("animationend", () => copyTextButton.classList.remove("rainbow"), false);
copyTextButton.addEventListener("click", () => {
copyTextButton.onclick = () => {
let toCopy = "";
document.querySelectorAll("#paper span").forEach(span => {
let guts = span.innerHTML;
@ -233,7 +187,7 @@
}, (err) => {
console.log(err);
});
});
}
</script>
</body>
</html>