-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodigofuente.html
More file actions
317 lines (270 loc) · 8.81 KB
/
codigofuente.html
File metadata and controls
317 lines (270 loc) · 8.81 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Plantillas</title>
<style>
body {
margin: 0;
font-family: Calibri;
overflow: scroll;
}
h1 {
width: fit-content;
margin: auto;
margin-top: 1%;
margin-bottom: 1%;
}
h2 {
text-align: center;
margin-top: 0;
background-color: rgb(32, 55, 100);
color: white;
margin-bottom: 0;
}
table {
display: inline-block;
border: 1px rgb(32, 55, 100) solid;
border-collapse: collapse;
table-layout: fixed;
width: fit-content;
height: fit-content;
margin: 5px;
}
td, th {
border: 1px black solid;
padding: 8px;
overflow-wrap: break-word;
white-space: normal;
text-align: center;
}
th {
width: 80px;
}
td {
background-color: aliceblue;
}
.tooltip {
position: absolute;
background-color: #333;
color: #fff;
padding: 6px 10px;
border-radius: 4px;
font-size: 0.9rem;
pointer-events: none;
white-space: pre-line;
display: none;
z-index: 1000;
}
.bigCategory {
background-color: #bebebe;
width: fit-content;
max-width: 30%;
height: fit-content;
margin: 20px;
}
#big-container {
width: 100vw;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
#dark-mode-button {
position: absolute;
border-radius: 100%;
top: 1vh;
right: 2.5vw;
width: 50px;
height: 50px;
}
#excel-icon{
position: absolute;
top: 0.1vh;
right: 5vw;
width: 120px;
height: 70px;
}
</style>
</head>
<body>
<h1>PLANTILLAS SOPORTE REMOTO</h1>
<div id="big-container"></div>
<div id="tooltip" class="tooltip"></div>
<div id="contacto"></div>
<div id="dark-mode-button"></div>
<img id="excel-icon" src="https://download.logo.wine/logo/Microsoft_Excel/Microsoft_Excel-Logo.wine.png">
<script src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js"></script>
<script>
//////////////////////////
// EXCEL FETCHING STUFF //
//////////////////////////
const fileNames = ["plantillas.xlsx"];
fileNames.forEach((name) => {
fetch(name)
.then((res) => {
if (!res.ok) throw new Error("📁 File not found!");
return res.arrayBuffer();
})
.then((buf) => {
const workbook = XLSX.read(buf, { type: "array" });
const sheet = workbook.Sheets[workbook.SheetNames[0]];
const rowWise = XLSX.utils.sheet_to_json(sheet, { header: 1 });
// Remove trailing empty rows
while (rowWise.length && rowWise[rowWise.length - 1].every(cell => !cell)) {
rowWise.pop();
}
// Check if the Excel is empty
if (rowWise.length === 0) {
alert("❗ The Excel file is empty or malformed.");
return;
}
const maxCols = Math.max(...rowWise.map(r => r.length));
const colWise = Array.from({ length: maxCols }, (_, col) =>
rowWise.map(row => row[col] ?? "")
);
const colLengths = colWise.map(colArr =>
colArr.filter(cell => cell !== "").length
);
colWise.forEach((col, i) => {
const length = colLengths[i];
const category = col[3];
const bigCategory = col[2];
// Ignore empty columns
if (length === 0) return;
// Remove the "Categoria grande" category
if (!category || !bigCategory || bigCategory === "Categoria grande") return;
const bigContainer = document.getElementById("big-container");
const tooltip = document.getElementById("tooltip");
// Create section if needed
let section = document.getElementById(bigCategory);
if (!section) {
section = document.createElement("div");
section.id = bigCategory;
section.className = "bigCategory";
section.innerHTML = `<h2>${bigCategory}</h2>`;
bigContainer.appendChild(section);
}
// Create a table per column with this format
const table = document.createElement("table");
table.innerHTML = `
<tr>
<th rowspan="2">${category}</th>
<td id="${category}-entera">Plantilla entera</td>
<td id="${category}-pie">Pie de página</td>
</tr>
<tr>
<td id="${category}-full">Full template</td>
<td id="${category}-footer">Footer</td>
</tr>
`;
// Store the color and textColor rows into arrays
var colors = [];
var textColors = [];
for (let i = 0; i < colWise.length; i++){
colors.push(colWise[i][1]);
textColors.push(colWise[i][0]);
}
// Assign each color from colors[] & textColors[] to each 'th'
const th = table.querySelector("th");
th.style.backgroundColor = colors[i % colors.length];
th.style.color = textColors[i % textColors.length];
section.appendChild(table);
// Assign the templates to each td as a property
const tds = table.querySelectorAll("td");
if (length == 8) {
tds[0].dataset.secret = col[4];
tds[1].dataset.secret = col[6];
tds[2].dataset.secret = col[5];
tds[3].dataset.secret = col[7];
} else if (length == 6) { // If there's only 2 templates, hide 2 of the 4 tds
tds[0].dataset.secret = col[4];
tds[1].style.display = "none";
tds[2].dataset.secret = col[5];
tds[3].style.display = "none";
}
///////////////
// DARK MODE //
///////////////
let isDarkMode = localStorage.getItem("darkMode") === "true";
const title = document.getElementsByTagName("h1")[0];
const button = document.getElementById("dark-mode-button")
// Switches between 'Dark mode on' and 'Dark mode off'
function applyDarkMode() {
document.body.style.backgroundColor = isDarkMode ? "#282b30" : "#fff";
title.style.color = isDarkMode ? "white" : "black";
button.style.backgroundColor = isDarkMode ? "#F6F1D5" : "#FFDF22";
}
applyDarkMode();
// If button is clicked, run applyDarkMode()
button.addEventListener("click", () => {
isDarkMode = !isDarkMode;
localStorage.setItem("darkMode", isDarkMode);
applyDarkMode();
});
// If hover over button, change to pointer
button.addEventListener("mouseover", () => {
button.style.cursor = "pointer";
});
///////////////////
// MARCA DE AGUA //
///////////////////
title.addEventListener("mouseover", () => {
title.style.cursor = "pointer";
})
var clickCount = 0;
title.addEventListener("click", () => {
clickCount++;
if (clickCount > 18) {
title.innerHTML = "Website made by Alberto Costea :)";
}
if (clickCount > 28) {
title.innerHTML = "On the day 30/05/2025";
}
if (clickCount > 38) {
title.innerHTML = "Remember to drink water :P";
}
if (clickCount > 48) {
title.innerHTML = "PLANTILLAS SOPORTE REMOTO";
}
})
/////////////////////////////
// TEMPLATE MANAGING STUFF //
/////////////////////////////
// Template preview and copying
tds.forEach(td => {
// Show tooltip on hover
td.addEventListener("mouseover", () => {
tooltip.textContent = td.dataset.secret || "";
tooltip.style.display = "block";
td.style.cursor = "pointer";
td.style.textDecoration = "underline";
});
// Move the tooltip along with the mouse
td.addEventListener("mousemove", e => {
tooltip.style.left = `${e.pageX + 10}px`;
tooltip.style.top = `${e.pageY + 10}px`;
});
// Remove tooltip on hover out
td.addEventListener("mouseout", () => {
tooltip.style.display = "none";
td.style.textDecoration = "none";
});
// Copy template on click
td.addEventListener("click", () => {
navigator.clipboard.writeText(td.dataset.secret || "");
tooltip.textContent = "Plantilla copiada al portapapeles!";
setTimeout(() => tooltip.style.display = 'none', 1000);
});
});
});
})
// If error, show alert
.catch((err) => {
console.error("⚠️ Failed to load or parse Excel file:", err);
alert("❌ Error loading file: " + err.message);
});
});
</script>
</body>
</html>