Add clipboard function

This commit is contained in:
Michał 2023-04-22 13:48:06 +00:00
parent e9e3706172
commit 76cc8456d2
4 changed files with 12 additions and 21 deletions

View file

@ -0,0 +1,8 @@
function copyToClipboard(data) {
try {
navigator.clipboard.writeText(data)
addNotification("Copied to clipboard!", 4);
} catch (err) {
addNotification("Oh noes, something when wrong D:", 2);
}
}

View file

@ -9,15 +9,6 @@
{% endif %}
<script type="text/javascript">
function groupShare() {
try {
navigator.clipboard.writeText(window.location.href)
addNotification("Copied link!", 4);
} catch (err) {
addNotification("Failed to copy link! Are you on HTTP?", 2);
}
}
{% if current_user.id == group.author.id %}
function groupDelete() {
cancelBtn = document.createElement('button');
@ -240,7 +231,7 @@
<p class="banner-subtitle">{{ images|length }} Images · {{ group.description }}</p>
<div class="pill-row">
<div>
<button class="pill-item" onclick="groupShare()"><i class="ph ph-export"></i></button>
<button class="pill-item" onclick="copyToClipboard(window.location.href)"><i class="ph ph-export"></i></button>
</div>
{% if current_user.id == group.author.id %}
<div>
@ -258,7 +249,7 @@
<p class="banner-info">By {{ group.author.username }}</p>
<div class="pill-row">
<div>
<button class="pill-item" onclick="groupShare()"><i class="ph ph-export"></i></button>
<button class="pill-item" onclick="copyToClipboard(window.location.href)"><i class="ph ph-export"></i></button>
</div>
{% if current_user.id == group.author.id %}
<div>

View file

@ -8,14 +8,6 @@
<meta name="twitter:card" content="summary_large_image">
<script type="text/javascript">
function imageShare() {
try {
navigator.clipboard.writeText(window.location.href)
addNotification("Copied link!", 4);
} catch (err) {
addNotification("Failed to copy link! Are you on HTTP?", 2);
}
}
function fullscreen() {
let info = document.querySelector('.info-container');
let wrapper = document.querySelector('.image-grid');
@ -119,7 +111,7 @@
{% if next_url %}<div><a class="pill-item" href="{{ next_url }}"><i class="ph ph-arrow-left"></i></a></div>{% endif %}
<div>
<button class="pill-item" onclick="fullscreen()" id="fullscreenImage"><i class="ph ph-info"></i></button>
<button class="pill-item" onclick="imageShare()"><i class="ph ph-export"></i></button>
<button class="pill-item" onclick="copyToClipboard(window.location.href)"><i class="ph ph-export"></i></button>
<a class="pill-item" href="{{ url_for('media_api.media', path='uploads/' + image.filename) }}" download onclick="addNotification('Download started!', 4)"><i class="ph ph-file-arrow-down"></i></a>
</div>
{% if current_user.id == image.author.id %}

View file

@ -56,7 +56,7 @@
<p class="banner-subtitle">{{ images|length }} Images · {{ groups|length }} Groups</p>
<div class="pill-row">
<div>
<button class="pill-item" onclick="profileShare()"><i class="ph ph-export"></i></button>
<button class="pill-item" onclick="copyToClipboard(window.location.href)"><i class="ph ph-export"></i></button>
<button class="pill-item" onclick="moreInfo()"><i class="ph ph-info"></i></button>
</div>
{% if user.id == current_user.id %}