Skip to content

Commit

Permalink
Merge pull request #3858 from Roardom/copy-announce-url-to-clipboard
Browse files Browse the repository at this point in the history
(Update) Copy announce url to clipboard on click
  • Loading branch information
HDVinnie committed May 26, 2024
2 parents 00a9b1d + 3323dec commit d2a08f4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion resources/views/torrent/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,12 @@ class="form__button form__button--filled"
<div class="panel__body">
<p>
{{ __('torrent.announce-url') }}:
<a href="{{ route('announce', ['passkey' => $user->passkey]) }}">
<a
x-data="upload"
data-announce-url="{{ route('announce', ['passkey' => $user->passkey]) }}"
x-on:click.prevent="copy"
href="{{ route('announce', ['passkey' => $user->passkey]) }}"
>
{{ route('announce', ['passkey' => $user->passkey]) }}
</a>
</p>
Expand All @@ -604,4 +609,21 @@ class="form__button form__button--filled"
<script src="{{ asset('build/unit3d/parser.js') }}" crossorigin="anonymous"></script>
<script src="{{ asset('build/unit3d/helper.js') }}" crossorigin="anonymous"></script>
<script src="{{ asset('build/unit3d/imgbb.js') }}" crossorigin="anonymous"></script>
<script nonce="{{ HDVinnie\SecureHeaders\SecureHeaders::nonce('script') }}">
document.addEventListener('alpine:init', () => {
Alpine.data('upload', () => ({
copy() {
navigator.clipboard.writeText(this.$el.dataset.announceUrl);
Swal.fire({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
icon: 'success',
title: 'Copied to clipboard!',
});
},
}));
});
</script>
@endsection

0 comments on commit d2a08f4

Please sign in to comment.