akhaliq HF Staff commited on
Commit
679c2b0
·
verified ·
1 Parent(s): b69c523

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +514 -19
index.html CHANGED
@@ -1,19 +1,514 @@
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="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Modern Calculator</title>
7
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
8
+ <style>
9
+ :root {
10
+ --primary-color: #4a6bff;
11
+ --primary-hover: #3a5bef;
12
+ --secondary-color: #f8f9fa;
13
+ --text-color: #333;
14
+ --text-light: #666;
15
+ --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
16
+ --border-radius: 16px;
17
+ --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
18
+ }
19
+
20
+ * {
21
+ margin: 0;
22
+ padding: 0;
23
+ box-sizing: border-box;
24
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
25
+ }
26
+
27
+ body {
28
+ background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
29
+ min-height: 100vh;
30
+ display: flex;
31
+ justify-content: center;
32
+ align-items: center;
33
+ padding: 20px;
34
+ }
35
+
36
+ .calculator-container {
37
+ width: 100%;
38
+ max-width: 400px;
39
+ background: white;
40
+ border-radius: var(--border-radius);
41
+ box-shadow: var(--shadow);
42
+ overflow: hidden;
43
+ position: relative;
44
+ }
45
+
46
+ .header {
47
+ padding: 20px;
48
+ text-align: center;
49
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
50
+ }
51
+
52
+ .header h1 {
53
+ color: var(--text-color);
54
+ font-size: 1.5rem;
55
+ margin-bottom: 5px;
56
+ }
57
+
58
+ .header .subtitle {
59
+ color: var(--text-light);
60
+ font-size: 0.9rem;
61
+ }
62
+
63
+ .header .anycoder-link {
64
+ color: var(--primary-color);
65
+ text-decoration: none;
66
+ font-size: 0.8rem;
67
+ margin-top: 10px;
68
+ display: inline-block;
69
+ }
70
+
71
+ .display {
72
+ padding: 25px;
73
+ background: var(--secondary-color);
74
+ position: relative;
75
+ }
76
+
77
+ .display-input {
78
+ font-size: 2rem;
79
+ color: var(--text-color);
80
+ text-align: right;
81
+ margin-bottom: 5px;
82
+ height: 40px;
83
+ overflow: hidden;
84
+ white-space: nowrap;
85
+ text-overflow: ellipsis;
86
+ }
87
+
88
+ .display-result {
89
+ font-size: 1.2rem;
90
+ color: var(--text-light);
91
+ text-align: right;
92
+ height: 24px;
93
+ overflow: hidden;
94
+ white-space: nowrap;
95
+ text-overflow: ellipsis;
96
+ }
97
+
98
+ .buttons {
99
+ display: grid;
100
+ grid-template-columns: repeat(4, 1fr);
101
+ gap: 1px;
102
+ background: rgba(0, 0, 0, 0.05);
103
+ }
104
+
105
+ .btn {
106
+ border: none;
107
+ outline: none;
108
+ padding: 20px;
109
+ font-size: 1.2rem;
110
+ cursor: pointer;
111
+ background: white;
112
+ color: var(--text-color);
113
+ transition: var(--transition);
114
+ display: flex;
115
+ justify-content: center;
116
+ align-items: center;
117
+ }
118
+
119
+ .btn:hover {
120
+ background: rgba(74, 107, 255, 0.1);
121
+ }
122
+
123
+ .btn:active {
124
+ transform: scale(0.95);
125
+ }
126
+
127
+ .btn-operator {
128
+ color: var(--primary-color);
129
+ font-weight: bold;
130
+ }
131
+
132
+ .btn-operator:hover {
133
+ background: rgba(74, 107, 255, 0.2);
134
+ }
135
+
136
+ .btn-equals {
137
+ background: var(--primary-color);
138
+ color: white;
139
+ }
140
+
141
+ .btn-equals:hover {
142
+ background: var(--primary-hover);
143
+ }
144
+
145
+ .btn-clear {
146
+ color: #ff4d4f;
147
+ }
148
+
149
+ .btn-clear:hover {
150
+ background: rgba(255, 77, 79, 0.1);
151
+ }
152
+
153
+ .btn-span-2 {
154
+ grid-column: span 2;
155
+ }
156
+
157
+ .history-btn {
158
+ position: absolute;
159
+ top: 20px;
160
+ right: 20px;
161
+ background: none;
162
+ border: none;
163
+ color: var(--text-light);
164
+ font-size: 1rem;
165
+ cursor: pointer;
166
+ transition: var(--transition);
167
+ }
168
+
169
+ .history-btn:hover {
170
+ color: var(--primary-color);
171
+ }
172
+
173
+ .history-panel {
174
+ position: absolute;
175
+ top: 0;
176
+ right: 0;
177
+ width: 100%;
178
+ height: 100%;
179
+ background: white;
180
+ z-index: 10;
181
+ transform: translateX(100%);
182
+ transition: var(--transition);
183
+ padding: 20px;
184
+ overflow-y: auto;
185
+ }
186
+
187
+ .history-panel.active {
188
+ transform: translateX(0);
189
+ }
190
+
191
+ .history-header {
192
+ display: flex;
193
+ justify-content: space-between;
194
+ align-items: center;
195
+ margin-bottom: 20px;
196
+ }
197
+
198
+ .history-header h2 {
199
+ color: var(--text-color);
200
+ font-size: 1.2rem;
201
+ }
202
+
203
+ .history-close {
204
+ background: none;
205
+ border: none;
206
+ font-size: 1.5rem;
207
+ cursor: pointer;
208
+ color: var(--text-light);
209
+ }
210
+
211
+ .history-item {
212
+ padding: 10px;
213
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
214
+ color: var(--text-color);
215
+ text-align: right;
216
+ }
217
+
218
+ .history-item:last-child {
219
+ border-bottom: none;
220
+ }
221
+
222
+ .history-empty {
223
+ text-align: center;
224
+ color: var(--text-light);
225
+ margin-top: 50px;
226
+ }
227
+
228
+ @media (max-width: 400px) {
229
+ .calculator-container {
230
+ border-radius: 0;
231
+ height: 100vh;
232
+ display: flex;
233
+ flex-direction: column;
234
+ }
235
+
236
+ .display {
237
+ padding: 20px;
238
+ }
239
+
240
+ .btn {
241
+ padding: 16px;
242
+ font-size: 1.1rem;
243
+ }
244
+ }
245
+ </style>
246
+ </head>
247
+ <body>
248
+ <div class="calculator-container">
249
+ <div class="header">
250
+ <h1>Modern Calculator</h1>
251
+ <p class="subtitle">Built with precision and style</p>
252
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link" target="_blank">Built with anycoder</a>
253
+ </div>
254
+
255
+ <div class="display">
256
+ <button class="history-btn" id="historyBtn">
257
+ <i class="fas fa-history"></i>
258
+ </button>
259
+ <div class="display-result" id="result">0</div>
260
+ <div class="display-input" id="input">0</div>
261
+ </div>
262
+
263
+ <div class="buttons">
264
+ <button class="btn btn-clear" id="clear">AC</button>
265
+ <button class="btn" id="backspace"><i class="fas fa-backspace"></i></button>
266
+ <button class="btn btn-operator" id="percent">%</button>
267
+ <button class="btn btn-operator" id="divide">/</button>
268
+
269
+ <button class="btn" id="7">7</button>
270
+ <button class="btn" id="8">8</button>
271
+ <button class="btn" id="9">9</button>
272
+ <button class="btn btn-operator" id="multiply">×</button>
273
+
274
+ <button class="btn" id="4">4</button>
275
+ <button class="btn" id="5">5</button>
276
+ <button class="btn" id="6">6</button>
277
+ <button class="btn btn-operator" id="subtract">-</button>
278
+
279
+ <button class="btn" id="1">1</button>
280
+ <button class="btn" id="2">2</button>
281
+ <button class="btn" id="3">3</button>
282
+ <button class="btn btn-operator" id="add">+</button>
283
+
284
+ <button class="btn" id="0">0</button>
285
+ <button class="btn" id="decimal">.</button>
286
+ <button class="btn btn-equals btn-span-2" id="equals">=</button>
287
+ </div>
288
+
289
+ <div class="history-panel" id="historyPanel">
290
+ <div class="history-header">
291
+ <h2>Calculation History</h2>
292
+ <button class="history-close" id="historyClose">&times;</button>
293
+ </div>
294
+ <div class="history-content" id="historyContent">
295
+ <div class="history-empty">No calculations yet</div>
296
+ </div>
297
+ </div>
298
+ </div>
299
+
300
+ <script>
301
+ document.addEventListener('DOMContentLoaded', function() {
302
+ // DOM Elements
303
+ const inputElement = document.getElementById('input');
304
+ const resultElement = document.getElementById('result');
305
+ const historyBtn = document.getElementById('historyBtn');
306
+ const historyPanel = document.getElementById('historyPanel');
307
+ const historyClose = document.getElementById('historyClose');
308
+ const historyContent = document.getElementById('historyContent');
309
+
310
+ // Calculator state
311
+ let currentInput = '0';
312
+ let previousInput = '';
313
+ let operation = null;
314
+ let resetInput = false;
315
+ let calculationHistory = [];
316
+
317
+ // Update display
318
+ function updateDisplay() {
319
+ inputElement.textContent = currentInput;
320
+ resultElement.textContent = previousInput + (operation ? ' ' + operation : '');
321
+ }
322
+
323
+ // Add to history
324
+ function addToHistory(expression, result) {
325
+ calculationHistory.unshift({
326
+ expression: expression,
327
+ result: result,
328
+ timestamp: new Date()
329
+ });
330
+
331
+ // Keep only last 10 calculations
332
+ if (calculationHistory.length > 10) {
333
+ calculationHistory.pop();
334
+ }
335
+
336
+ updateHistoryPanel();
337
+ }
338
+
339
+ // Update history panel
340
+ function updateHistoryPanel() {
341
+ if (calculationHistory.length === 0) {
342
+ historyContent.innerHTML = '<div class="history-empty">No calculations yet</div>';
343
+ return;
344
+ }
345
+
346
+ historyContent.innerHTML = calculationHistory.map(item => {
347
+ return `
348
+ <div class="history-item">
349
+ <div>${item.expression} = ${item.result}</div>
350
+ <div style="font-size: 0.7rem; color: var(--text-light); text-align: right;">
351
+ ${item.timestamp.toLocaleTimeString()}
352
+ </div>
353
+ </div>
354
+ `;
355
+ }).join('');
356
+ }
357
+
358
+ // Handle number input
359
+ function inputNumber(number) {
360
+ if (currentInput === '0' || resetInput) {
361
+ currentInput = number;
362
+ resetInput = false;
363
+ } else {
364
+ currentInput += number;
365
+ }
366
+ updateDisplay();
367
+ }
368
+
369
+ // Handle decimal input
370
+ function inputDecimal() {
371
+ if (resetInput) {
372
+ currentInput = '0.';
373
+ resetInput = false;
374
+ } else if (!currentInput.includes('.')) {
375
+ currentInput += '.';
376
+ }
377
+ updateDisplay();
378
+ }
379
+
380
+ // Handle operator input
381
+ function handleOperator(op) {
382
+ if (operation !== null) calculate();
383
+ previousInput = currentInput;
384
+ operation = op;
385
+ resetInput = true;
386
+ updateDisplay();
387
+ }
388
+
389
+ // Perform calculation
390
+ function calculate() {
391
+ let result;
392
+ const prev = parseFloat(previousInput);
393
+ const current = parseFloat(currentInput);
394
+
395
+ if (isNaN(prev) || isNaN(current)) return;
396
+
397
+ switch (operation) {
398
+ case '+':
399
+ result = prev + current;
400
+ break;
401
+ case '-':
402
+ result = prev - current;
403
+ break;
404
+ case '×':
405
+ result = prev * current;
406
+ break;
407
+ case '/':
408
+ result = prev / current;
409
+ break;
410
+ case '%':
411
+ result = prev % current;
412
+ break;
413
+ default:
414
+ return;
415
+ }
416
+
417
+ // Format the result
418
+ currentInput = formatNumber(result);
419
+ operation = null;
420
+ resetInput = true;
421
+
422
+ // Add to history
423
+ addToHistory(`${previousInput} ${operation} ${current}`, currentInput);
424
+
425
+ updateDisplay();
426
+ }
427
+
428
+ // Format number to avoid scientific notation and limit decimals
429
+ function formatNumber(num) {
430
+ // Handle very large or very small numbers
431
+ if (Math.abs(num) > 999999999 || Math.abs(num) < 0.0000001) {
432
+ return num.toExponential(6);
433
+ }
434
+
435
+ // Limit to 8 decimal places
436
+ const numStr = num.toString();
437
+ if (numStr.includes('.')) {
438
+ const parts = numStr.split('.');
439
+ if (parts[1].length > 8) {
440
+ return parseFloat(num).toFixed(8).toString();
441
+ }
442
+ }
443
+
444
+ return numStr;
445
+ }
446
+
447
+ // Clear calculator
448
+ function clear() {
449
+ currentInput = '0';
450
+ previousInput = '';
451
+ operation = null;
452
+ updateDisplay();
453
+ }
454
+
455
+ // Backspace
456
+ function backspace() {
457
+ if (currentInput.length === 1 || (currentInput.length === 2 && currentInput.startsWith('-'))) {
458
+ currentInput = '0';
459
+ } else {
460
+ currentInput = currentInput.slice(0, -1);
461
+ }
462
+ updateDisplay();
463
+ }
464
+
465
+ // Event listeners for buttons
466
+ document.getElementById('clear').addEventListener('click', clear);
467
+ document.getElementById('backspace').addEventListener('click', backspace);
468
+ document.getElementById('percent').addEventListener('click', () => handleOperator('%'));
469
+ document.getElementById('divide').addEventListener('click', () => handleOperator('/'));
470
+ document.getElementById('multiply').addEventListener('click', () => handleOperator('×'));
471
+ document.getElementById('subtract').addEventListener('click', () => handleOperator('-'));
472
+ document.getElementById('add').addEventListener('click', () => handleOperator('+'));
473
+ document.getElementById('equals').addEventListener('click', calculate);
474
+ document.getElementById('decimal').addEventListener('click', inputDecimal);
475
+
476
+ // Number buttons
477
+ for (let i = 0; i <= 9; i++) {
478
+ document.getElementById(i.toString()).addEventListener('click', () => inputNumber(i.toString()));
479
+ }
480
+
481
+ // History panel toggle
482
+ historyBtn.addEventListener('click', () => {
483
+ historyPanel.classList.add('active');
484
+ });
485
+
486
+ historyClose.addEventListener('click', () => {
487
+ historyPanel.classList.remove('active');
488
+ });
489
+
490
+ // Keyboard support
491
+ document.addEventListener('keydown', (e) => {
492
+ if (e.key >= 0 && e.key <= 9) {
493
+ inputNumber(e.key);
494
+ } else if (e.key === '.') {
495
+ inputDecimal();
496
+ } else if (e.key === '+' || e.key === '-' || e.key === '*' || e.key === '/') {
497
+ let op = e.key;
498
+ if (op === '*') op = '×';
499
+ handleOperator(op);
500
+ } else if (e.key === 'Enter' || e.key === '=') {
501
+ calculate();
502
+ } else if (e.key === 'Escape') {
503
+ clear();
504
+ } else if (e.key === 'Backspace') {
505
+ backspace();
506
+ }
507
+ });
508
+
509
+ // Initialize
510
+ updateDisplay();
511
+ });
512
+ </script>
513
+ </body>
514
+ </html>