linkform.js 545 B

123456789101112131415161718
  1. // https://stackoverflow.com/a/23395136/349514
  2. function tick() {
  3. return new Audio("../themes/current/tick.mp3");
  4. }
  5. document.querySelectorAll('#snippets button').forEach(e => {
  6. // https://stackoverflow.com/a/30810322/349514
  7. e.addEventListener('click',evt => {
  8. evt.preventDefault();
  9. navigator.clipboard.writeText(e.innerText).then(function() {
  10. console.log('Async: Copying to clipboard was successful!');
  11. tick().play();
  12. }, function(err) {
  13. console.error('Async: Could not copy text: ', err);
  14. });
  15. });
  16. });