-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
104 lines (97 loc) · 2.53 KB
/
index.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
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
102
103
104
const grid = document.getElementById("emojigrid"),
emojis = [],
emojitypes = [
"big_smile",
"cool",
"hmm",
"lol",
"mad",
"neutral",
"roll",
"smile",
"tongue",
"wink",
"yikes"
],
emojire = [
":D",
":cool:",
":/",
":lol:",
":mad:",
":|",
":rolleyes:",
":)",
":P",
";)",
":o"
]
i = 0;
let width = document.getElementById("width").value,
height = document.getElementById("height").value;
function generateEmojis() {
width = document.getElementById("width").value;
height = document.getElementById("height").value;
grid.style.gridTemplateColumns = `repeat(${width}, 1fr)`;
grid.style.gridTemplateRows = `repeat(${height}, 1fr)`;
grid.innerHTML = "";
let eI = 0;
for (let i = 0; i < height; i++) {
for (let j = 0; j < width; j++) {
const img = document.createElement('img');
let currentIndex = 0;
img.src = `imgs/${emojitypes[currentIndex]}.png`;
img.addEventListener('click', () => {
currentIndex = (currentIndex + 1) % emojitypes.length;
img.src = `imgs/${emojitypes[currentIndex]}.png`;
img.setAttribute('data-emoji', emojire[currentIndex]);
});
img.setAttribute('data-emoji', emojire[currentIndex]);
img.style.display = "block";
img.style.marginLeft = "auto";
img.style.marginRight = "auto";
img.style.cursor = "pointer";
img.id = `e-img-${i}-${j}`;
grid.appendChild(img);
eI++;
if (eI >= emojitypes.length) {
eI = 0;
}
}
}
}
function parseGrid() {
document.getElementById("result").style.display = "block";
const bbcode = document.getElementById("bbcode");
const emojis = grid.querySelectorAll("img");
let parsedText = "";
let columnIndex = 1;
emojis.forEach((emoji, index) => {
parsedText += `${emoji.getAttribute("data-emoji")} `;
if (columnIndex >= width) {
parsedText += "\n"; // add a newline after each row
columnIndex = 1;
} else {
columnIndex++;
}
});
bbcode.value = parsedText.trim();
document.getElementById("result").style.display = "block";
}
const checkbox = document.getElementById('update-s');
checkbox.addEventListener('click', function() {
if (this.checked) {
checkBoxUpdate();
function checkBoxUpdate(){
parseGrid();
if (this.checked) {
}
setTimeout(checkBoxUpdate, 0010);
}
}
});
if (window.location.search) {
const param = new URLSearchParams(window.location.search);
const data = param.get("data");
} else {
}