-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
34 lines (29 loc) · 1.54 KB
/
main.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
// Axel Cotón Gutiérrez Copyright 2023
document.addEventListener('DOMContentLoaded', () => {
const generateOutputBtn = document.getElementById('generate-output-btn');
const formattedJsonContainer = document.getElementById('formatted-json');
generateOutputBtn.addEventListener('click', () => {
const title = document.getElementById('concept-title').value.replace(/"/g, '\\"');
const source = document.getElementById('concept-source').value.replace(/"/g, '\\"');
const definition = document.getElementById('concept-definition').value.replace(/"/g, '\\"');
const description = document.getElementById('concept-description').value.replace(/"/g, '\\"');
const link = document.getElementById('concept-link').value.replace(/"/g, '\\"'); // Obtener el valor del enlace
const video = document.getElementById('concept-video').value.replace(/"/g, '\\"'); // Obtener el valor del vídeo
if (!title || !source || !definition || !description) {
alert('Por favor, complete todos los campos obligatorios.');
return;
}
const formattedJSON = `
{
"${title}": {
"title": "<h3 style='font-size: 3em;'>${title}</h3>",
"source": "<p style='color: #007BFF;'>${source}</p>",
"definition": "<p style='font-style: italic;'>${definition}</p>",
"description": "<p style='font-style: italic;'>${description}</p>",
"link": "${link}",
"video": "${video}"
}
}`;
formattedJsonContainer.textContent = formattedJSON;
});
});