-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
258 lines (214 loc) · 8.11 KB
/
script.js
File metadata and controls
258 lines (214 loc) · 8.11 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
/* BLUEPRINT-JS-START */
// 🚀 Auto-generado para python: 4/29/2026, 12:52:32 PM
'use strict';
console.log('✅ 22 funciones y 1 clases detectadas');
// Funciones interactivas
function demo_resource_path() {
console.log('▶️ Ejecutando: resource_path()');
alert('Función resource_path() ejecutada');
}
function demo_emit() {
console.log('▶️ Ejecutando: emit()');
alert('Función emit() ejecutada');
}
function demo_add_particles() {
console.log('▶️ Ejecutando: add_particles()');
alert('Función add_particles() ejecutada');
}
function demo_delete_particles() {
console.log('▶️ Ejecutando: delete_particles()');
alert('Función delete_particles() ejecutada');
}
function demo_semitone_ratio() {
console.log('▶️ Ejecutando: semitone_ratio()');
alert('Función semitone_ratio() ejecutada');
}
function demo_speed_ratio() {
console.log('▶️ Ejecutando: speed_ratio()');
alert('Función speed_ratio() ejecutada');
}
function demo_fexp() {
console.log('▶️ Ejecutando: fexp()');
alert('Función fexp() ejecutada');
}
function demo_fman() {
console.log('▶️ Ejecutando: fman()');
alert('Función fman() ejecutada');
}
function demo_decimal_sign() {
console.log('▶️ Ejecutando: decimal_sign()');
alert('Función decimal_sign() ejecutada');
}
function demo_abbreviate() {
console.log('▶️ Ejecutando: abbreviate()');
alert('Función abbreviate() ejecutada');
}
function demo_resetupgrades() {
console.log('▶️ Ejecutando: resetupgrades()');
alert('Función resetupgrades() ejecutada');
}
function demo_constrain() {
console.log('▶️ Ejecutando: constrain()');
alert('Función constrain() ejecutada');
}
function demo_PlayMusic() {
console.log('▶️ Ejecutando: PlayMusic()');
alert('Función PlayMusic() ejecutada');
}
function demo_save_game() {
console.log('▶️ Ejecutando: save_game()');
alert('Función save_game() ejecutada');
}
function demo_load_game() {
console.log('▶️ Ejecutando: load_game()');
alert('Función load_game() ejecutada');
}
function demo_reset() {
console.log('▶️ Ejecutando: reset()');
alert('Función reset() ejecutada');
}
function demo_checkenemyded() {
console.log('▶️ Ejecutando: checkenemyded()');
alert('Función checkenemyded() ejecutada');
}
function demo_draw_text() {
console.log('▶️ Ejecutando: draw_text()');
alert('Función draw_text() ejecutada');
}
function demo_prestige() {
console.log('▶️ Ejecutando: prestige()');
alert('Función prestige() ejecutada');
}
function demo_calcmax() {
console.log('▶️ Ejecutando: calcmax()');
alert('Función calcmax() ejecutada');
}
function demo_calcmax0() {
console.log('▶️ Ejecutando: calcmax0()');
alert('Función calcmax0() ejecutada');
}
function demo_distance_to() {
console.log('▶️ Ejecutando: distance_to()');
alert('Función distance_to() ejecutada');
}
// Clases detectadas
console.log('📦 Clase: ParticlePrinciple');
// 🛒 Lógica de Tienda Automática con MockServer
function addToCart(product, price) {
const item = {
product,
price,
date: new Date().toLocaleString()
};
if (window.MockServer) {
MockServer.save('orders', item);
console.log('📦 Pedido guardado:', item);
// Disparar evento para actualizar historial
window.dispatchEvent(new CustomEvent('orderUpdated'));
} else {
alert('¡' + product + ' añadido al carrito!');
}
updateCartUI();
}
function updateCartUI() {
const badge = document.getElementById('cart-badge');
if (badge && window.MockServer) {
badge.innerText = MockServer.get('orders').length;
}
}
console.log('🛍️ Sistema de Tienda Pro con Persistencia listo.');
// 📜 Sistema de Historial de Pedidos Automático
window.StoreHistory = {
init() {
console.log('📜 Historial de Tienda Activado');
this.render();
// Escuchar actualizaciones de pedidos
window.addEventListener('orderUpdated', () => this.render());
// También refrescar periódicamente o si cambia localStorage
window.addEventListener('storage', () => this.render());
},
render() {
const historyList = document.getElementById('order-history-list');
if (!historyList || !window.MockServer) return;
const orders = MockServer.get('orders').reverse(); // Ver los más nuevos primero
if (orders.length === 0) {
historyList.innerHTML = '<p style="color: #666; font-style: italic;">No hay pedidos registrados aún.</p>';
return;
}
let html = '<table class="history-table">';
html += '<thead><tr><th>Fecha</th><th>Producto</th><th>Precio</th><th>Acción</th></tr></thead>';
html += '<tbody>';
orders.forEach(order => {
html += '<tr>';
html += '<td>' + order.date + '</td>';
html += '<td style="font-weight: bold;">' + order.product + '</td>';
html += '<td style="color: #10b981; font-weight: bold;">' + order.price + '</td>';
html += '<td><button class="btn-delete-sm" onclick="MockServer.delete(\'orders\', \'' + order.id_uuid + '\'); window.dispatchEvent(new CustomEvent(\'orderUpdated\'));">🗑️</button></td>';
html += '</tr>';
});
html += '</tbody></table>';
historyList.innerHTML = html;
console.log('✅ Historial renderizado:', orders.length, 'pedidos');
}
};
document.addEventListener('DOMContentLoaded', () => StoreHistory.init());
// 🧬 Servidor Universal de Datos (Multi-Use)
window.MockServer = {
save(collection, data) {
const items = JSON.parse(localStorage.getItem(collection) || '[]');
items.push({ ...data, id_uuid: Math.random().toString(36).substr(2, 9) });
localStorage.setItem(collection, JSON.stringify(items));
console.log('📁 Guardado en ['+collection+']:', data);
if (window.AdminConsole) AdminConsole.refresh();
},
get(collection) {
return JSON.parse(localStorage.getItem(collection) || '[]');
},
delete(collection, id) {
const items = this.get(collection).filter(i => i.id_uuid !== id);
localStorage.setItem(collection, JSON.stringify(items));
if (window.AdminConsole) AdminConsole.refresh();
},
clear(collection) {
localStorage.removeItem(collection);
if (window.AdminConsole) AdminConsole.refresh();
}
};
// 🛠️ Consola de Administración Visual
window.AdminConsole = {
isOpen: false,
init() {
const btn = document.createElement('div');
btn.id = 'admin-btn'; btn.innerHTML = '🛠️';
btn.onclick = () => this.toggle();
document.body.appendChild(btn);
const panel = document.createElement('div');
panel.id = 'admin-panel';
panel.innerHTML = '<h3>🛠️ Admin Console</h3><div id="admin-content"></div><button onclick="AdminConsole.toggle()">Cerrar</button>';
document.body.appendChild(panel);
this.refresh();
},
toggle() {
this.isOpen = !this.isOpen;
document.getElementById('admin-panel').style.display = this.isOpen ? 'block' : 'none';
},
refresh() {
const content = document.getElementById('admin-content');
if (!content) return;
let html = '';
const collections = ['orders', 'highscores', 'logs', 'users'];
collections.forEach(c => {
const data = MockServer.get(c);
if (data.length > 0) {
html += '<h4>'+c.toUpperCase()+' ('+data.length+')</h4><table>';
data.slice(-5).forEach(i => {
html += '<tr><td>'+JSON.stringify(i).substr(0,40)+'...</td><td><button onclick="MockServer.delete(\''+c+'\', \''+i.id_uuid+'\')">🗑️</button></td></tr>';
});
html += '</table>';
}
});
content.innerHTML = html || '<p>Esperando datos...</p>';
}
};
document.addEventListener('DOMContentLoaded', () => AdminConsole.init());
/* BLUEPRINT-JS-END */