-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtradeCount.js
48 lines (40 loc) · 1.62 KB
/
tradeCount.js
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
/* SITE */
//grab the body
const body = document.querySelector("body");
//grab the button
const modBtn = document.querySelector(".cardCountButton");
modBtn.addEventListener("click", () => {
body.appendChild(cardInputOverlay);
});
//overlay
const cardInputOverlay = document.createElement("div");
cardInputOverlay.setAttribute("class", "cIOverlay");
//instructions
const cardDir = document.createElement("span");
cardDir.textContent = "Input your card list below. Use full card names (filler00, filler01 - NOT filler00/01) and separate them with commas, like you would on a trade form.";
cardInputOverlay.appendChild(cardDir);
//textarea
const cardInput = document.createElement("textarea");
cardInputOverlay.appendChild(cardInput);
//counting button
const cardBtn = document.createElement("input");
cardBtn.setAttribute("type", "button");
cardBtn.setAttribute("value", "Count!");
cardBtn.addEventListener("click", () => {
const val = cardInput.value;
countText.textContent = `${val.split(",").length} cards`;
});
cardInputOverlay.appendChild(cardBtn);
//number of cards
const countText = document.createElement("span");
countText.setAttribute("id", "countText");
countText.textContent = `0 cards`;
cardInputOverlay.appendChild(countText);
//close button
const closeBtn = document.createElement("input");
closeBtn.setAttribute("type", "button");
closeBtn.setAttribute("value", "X");
closeBtn.addEventListener("click", () => {
cardInputOverlay.remove()
});
cardInputOverlay.appendChild(closeBtn);