Skip to content

Commit eb4bfab

Browse files
committed
Add onClick copy to clipboard
1 parent 3a58f19 commit eb4bfab

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

script.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,27 @@ function createTableFromJSON(arr) {
1313
tr = table.insertRow(-1);
1414

1515
var tabK = tr.insertCell(0);
16-
tabK.textContent = arr[i].key;
17-
tabK.style = "padding-right: 2rem;";
16+
Object.assign(tabK, {
17+
textContent: arr[i].key,
18+
style: "padding-right: 2rem;",
19+
id: "gl-ext-key-" + i,
20+
data-clipboard-target: "#gl-ext-key-" + i
21+
title: "Copy name",
22+
aria-live: "polite",
23+
data-placement: "bottom",
24+
data-toggle: "tooltip"
25+
});
1826

1927
var tabV = tr.insertCell(1);
20-
tabV.textContent = arr[i].value;
28+
Object.assign(tabV, {
29+
textContent: arr[i].value,
30+
id: "gl-ext-val-" + i,
31+
data-clipboard-target: "#gl-ext-val-" + i
32+
title: "Copy value",
33+
aria-live: "polite",
34+
data-placement: "bottom",
35+
data-toggle: "tooltip"
36+
});
2137
}
2238

2339
divForTheTable.appendChild(table);

0 commit comments

Comments
 (0)