-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (54 loc) · 1.66 KB
/
Copy pathscript.js
File metadata and controls
63 lines (54 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const roles = [
"Conceptualization",
"Methodology",
"Software",
"Validation",
"Formal analysis",
"Investigation",
"Resources",
"Data curation",
"Writing – original draft",
"Writing – review & editing",
"Visualization",
"Supervision",
"Project administration",
"Funding acquisition"
];
const container = document.getElementById("author-container");
const addBtn = document.getElementById("add-author");
const generateBtn = document.getElementById("generate");
const output = document.getElementById("output");
// Create an author block
function addAuthor() {
const block = document.createElement("div");
block.className = "author-block";
block.innerHTML = `
<input type="text" class="author-name" placeholder="Author name">
<div class="roles">
${roles
.map(
r =>
`<label><input type="checkbox" value="${r}"> ${r}</label>`
)
.join("<br>")}
</div>
<hr>
`;
container.appendChild(block);
}
addBtn.onclick = addAuthor;
addAuthor(); // Start with one author
generateBtn.onclick = () => {
const blocks = document.querySelectorAll(".author-block");
let result = "CRediT Author Contributions:\n\n";
blocks.forEach(block => {
const name = block.querySelector(".author-name").value.trim();
const checked = [...block.querySelectorAll("input[type=checkbox]:checked")].map(
c => c.value
);
if (name && checked.length > 0) {
result += `${name}: ${checked.join(", ")}.\n`;
}
});
output.value = result;
};