Skip to content
Snippets Groups Projects
Commit 4e502053 authored by Julian's avatar Julian
Browse files

Implement iCal url copy button

parent 4b843c87
No related branches found
No related tags found
1 merge request!975Resolve "Add possibility to create Ical feeds for all apps"
$(".copy-button").click((e) => {
const target = $(e.currentTarget);
const input = $("#" + target.data("target"));
const icon = target.children("svg")[0];
if (!Iconify.iconExists("mdi:content-copy")) {
Iconify.loadIcon("mdi:content-copy");
}
const copy = Iconify.renderSVG("mdi:content-copy");
copy.classList.add("material-icons");
if (!Iconify.iconExists("mdi:check")) {
Iconify.loadIcon("mdi:check");
}
const check = Iconify.renderSVG("mdi:check");
check.classList.add("material-icons");
console.log(copy);
if (navigator.clipboard) {
console.log("Copying to clipboard");
navigator.clipboard.writeText(input.val()).then(r => {
icon.replaceWith(check);
// target.children("svg")[0].classList.add("material-icons");
setTimeout(() => {
target.children("svg")[0].replaceWith(copy);
// target.children("svg")[0].classList.add("material-icons");
}, 1000);
});
} else {
console.log("Clipboard API not supported");
input.select();
document.execCommand("copy");
input.blur();
icon.replaceWith(check);
// target.children("svg")[0].classList.add("material-icons");
setTimeout(() => {
icon.innerHTML = copy.body;
}, 1000);
}
});
......@@ -36,4 +36,5 @@
</div>
{% endfor %}
</div>
<script src="{% static "js/ical_urls.js" %}" type="text/javascript"></script>
{% endblock content %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment