Beta v2
This commit is contained in:
56
genqr.php
Normal file
56
genqr.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/head.php" ?>
|
||||
<body>
|
||||
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/header.php" ?>
|
||||
|
||||
<div class="container">
|
||||
<div class="content flex-vertical">
|
||||
<div class="section-one">
|
||||
<h1>QR Code</h1>
|
||||
<a id="qr-link" href="">
|
||||
<div id="qr"></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="section-two">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/footer.php" ?>
|
||||
|
||||
<script src="/static/qrcode.min.js"></script>
|
||||
<script>
|
||||
const path = window.location.pathname;
|
||||
const parts = path.split("/");
|
||||
const user = parts.pop();
|
||||
let url = location.protocol + "//" + location.host + "/u/" + user;
|
||||
|
||||
const qrcode = new QRCode(document.getElementById('qr'), {
|
||||
text: url,
|
||||
width: 1024,
|
||||
height: 1024,
|
||||
colorDark : '#000',
|
||||
colorLight : '#fff',
|
||||
correctLevel : QRCode.CorrectLevel.L
|
||||
});
|
||||
|
||||
let qrLink = document.getElementById("qr-link");
|
||||
let qrImg = document.querySelector("#qr img");
|
||||
console.log(qrImg.src);
|
||||
qrLink.setAttribute("download", "qrcode-" + user + ".png");
|
||||
|
||||
const delay = ms => new Promise(res => setTimeout(res, ms));
|
||||
const setHref = async () => {
|
||||
while (!qrLink.href.startsWith("data:")) {
|
||||
await delay(100);
|
||||
qrLink.setAttribute("href", qrImg.src);
|
||||
console.log("Refreshing...");
|
||||
}
|
||||
document.getElementById("loading").remove();
|
||||
};
|
||||
setHref();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user