-
Notifications
You must be signed in to change notification settings - Fork 0
/
p.html
394 lines (373 loc) · 15.1 KB
/
p.html
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Formulario de Prompts</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://preview.tabler.io//dist/libs/tinymce/tinymce.min.js?1695847769" defer></script>
<!-- Tabler Core -->
<script src="https://preview.tabler.io/dist/js/tabler.min.js?1695847769" defer></script>
<script src="https://preview.tabler.io/dist/js/demo.min.js?1695847769" defer></script>
<style>
/* Estilos para la barra de navegación */
.navbar {
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
}
.content {
margin-top: 80px;
/* Ajustar según la altura de la barra de navegación */
}
/* Estilos para el modo oscuro */
body {
background-color: transparent;
color: black;
}
body.dark-mode {
background-color: #333;
color: #fff;
}
.card {
background-color: transparent;
}
.modal-dialog.dark-mode {
background-color: #333;
color: #fff;
}
#buttonsContainer {
display: none;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<span class="navbar-brand mx-auto" href="#" data-toggle="modal" data-target="#addPromptModal">LAMP+</span>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link " id="phiphi-tab" data-toggle="tab" href="#phiphi" role="tab" aria-controls="phiphi" aria-selected="true">Inicio</a>
</li>
<li class="nav-item">
<a class="nav-link" id="eevee-tab" data-toggle="tab" href="#eevee" role="tab" aria-controls="eevee" aria-selected="false">Nuevos</a>
</li>
<li class="nav-item">
<a class="nav-link" id="sharon-tab" data-toggle="tab" href="#sharon" role="tab" aria-controls="sharon" aria-selected="false">Sugerencias</a>
</li>
<li class="nav-item">
<span id="downloadJson" class="nav-link">Descargar JSON</span>
</li>
<li class="nav-item" id="buttonToggle">
<span class="nav-link" onclick="toggleButtons()">Mostrar/Ocultar botones</span>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="darkModeDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Modo Oscuro
</a>
<div class="dropdown-menu" aria-labelledby="darkModeDropdown">
<a class="dropdown-item" href="#" id="darkModeOn">Encender</a>
<a class="dropdown-item" href="#" id="darkModeOff">Apagar</a>
</div>
</li>
</ul>
</div>
</nav>
<br>
<div class="container mt-5 content darkmode card">
<br>
<!-- h2 class="mt-5">Buscar y Filtrar</h2-->
<input type="text" id="search" class="form-control mb-3" placeholder="Buscar por nombre o descripción">
<select id="filter" class="form-control mb-3">
<option value="">Todos</option>
<option value="perfil">Perfil</option>
<option value="contenido">Contenido</option>
<option value="seo">SEO</option>
<option value="extra">Extra</option>
</select>
</div>
<div class="container">
<!-- Tab content -->
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="phiphi" role="tabpanel" aria-labelledby="phiphi-tab"><br>
<div id="records" class="row row-cards darkmode"></div><br>
</div>
<div class="tab-pane fade" id="sharon" role="tabpanel" aria-labelledby="sharon-tab">
<br>
<p>Sugerencias</p>
</div>
<div class="tab-pane fade" id="eevee" role="tabpanel" aria-labelledby="eevee-tab">
<br>
<p>Nuevos</p>
</div>
</div>
<!-- Modal for Adding and Editing Prompt -->
<div class="modal fade" id="addPromptModal" tabindex="-1" role="dialog" aria-labelledby="addPromptModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addPromptModalLabel">Agregar Prompt</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body ">
<form id="promptForm">
<div class="mb-3">
<label class="form-label" for="name">Prompt name</label>
<input type="text" id="name" required class="form-control" placeholder="Name">
</div>
<div class="mb-3">
<label class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="perfil" required>
<span class="form-check-label">Perfil</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="contenido">
<span class="form-check-label">Contenido</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="seo">
<span class="form-check-label">SEO</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="extra">
<span class="form-check-label">Extra</span>
</label>
</div>
<div class="mb-3">
<label class="form-label" for="description">Description</label>
<textarea id="tinymce-mytextarea" class="form-control" placeholder="Description"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
<button type="button" id="savePrompt" class="btn btn-primary">Guardar</button>
</div>
</div>
</div>
</div>
</div>
<!-- Modal for Deleting Prompt -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content ">
<div class="modal-header ">
<h5 class="modal-title" id="deleteModalLabel">Confirmar Eliminación</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body card">
¿Seguro que deseas borrar este prompt?
</div>
<div class="modal-footer ">
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
<button type="button" id="confirmDelete" class="btn btn-danger">Sí</button>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
tinymce.init({
selector: '#tinymce-mytextarea'
});
let prompts = JSON.parse(localStorage.getItem('prompts')) || [];
let deleteId = null;
let editId = null;
function renderPrompts() {
const recordsDiv = document.getElementById('records');
recordsDiv.innerHTML = '';
const search = document.getElementById('search').value.toLowerCase();
const filter = document.getElementById('filter').value;
const filteredPrompts = prompts.filter(prompt => {
return (prompt.name.toLowerCase().includes(search) || prompt.description.toLowerCase().includes(search)) &&
(filter === '' || prompt.type === filter);
});
filteredPrompts.forEach((prompt, index) => {
const card = document.createElement('div');
card.className = 'col-sm-6 col-lg-4';
card.innerHTML = `
<div class="card darkmode">
<div class="card-body">
<h5 class="card-title">${prompt.name}</h5>
<p class="card-text">${prompt.description}</p>
<p class="card-text"><small class="text-muted">${prompt.type}</small></p>
<div id="buttonsContainer"> <button class="btn btn-warning btn-sm" onclick="editPrompt(${index})">Editar</button>
<button class="btn btn-danger btn-sm" onclick="deletePrompt(${index})">Eliminar</button>
</div></div>
</div>
`;
recordsDiv.appendChild(card);
});
}
document.getElementById('savePrompt').addEventListener('click', function() {
const name = document.getElementById('name').value;
const type = document.querySelector('input[name="type"]:checked').value;
const description = tinymce.get('tinymce-mytextarea').getContent();
if (name && type && description) {
if (editId !== null) {
prompts[editId] = {
name,
type,
description
};
editId = null;
} else {
prompts.push({
name,
type,
description
});
}
localStorage.setItem('prompts', JSON.stringify(prompts));
$('#addPromptModal').modal('hide');
renderPrompts();
document.getElementById('promptForm').reset();
tinymce.get('tinymce-mytextarea').setContent('');
}
});
window.deletePrompt = function(index) {
deleteId = index;
$('#deleteModal').modal('show');
};
document.getElementById('confirmDelete').addEventListener('click', function() {
if (deleteId !== null) {
prompts.splice(deleteId, 1);
localStorage.setItem('prompts', JSON.stringify(prompts));
$('#deleteModal').modal('hide');
renderPrompts();
}
});
window.editPrompt = function(index) {
editId = index;
const prompt = prompts[index];
document.getElementById('name').value = prompt.name;
document.querySelector(`input[name="type"][value="${prompt.type}"]`).checked = true;
tinymce.get('tinymce-mytextarea').setContent(prompt.description);
$('#addPromptModal').modal('show');
};
document.getElementById('search').addEventListener('input', renderPrompts);
document.getElementById('filter').addEventListener('change', renderPrompts);
document.getElementById('downloadJson').addEventListener('click', function() {
const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(prompts));
const downloadAnchorNode = document.createElement('a');
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("download", "prompts.json");
document.body.appendChild(downloadAnchorNode);
downloadAnchorNode.click();
downloadAnchorNode.remove();
});
renderPrompts();
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
let prompts = JSON.parse(localStorage.getItem('prompts')) || [];
let deleteId = null;
let editId = null;
function renderPrompts() {
// rest of your renderPrompts function here
}
// Rest of your existing code for adding, editing, deleting prompts
// Dark mode functionality
const darkModeToggle = document.getElementById('darkModeDropdown');
const darkModeOn = document.getElementById('darkModeOn');
const darkModeOff = document.getElementById('darkModeOff');
darkModeOn.addEventListener('click', function() {
document.body.classList.add('dark-mode');
localStorage.setItem('darkMode', 'on');
});
darkModeOff.addEventListener('click', function() {
document.body.classList.remove('dark-mode');
localStorage.setItem('darkMode', 'off');
});
// Check local storage for dark mode preference
const darkMode = localStorage.getItem('darkMode');
if (darkMode === 'on') {
document.body.classList.add('dark-mode');
}
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
let buttonsVisible = false; // Variable para controlar el estado de visibilidad de los botones
let prompts = JSON.parse(localStorage.getItem('prompts')) || [];
function toggleButtons() {
buttonsVisible = !buttonsVisible; // Cambiar el estado de visibilidad
const buttonsContainer = document.querySelectorAll(".card #buttonsContainer");
buttonsContainer.forEach(container => {
container.style.display = buttonsVisible ? "block" : "none"; // Mostrar u ocultar los botones
});
}
// Resto de tu código aquí...
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
let buttonsVisible = false; // Variable para controlar el estado de visibilidad de los botones
let prompts = JSON.parse(localStorage.getItem('prompts')) || [];
const darkMode = localStorage.getItem('darkMode');
function toggleButtons() {
buttonsVisible = !buttonsVisible; // Cambiar el estado de visibilidad
const buttonsContainer = document.querySelectorAll("#buttonsContainer");
buttonsContainer.forEach(container => {
container.style.display = buttonsVisible ? "block" : "none"; // Mostrar u ocultar los botones
});
}
function renderPrompts() {
const recordsDiv = document.getElementById('records');
recordsDiv.innerHTML = '';
const search = document.getElementById('search').value.toLowerCase();
const filter = document.getElementById('filter').value;
const filteredPrompts = prompts.filter(prompt => {
return (prompt.name.toLowerCase().includes(search) || prompt.description.toLowerCase().includes(search)) &&
(filter === '' || prompt.type === filter);
});
filteredPrompts.forEach((prompt, index) => {
const card = document.createElement('div');
card.className = 'col-sm-6 col-lg-4';
card.innerHTML = `
<div class="card darkmode">
<div class="card-body">
<h5 class="card-title">${prompt.name}</h5>
<p class="card-text">${prompt.description}</p>
<p class="card-text"><small class="text-muted">${prompt.type}</small></p>
<div id="buttonsContainer"> <button class="btn btn-warning btn-sm" onclick="editPrompt(${index})">Editar</button>
<button class="btn btn-danger btn-sm" onclick="deletePrompt(${index})">Eliminar</button>
</div></div>
</div>
`;
recordsDiv.appendChild(card);
});
}
document.getElementById('buttonToggle').addEventListener('click', toggleButtons);
document.getElementById('search').addEventListener('input', renderPrompts);
document.getElementById('filter').addEventListener('change', renderPrompts);
const darkModeToggle = document.getElementById('darkModeDropdown');
const darkModeOn = document.getElementById('darkModeOn');
const darkModeOff = document.getElementById('darkModeOff');
darkModeOn.addEventListener('click', function() {
document.body.classList.add('dark-mode');
localStorage.setItem('darkMode', 'on');
});
darkModeOff.addEventListener('click', function() {
document.body.classList.remove('dark-mode');
localStorage.setItem('darkMode', 'off');
});
if (darkMode === 'on') {
document.body.classList.add('dark-mode');
}
renderPrompts(); // Renderizar los prompts al cargar la página
});
</script>
</body>
</html>