deedrop1140 commited on
Commit
d46b6ab
·
verified ·
1 Parent(s): 6df08a1

Update templates/frontpage.html

Browse files
Files changed (1) hide show
  1. templates/frontpage.html +459 -455
templates/frontpage.html CHANGED
@@ -1,455 +1,459 @@
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>ML Learning Platform</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
- <style>
10
- @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
11
- body {
12
- font-family: 'Inter', sans-serif;
13
- margin: 0;
14
- overflow: hidden; /* Prevent scrolling to keep the canvas in place */
15
- height: 100vh;
16
- color: grey; /* Changed all text to grey */
17
- position: relative;
18
- background-color: #ffffff; /* Solid white background */
19
- }
20
-
21
- /* Styles for the canvas background */
22
- #canvas {
23
- position: fixed;
24
- top: 0;
25
- left: 0;
26
- z-index: -1; /* Puts the canvas behind other content */
27
- display: block;
28
- background-color: transparent;
29
- }
30
-
31
- .button-hover {
32
- transition: all 0.3s ease;
33
- }
34
- .button-hover:hover {
35
- transform: translateY(-2px);
36
- box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
37
- }
38
- .stats-card {
39
- background: rgba(255, 255, 255, 0.1);
40
- border: 1px solid rgba(255, 255, 255, 0.2);
41
- }
42
- .content-card {
43
- background: rgba(255, 255, 255, 0.05);
44
- border: 1px solid rgba(255, 255, 255, 0.1);
45
- backdrop-filter: blur(10px);
46
- }
47
- .modal {
48
- background: rgba(0, 0, 0, 0.75);
49
- }
50
- .modal-content {
51
- background: #1f2937;
52
- border: 1px solid #374151;
53
- }
54
-
55
- /* Ensure main content is visible on top of the canvas */
56
- main, footer, .content-container {
57
- position: relative;
58
- z-index: 1;
59
- }
60
- </style>
61
- </head>
62
- <body class="min-h-screen text-white">
63
- <!-- The Bouncing Canvas is now the background -->
64
- <canvas id="canvas"></canvas>
65
-
66
- <!-- Main content container -->
67
- <div class="container mx-auto px-4 py-8">
68
- <div class="text-center mt-8">
69
- <h1 class="text-4xl sm:text-5xl font-bold text-gray-800 mb-4">Machine Learning Platform</h1>
70
- <p class="text-gray-600 text-sm sm:text-base">Explore the world of artificial intelligence and machine learning</p>
71
- </div>
72
-
73
- <!-- Main Content - Desktop Cards (visible on medium and up) -->
74
- <div class="hidden md:grid grid-cols-1 md:grid-cols-2 gap-8 mb-12 mt-20">
75
- <!-- Left Side - Test Assessment Card -->
76
- <div class="content-card rounded-2xl p-6">
77
- <h3 class="text-xl sm:text-2xl font-bold mb-3 text-green-600">Test Your Knowledge</h3>
78
- <p class="text-sm mb-4 text-gray-600">"Test yourself and see what you know about ML"</p>
79
- <p class="mb-4 text-xs sm:text-sm text-gray-500">Assess your current machine learning knowledge and identify areas for improvement</p>
80
- <button onclick="takeQuiz()" class="button-hover bg-gradient-to-r from-green-500 to-teal-600 hover:from-green-600 hover:to-teal-700 text-white px-6 py-3 rounded-full font-semibold text-base shadow-lg w-full">
81
- <i class="fas fa-graduation-cap mr-2"></i>Take Assessment
82
- </button>
83
- </div>
84
-
85
- <!-- Right Side - Start Learning Card -->
86
- <div class="content-card rounded-2xl p-6">
87
- <h3 class="text-xl sm:text-2xl font-bold mb-3 text-blue-600">Start Your ML Journey</h3>
88
- <p class="text-sm mb-4 text-gray-600">"Start your ML learning with start button"</p>
89
- <p class="mb-4 text-xs sm:text-sm text-gray-500">Build foundational skills and progress to advanced machine learning concepts</p>
90
- <button onclick="startLearning()" class="button-hover bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white px-6 py-3 rounded-full font-semibold text-base shadow-lg w-full">
91
- <i class="fas fa-rocket mr-2"></i>Start Learning
92
- </button>
93
- </div>
94
- </div>
95
-
96
- <!-- Mobile Buttons (visible on small screens) -->
97
- <div class="block md:hidden mb-12 flex flex-col gap-4 mt-20">
98
- <button onclick="takeQuiz()" class="button-hover bg-gradient-to-r from-green-500 to-teal-600 hover:from-green-600 hover:to-teal-700 text-white px-6 py-3 rounded-full font-semibold text-sm shadow-lg w-full">
99
- <i class="fas fa-graduation-cap mr-2"></i>Test Your Knowledge
100
- </button>
101
- <button onclick="startLearning()" class="button-hover bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white px-6 py-3 rounded-full font-semibold text-sm shadow-lg w-full">
102
- <i class="fas fa-rocket mr-2"></i>Start Learning
103
- </button>
104
- </div>
105
- </div>
106
-
107
- <!-- Modal Message Box -->
108
- <div id="messageModal" class="fixed inset-0 z-50 flex items-center justify-center modal hidden">
109
- <div class="modal-content p-8 rounded-2xl shadow-lg max-w-sm w-full mx-4 transform transition-all scale-95 duration-300">
110
- <h3 id="modalTitle" class="text-2xl font-bold mb-4 text-center"></h3>
111
- <p id="modalMessage" class="text-gray-300 mb-6 text-center"></p>
112
- <div class="flex justify-center">
113
- <button onclick="hideMessage()" class="button-hover bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white px-8 py-3 rounded-full font-semibold shadow-lg">
114
- OK
115
- </button>
116
- </div>
117
- </div>
118
- </div>
119
-
120
- <script>
121
- /**
122
- * Shows a custom message box as a modal.
123
- * @param {string} title The title of the message box.
124
- * @param {string} message The message to display.
125
- */
126
- function showMessage(title, message) {
127
- const modal = document.getElementById('messageModal');
128
- const modalTitle = document.getElementById('modalTitle');
129
- const modalMessage = document.getElementById('modalMessage');
130
-
131
- modalTitle.textContent = title;
132
- modalMessage.textContent = message;
133
-
134
- modal.classList.remove('hidden');
135
- document.body.style.overflow = 'hidden'; // Prevents scrolling
136
- }
137
-
138
- /**
139
- * Hides the custom message box.
140
- */
141
- function hideMessage() {
142
- const modal = document.getElementById('messageModal');
143
- modal.classList.add('hidden');
144
- document.body.style.overflow = ''; // Restores scrolling
145
- }
146
-
147
- /**
148
- * Function to handle the start learning button click.
149
- */
150
- function startLearning() {
151
- // Redirects to home.html when the button is clicked
152
- window.location.href = '/home';
153
- }
154
-
155
- /**
156
- * Function to handle the take quiz button click.
157
- */
158
- function takeQuiz() {
159
- showMessage('Knowledge Assessment', 'Preparing your ML knowledge assessment...');
160
- // Here you would typically redirect to the quiz page, e.g.,
161
- // window.location.href = '/assessment';
162
- }
163
-
164
- // --- Bouncing balls canvas code ---
165
-
166
- const canvas = document.getElementById('canvas');
167
- const ctx = canvas.getContext('2d');
168
- canvas.width = window.innerWidth;
169
- canvas.height = window.innerHeight;
170
-
171
- // Ball class with improved physics and dynamic color
172
- class Ball {
173
- constructor(name, x, y, dx, dy) {
174
- this.name = name;
175
- this.x = x;
176
- this.y = y;
177
- this.dx = dx;
178
- this.dy = dy;
179
- this.isControlled = false;
180
- this.isHovered = false;
181
-
182
- // Set the font size based on screen width
183
- const fontSize = window.innerWidth < 768 ? '12px' : '16px';
184
-
185
- const tempCanvas = document.createElement('canvas');
186
- const tempCtx = tempCanvas.getContext('2d');
187
- tempCtx.font = `bold ${fontSize} Arial`;
188
- const metrics = tempCtx.measureText(this.name);
189
- this.width = metrics.width;
190
- this.height = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;
191
-
192
- this.radius = Math.max(this.width, this.height) / 2;
193
- this.mass = this.radius * 0.1;
194
- }
195
-
196
- draw() {
197
- // Glow effect for hover and control
198
- if (this.isHovered || this.isControlled) {
199
- ctx.fillStyle = 'rgba(0, 153, 255, 0.3)';
200
- ctx.beginPath();
201
- ctx.roundRect(this.x - this.width/2 - 3, this.y - this.height/2 - 3, this.width + 6, this.height + 6, 5);
202
- ctx.fill();
203
- }
204
-
205
- // Draw the machine learning algorithm's name
206
- ctx.fillStyle = this.isControlled ? '#3498db' : '#555555';
207
- const fontSize = window.innerWidth < 768 ? '12px' : '16px';
208
- ctx.font = `bold ${fontSize} Arial`;
209
- ctx.textAlign = 'center';
210
- ctx.textBaseline = 'middle';
211
- ctx.fillText(this.name, this.x, this.y);
212
- }
213
-
214
- update() {
215
- if (!this.isControlled) {
216
- this.x += this.dx;
217
- this.y += this.dy;
218
-
219
- if (this.x + this.width / 2 > canvas.width) {
220
- this.dx *= -1;
221
- this.x = canvas.width - this.width / 2;
222
- }
223
- if (this.x - this.width / 2 < 0) {
224
- this.dx *= -1;
225
- this.x = this.width / 2;
226
- }
227
- if (this.y + this.height / 2 > canvas.height) {
228
- this.dy *= -1;
229
- this.y = canvas.height - this.height / 2;
230
- }
231
- if (this.y - this.height / 2 < 0) {
232
- this.dy *= -1;
233
- this.y = this.height / 2;
234
- }
235
- }
236
- }
237
- }
238
-
239
- function rotate(dx, dy, angle) {
240
- const rotatedVelocities = {
241
- x: dx * Math.cos(angle) - dy * Math.sin(angle),
242
- y: dx * Math.sin(angle) + dy * Math.cos(angle)
243
- };
244
- return rotatedVelocities;
245
- }
246
-
247
- function resolveCollision(ball1, ball2) {
248
- const dx = ball1.x - ball2.x;
249
- const dy = ball1.y - ball2.y;
250
- const distance = Math.sqrt(dx * dx + dy * dy);
251
- const sumOfRadii = ball1.radius + ball2.radius;
252
-
253
- if (distance < sumOfRadii) {
254
- const overlap = sumOfRadii - distance;
255
- const pushBackVectorX = dx / distance * overlap * 0.5;
256
- const pushBackVectorY = dy / distance * overlap * 0.5;
257
-
258
- ball1.x += pushBackVectorX;
259
- ball1.y += pushBackVectorY;
260
- ball2.x -= pushBackVectorX;
261
- ball2.y -= pushBackVectorY;
262
-
263
- const angle = -Math.atan2(dy, dx);
264
- const m1 = ball1.mass;
265
- const m2 = ball2.mass;
266
-
267
- const u1 = rotate(ball1.dx, ball1.dy, angle);
268
- const u2 = rotate(ball2.dx, ball2.dy, angle);
269
-
270
- const v1 = {
271
- x: ((u1.x * (m1 - m2)) / (m1 + m2)) + ((u2.x * 2 * m2) / (m1 + m2)),
272
- y: u1.y
273
- };
274
- const v2 = {
275
- x: ((u2.x * (m2 - m1)) / (m1 + m2)) + ((u1.x * 2 * m1) / (m1 + m2)),
276
- y: u2.y
277
- };
278
-
279
- const vFinal1 = rotate(v1.x, v1.y, -angle);
280
- const vFinal2 = rotate(v2.x, v2.y, -angle);
281
-
282
- ball1.dx = vFinal1.x;
283
- ball1.dy = vFinal1.y;
284
- ball2.dx = vFinal2.x;
285
- ball2.dy = vFinal2.y;
286
- }
287
- }
288
-
289
- const algorithmNames = [
290
- 'Supervised', 'Unsupervised', 'Python', 'LLM', 'RAG', 'Agentic AI',
291
- 'Reinforcement Learning', 'Deep Learning', 'Computer Vision',
292
- 'Generative AI', 'Natural Language Processing', 'Vector Embeddings',
293
- 'Transformers', 'Prompt Engineering', 'Data Science', 'Machine Learning'
294
- ];
295
-
296
- const mobileAlgorithmNames = [
297
- 'Supervised', 'Unsupervised', 'LLM', 'RAG','Deep Learning', 'Computer Vision',
298
- 'Generative AI', 'NLP', 'Vector Embeddings'
299
- ];
300
-
301
- let balls = [];
302
-
303
- function getRandomPosition() {
304
- return {
305
- x: Math.random() * (canvas.width * 0.8) + (canvas.width * 0.1),
306
- y: Math.random() * (canvas.height * 0.8) + (canvas.height * 0.1)
307
- };
308
- }
309
-
310
- function getRandomVelocity() {
311
- const speed = 2;
312
- const angle = Math.random() * 2 * Math.PI;
313
- return {
314
- dx: Math.cos(angle) * speed,
315
- dy: Math.sin(angle) * speed
316
- };
317
- }
318
-
319
- function initializeBalls() {
320
- const names = window.innerWidth < 768 ? mobileAlgorithmNames : algorithmNames;
321
- balls = names.map(name => {
322
- const pos = getRandomPosition();
323
- const vel = getRandomVelocity();
324
- return new Ball(name, pos.x, pos.y, vel.dx, vel.dy);
325
- });
326
- }
327
-
328
- let controlledBall = null;
329
- let startX, startY;
330
-
331
- function animate() {
332
- ctx.clearRect(0, 0, canvas.width, canvas.height);
333
-
334
- for (let i = 0; i < balls.length; i++) {
335
- balls[i].update();
336
- balls[i].draw();
337
- }
338
-
339
- for (let i = 0; i < balls.length; i++) {
340
- for (let j = i + 1; j < balls.length; j++) {
341
- resolveCollision(balls[i], balls[j]);
342
- }
343
- }
344
- requestAnimationFrame(animate);
345
- }
346
-
347
- canvas.addEventListener('mousedown', (event) => {
348
- const mouseX = event.clientX;
349
- const mouseY = event.clientY;
350
-
351
- for (let i = 0; i < balls.length; i++) {
352
- const ball = balls[i];
353
- const distance = Math.sqrt((mouseX - ball.x) ** 2 + (mouseY - ball.y) ** 2);
354
- if (distance < ball.radius) {
355
- controlledBall = ball;
356
- controlledBall.isControlled = true;
357
- startX = controlledBall.x;
358
- startY = controlledBall.y;
359
- break;
360
- }
361
- }
362
- });
363
-
364
- canvas.addEventListener('mousemove', (event) => {
365
- const mouseX = event.clientX;
366
- const mouseY = event.clientY;
367
-
368
- let isHovering = false;
369
- balls.forEach(ball => {
370
- const distance = Math.sqrt((mouseX - ball.x) ** 2 + (mouseY - ball.y) ** 2);
371
- if (distance < ball.radius) {
372
- ball.isHovered = true;
373
- isHovering = true;
374
- } else {
375
- ball.isHovered = false;
376
- }
377
- });
378
-
379
- if (isHovering || controlledBall) {
380
- canvas.style.cursor = 'pointer';
381
- } else {
382
- canvas.style.cursor = 'default';
383
- }
384
-
385
- if (controlledBall) {
386
- controlledBall.x = mouseX;
387
- controlledBall.y = mouseY;
388
- }
389
- });
390
-
391
- canvas.addEventListener('mouseup', () => {
392
- if (controlledBall) {
393
- const speedFactor = 0.1;
394
- let dx = (controlledBall.x - startX) * speedFactor;
395
- let dy = (controlledBall.y - startY) * speedFactor;
396
-
397
- const maxSpeed = 10;
398
- if (Math.sqrt(dx*dx + dy*dy) > maxSpeed) {
399
- const angle = Math.atan2(dy, dx);
400
- dx = Math.cos(angle) * maxSpeed;
401
- dy = Math.sin(angle) * maxSpeed;
402
- }
403
-
404
- controlledBall.dx = dx;
405
- controlledBall.dy = dy;
406
-
407
- controlledBall.isControlled = false;
408
- controlledBall = null;
409
- }
410
- });
411
-
412
- // Functions for the modal message box
413
- function showMessage(title, message) {
414
- const modal = document.getElementById('messageModal');
415
- const modalTitle = document.getElementById('modalTitle');
416
- const modalMessage = document.getElementById('modalMessage');
417
-
418
- modalTitle.textContent = title;
419
- modalMessage.textContent = message;
420
-
421
- modal.classList.remove('hidden');
422
- document.body.style.overflow = 'hidden'; // Prevents scrolling
423
- }
424
-
425
- function hideMessage() {
426
- const modal = document.getElementById('messageModal');
427
- modal.classList.add('hidden');
428
- document.body.style.overflow = ''; // Restores scrolling
429
- }
430
-
431
- function startLearning() {
432
- window.location.href = '/home';
433
- }
434
-
435
- function takeQuiz() {
436
- showMessage('Knowledge Assessment', 'Preparing your ML knowledge assessment...');
437
- }
438
-
439
- // Adjust canvas size dynamically on screen resize
440
- function resizeCanvas() {
441
- canvas.width = window.innerWidth;
442
- canvas.height = window.innerHeight;
443
-
444
- // Re-initialize the balls to adjust the number of names
445
- initializeBalls();
446
- }
447
-
448
- window.addEventListener('resize', resizeCanvas);
449
-
450
- // Start the animation and initialize balls on page load
451
- initializeBalls();
452
- animate();
453
- </script>
454
- </body>
455
- </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>ML Learning Platform</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
+ <style>
10
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
11
+ body {
12
+ font-family: 'Inter', sans-serif;
13
+ margin: 0;
14
+ overflow: hidden; /* Prevent scrolling to keep the canvas in place */
15
+ height: 100vh;
16
+ color: grey; /* Changed all text to grey */
17
+ position: relative;
18
+ background-color: #ffffff; /* Solid white background */
19
+ }
20
+
21
+ /* Styles for the canvas background */
22
+ #canvas {
23
+ position: fixed;
24
+ top: 0;
25
+ left: 0;
26
+ z-index: -1; /* Puts the canvas behind other content */
27
+ display: block;
28
+ background-color: transparent;
29
+ }
30
+
31
+ .button-hover {
32
+ transition: all 0.3s ease;
33
+ }
34
+ .button-hover:hover {
35
+ transform: translateY(-2px);
36
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
37
+ }
38
+ .stats-card {
39
+ background: rgba(255, 255, 255, 0.1);
40
+ border: 1px solid rgba(255, 255, 255, 0.2);
41
+ }
42
+ .content-card {
43
+ background: rgba(255, 255, 255, 0.05);
44
+ border: 1px solid rgba(255, 255, 255, 0.1);
45
+ backdrop-filter: blur(10px);
46
+ }
47
+ .modal {
48
+ background: rgba(0, 0, 0, 0.75);
49
+ }
50
+ .modal-content {
51
+ background: #1f2937;
52
+ border: 1px solid #374151;
53
+ }
54
+
55
+ /* Ensure main content is visible on top of the canvas */
56
+ main, footer, .content-container {
57
+ position: relative;
58
+ z-index: 1;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body class="min-h-screen text-white">
63
+ <!-- The Bouncing Canvas is now the background -->
64
+ <canvas id="canvas"></canvas>
65
+
66
+ <!-- Main content container -->
67
+ <div class="container mx-auto px-4 py-8">
68
+ <div class="text-center mt-8">
69
+ <h1 class="text-4xl sm:text-5xl font-bold text-gray-800 mb-4">Machine Learning Platform</h1>
70
+ <p class="text-gray-600 text-sm sm:text-base">Explore the world of artificial intelligence and machine learning</p>
71
+ </div>
72
+
73
+ <!-- Main Content - Desktop Cards (visible on medium and up) -->
74
+ <div class="hidden md:grid grid-cols-1 md:grid-cols-2 gap-8 mb-12 mt-20">
75
+ <!-- Left Side - Test Assessment Card -->
76
+ <div class="content-card rounded-2xl p-6">
77
+ <h3 class="text-xl sm:text-2xl font-bold mb-3 text-green-600">Test Your Knowledge</h3>
78
+ <p class="text-sm mb-4 text-gray-600">"Test yourself and see what you know about ML"</p>
79
+ <p class="mb-4 text-xs sm:text-sm text-gray-500">Assess your current machine learning knowledge and identify areas for improvement</p>
80
+ <button onclick="takeQuiz()" class="button-hover bg-gradient-to-r from-green-500 to-teal-600 hover:from-green-600 hover:to-teal-700 text-white px-6 py-3 rounded-full font-semibold text-base shadow-lg w-full">
81
+ <i class="fas fa-graduation-cap mr-2"></i>Take Assessment
82
+ </button>
83
+ </div>
84
+
85
+ <!-- Right Side - Start Learning Card -->
86
+ <div class="content-card rounded-2xl p-6">
87
+ <h3 class="text-xl sm:text-2xl font-bold mb-3 text-blue-600">Start Your ML Journey</h3>
88
+ <p class="text-sm mb-4 text-gray-600">"Start your ML learning with start button"</p>
89
+ <p class="mb-4 text-xs sm:text-sm text-gray-500">Build foundational skills and progress to advanced machine learning concepts</p>
90
+ <button onclick="startLearning()" class="button-hover bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white px-6 py-3 rounded-full font-semibold text-base shadow-lg w-full">
91
+ <i class="fas fa-rocket mr-2"></i>Start Learning
92
+ </button>
93
+ </div>
94
+ </div>
95
+
96
+ <!-- Mobile Buttons (visible on small screens) -->
97
+ <div class="block md:hidden mb-12 flex flex-col gap-4 mt-20">
98
+ <button onclick="takeQuiz()" class="button-hover bg-gradient-to-r from-green-500 to-teal-600 hover:from-green-600 hover:to-teal-700 text-white px-6 py-3 rounded-full font-semibold text-sm shadow-lg w-full">
99
+ <i class="fas fa-graduation-cap mr-2"></i>Test Your Knowledge
100
+ </button>
101
+ <button onclick="startLearning()" class="button-hover bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white px-6 py-3 rounded-full font-semibold text-sm shadow-lg w-full">
102
+ <i class="fas fa-rocket mr-2"></i>Start Learning
103
+ </button>
104
+ </div>
105
+ </div>
106
+
107
+ <!-- Modal Message Box -->
108
+ <div id="messageModal" class="fixed inset-0 z-50 flex items-center justify-center modal hidden">
109
+ <div class="modal-content p-8 rounded-2xl shadow-lg max-w-sm w-full mx-4 transform transition-all scale-95 duration-300">
110
+ <h3 id="modalTitle" class="text-2xl font-bold mb-4 text-center"></h3>
111
+ <p id="modalMessage" class="text-gray-300 mb-6 text-center"></p>
112
+ <div class="flex justify-center">
113
+ <button onclick="hideMessage()" class="button-hover bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white px-8 py-3 rounded-full font-semibold shadow-lg">
114
+ OK
115
+ </button>
116
+ </div>
117
+ </div>
118
+ </div>
119
+
120
+ <script>
121
+ /**
122
+ * Shows a custom message box as a modal.
123
+ * @param {string} title The title of the message box.
124
+ * @param {string} message The message to display.
125
+ */
126
+ function showMessage(title, message) {
127
+ const modal = document.getElementById('messageModal');
128
+ const modalTitle = document.getElementById('modalTitle');
129
+ const modalMessage = document.getElementById('modalMessage');
130
+
131
+ modalTitle.textContent = title;
132
+ modalMessage.textContent = message;
133
+
134
+ modal.classList.remove('hidden');
135
+ document.body.style.overflow = 'hidden'; // Prevents scrolling
136
+ }
137
+
138
+ /**
139
+ * Hides the custom message box.
140
+ */
141
+ function hideMessage() {
142
+ const modal = document.getElementById('messageModal');
143
+ modal.classList.add('hidden');
144
+ document.body.style.overflow = ''; // Restores scrolling
145
+ }
146
+
147
+ /**
148
+ * Function to handle the start learning button click.
149
+ */
150
+ function startLearning() {
151
+ // Redirects to home.html when the button is clicked
152
+ window.location.href = '/home';
153
+ }
154
+
155
+ /**
156
+ * Function to handle the take quiz button click.
157
+ */
158
+ function takeQuiz() {
159
+ window.location.href = '/Test-home';
160
+
161
+ // Here you would typically redirect to the quiz page, e.g.,
162
+ // window.location.href = '/assessment';
163
+ }
164
+
165
+ // --- Bouncing balls canvas code ---
166
+
167
+ const canvas = document.getElementById('canvas');
168
+ const ctx = canvas.getContext('2d');
169
+ canvas.width = window.innerWidth;
170
+ canvas.height = window.innerHeight;
171
+
172
+ // Ball class with improved physics and dynamic color
173
+ class Ball {
174
+ constructor(name, x, y, dx, dy) {
175
+ this.name = name;
176
+ this.x = x;
177
+ this.y = y;
178
+ this.dx = dx;
179
+ this.dy = dy;
180
+ this.isControlled = false;
181
+ this.isHovered = false;
182
+
183
+ // Set the font size based on screen width
184
+ const fontSize = window.innerWidth < 768 ? '12px' : '16px';
185
+
186
+ const tempCanvas = document.createElement('canvas');
187
+ const tempCtx = tempCanvas.getContext('2d');
188
+ tempCtx.font = `bold ${fontSize} Arial`;
189
+ const metrics = tempCtx.measureText(this.name);
190
+ this.width = metrics.width;
191
+ this.height = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;
192
+
193
+ this.radius = Math.max(this.width, this.height) / 2;
194
+ this.mass = this.radius * 0.1;
195
+ }
196
+
197
+ draw() {
198
+ // Glow effect for hover and control
199
+ if (this.isHovered || this.isControlled) {
200
+ ctx.fillStyle = 'rgba(0, 153, 255, 0.3)';
201
+ ctx.beginPath();
202
+ ctx.roundRect(this.x - this.width/2 - 3, this.y - this.height/2 - 3, this.width + 6, this.height + 6, 5);
203
+ ctx.fill();
204
+ }
205
+
206
+ // Draw the machine learning algorithm's name
207
+ ctx.fillStyle = this.isControlled ? '#3498db' : '#555555';
208
+ const fontSize = window.innerWidth < 768 ? '12px' : '16px';
209
+ ctx.font = `bold ${fontSize} Arial`;
210
+ ctx.textAlign = 'center';
211
+ ctx.textBaseline = 'middle';
212
+ ctx.fillText(this.name, this.x, this.y);
213
+ }
214
+
215
+ update() {
216
+ if (!this.isControlled) {
217
+ this.x += this.dx;
218
+ this.y += this.dy;
219
+
220
+ if (this.x + this.width / 2 > canvas.width) {
221
+ this.dx *= -1;
222
+ this.x = canvas.width - this.width / 2;
223
+ }
224
+ if (this.x - this.width / 2 < 0) {
225
+ this.dx *= -1;
226
+ this.x = this.width / 2;
227
+ }
228
+ if (this.y + this.height / 2 > canvas.height) {
229
+ this.dy *= -1;
230
+ this.y = canvas.height - this.height / 2;
231
+ }
232
+ if (this.y - this.height / 2 < 0) {
233
+ this.dy *= -1;
234
+ this.y = this.height / 2;
235
+ }
236
+ }
237
+ }
238
+ }
239
+
240
+ function rotate(dx, dy, angle) {
241
+ const rotatedVelocities = {
242
+ x: dx * Math.cos(angle) - dy * Math.sin(angle),
243
+ y: dx * Math.sin(angle) + dy * Math.cos(angle)
244
+ };
245
+ return rotatedVelocities;
246
+ }
247
+
248
+ function resolveCollision(ball1, ball2) {
249
+ const dx = ball1.x - ball2.x;
250
+ const dy = ball1.y - ball2.y;
251
+ const distance = Math.sqrt(dx * dx + dy * dy);
252
+ const sumOfRadii = ball1.radius + ball2.radius;
253
+
254
+ if (distance < sumOfRadii) {
255
+ const overlap = sumOfRadii - distance;
256
+ const pushBackVectorX = dx / distance * overlap * 0.5;
257
+ const pushBackVectorY = dy / distance * overlap * 0.5;
258
+
259
+ ball1.x += pushBackVectorX;
260
+ ball1.y += pushBackVectorY;
261
+ ball2.x -= pushBackVectorX;
262
+ ball2.y -= pushBackVectorY;
263
+
264
+ const angle = -Math.atan2(dy, dx);
265
+ const m1 = ball1.mass;
266
+ const m2 = ball2.mass;
267
+
268
+ const u1 = rotate(ball1.dx, ball1.dy, angle);
269
+ const u2 = rotate(ball2.dx, ball2.dy, angle);
270
+
271
+ const v1 = {
272
+ x: ((u1.x * (m1 - m2)) / (m1 + m2)) + ((u2.x * 2 * m2) / (m1 + m2)),
273
+ y: u1.y
274
+ };
275
+ const v2 = {
276
+ x: ((u2.x * (m2 - m1)) / (m1 + m2)) + ((u1.x * 2 * m1) / (m1 + m2)),
277
+ y: u2.y
278
+ };
279
+
280
+ const vFinal1 = rotate(v1.x, v1.y, -angle);
281
+ const vFinal2 = rotate(v2.x, v2.y, -angle);
282
+
283
+ ball1.dx = vFinal1.x;
284
+ ball1.dy = vFinal1.y;
285
+ ball2.dx = vFinal2.x;
286
+ ball2.dy = vFinal2.y;
287
+ }
288
+ }
289
+
290
+ const algorithmNames = [
291
+ 'Supervised', 'Unsupervised', 'Python', 'LLM', 'RAG', 'Agentic AI',
292
+ 'Reinforcement Learning', 'Deep Learning', 'Computer Vision',
293
+ 'Generative AI', 'Natural Language Processing', 'Vector Embeddings',
294
+ 'Transformers', 'Prompt Engineering', 'Data Science', 'Machine Learning'
295
+ ];
296
+
297
+ const mobileAlgorithmNames = [
298
+ 'Supervised', 'Unsupervised', 'LLM', 'RAG','Deep Learning', 'Computer Vision',
299
+ 'Generative AI', 'NLP', 'Vector Embeddings'
300
+ ];
301
+
302
+ let balls = [];
303
+
304
+ function getRandomPosition() {
305
+ return {
306
+ x: Math.random() * (canvas.width * 0.8) + (canvas.width * 0.1),
307
+ y: Math.random() * (canvas.height * 0.8) + (canvas.height * 0.1)
308
+ };
309
+ }
310
+
311
+ function getRandomVelocity() {
312
+ const speed = 2;
313
+ const angle = Math.random() * 2 * Math.PI;
314
+ return {
315
+ dx: Math.cos(angle) * speed,
316
+ dy: Math.sin(angle) * speed
317
+ };
318
+ }
319
+
320
+ function initializeBalls() {
321
+ const names = window.innerWidth < 768 ? mobileAlgorithmNames : algorithmNames;
322
+ balls = names.map(name => {
323
+ const pos = getRandomPosition();
324
+ const vel = getRandomVelocity();
325
+ return new Ball(name, pos.x, pos.y, vel.dx, vel.dy);
326
+ });
327
+ }
328
+
329
+ let controlledBall = null;
330
+ let startX, startY;
331
+
332
+ function animate() {
333
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
334
+
335
+ for (let i = 0; i < balls.length; i++) {
336
+ balls[i].update();
337
+ balls[i].draw();
338
+ }
339
+
340
+ for (let i = 0; i < balls.length; i++) {
341
+ for (let j = i + 1; j < balls.length; j++) {
342
+ resolveCollision(balls[i], balls[j]);
343
+ }
344
+ }
345
+ requestAnimationFrame(animate);
346
+ }
347
+
348
+ canvas.addEventListener('mousedown', (event) => {
349
+ const mouseX = event.clientX;
350
+ const mouseY = event.clientY;
351
+
352
+ for (let i = 0; i < balls.length; i++) {
353
+ const ball = balls[i];
354
+ const distance = Math.sqrt((mouseX - ball.x) ** 2 + (mouseY - ball.y) ** 2);
355
+ if (distance < ball.radius) {
356
+ controlledBall = ball;
357
+ controlledBall.isControlled = true;
358
+ startX = controlledBall.x;
359
+ startY = controlledBall.y;
360
+ break;
361
+ }
362
+ }
363
+ });
364
+
365
+ canvas.addEventListener('mousemove', (event) => {
366
+ const mouseX = event.clientX;
367
+ const mouseY = event.clientY;
368
+
369
+ let isHovering = false;
370
+ balls.forEach(ball => {
371
+ const distance = Math.sqrt((mouseX - ball.x) ** 2 + (mouseY - ball.y) ** 2);
372
+ if (distance < ball.radius) {
373
+ ball.isHovered = true;
374
+ isHovering = true;
375
+ } else {
376
+ ball.isHovered = false;
377
+ }
378
+ });
379
+
380
+ if (isHovering || controlledBall) {
381
+ canvas.style.cursor = 'pointer';
382
+ } else {
383
+ canvas.style.cursor = 'default';
384
+ }
385
+
386
+ if (controlledBall) {
387
+ controlledBall.x = mouseX;
388
+ controlledBall.y = mouseY;
389
+ }
390
+ });
391
+
392
+ canvas.addEventListener('mouseup', () => {
393
+ if (controlledBall) {
394
+ const speedFactor = 0.1;
395
+ let dx = (controlledBall.x - startX) * speedFactor;
396
+ let dy = (controlledBall.y - startY) * speedFactor;
397
+
398
+ const maxSpeed = 10;
399
+ if (Math.sqrt(dx*dx + dy*dy) > maxSpeed) {
400
+ const angle = Math.atan2(dy, dx);
401
+ dx = Math.cos(angle) * maxSpeed;
402
+ dy = Math.sin(angle) * maxSpeed;
403
+ }
404
+
405
+ controlledBall.dx = dx;
406
+ controlledBall.dy = dy;
407
+
408
+ controlledBall.isControlled = false;
409
+ controlledBall = null;
410
+ }
411
+ });
412
+
413
+ // Functions for the modal message box
414
+ function showMessage(title, message) {
415
+ const modal = document.getElementById('messageModal');
416
+ const modalTitle = document.getElementById('modalTitle');
417
+ const modalMessage = document.getElementById('modalMessage');
418
+
419
+ modalTitle.textContent = title;
420
+ modalMessage.textContent = message;
421
+
422
+ modal.classList.remove('hidden');
423
+ document.body.style.overflow = 'hidden'; // Prevents scrolling
424
+ }
425
+
426
+ function hideMessage() {
427
+ const modal = document.getElementById('messageModal');
428
+ modal.classList.add('hidden');
429
+ document.body.style.overflow = ''; // Restores scrolling
430
+ }
431
+
432
+ function startLearning() {
433
+ window.location.href = '/home';
434
+ }
435
+
436
+ function takeQuiz() {
437
+ window.location.href = '/Test-home';
438
+
439
+ // Here you would typically redirect to the quiz page, e.g.,
440
+ // window.location.href = '/assessment';
441
+ }
442
+
443
+ // Adjust canvas size dynamically on screen resize
444
+ function resizeCanvas() {
445
+ canvas.width = window.innerWidth;
446
+ canvas.height = window.innerHeight;
447
+
448
+ // Re-initialize the balls to adjust the number of names
449
+ initializeBalls();
450
+ }
451
+
452
+ window.addEventListener('resize', resizeCanvas);
453
+
454
+ // Start the animation and initialize balls on page load
455
+ initializeBalls();
456
+ animate();
457
+ </script>
458
+ </body>
459
+ </html>