Repository navigation
Expand file tree
/
Copy pathajustes.html
More file actions
214 lines (188 loc) · 8.01 KB
/
Copy pathajustes.html
File metadata and controls
214 lines (188 loc) · 8.01 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
<!DOCTYPE html>
<html lang="es">
<head>
<link rel="stylesheet" href="estilos.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Backtesting - Ajustes</title>
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" sizes="192x192" href="Logo_app_trading-removebg-preview.png">
<link rel="icon" type="image/png" sizes="512x512" href="Logo_app_trading-removebg-preview.png">
<style>
.username-setting {
display: flex;
gap: 10px;
align-items: center;
margin-top: 10px;
}
.username-setting input {
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
width: 200px;
}
.username-setting .nav-btn {
padding: 8px 16px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
.username-setting .nav-btn:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Ajustes</h1>
<div id="datetime" class="datetime"></div>
</div>
<div class="settings-container">
<div class="settings-section">
<h3>Tema de la Aplicación</h3>
<div class="theme-options">
<label>
<input type="radio" name="theme" value="light" id="theme-light">
Tema Claro
</label>
<label>
<input type="radio" name="theme" value="dark" id="theme-dark">
Tema Oscuro
</label>
</div>
</div>
<div class="settings-section">
<h3>Meta</h3>
<div class="goal-setting">
<div class="period-selector">
<label>Período:</label>
<select id="goal-period">
<option value="daily">Diaria</option>
<option value="weekly">Semanal</option>
<option value="monthly">Mensual</option>
<option value="yearly">Anual</option>
</select>
</div>
<input type="number" id="monthly-goal" min="0" step="100" placeholder="Ingrese su meta">
<button id="save-goal" class="nav-btn">Guardar Meta</button>
</div>
</div>
<div class="settings-section">
<h3>Nombre de Usuario</h3>
<div class="username-setting">
<input type="text" id="username" placeholder="Ingrese su nombre">
<button id="save-username" class="nav-btn">Guardar Nombre</button>
</div>
</div>
<div class="settings-section">
<h3>Capital Inicial del Broker</h3>
<div class="capital-setting">
<input type="number" id="initial-capital" min="0" step="1000" placeholder="Ingrese su capital inicial">
<button id="save-capital" class="nav-btn">Guardar Capital</button>
</div>
</div>
</div>
<div class="navigation-buttons">
<button class="nav-btn" onclick="window.location.href='index.html'">Volver al Inicio</button>
</div>
</div>
<script src="javascript.js"></script>
<script>
// Actualizar fecha y hora
function updateDateTime() {
const now = new Date();
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
};
document.getElementById('datetime').textContent = now.toLocaleDateString('es-ES', options);
}
setInterval(updateDateTime, 1000);
updateDateTime();
// Función para establecer una cookie
function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}
// Función para obtener una cookie
function getCookie(name) {
const nameEQ = name + "=";
const ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
// Cargar configuración guardada
function loadSettings() {
const theme = getCookie('theme') || 'light';
document.getElementById(`theme-${theme}`).checked = true;
document.body.className = theme;
const monthlyGoal = getCookie('monthlyGoal') || '10000';
document.getElementById('monthly-goal').value = monthlyGoal;
const goalPeriod = getCookie('goalPeriod') || 'monthly';
document.getElementById('goal-period').value = goalPeriod;
// Cargar capital inicial
const initialCapital = localStorage.getItem('initialCapital') || '100000';
document.getElementById('initial-capital').value = initialCapital;
// Cargar nombre de usuario
const username = localStorage.getItem('username') || '';
document.getElementById('username').value = username;
}
// Guardar configuración
function saveSettings() {
const selectedTheme = document.querySelector('input[name="theme"]:checked').value;
setCookie('theme', selectedTheme, 365);
document.body.className = selectedTheme;
const monthlyGoal = document.getElementById('monthly-goal').value;
setCookie('monthlyGoal', monthlyGoal, 365);
const goalPeriod = document.getElementById('goal-period').value;
setCookie('goalPeriod', goalPeriod, 365);
alert('Configuración guardada exitosamente');
}
// Función para guardar el capital inicial
function saveInitialCapital() {
const initialCapital = document.getElementById('initial-capital').value;
if (initialCapital && initialCapital > 0) {
localStorage.setItem('initialCapital', initialCapital);
alert('Capital inicial guardado exitosamente');
} else {
alert('Por favor ingrese un valor válido para el capital inicial');
}
}
// Función para guardar el nombre de usuario
function saveUsername() {
const username = document.getElementById('username').value;
if (username && username.trim() !== '') {
localStorage.setItem('username', username);
alert('Nombre de usuario guardado exitosamente');
} else {
alert('Por favor ingrese un nombre de usuario válido');
}
}
// Event Listeners
document.querySelectorAll('input[name="theme"]').forEach(radio => {
radio.addEventListener('change', saveSettings);
});
document.getElementById('save-goal').addEventListener('click', saveSettings);
document.getElementById('save-capital').addEventListener('click', saveInitialCapital);
document.getElementById('save-username').addEventListener('click', saveUsername);
// Cargar configuración al iniciar
loadSettings();
</script>
</body>
</html>