ainjbbck commited on
Commit
b8a4283
·
verified ·
1 Parent(s): 8cbc9c1

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +706 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Math
3
- emoji: 🐠
4
- colorFrom: red
5
- colorTo: pink
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: math
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: purple
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,706 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Calculatrice Graphique TI-89</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10
+ <style>
11
+ body {
12
+ font-family: 'Courier New', monospace;
13
+ background-color: #f0f0f0;
14
+ }
15
+ .calculator-screen {
16
+ background-color: #e0f0d0;
17
+ color: #1a3b1a;
18
+ font-family: 'Courier New', monospace;
19
+ font-size: 1.2rem;
20
+ height: 120px;
21
+ }
22
+ .btn-primary {
23
+ background-color: #4a6ea9;
24
+ color: white;
25
+ }
26
+ .btn-secondary {
27
+ background-color: #6c757d;
28
+ color: white;
29
+ }
30
+ .btn-function {
31
+ background-color: #5a6268;
32
+ color: white;
33
+ }
34
+ .btn-enter {
35
+ background-color: #28a745;
36
+ color: white;
37
+ }
38
+ .btn-clear {
39
+ background-color: #dc3545;
40
+ color: white;
41
+ }
42
+ .btn:hover {
43
+ filter: brightness(90%);
44
+ }
45
+ .btn:active {
46
+ transform: scale(0.98);
47
+ }
48
+ .graph-container {
49
+ background-color: white;
50
+ border: 1px solid #ddd;
51
+ }
52
+ .tab-active {
53
+ border-bottom: 3px solid #4a6ea9;
54
+ font-weight: bold;
55
+ }
56
+ </style>
57
+ </head>
58
+ <body class="bg-gray-100 min-h-screen">
59
+ <div class="container mx-auto px-4 py-8 max-w-4xl">
60
+ <!-- Header -->
61
+ <div class="flex justify-between items-center mb-6">
62
+ <div class="flex items-center">
63
+ <div class="w-10 h-10 bg-gray-800 rounded flex items-center justify-center mr-3">
64
+ <i class="fas fa-calculator text-white"></i>
65
+ </div>
66
+ <h1 class="text-2xl font-bold text-gray-800">TI-89 Graphique</h1>
67
+ </div>
68
+ <div class="text-sm text-gray-600">
69
+ <i class="fas fa-battery-three-quarters mr-1"></i>
70
+ <span>89%</span>
71
+ </div>
72
+ </div>
73
+
74
+ <!-- Calculator Body -->
75
+ <div class="bg-gray-800 rounded-lg shadow-xl overflow-hidden">
76
+ <!-- Screen Area -->
77
+ <div class="p-4 bg-gray-700">
78
+ <div class="calculator-screen rounded-lg p-3 mb-2 overflow-auto">
79
+ <div id="history" class="text-right text-sm h-1/3 overflow-hidden"></div>
80
+ <div id="display" class="text-right text-2xl h-2/3 font-semibold">0</div>
81
+ </div>
82
+ <div class="flex justify-between text-xs text-gray-300 mb-1">
83
+ <div>TI-89</div>
84
+ <div id="mode-indicator">ALG</div>
85
+ </div>
86
+ </div>
87
+
88
+ <!-- Tabs -->
89
+ <div class="flex border-b border-gray-600">
90
+ <button class="tab-btn px-4 py-2 text-white tab-active" data-tab="home">Accueil</button>
91
+ <button class="tab-btn px-4 py-2 text-gray-400" data-tab="graph">Graphique</button>
92
+ <button class="tab-btn px-4 py-2 text-gray-400" data-tab="math">Math</button>
93
+ <button class="tab-btn px-4 py-2 text-gray-400" data-tab="apps">Apps</button>
94
+ </div>
95
+
96
+ <!-- Home Tab Content -->
97
+ <div id="home-tab" class="tab-content p-4">
98
+ <!-- Second Function Row -->
99
+ <div class="grid grid-cols-6 gap-2 mb-2">
100
+ <button class="btn btn-secondary py-2 rounded" data-value="2nd">2nd</button>
101
+ <button class="btn btn-secondary py-2 rounded" data-value="mode">MODE</button>
102
+ <button class="btn btn-secondary py-2 rounded" data-value="del">DEL</button>
103
+ <button class="btn btn-secondary py-2 rounded" data-value="clear">CLEAR</button>
104
+ <button class="btn btn-secondary py-2 rounded" data-value="◄">◄</button>
105
+ <button class="btn btn-secondary py-2 rounded" data-value="►">►</button>
106
+ </div>
107
+
108
+ <!-- Alpha Row -->
109
+ <div class="grid grid-cols-6 gap-2 mb-2">
110
+ <button class="btn btn-secondary py-2 rounded" data-value="alpha">ALPHA</button>
111
+ <button class="btn btn-secondary py-2 rounded" data-value="x">X</button>
112
+ <button class="btn btn-secondary py-2 rounded" data-value="y">Y</button>
113
+ <button class="btn btn-secondary py-2 rounded" data-value="z">Z</button>
114
+ <button class="btn btn-secondary py-2 rounded" data-value="t">T</button>
115
+ <button class="btn btn-secondary py-2 rounded" data-value="θ">θ</button>
116
+ </div>
117
+
118
+ <!-- Main Keypad -->
119
+ <div class="grid grid-cols-5 gap-2">
120
+ <!-- First Column -->
121
+ <div class="grid grid-rows-5 gap-2">
122
+ <button class="btn btn-function py-2 rounded" data-value="sin">sin</button>
123
+ <button class="btn btn-function py-2 rounded" data-value="cos">cos</button>
124
+ <button class="btn btn-function py-2 rounded" data-value="tan">tan</button>
125
+ <button class="btn btn-function py-2 rounded" data-value="π">π</button>
126
+ <button class="btn btn-function py-2 rounded" data-value="^">^</button>
127
+ </div>
128
+
129
+ <!-- Second Column -->
130
+ <div class="grid grid-rows-5 gap-2">
131
+ <button class="btn btn-function py-2 rounded" data-value="ln">ln</button>
132
+ <button class="btn btn-function py-2 rounded" data-value="log">log</button>
133
+ <button class="btn btn-function py-2 rounded" data-value="√">√</button>
134
+ <button class="btn btn-function py-2 rounded" data-value="x²">x²</button>
135
+ <button class="btn btn-function py-2 rounded" data-value="EE">EE</button>
136
+ </div>
137
+
138
+ <!-- Third Column (Numbers) -->
139
+ <div class="grid grid-rows-5 gap-2 col-span-2">
140
+ <div class="grid grid-cols-3 gap-2">
141
+ <button class="btn btn-primary py-2 rounded" data-value="7">7</button>
142
+ <button class="btn btn-primary py-2 rounded" data-value="8">8</button>
143
+ <button class="btn btn-primary py-2 rounded" data-value="9">9</button>
144
+ </div>
145
+ <div class="grid grid-cols-3 gap-2">
146
+ <button class="btn btn-primary py-2 rounded" data-value="4">4</button>
147
+ <button class="btn btn-primary py-2 rounded" data-value="5">5</button>
148
+ <button class="btn btn-primary py-2 rounded" data-value="6">6</button>
149
+ </div>
150
+ <div class="grid grid-cols-3 gap-2">
151
+ <button class="btn btn-primary py-2 rounded" data-value="1">1</button>
152
+ <button class="btn btn-primary py-2 rounded" data-value="2">2</button>
153
+ <button class="btn btn-primary py-2 rounded" data-value="3">3</button>
154
+ </div>
155
+ <div class="grid grid-cols-3 gap-2">
156
+ <button class="btn btn-primary py-2 rounded" data-value="0">0</button>
157
+ <button class="btn btn-primary py-2 rounded" data-value=".">.</button>
158
+ <button class="btn btn-primary py-2 rounded" data-value="(-)">(-)</button>
159
+ </div>
160
+ <div class="grid grid-cols-3 gap-2">
161
+ <button class="btn btn-function py-2 rounded" data-value=",">,</button>
162
+ <button class="btn btn-function py-2 rounded" data-value="(">(</button>
163
+ <button class="btn btn-function py-2 rounded" data-value=")">)</button>
164
+ </div>
165
+ </div>
166
+
167
+ <!-- Fourth Column -->
168
+ <div class="grid grid-rows-5 gap-2">
169
+ <button class="btn btn-function py-2 rounded" data-value="÷">÷</button>
170
+ <button class="btn btn-function py-2 rounded" data-value="×">×</button>
171
+ <button class="btn btn-function py-2 rounded" data-value="-">-</button>
172
+ <button class="btn btn-function py-2 rounded" data-value="+">+</button>
173
+ <button class="btn btn-enter py-2 rounded" data-value="enter">ENTER</button>
174
+ </div>
175
+ </div>
176
+ </div>
177
+
178
+ <!-- Graph Tab Content (Hidden by default) -->
179
+ <div id="graph-tab" class="tab-content hidden p-4">
180
+ <div class="mb-4">
181
+ <div class="graph-container rounded-lg p-4 mb-4">
182
+ <canvas id="graphCanvas" height="200"></canvas>
183
+ </div>
184
+ <div class="grid grid-cols-2 gap-4">
185
+ <div>
186
+ <label class="block text-white text-sm mb-1">Fonction Y1:</label>
187
+ <input type="text" id="functionInput" class="w-full px-3 py-2 rounded bg-gray-700 text-white" value="sin(x)">
188
+ </div>
189
+ <div>
190
+ <label class="block text-white text-sm mb-1">Plage X:</label>
191
+ <div class="flex gap-2">
192
+ <input type="number" class="w-1/2 px-3 py-2 rounded bg-gray-700 text-white" value="-10" step="1" id="xMin">
193
+ <input type="number" class="w-1/2 px-3 py-2 rounded bg-gray-700 text-white" value="10" step="1" id="xMax">
194
+ </div>
195
+ </div>
196
+ </div>
197
+ </div>
198
+ <div class="grid grid-cols-3 gap-2">
199
+ <button class="btn btn-secondary py-2 rounded" id="plotBtn">Tracer</button>
200
+ <button class="btn btn-secondary py-2 rounded" id="zoomInBtn">Zoom +</button>
201
+ <button class="btn btn-secondary py-2 rounded" id="zoomOutBtn">Zoom -</button>
202
+ </div>
203
+ </div>
204
+
205
+ <!-- Math Tab Content (Hidden by default) -->
206
+ <div id="math-tab" class="tab-content hidden p-4">
207
+ <div class="bg-gray-700 rounded-lg p-4 mb-4">
208
+ <h3 class="text-white font-bold mb-2">Outils Mathématiques</h3>
209
+ <div class="grid grid-cols-3 gap-2">
210
+ <button class="btn btn-function py-2 rounded" data-value="∫">∫</button>
211
+ <button class="btn btn-function py-2 rounded" data-value="d/dx">d/dx</button>
212
+ <button class="btn btn-function py-2 rounded" data-value="∑">∑</button>
213
+ <button class="btn btn-function py-2 rounded" data-value="lim">lim</button>
214
+ <button class="btn btn-function py-2 rounded" data-value="∞">∞</button>
215
+ <button class="btn btn-function py-2 rounded" data-value="∠">∠</button>
216
+ </div>
217
+ </div>
218
+ <div class="text-white text-sm">
219
+ <p>Utilisez les touches mathématiques pour les calculs avancés :</p>
220
+ <ul class="list-disc pl-5 mt-2">
221
+ <li>Calcul intégral (∫)</li>
222
+ <li>Dérivées (d/dx)</li>
223
+ <li>Sommes (∑)</li>
224
+ <li>Limites (lim)</li>
225
+ </ul>
226
+ </div>
227
+ </div>
228
+
229
+ <!-- Apps Tab Content (Hidden by default) -->
230
+ <div id="apps-tab" class="tab-content hidden p-4">
231
+ <div class="grid grid-cols-3 gap-4">
232
+ <button class="btn btn-secondary py-4 rounded flex flex-col items-center">
233
+ <i class="fas fa-table text-xl mb-1"></i>
234
+ <span class="text-xs">Tableur</span>
235
+ </button>
236
+ <button class="btn btn-secondary py-4 rounded flex flex-col items-center">
237
+ <i class="fas fa-cube text-xl mb-1"></i>
238
+ <span class="text-xs">3D Graph</span>
239
+ </button>
240
+ <button class="btn btn-secondary py-4 rounded flex flex-col items-center">
241
+ <i class="fas fa-calculator text-xl mb-1"></i>
242
+ <span class="text-xs">Solveur</span>
243
+ </button>
244
+ <button class="btn btn-secondary py-4 rounded flex flex-col items-center">
245
+ <i class="fas fa-code text-xl mb-1"></i>
246
+ <span class="text-xs">Programme</span>
247
+ </button>
248
+ <button class="btn btn-secondary py-4 rounded flex flex-col items-center">
249
+ <i class="fas fa-list-ol text-xl mb-1"></i>
250
+ <span class="text-xs">Stats</span>
251
+ </button>
252
+ <button class="btn btn-secondary py-4 rounded flex flex-col items-center">
253
+ <i class="fas fa-exchange-alt text-xl mb-1"></i>
254
+ <span class="text-xs">Base</span>
255
+ </button>
256
+ </div>
257
+ </div>
258
+ </div>
259
+
260
+ <!-- Footer -->
261
+ <div class="mt-6 text-center text-sm text-gray-600">
262
+ <p>Calculatrice graphique inspirée de la TI-89 - Fonctionne dans le navigateur</p>
263
+ </div>
264
+ </div>
265
+
266
+ <script>
267
+ // Calculator logic
268
+ let currentInput = '0';
269
+ let previousInput = '';
270
+ let operation = null;
271
+ let resetScreen = false;
272
+ let isGraphMode = false;
273
+ let currentMode = 'ALG'; // ALG or RPN
274
+
275
+ // DOM Elements
276
+ const display = document.getElementById('display');
277
+ const history = document.getElementById('history');
278
+ const modeIndicator = document.getElementById('mode-indicator');
279
+ const functionInput = document.getElementById('functionInput');
280
+ const plotBtn = document.getElementById('plotBtn');
281
+ const zoomInBtn = document.getElementById('zoomInBtn');
282
+ const zoomOutBtn = document.getElementById('zoomOutBtn');
283
+ const graphCanvas = document.getElementById('graphCanvas');
284
+
285
+ // Chart instance
286
+ let graphChart = null;
287
+
288
+ // Initialize calculator
289
+ function initCalculator() {
290
+ updateDisplay();
291
+
292
+ // Setup tabs
293
+ document.querySelectorAll('.tab-btn').forEach(btn => {
294
+ btn.addEventListener('click', () => {
295
+ const tab = btn.getAttribute('data-tab');
296
+ switchTab(tab);
297
+ });
298
+ });
299
+
300
+ // Setup buttons
301
+ document.querySelectorAll('.btn').forEach(btn => {
302
+ if (btn.getAttribute('data-value')) {
303
+ btn.addEventListener('click', () => {
304
+ const value = btn.getAttribute('data-value');
305
+ handleButtonPress(value);
306
+ });
307
+ }
308
+ });
309
+
310
+ // Special buttons
311
+ document.getElementById('plotBtn').addEventListener('click', plotGraph);
312
+ document.getElementById('zoomInBtn').addEventListener('click', () => zoomGraph(0.5));
313
+ document.getElementById('zoomOutBtn').addEventListener('click', () => zoomGraph(2));
314
+ }
315
+
316
+ // Switch between tabs
317
+ function switchTab(tab) {
318
+ // Hide all tab contents
319
+ document.querySelectorAll('.tab-content').forEach(content => {
320
+ content.classList.add('hidden');
321
+ });
322
+
323
+ // Show selected tab content
324
+ document.getElementById(`${tab}-tab`).classList.remove('hidden');
325
+
326
+ // Update active tab button
327
+ document.querySelectorAll('.tab-btn').forEach(btn => {
328
+ if (btn.getAttribute('data-tab') === tab) {
329
+ btn.classList.remove('text-gray-400');
330
+ btn.classList.add('text-white', 'tab-active');
331
+ } else {
332
+ btn.classList.add('text-gray-400');
333
+ btn.classList.remove('text-white', 'tab-active');
334
+ }
335
+ });
336
+
337
+ // Special handling for graph tab
338
+ isGraphMode = (tab === 'graph');
339
+ if (isGraphMode && !graphChart) {
340
+ initGraph();
341
+ }
342
+ }
343
+
344
+ // Handle button presses
345
+ function handleButtonPress(value) {
346
+ if (isGraphMode) return;
347
+
348
+ switch(value) {
349
+ case '0':
350
+ case '1':
351
+ case '2':
352
+ case '3':
353
+ case '4':
354
+ case '5':
355
+ case '6':
356
+ case '7':
357
+ case '8':
358
+ case '9':
359
+ inputNumber(value);
360
+ break;
361
+ case '.':
362
+ inputDecimal();
363
+ break;
364
+ case '(-)':
365
+ toggleSign();
366
+ break;
367
+ case '+':
368
+ case '-':
369
+ case '×':
370
+ case '÷':
371
+ case '^':
372
+ setOperation(value);
373
+ break;
374
+ case 'enter':
375
+ calculate();
376
+ break;
377
+ case 'clear':
378
+ clearAll();
379
+ break;
380
+ case 'del':
381
+ deleteLastChar();
382
+ break;
383
+ case '◄':
384
+ case '►':
385
+ // Navigation - not implemented
386
+ break;
387
+ case '2nd':
388
+ // Second function - not implemented
389
+ break;
390
+ case 'mode':
391
+ toggleMode();
392
+ break;
393
+ case 'alpha':
394
+ // Alpha mode - not implemented
395
+ break;
396
+ case 'sin':
397
+ case 'cos':
398
+ case 'tan':
399
+ case 'ln':
400
+ case 'log':
401
+ case '√':
402
+ case 'x²':
403
+ case 'π':
404
+ case 'EE':
405
+ case '∫':
406
+ case 'd/dx':
407
+ case '∑':
408
+ case 'lim':
409
+ case '∞':
410
+ case '∠':
411
+ inputFunction(value);
412
+ break;
413
+ case '(':
414
+ case ')':
415
+ case ',':
416
+ inputSpecialChar(value);
417
+ break;
418
+ case 'x':
419
+ case 'y':
420
+ case 'z':
421
+ case 't':
422
+ case 'θ':
423
+ inputVariable(value);
424
+ break;
425
+ }
426
+ }
427
+
428
+ // Input a number
429
+ function inputNumber(number) {
430
+ if (currentInput === '0' || resetScreen) {
431
+ currentInput = number;
432
+ resetScreen = false;
433
+ } else {
434
+ currentInput += number;
435
+ }
436
+ updateDisplay();
437
+ }
438
+
439
+ // Input a decimal point
440
+ function inputDecimal() {
441
+ if (resetScreen) {
442
+ currentInput = '0.';
443
+ resetScreen = false;
444
+ } else if (!currentInput.includes('.')) {
445
+ currentInput += '.';
446
+ }
447
+ updateDisplay();
448
+ }
449
+
450
+ // Toggle sign
451
+ function toggleSign() {
452
+ if (currentInput.startsWith('-')) {
453
+ currentInput = currentInput.substring(1);
454
+ } else {
455
+ currentInput = '-' + currentInput;
456
+ }
457
+ updateDisplay();
458
+ }
459
+
460
+ // Set operation
461
+ function setOperation(op) {
462
+ if (operation !== null) calculate();
463
+ previousInput = currentInput;
464
+ operation = op;
465
+ resetScreen = true;
466
+ updateDisplay();
467
+ }
468
+
469
+ // Calculate result
470
+ function calculate() {
471
+ if (operation === null || resetScreen) return;
472
+
473
+ let result;
474
+ const prev = parseFloat(previousInput);
475
+ const current = parseFloat(currentInput);
476
+
477
+ switch(operation) {
478
+ case '+':
479
+ result = prev + current;
480
+ break;
481
+ case '-':
482
+ result = prev - current;
483
+ break;
484
+ case '×':
485
+ result = prev * current;
486
+ break;
487
+ case '÷':
488
+ result = prev / current;
489
+ break;
490
+ case '^':
491
+ result = Math.pow(prev, current);
492
+ break;
493
+ default:
494
+ return;
495
+ }
496
+
497
+ // Add to history
498
+ addToHistory(`${previousInput} ${operation} ${currentInput} = ${result}`);
499
+
500
+ currentInput = result.toString();
501
+ operation = null;
502
+ resetScreen = true;
503
+ updateDisplay();
504
+ }
505
+
506
+ // Clear all
507
+ function clearAll() {
508
+ currentInput = '0';
509
+ previousInput = '';
510
+ operation = null;
511
+ history.innerHTML = '';
512
+ updateDisplay();
513
+ }
514
+
515
+ // Delete last character
516
+ function deleteLastChar() {
517
+ if (currentInput.length === 1 || (currentInput.length === 2 && currentInput.startsWith('-'))) {
518
+ currentInput = '0';
519
+ } else {
520
+ currentInput = currentInput.slice(0, -1);
521
+ }
522
+ updateDisplay();
523
+ }
524
+
525
+ // Toggle mode (ALG/RPN)
526
+ function toggleMode() {
527
+ currentMode = currentMode === 'ALG' ? 'RPN' : 'ALG';
528
+ modeIndicator.textContent = currentMode;
529
+ // In a real implementation, you would change the calculator logic here
530
+ }
531
+
532
+ // Input a function
533
+ function inputFunction(func) {
534
+ if (resetScreen) {
535
+ currentInput = func + '(';
536
+ resetScreen = false;
537
+ } else {
538
+ currentInput += func + '(';
539
+ }
540
+ updateDisplay();
541
+ }
542
+
543
+ // Input special characters
544
+ function inputSpecialChar(char) {
545
+ if (resetScreen) {
546
+ currentInput = char;
547
+ resetScreen = false;
548
+ } else {
549
+ currentInput += char;
550
+ }
551
+ updateDisplay();
552
+ }
553
+
554
+ // Input variables
555
+ function inputVariable(varName) {
556
+ if (resetScreen) {
557
+ currentInput = varName;
558
+ resetScreen = false;
559
+ } else {
560
+ currentInput += varName;
561
+ }
562
+ updateDisplay();
563
+ }
564
+
565
+ // Add to history
566
+ function addToHistory(entry) {
567
+ const historyEntry = document.createElement('div');
568
+ historyEntry.textContent = entry;
569
+ history.appendChild(historyEntry);
570
+ history.scrollTop = history.scrollHeight;
571
+ }
572
+
573
+ // Update display
574
+ function updateDisplay() {
575
+ display.textContent = currentInput;
576
+ }
577
+
578
+ // Graph functions
579
+ function initGraph() {
580
+ if (graphChart) {
581
+ graphChart.destroy();
582
+ }
583
+
584
+ const ctx = graphCanvas.getContext('2d');
585
+ graphChart = new Chart(ctx, {
586
+ type: 'line',
587
+ data: {
588
+ labels: [],
589
+ datasets: [{
590
+ label: 'Y1',
591
+ borderColor: 'rgb(75, 192, 192)',
592
+ borderWidth: 2,
593
+ fill: false,
594
+ data: [],
595
+ tension: 0.1
596
+ }]
597
+ },
598
+ options: {
599
+ responsive: true,
600
+ maintainAspectRatio: false,
601
+ scales: {
602
+ x: {
603
+ type: 'linear',
604
+ position: 'center',
605
+ title: {
606
+ display: true,
607
+ text: 'X'
608
+ }
609
+ },
610
+ y: {
611
+ type: 'linear',
612
+ position: 'center',
613
+ title: {
614
+ display: true,
615
+ text: 'Y'
616
+ }
617
+ }
618
+ },
619
+ plugins: {
620
+ legend: {
621
+ display: false
622
+ }
623
+ }
624
+ }
625
+ });
626
+ }
627
+
628
+ function plotGraph() {
629
+ const funcStr = functionInput.value;
630
+ const xMin = parseFloat(document.getElementById('xMin').value);
631
+ const xMax = parseFloat(document.getElementById('xMax').value);
632
+
633
+ if (xMin >= xMax) {
634
+ alert("La valeur minimale de X doit être inférieure à la valeur maximale");
635
+ return;
636
+ }
637
+
638
+ // Generate data points
639
+ const step = (xMax - xMin) / 100;
640
+ const labels = [];
641
+ const data = [];
642
+
643
+ for (let x = xMin; x <= xMax; x += step) {
644
+ try {
645
+ // WARNING: Using eval is dangerous and should be avoided in production
646
+ // This is just for demonstration purposes
647
+ const y = evaluateFunction(funcStr, x);
648
+ labels.push(x);
649
+ data.push(y);
650
+ } catch (e) {
651
+ console.error("Erreur d'évaluation:", e);
652
+ }
653
+ }
654
+
655
+ // Update chart
656
+ graphChart.data.labels = labels;
657
+ graphChart.data.datasets[0].data = data;
658
+ graphChart.data.datasets[0].label = `Y1 = ${funcStr}`;
659
+ graphChart.update();
660
+ }
661
+
662
+ function zoomGraph(factor) {
663
+ const xMinInput = document.getElementById('xMin');
664
+ const xMaxInput = document.getElementById('xMax');
665
+
666
+ let xMin = parseFloat(xMinInput.value);
667
+ let xMax = parseFloat(xMaxInput.value);
668
+ const center = (xMin + xMax) / 2;
669
+ const range = (xMax - xMin) * factor;
670
+
671
+ xMin = center - range/2;
672
+ xMax = center + range/2;
673
+
674
+ xMinInput.value = xMin;
675
+ xMaxInput.value = xMax;
676
+
677
+ plotGraph();
678
+ }
679
+
680
+ // Simple function evaluator (very limited)
681
+ function evaluateFunction(funcStr, x) {
682
+ // Replace '^' with '**' for exponentiation
683
+ const expr = funcStr
684
+ .replace(/x/g, `(${x})`)
685
+ .replace(/\^/g, '**')
686
+ .replace(/sin/g, 'Math.sin')
687
+ .replace(/cos/g, 'Math.cos')
688
+ .replace(/tan/g, 'Math.tan')
689
+ .replace(/ln/g, 'Math.log')
690
+ .replace(/log/g, 'Math.log10')
691
+ .replace(/√/g, 'Math.sqrt')
692
+ .replace(/π/g, 'Math.PI');
693
+
694
+ try {
695
+ return eval(expr);
696
+ } catch (e) {
697
+ console.error("Erreur d'évaluation:", e);
698
+ return NaN;
699
+ }
700
+ }
701
+
702
+ // Initialize calculator when DOM is loaded
703
+ document.addEventListener('DOMContentLoaded', initCalculator);
704
+ </script>
705
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=ainjbbck/math" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
706
+ </html>