macro
This commit is contained in:
1 parent
d73f01c5f5
commit
f2559bc63e
3 files changed
+71
-42
No files matched your search
@@ -0,0 +1,55 @@
|
||||
{% macro magic_link(url, text, unique_id='magic_link') %}
|
||||
<a
|
||||
href="{{ url }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
id="{{ unique_id }}"
|
||||
>
|
||||
{{ text }}
|
||||
</a>
|
||||
<script>
|
||||
(function () {
|
||||
const a = document.getElementById("{{ unique_id }}");
|
||||
a.addEventListener("click", function (e) {
|
||||
e.preventDefault();
|
||||
window.open(
|
||||
this.href,
|
||||
this.target,
|
||||
Array.from(this.relList).join(", ")
|
||||
);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{% endmacro %} {% macro qrcode_queue(queue_items) %} {% if queue_items %}
|
||||
<ol>
|
||||
{% for item in queue_items %}
|
||||
<li>
|
||||
<a href="{{ item }}" target="_blank" rel="noreferrer noopener">
|
||||
{{ item }}
|
||||
<div class="qrcode"></div>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
<style>
|
||||
/* it works ig */
|
||||
li:has(.qrcode) {
|
||||
width: min-content;
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/qrcode.js"></script>
|
||||
<script>
|
||||
window.addEventListener("load", (_) => {
|
||||
document.querySelectorAll(".qrcode").forEach((e) => {
|
||||
const a = e.parentElement.textContent.trim();
|
||||
new QRCode(e, {
|
||||
text: a,
|
||||
correctLevel: QRCode.CorrectLevel.L,
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %} {% endmacro %}
|
||||
Reference in new issue
Block a user