-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
101 lines (81 loc) · 3.25 KB
/
Copy pathscript.js
File metadata and controls
101 lines (81 loc) · 3.25 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
let rankCounter = 1;
function addRank() {
if(rankCounter >= 10) {
alert("You can only add up to 10 ranks.");
return;
}
rankCounter++;
const rankDiv = document.createElement('div');
rankDiv.className = 'rank';
rankDiv.id = `rankContainer${rankCounter}`;
const rankLabelSpan = document.createElement('span');
rankLabelSpan.className = 'rankLabel';
rankLabelSpan.innerText = `Rank ${rankCounter}:`;
const rankNameLabel = document.createElement('label');
rankNameLabel.setAttribute('for', `rank${rankCounter}_name`);
rankNameLabel.innerText = `Name: `;
const rankNameInput = document.createElement('input');
rankNameInput.type = 'text';
rankNameInput.id = `rank${rankCounter}_name`;
rankNameInput.placeholder = "e.g. VIP";
rankNameInput.style.marginRight = "20px";
const rankLabel = document.createElement('label');
rankLabel.setAttribute('for', `rank${rankCounter}`);
rankLabel.innerText = `Player Usernames (comma separated): `;
const rankInput = document.createElement('input');
rankInput.type = 'text';
rankInput.id = `rank${rankCounter}`;
rankInput.placeholder = "e.g. John,Jane";
// Create color label and input
const colorLabel = document.createElement('label');
colorLabel.setAttribute('for', `rank${rankCounter}_color`);
colorLabel.innerText = 'Rank Color: ';
colorLabel.style.marginLeft = '20px';
const colorInput = document.createElement('input');
colorInput.type = 'color';
colorInput.id = `rank${rankCounter}_color`;
// Appending elements to rankDiv
rankDiv.appendChild(rankLabelSpan);
rankDiv.appendChild(rankNameLabel);
rankDiv.appendChild(rankNameInput);
rankDiv.appendChild(rankLabel);
rankDiv.appendChild(rankInput);
rankDiv.appendChild(colorLabel); // Append color label
rankDiv.appendChild(colorInput); // Append color input
document.getElementById('ranksContainer').appendChild(rankDiv);
}
function removeRank() {
if(rankCounter == 1) {
alert("You can't remove the first rank.");
return;
}
const lastRank = document.getElementById(`rankContainer${rankCounter}`);
if (lastRank) {
lastRank.remove();
rankCounter--;
}
}
function generateInput() {
let inputStr = "";
for(let i = 1; i <= rankCounter; i++) {
const rankName = document.getElementById(`rank${i}_name`).value || 'NAME NOT GIVEN';
const players = document.getElementById(`rank${i}`).value;
const color = document.getElementById(`rank${i}_color`).value.slice(1); // Note the ID change here
inputStr += `[Rank${i}_Name]${rankName}[/Rank${i}_Name] `;
inputStr += "\n";
inputStr += `[Rank${i}]${players}[/Rank${i}] `;
inputStr += "\n";
inputStr += `[Rank${i}_Color]#${color}[/Rank${i}_Color]`; // Add the color to the string
// If it's not the last rank, add two new lines for spacing
if (i < rankCounter) {
inputStr += "\n\n";
}
}
document.getElementById('generatedInput').value = inputStr.trim();
}
function copyToClipboard() {
var textarea = document.getElementById("generatedInput");
textarea.select();
document.execCommand("copy");
alert("Copied to clipboard!");
}