Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/templates/index.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<script src="<?= assetUrl('/js/highlight.pack.js') ?>"></script>
<script src="<?= assetUrl('/js/uploads-store.js') ?>"></script>
<script src="<?= assetUrl('/js/pictshare.js') ?>"></script>
<script src="<?= assetUrl('/js/qrcode.min.js') ?>"></script>
</BODY>

</HTML>
17 changes: 15 additions & 2 deletions web/js/pictshare.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ document.addEventListener("DOMContentLoaded", function () {
if (typeof refreshMyUploads === 'function') refreshMyUploads();
}
uploadInfo.insertAdjacentHTML("beforeend",
renderMessage(file.name + " uploaded as <a target='_blank' href='/" + response.hash + "'>" + response.hash + "</a>", "URL: <a target='_blank' href='" + response.url + "'>" + response.url + "</a> <button class='btn btn-primary btn-sm' onClick='navigator.clipboard.writeText(\"" + response.url + "\");'>Copy URL</button>", "success")
renderMessage(file.name + " uploaded as <a target='_blank' href='/" + response.hash + "'>" + response.hash + "</a>", "URL: <a target='_blank' href='" + response.url + "'>" + response.url + "</a> <button class='btn btn-primary btn-sm' onClick='navigator.clipboard.writeText(\"" + response.url + "\");'>Copy URL</button> <button id='showqrdtn-" + response.hash + "' class='btn btn-primary btn-sm' onClick='showQrcode(\"" + response.hash + "\", \""+ response.url + "\");'>Show QRCode</button><div id='" + response.hash + "' class='p-1'></div>", "success")
);
} else if (response.status == 'err') {
uploadInfo.insertAdjacentHTML("beforeend",
Expand Down Expand Up @@ -148,7 +148,7 @@ document.addEventListener("DOMContentLoaded", function () {
// but the current API logic determines type by content.
// For text/markdown, we might need to adjust src/api/upload.php
uploadInfo.insertAdjacentHTML("beforeend",
renderMessage("Paste uploaded as <a target='_blank' href='/" + data.hash + "'>" + data.hash + "</a>", "URL: <a target='_blank' href='" + data.url + "'>" + data.url + "</a> <button class='btn btn-primary btn-sm' onClick='navigator.clipboard.writeText(\"" + data.url + "\");'>Copy URL</button>", "success")
renderMessage("Paste uploaded as <a target='_blank' href='/" + data.hash + "'>" + data.hash + "</a>", "URL: <a target='_blank' href='" + data.url + "'>" + data.url + "</a> <button class='btn btn-primary btn-sm' onClick='navigator.clipboard.writeText(\"" + data.url + "\");'>Copy URL</button> <button id='showqrdtn-" + data.hash + "' class='btn btn-primary btn-sm' onClick='showQrcode(\"" + data.hash + "\", \""+ data.url + "\");'>Show QRCode</button><div id='" + data.hash + "' class='p-1'></div>", "success")
);
document.getElementById("pasteText").value = "";
} else {
Expand All @@ -168,6 +168,19 @@ document.addEventListener("DOMContentLoaded", function () {
}
});

function showQrcode(hash, url) {
showqrbtn = document.getElementById('showqrdtn-' + hash);
targetDiv = document.getElementById(hash);

if (targetDiv.hasChildNodes()) {
targetDiv.innerHTML = '';
showqrbtn.textContent = "Show QRCode";
} else {
new QRCode(targetDiv, url);
showqrbtn.textContent = "Hide QRCode";
}
}

function renderMessage(title, message, type) {
if (!type)
type = "danger";
Expand Down
Loading