Remove onclick because CSP doesn't allow it
This commit is contained in:
parent
9813b4252b
commit
6c3ab47a9b
1 changed files with 6 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
function copy(data) {
|
function copy(data) {
|
||||||
navigator.clipboard.writeText(data).then(() => {
|
navigator.clipboard.writeText(data.data).then(() => {
|
||||||
console.log("Copied");
|
console.log("Copied");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,18 @@ function copy(data) {
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
const $ = django.jQuery;
|
const $ = django.jQuery;
|
||||||
const fileUrls = $('td.field-processed_file_url, td.field-original_file_url');
|
const fileUrls = $('td.field-processed_file_url, td.field-original_file_url');
|
||||||
|
let id = 0;
|
||||||
for (let fileUrl of fileUrls) {
|
for (let fileUrl of fileUrls) {
|
||||||
fileUrl = $(fileUrl);
|
fileUrl = $(fileUrl);
|
||||||
const existingText = fileUrl.text().trim();
|
const existingText = fileUrl.text().trim();
|
||||||
if (!existingText) {
|
if (!existingText) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const copyButton = `<a class='copy-button' href='#' onclick="copy(\'${existingText}\')">📋</a>`;
|
const buttonId = `copy-button-${id}`;
|
||||||
|
const copyButton = `<a class="copy-button" id="${buttonId}" href="#">📋</a>`;
|
||||||
let innerHTML = `<span>${existingText}</span> ${copyButton}`;
|
let innerHTML = `<span>${existingText}</span> ${copyButton}`;
|
||||||
fileUrl.html(innerHTML);
|
fileUrl.html(innerHTML);
|
||||||
|
$(`#${buttonId}`).on("click", null, existingText, copy);
|
||||||
|
id++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue