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