omarito03 commited on
Commit
ad2482e
·
verified ·
1 Parent(s): 0ea6bef

An offline interactive and simple web application to calculate the final average of subjects. It includes 9 sliders, each representing a subject, allowing the user to set the grade between 10 and 20. Next to each slider is a text field to enter the subject's coefficient, and the product of grade × coefficient is displayed automatically. At the bottom, a large field shows the final average in real time, calculated as the sum of (grades × coefficients) divided by the sum of coefficients. The design is clean and responsive for both mobile and desktop, and there is a Reset button to return all values to their default settings. Optionally, the app can include a feature to calculate the required grades in remaining subjects to achieve a desired final average (e.g., 15/20). - Initial Deployment

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +246 -18
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Notation
3
- emoji: 🌍
4
- colorFrom: indigo
5
- colorTo: yellow
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: notation
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: blue
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,247 @@
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>Grade Calculator</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://unpkg.com/feather-icons"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
11
+ <style>
12
+ input[type="range"]::-webkit-slider-thumb {
13
+ -webkit-appearance: none;
14
+ width: 20px;
15
+ height: 20px;
16
+ background: #4f46e5;
17
+ border-radius: 50%;
18
+ cursor: pointer;
19
+ box-shadow: 0 0 2px rgba(0,0,0,0.2);
20
+ }
21
+ input[type="range"]::-moz-range-thumb {
22
+ width: 20px;
23
+ height: 20px;
24
+ background: #4f46e5;
25
+ border-radius: 50%;
26
+ cursor: pointer;
27
+ box-shadow: 0 0 2px rgba(0,0,0,0.2);
28
+ }
29
+ .grade-display {
30
+ min-width: 40px;
31
+ text-align: center;
32
+ font-weight: 600;
33
+ color: #4f46e5;
34
+ }
35
+ .product-display {
36
+ min-width: 60px;
37
+ text-align: center;
38
+ font-weight: 500;
39
+ color: #6b7280;
40
+ }
41
+ </style>
42
+ </head>
43
+ <body class="font-inter bg-gray-50 min-h-screen">
44
+ <div class="container mx-auto px-4 py-8 max-w-4xl">
45
+ <header class="mb-8 text-center">
46
+ <h1 class="text-3xl font-bold text-gray-800 mb-2">Grade Calculator</h1>
47
+ <p class="text-gray-600">Calculate your weighted average in real-time</p>
48
+ </header>
49
+
50
+ <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
51
+ <div class="p-6">
52
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
53
+ <div>
54
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Subjects</h2>
55
+ <div id="subjects-container" class="space-y-5">
56
+ <!-- Subjects will be added here by JavaScript -->
57
+ </div>
58
+ </div>
59
+ <div>
60
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Results</h2>
61
+ <div class="bg-indigo-50 rounded-lg p-6">
62
+ <div class="flex justify-between items-center mb-4">
63
+ <span class="text-gray-700 font-medium">Current Average:</span>
64
+ <span id="current-average" class="text-3xl font-bold text-indigo-600">0.00</span>
65
+ </div>
66
+ <div class="mb-6">
67
+ <label for="target-average" class="block text-sm font-medium text-gray-700 mb-1">Target Average</label>
68
+ <div class="relative">
69
+ <input type="number" id="target-average" min="10" max="20" step="0.1" value="15"
70
+ class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500">
71
+ <span class="absolute right-3 top-2 text-gray-500">/20</span>
72
+ </div>
73
+ </div>
74
+ <div id="required-grades" class="text-sm text-gray-600 hidden">
75
+ <p class="font-medium mb-2">To reach your target:</p>
76
+ <p>You need an average of <span id="required-average" class="font-semibold">0.00</span> in remaining subjects.</p>
77
+ <p class="mt-1">Assuming equal coefficients.</p>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+
83
+ <div class="flex justify-center space-x-4">
84
+ <button id="reset-btn" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300 transition flex items-center">
85
+ <i data-feather="refresh-cw" class="mr-2 w-4 h-4"></i>
86
+ Reset All
87
+ </button>
88
+ <button id="calculate-btn" class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition flex items-center">
89
+ <i data-feather="calculator" class="mr-2 w-4 h-4"></i>
90
+ Calculate Target
91
+ </button>
92
+ </div>
93
+ </div>
94
+ </div>
95
+
96
+ <footer class="text-center text-gray-500 text-sm">
97
+ <p>Offline grade calculator - All calculations happen in your browser</p>
98
+ </footer>
99
+ </div>
100
+
101
+ <script>
102
+ document.addEventListener('DOMContentLoaded', function() {
103
+ feather.replace();
104
+
105
+ // Initialize subjects
106
+ const subjectsContainer = document.getElementById('subjects-container');
107
+ const subjectNames = [
108
+ 'Mathematics', 'Physics', 'Chemistry',
109
+ 'Biology', 'History', 'Geography',
110
+ 'Literature', 'Philosophy', 'Foreign Language'
111
+ ];
112
+
113
+ let subjects = [];
114
+
115
+ // Create subject elements
116
+ subjectNames.forEach((name, index) => {
117
+ const subjectId = `subject-${index}`;
118
+ const subjectHtml = `
119
+ <div class="subject-item" data-id="${index}">
120
+ <div class="flex justify-between items-center mb-1">
121
+ <label for="${subjectId}-name" class="text-sm font-medium text-gray-700">${name}</label>
122
+ <span class="grade-display" id="${subjectId}-grade">10.0</span>
123
+ </div>
124
+ <div class="flex items-center space-x-4">
125
+ <input type="range" id="${subjectId}-slider" min="10" max="20" step="0.1" value="10"
126
+ class="flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
127
+ <input type="number" id="${subjectId}-coeff" min="1" max="10" value="1"
128
+ class="w-16 px-2 py-1 border border-gray-300 rounded-md text-center">
129
+ <span class="product-display" id="${subjectId}-product">10.0</span>
130
+ </div>
131
+ </div>
132
+ `;
133
+ subjectsContainer.innerHTML += subjectHtml;
134
+
135
+ subjects.push({
136
+ id: index,
137
+ name: name,
138
+ grade: 10,
139
+ coeff: 1,
140
+ product: 10
141
+ });
142
+ });
143
+
144
+ // Initialize event listeners
145
+ subjectNames.forEach((_, index) => {
146
+ const subjectId = `subject-${index}`;
147
+ const slider = document.getElementById(`${subjectId}-slider`);
148
+ const coeffInput = document.getElementById(`${subjectId}-coeff`);
149
+ const gradeDisplay = document.getElementById(`${subjectId}-grade`);
150
+ const productDisplay = document.getElementById(`${subjectId}-product`);
151
+
152
+ slider.addEventListener('input', function() {
153
+ const grade = parseFloat(this.value);
154
+ subjects[index].grade = grade;
155
+ gradeDisplay.textContent = grade.toFixed(1);
156
+ updateProduct(index);
157
+ updateAverage();
158
+ });
159
+
160
+ coeffInput.addEventListener('input', function() {
161
+ const coeff = parseInt(this.value) || 1;
162
+ if (coeff < 1) this.value = 1;
163
+ if (coeff > 10) this.value = 10;
164
+ subjects[index].coeff = coeff;
165
+ updateProduct(index);
166
+ updateAverage();
167
+ });
168
+ });
169
+
170
+ // Reset button
171
+ document.getElementById('reset-btn').addEventListener('click', function() {
172
+ subjectNames.forEach((_, index) => {
173
+ const subjectId = `subject-${index}`;
174
+ document.getElementById(`${subjectId}-slider`).value = 10;
175
+ document.getElementById(`${subjectId}-coeff`).value = 1;
176
+ document.getElementById(`${subjectId}-grade`).textContent = '10.0';
177
+ document.getElementById(`${subjectId}-product`).textContent = '10.0';
178
+
179
+ subjects[index] = {
180
+ id: index,
181
+ name: subjectNames[index],
182
+ grade: 10,
183
+ coeff: 1,
184
+ product: 10
185
+ };
186
+ });
187
+ updateAverage();
188
+ document.getElementById('target-average').value = 15;
189
+ document.getElementById('required-grades').classList.add('hidden');
190
+ });
191
+
192
+ // Calculate target button
193
+ document.getElementById('calculate-btn').addEventListener('click', function() {
194
+ const targetAverage = parseFloat(document.getElementById('target-average').value);
195
+ if (isNaN(targetAverage) || targetAverage < 10 || targetAverage > 20) {
196
+ alert('Please enter a valid target average between 10 and 20');
197
+ return;
198
+ }
199
+
200
+ calculateRequiredGrades(targetAverage);
201
+ });
202
+
203
+ // Helper functions
204
+ function updateProduct(index) {
205
+ const subject = subjects[index];
206
+ subject.product = subject.grade * subject.coeff;
207
+ document.getElementById(`subject-${index}-product`).textContent = subject.product.toFixed(1);
208
+ }
209
+
210
+ function updateAverage() {
211
+ const totalProducts = subjects.reduce((sum, subject) => sum + subject.product, 0);
212
+ const totalCoeffs = subjects.reduce((sum, subject) => sum + subject.coeff, 0);
213
+ const average = totalProducts / totalCoeffs;
214
+
215
+ document.getElementById('current-average').textContent = average.toFixed(2);
216
+ }
217
+
218
+ function calculateRequiredGrades(target) {
219
+ const totalProducts = subjects.reduce((sum, subject) => sum + subject.product, 0);
220
+ const totalCoeffs = subjects.reduce((sum, subject) => sum + subject.coeff, 0);
221
+ const currentAverage = totalProducts / totalCoeffs;
222
+
223
+ // Assuming remaining subjects have the same coefficients as the average of current ones
224
+ const avgCoeff = totalCoeffs > 0 ? totalCoeffs / subjects.length : 1;
225
+ const remainingCoeff = 10 - totalCoeffs;
226
+
227
+ if (remainingCoeff <= 0) {
228
+ document.getElementById('required-grades').classList.remove('hidden');
229
+ document.getElementById('required-average').textContent = currentAverage.toFixed(2);
230
+ return;
231
+ }
232
+
233
+ const requiredTotal = target * (totalCoeffs + remainingCoeff);
234
+ const requiredProducts = requiredTotal - totalProducts;
235
+ const requiredAverage = requiredProducts / remainingCoeff;
236
+
237
+ document.getElementById('required-grades').classList.remove('hidden');
238
+ document.getElementById('required-average').textContent = requiredAverage.toFixed(2);
239
+ }
240
+
241
+ // Initialize
242
+ updateAverage();
243
+ });
244
+ </script>
245
+ <script>feather.replace();</script>
246
+ </body>
247
  </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ An offline interactive and simple web application to calculate the final average of subjects. It includes 9 sliders, each representing a subject, allowing the user to set the grade between 10 and 20. Next to each slider is a text field to enter the subject's coefficient, and the product of grade × coefficient is displayed automatically. At the bottom, a large field shows the final average in real time, calculated as the sum of (grades × coefficients) divided by the sum of coefficients. The design is clean and responsive for both mobile and desktop, and there is a Reset button to return all values to their default settings. Optionally, the app can include a feature to calculate the required grades in remaining subjects to achieve a desired final average (e.g., 15/20).