From 6c3ab47a9b94d8ead7fa82a1d7b5f755a3972dcd Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 28 Aug 2020 22:09:50 +0200 Subject: [PATCH] Remove onclick because CSP doesn't allow it --- attachments/static/attachments/js/copy_url.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/attachments/static/attachments/js/copy_url.js b/attachments/static/attachments/js/copy_url.js index 0ac4097..22a6ea6 100644 --- a/attachments/static/attachments/js/copy_url.js +++ b/attachments/static/attachments/js/copy_url.js @@ -1,5 +1,5 @@ function copy(data) { - navigator.clipboard.writeText(data).then(() => { + navigator.clipboard.writeText(data.data).then(() => { console.log("Copied"); }) } @@ -7,14 +7,18 @@ function copy(data) { $(document).ready(function() { const $ = django.jQuery; const fileUrls = $('td.field-processed_file_url, td.field-original_file_url'); + let id = 0; for (let fileUrl of fileUrls) { fileUrl = $(fileUrl); const existingText = fileUrl.text().trim(); if (!existingText) { continue; } - const copyButton = `📋`; + const buttonId = `copy-button-${id}`; + const copyButton = `📋`; let innerHTML = `${existingText} ${copyButton}`; fileUrl.html(innerHTML); + $(`#${buttonId}`).on("click", null, existingText, copy); + id++; } });