mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Use the clipboard API for copy paste
The Document.execCommand API is deprecated and no longer recommended to be used. It's replacement is the much simpler navigator.clipboard API which is supported in all browsers except internet explorer. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
This commit is contained in:
parent
8d9f20939c
commit
8b6f92f9e9
2 changed files with 6 additions and 14 deletions
|
@ -308,14 +308,10 @@ endif;
|
|||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.copy').click(function(e) {
|
||||
var tmp = $("<input>");
|
||||
$("body").append(tmp);
|
||||
tmp.val($(this).text()).select();
|
||||
document.execCommand("copy");
|
||||
tmp.remove();
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelector('.copy').addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
navigator.clipboard.writeText(event.target.text);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -137,14 +137,10 @@ endif;
|
|||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.copy').click(function(e) {
|
||||
var tmp = $("<input>");
|
||||
$("body").append(tmp);
|
||||
tmp.val($(this).text()).select();
|
||||
document.execCommand("copy");
|
||||
tmp.remove();
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelector('.copy').addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
navigator.clipboard.writeText(event.target.text);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Reference in a new issue