Verified Commit a665b89b authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by Eli Schwartz
Browse files

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's avatarEli Schwartz <eschwartz@archlinux.org>
parent 0e426f95
...@@ -308,14 +308,10 @@ endif; ...@@ -308,14 +308,10 @@ endif;
</div> </div>
<script> <script>
$(document).ready(function() { document.addEventListener('DOMContentLoaded', function() {
$('.copy').click(function(e) { document.querySelector('.copy').addEventListener('click', function(e) {
var tmp = $("<input>");
$("body").append(tmp);
tmp.val($(this).text()).select();
document.execCommand("copy");
tmp.remove();
e.preventDefault(); e.preventDefault();
navigator.clipboard.writeText(event.target.text);
}); });
}); });
</script> </script>
...@@ -137,14 +137,10 @@ endif; ...@@ -137,14 +137,10 @@ endif;
</div> </div>
<script> <script>
$(document).ready(function() { document.addEventListener('DOMContentLoaded', function() {
$('.copy').click(function(e) { document.querySelector('.copy').addEventListener('click', function(e) {
var tmp = $("<input>");
$("body").append(tmp);
tmp.val($(this).text()).select();
document.execCommand("copy");
tmp.remove();
e.preventDefault(); e.preventDefault();
navigator.clipboard.writeText(event.target.text);
}); });
}); });
</script> </script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment