Spaces:
Running
Running
Download index.html from mohamed7869/learning-coding: direct link, hf CLI and curl.
- Browser
- Download file 38.1 kB
-
https://huggingface.co/spaces/mohamed7869/learning-coding/resolve/main/index.html
- Command line
-
hf download hf://spaces/mohamed7869/learning-coding/index.html
-
curl -L -o index.html https://huggingface.co/spaces/mohamed7869/learning-coding/resolve/main/index.html
38.1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>CodeMaster - Learn Programming Easily</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .language-dropdown:hover .language-menu { | |
| display: block; | |
| } | |
| .lesson-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); | |
| } | |
| .progress-ring__circle { | |
| transition: stroke-dashoffset 0.5s; | |
| transform: rotate(-90deg); | |
| transform-origin: 50% 50%; | |
| } | |
| .quiz-option:hover { | |
| background-color: #f3f4f6; | |
| } | |
| .quiz-option.selected { | |
| background-color: #3b82f6; | |
| color: white; | |
| } | |
| .quiz-option.correct { | |
| background-color: #10b981; | |
| color: white; | |
| } | |
| .quiz-option.incorrect { | |
| background-color: #ef4444; | |
| color: white; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 font-sans"> | |
| <!-- Header --> | |
| <header class="bg-white shadow-sm sticky top-0 z-10"> | |
| <div class="container mx-auto px-4 py-3 flex justify-between items-center"> | |
| <div class="flex items-center space-x-2"> | |
| <i class="fas fa-code text-blue-600 text-2xl"></i> | |
| <h1 class="text-xl font-bold text-gray-800">CodeMaster</h1> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <div class="language-dropdown relative"> | |
| <button id="languageBtn" class="flex items-center space-x-1 px-3 py-2 rounded-md hover:bg-gray-100"> | |
| <i class="fas fa-globe"></i> | |
| <span>English</span> | |
| <i class="fas fa-chevron-down text-xs"></i> | |
| </button> | |
| <div id="languageMenu" class="language-menu absolute right-0 mt-2 w-40 bg-white rounded-md shadow-lg py-1 z-20 hidden"> | |
| <a href="#" data-lang="en" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">English</a> | |
| <a href="#" data-lang="ar" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">العربية</a> | |
| <a href="#" data-lang="es" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Español</a> | |
| <a href="#" data-lang="fr" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Français</a> | |
| </div> | |
| </div> | |
| <button id="themeToggle" class="p-2 rounded-full hover:bg-gray-100"> | |
| <i class="fas fa-moon"></i> | |
| </button> | |
| <button id="authBtn" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition"> | |
| Sign In | |
| </button> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Hero Section --> | |
| <section class="bg-gradient-to-r from-blue-600 to-indigo-700 text-white py-16"> | |
| <div class="container mx-auto px-4 text-center"> | |
| <h1 class="text-4xl md:text-5xl font-bold mb-4">Learn Programming the Easy Way</h1> | |
| <p class="text-xl mb-8 max-w-2xl mx-auto">Master coding skills with interactive lessons and quizzes. Start your journey today!</p> | |
| <div class="flex flex-col sm:flex-row justify-center gap-4"> | |
| <button class="bg-white text-blue-600 px-6 py-3 rounded-md font-medium hover:bg-gray-100 transition">Start Learning</button> | |
| <button class="border-2 border-white text-white px-6 py-3 rounded-md font-medium hover:bg-white hover:text-blue-600 transition">Explore Courses</button> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Main Content --> | |
| <main class="container mx-auto px-4 py-12"> | |
| <div class="flex flex-col lg:flex-row gap-8"> | |
| <!-- Sidebar --> | |
| <aside class="lg:w-1/4 bg-white rounded-lg shadow-md p-6 h-fit sticky top-24"> | |
| <h2 class="text-xl font-bold mb-4 text-gray-800">Courses</h2> | |
| <div class="space-y-2"> | |
| <div class="course-category"> | |
| <button class="flex justify-between items-center w-full px-3 py-2 rounded-md hover:bg-gray-100"> | |
| <span class="font-medium">Web Development</span> | |
| <i class="fas fa-chevron-down text-xs"></i> | |
| </button> | |
| <div class="pl-4 mt-1 space-y-1"> | |
| <a href="#" class="block px-3 py-1 text-sm rounded-md hover:bg-gray-100">HTML & CSS</a> | |
| <a href="#" class="block px-3 py-1 text-sm rounded-md hover:bg-gray-100">JavaScript</a> | |
| <a href="#" class="block px-3 py-1 text-sm rounded-md hover:bg-gray-100">React</a> | |
| </div> | |
| </div> | |
| <div class="course-category"> | |
| <button class="flex justify-between items-center w-full px-3 py-2 rounded-md hover:bg-gray-100"> | |
| <span class="font-medium">Mobile Development</span> | |
| <i class="fas fa-chevron-down text-xs"></i> | |
| </button> | |
| </div> | |
| <div class="course-category"> | |
| <button class="flex justify-between items-center w-full px-3 py-2 rounded-md hover:bg-gray-100"> | |
| <span class="font-medium">Data Science</span> | |
| <i class="fas fa-chevron-down text-xs"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div class="mt-8"> | |
| <h3 class="font-bold mb-3 text-gray-800">Your Progress</h3> | |
| <div class="flex items-center justify-center"> | |
| <div class="relative w-32 h-32"> | |
| <svg class="w-full h-full" viewBox="0 0 100 100"> | |
| <circle class="text-gray-200" stroke-width="8" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" /> | |
| <circle class="text-blue-600 progress-ring__circle" stroke-width="8" stroke-linecap="round" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" stroke-dasharray="251.2" stroke-dashoffset="125.6" /> | |
| </svg> | |
| <div class="absolute inset-0 flex items-center justify-center flex-col"> | |
| <span class="text-2xl font-bold">50%</span> | |
| <span class="text-xs text-gray-500">Completed</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="mt-4 space-y-2"> | |
| <div class="flex justify-between text-sm"> | |
| <span>Completed Lessons</span> | |
| <span>12/24</span> | |
| </div> | |
| <div class="w-full bg-gray-200 rounded-full h-2"> | |
| <div class="bg-blue-600 h-2 rounded-full" style="width: 50%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </aside> | |
| <!-- Lessons Content --> | |
| <div class="lg:w-3/4"> | |
| <!-- Breadcrumbs --> | |
| <nav class="flex mb-6" aria-label="Breadcrumb"> | |
| <ol class="inline-flex items-center space-x-1 md:space-x-3"> | |
| <li class="inline-flex items-center"> | |
| <a href="#" class="inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600"> | |
| <i class="fas fa-home mr-2"></i> | |
| Home | |
| </a> | |
| </li> | |
| <li> | |
| <div class="flex items-center"> | |
| <i class="fas fa-chevron-right text-gray-400 text-xs"></i> | |
| <a href="#" class="ml-1 text-sm font-medium text-gray-700 hover:text-blue-600 md:ml-2">Web Development</a> | |
| </div> | |
| </li> | |
| <li aria-current="page"> | |
| <div class="flex items-center"> | |
| <i class="fas fa-chevron-right text-gray-400 text-xs"></i> | |
| <span class="ml-1 text-sm font-medium text-gray-500 md:ml-2">JavaScript Basics</span> | |
| </div> | |
| </li> | |
| </ol> | |
| </nav> | |
| <!-- Current Lesson --> | |
| <div class="bg-white rounded-lg shadow-md overflow-hidden mb-8"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-2xl font-bold text-gray-800">Variables and Data Types</h2> | |
| <span class="bg-green-100 text-green-800 text-xs font-medium px-2.5 py-0.5 rounded">Beginner</span> | |
| </div> | |
| <div class="prose max-w-none mb-6"> | |
| <p>In JavaScript, variables are containers for storing data values. JavaScript uses the <code>var</code>, <code>let</code>, and <code>const</code> keywords to declare variables.</p> | |
| <h3 class="text-xl font-semibold mt-4">Variable Declaration</h3> | |
| <pre class="bg-gray-100 p-4 rounded-md overflow-x-auto"> | |
| <code> | |
| // Using var (old way, not recommended) | |
| var name = "John"; | |
| // Using let (block-scoped, can be reassigned) | |
| let age = 25; | |
| // Using const (block-scoped, cannot be reassigned) | |
| const PI = 3.14; | |
| </code> | |
| </pre> | |
| <h3 class="text-xl font-semibold mt-4">Data Types</h3> | |
| <p>JavaScript has several data types:</p> | |
| <ul class="list-disc pl-5"> | |
| <li><strong>String:</strong> Textual data (e.g., "Hello World")</li> | |
| <li><strong>Number:</strong> Numeric data (e.g., 42, 3.14)</li> | |
| <li><strong>Boolean:</strong> True or false values</li> | |
| <li><strong>Object:</strong> Collections of key-value pairs</li> | |
| <li><strong>Array:</strong> Ordered lists of values</li> | |
| <li><strong>Null:</strong> Intentional absence of any object value</li> | |
| <li><strong>Undefined:</strong> Variable that has not been assigned a value</li> | |
| </ul> | |
| <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mt-4"> | |
| <div class="flex"> | |
| <div class="flex-shrink-0"> | |
| <i class="fas fa-lightbulb text-blue-500"></i> | |
| </div> | |
| <div class="ml-3"> | |
| <p class="text-sm text-blue-700"> | |
| <strong>Tip:</strong> Always use <code>const</code> by default, and only use <code>let</code> when you know the variable's value will change. Avoid <code>var</code> in modern JavaScript. | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="flex justify-between mt-8"> | |
| <button class="flex items-center text-blue-600 hover:text-blue-800"> | |
| <i class="fas fa-arrow-left mr-2"></i> | |
| Previous Lesson | |
| </button> | |
| <button id="startQuizBtn" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition"> | |
| Take Quiz | |
| <i class="fas fa-arrow-right ml-2"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Lesson Navigation --> | |
| <div class="bg-white rounded-lg shadow-md overflow-hidden mb-8"> | |
| <div class="p-6"> | |
| <h3 class="text-lg font-semibold mb-4">Course Lessons</h3> | |
| <div class="space-y-3"> | |
| <div class="flex items-center p-3 rounded-md bg-blue-50 border border-blue-200"> | |
| <div class="flex-shrink-0 w-8 h-8 rounded-full bg-blue-600 text-white flex items-center justify-center"> | |
| <span>1</span> | |
| </div> | |
| <div class="ml-3 flex-1"> | |
| <h4 class="text-sm font-medium">Introduction to JavaScript</h4> | |
| <p class="text-xs text-gray-500">Completed</p> | |
| </div> | |
| <i class="fas fa-check text-green-500"></i> | |
| </div> | |
| <div class="flex items-center p-3 rounded-md bg-blue-50 border border-blue-200"> | |
| <div class="flex-shrink-0 w-8 h-8 rounded-full bg-blue-600 text-white flex items-center justify-center"> | |
| <span>2</span> | |
| </div> | |
| <div class="ml-3 flex-1"> | |
| <h4 class="text-sm font-medium">Variables and Data Types</h4> | |
| <p class="text-xs text-gray-500">Current Lesson</p> | |
| </div> | |
| <i class="fas fa-play text-blue-500"></i> | |
| </div> | |
| <div class="flex items-center p-3 rounded-md hover:bg-gray-50 cursor-pointer"> | |
| <div class="flex-shrink-0 w-8 h-8 rounded-full bg-gray-200 text-gray-600 flex items-center justify-center"> | |
| <span>3</span> | |
| </div> | |
| <div class="ml-3 flex-1"> | |
| <h4 class="text-sm font-medium">Operators and Expressions</h4> | |
| <p class="text-xs text-gray-500">Locked</p> | |
| </div> | |
| <i class="fas fa-lock text-gray-400"></i> | |
| </div> | |
| <div class="flex items-center p-3 rounded-md hover:bg-gray-50 cursor-pointer"> | |
| <div class="flex-shrink-0 w-8 h-8 rounded-full bg-gray-200 text-gray-600 flex items-center justify-center"> | |
| <span>4</span> | |
| </div> | |
| <div class="ml-3 flex-1"> | |
| <h4 class="text-sm font-medium">Control Flow</h4> | |
| <p class="text-xs text-gray-500">Locked</p> | |
| </div> | |
| <i class="fas fa-lock text-gray-400"></i> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <!-- Quiz Modal --> | |
| <div id="quizModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-6"> | |
| <h3 class="text-xl font-bold">Lesson Quiz</h3> | |
| <button id="closeQuizModal" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="mb-6"> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span>Progress</span> | |
| <span><span id="currentQuestion">1</span>/5</span> | |
| </div> | |
| <div class="w-full bg-gray-200 rounded-full h-2"> | |
| <div id="quizProgress" class="bg-blue-600 h-2 rounded-full" style="width: 20%"></div> | |
| </div> | |
| </div> | |
| <div id="quizContent"> | |
| <div class="question mb-6"> | |
| <h4 class="text-lg font-semibold mb-4">1. Which keyword is used to declare a variable that cannot be reassigned?</h4> | |
| <div class="space-y-3"> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>var</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>let</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true"> | |
| <span>const</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>static</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="question mb-6 hidden"> | |
| <h4 class="text-lg font-semibold mb-4">2. What will be the output of: <code>console.log(typeof 42);</code></h4> | |
| <div class="space-y-3"> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>"string"</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true"> | |
| <span>"number"</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>"integer"</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>"float"</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="question mb-6 hidden"> | |
| <h4 class="text-lg font-semibold mb-4">3. Which of the following is NOT a valid JavaScript data type?</h4> | |
| <div class="space-y-3"> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>Boolean</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>Undefined</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true"> | |
| <span>Character</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>Symbol</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="question mb-6 hidden"> | |
| <h4 class="text-lg font-semibold mb-4">4. What is the correct way to declare a variable in modern JavaScript?</h4> | |
| <div class="space-y-3"> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>variable name = "Alice";</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true"> | |
| <span>let name = "Alice";</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>v name = "Alice";</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>string name = "Alice";</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="question mb-6 hidden"> | |
| <h4 class="text-lg font-semibold mb-4">5. Which of the following is a valid variable name in JavaScript?</h4> | |
| <div class="space-y-3"> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>2ndPlace</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>first-name</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true"> | |
| <span>firstName</span> | |
| </div> | |
| <div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false"> | |
| <span>let</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="flex justify-between mt-8"> | |
| <button id="prevQuestionBtn" class="text-blue-600 hover:text-blue-800 disabled:opacity-50 disabled:cursor-not-allowed" disabled> | |
| <i class="fas fa-arrow-left mr-2"></i> | |
| Previous | |
| </button> | |
| <button id="nextQuestionBtn" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition"> | |
| Next Question | |
| <i class="fas fa-arrow-right ml-2"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Quiz Results Modal --> | |
| <div id="resultsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-lg shadow-xl w-full max-w-md"> | |
| <div class="p-6 text-center"> | |
| <div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-green-100 mb-4"> | |
| <i class="fas fa-trophy text-green-600 text-xl"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-gray-900 mb-2">Quiz Completed!</h3> | |
| <div class="mt-2"> | |
| <p class="text-sm text-gray-500">You scored <span id="quizScore" class="font-bold">0</span> out of 5</p> | |
| </div> | |
| <div class="mt-6"> | |
| <div class="w-full bg-gray-200 rounded-full h-2.5 mb-4"> | |
| <div id="scoreBar" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| <div class="mt-6 flex justify-center gap-4"> | |
| <button id="retakeQuizBtn" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50"> | |
| Retake Quiz | |
| </button> | |
| <button id="continueLearningBtn" class="px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700"> | |
| Continue Learning | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Footer --> | |
| <footer class="bg-gray-800 text-white py-12"> | |
| <div class="container mx-auto px-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-4 gap-8"> | |
| <div> | |
| <h3 class="text-lg font-semibold mb-4">CodeMaster</h3> | |
| <p class="text-gray-400">Learn programming the easy way with interactive lessons and quizzes.</p> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4">Courses</h4> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Web Development</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Mobile Development</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Data Science</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Algorithms</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4">Resources</h4> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Documentation</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Blog</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Community</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Support</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4">Connect</h4> | |
| <div class="flex space-x-4"> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-facebook-f"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-twitter"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-instagram"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-linkedin-in"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-github"></i></a> | |
| </div> | |
| <div class="mt-4"> | |
| <p class="text-gray-400">Subscribe to our newsletter</p> | |
| <div class="mt-2 flex"> | |
| <input type="email" placeholder="Your email" class="px-3 py-2 bg-gray-700 text-white rounded-l-md focus:outline-none focus:ring-1 focus:ring-blue-500 w-full"> | |
| <button class="bg-blue-600 text-white px-4 py-2 rounded-r-md hover:bg-blue-700">Subscribe</button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400 text-sm"> | |
| <p>© 2023 CodeMaster. All rights reserved.</p> | |
| </div> | |
| </div> | |
| </footer> | |
| <script> | |
| // Language switcher | |
| const languageBtn = document.getElementById('languageBtn'); | |
| const languageMenu = document.getElementById('languageMenu'); | |
| const languageLinks = document.querySelectorAll('#languageMenu a'); | |
| languageBtn.addEventListener('click', () => { | |
| languageMenu.classList.toggle('hidden'); | |
| }); | |
| languageLinks.forEach(link => { | |
| link.addEventListener('click', (e) => { | |
| e.preventDefault(); | |
| const lang = link.getAttribute('data-lang'); | |
| languageBtn.querySelector('span').textContent = link.textContent; | |
| languageMenu.classList.add('hidden'); | |
| // In a real app, you would change the language here | |
| console.log(`Language changed to: ${lang}`); | |
| }); | |
| }); | |
| // Theme toggle | |
| const themeToggle = document.getElementById('themeToggle'); | |
| const icon = themeToggle.querySelector('i'); | |
| themeToggle.addEventListener('click', () => { | |
| document.documentElement.classList.toggle('dark'); | |
| if (document.documentElement.classList.contains('dark')) { | |
| icon.classList.remove('fa-moon'); | |
| icon.classList.add('fa-sun'); | |
| localStorage.setItem('theme', 'dark'); | |
| } else { | |
| icon.classList.remove('fa-sun'); | |
| icon.classList.add('fa-moon'); | |
| localStorage.setItem('theme', 'light'); | |
| } | |
| }); | |
| // Check for saved theme preference | |
| if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) { | |
| document.documentElement.classList.add('dark'); | |
| icon.classList.remove('fa-moon'); | |
| icon.classList.add('fa-sun'); | |
| } | |
| // Quiz functionality | |
| const quizModal = document.getElementById('quizModal'); | |
| const startQuizBtn = document.getElementById('startQuizBtn'); | |
| const closeQuizModal = document.getElementById('closeQuizModal'); | |
| const nextQuestionBtn = document.getElementById('nextQuestionBtn'); | |
| const prevQuestionBtn = document.getElementById('prevQuestionBtn'); | |
| const currentQuestionDisplay = document.getElementById('currentQuestion'); | |
| const quizProgress = document.getElementById('quizProgress'); | |
| const quizContent = document.getElementById('quizContent'); | |
| const questions = document.querySelectorAll('.question'); | |
| const quizOptions = document.querySelectorAll('.quiz-option'); | |
| const resultsModal = document.getElementById('resultsModal'); | |
| const quizScore = document.getElementById('quizScore'); | |
| const scoreBar = document.getElementById('scoreBar'); | |
| const retakeQuizBtn = document.getElementById('retakeQuizBtn'); | |
| const continueLearningBtn = document.getElementById('continueLearningBtn'); | |
| let currentQuestion = 0; | |
| let score = 0; | |
| let userAnswers = Array(questions.length).fill(null); | |
| startQuizBtn.addEventListener('click', () => { | |
| quizModal.classList.remove('hidden'); | |
| document.body.style.overflow = 'hidden'; | |
| showQuestion(0); | |
| }); | |
| closeQuizModal.addEventListener('click', () => { | |
| quizModal.classList.add('hidden'); | |
| document.body.style.overflow = 'auto'; | |
| }); | |
| nextQuestionBtn.addEventListener('click', () => { | |
| if (currentQuestion < questions.length - 1) { | |
| currentQuestion++; | |
| showQuestion(currentQuestion); | |
| } else { | |
| showResults(); | |
| } | |
| }); | |
| prevQuestionBtn.addEventListener('click', () => { | |
| if (currentQuestion > 0) { | |
| currentQuestion--; | |
| showQuestion(currentQuestion); | |
| } | |
| }); | |
| quizOptions.forEach(option => { | |
| option.addEventListener('click', () => { | |
| const questionContainer = option.closest('.question'); | |
| const options = questionContainer.querySelectorAll('.quiz-option'); | |
| // Remove selected class from all options in this question | |
| options.forEach(opt => { | |
| opt.classList.remove('selected'); | |
| }); | |
| // Add selected class to clicked option | |
| option.classList.add('selected'); | |
| // Store user answer | |
| const questionIndex = Array.from(questions).indexOf(questionContainer); | |
| userAnswers[questionIndex] = option.getAttribute('data-correct') === 'true'; | |
| // Enable next button | |
| nextQuestionBtn.disabled = false; | |
| }); | |
| }); | |
| retakeQuizBtn.addEventListener('click', () => { | |
| resultsModal.classList.add('hidden'); | |
| currentQuestion = 0; | |
| score = 0; | |
| userAnswers = Array(questions.length).fill(null); | |
| resetQuiz(); | |
| showQuestion(0); | |
| quizModal.classList.remove('hidden'); | |
| }); | |
| continueLearningBtn.addEventListener('click', () => { | |
| resultsModal.classList.add('hidden'); | |
| quizModal.classList.add('hidden'); | |
| document.body.style.overflow = 'auto'; | |
| }); | |
| function showQuestion(index) { | |
| // Hide all questions | |
| questions.forEach(question => { | |
| question.classList.add('hidden'); | |
| }); | |
| // Show current question | |
| questions[index].classList.remove('hidden'); | |
| // Update progress display | |
| currentQuestionDisplay.textContent = index + 1; | |
| const progressPercent = ((index + 1) / questions.length) * 100; | |
| quizProgress.style.width = `${progressPercent}%`; | |
| // Update button states | |
| prevQuestionBtn.disabled = index === 0; | |
| if (index === questions.length - 1) { | |
| nextQuestionBtn.innerHTML = 'Finish Quiz <i class="fas fa-check ml-2"></i>'; | |
| } else { | |
| nextQuestionBtn.innerHTML = 'Next Question <i class="fas fa-arrow-right ml-2"></i>'; | |
| } | |
| // Disable next button if no answer selected for current question | |
| const currentOptions = questions[index].querySelectorAll('.quiz-option'); | |
| const hasSelected = Array.from(currentOptions).some(opt => opt.classList.contains('selected')); | |
| nextQuestionBtn.disabled = !hasSelected; | |
| // Restore user's previous answer if exists | |
| if (userAnswers[index] !== null) { | |
| currentOptions.forEach(opt => { | |
| if (opt.classList.contains('selected')) { | |
| opt.classList.remove('selected'); | |
| } | |
| }); | |
| // In a real app, you would restore the user's actual selected answer | |
| // This is simplified for the demo | |
| currentOptions[0].classList.add('selected'); | |
| } | |
| } | |
| function showResults() { | |
| // Calculate score | |
| score = userAnswers.filter(answer => answer === true).length; | |
| // Update results display | |
| quizScore.textContent = score; | |
| const scorePercent = (score / questions.length) * 100; | |
| scoreBar.style.width = `${scorePercent}%`; | |
| // Close quiz modal and show results | |
| quizModal.classList.add('hidden'); | |
| resultsModal.classList.remove('hidden'); | |
| } | |
| function resetQuiz() { | |
| // Reset all options | |
| quizOptions.forEach(option => { | |
| option.classList.remove('selected', 'correct', 'incorrect'); | |
| }); | |
| // Reset progress | |
| currentQuestionDisplay.textContent = '1'; | |
| quizProgress.style.width = '20%'; | |
| nextQuestionBtn.innerHTML = 'Next Question <i class="fas fa-arrow-right ml-2"></i>'; | |
| nextQuestionBtn.disabled = true; | |
| prevQuestionBtn.disabled = true; | |
| } | |
| // Close modals when clicking outside | |
| window.addEventListener('click', (e) => { | |
| if (e.target === quizModal) { | |
| quizModal.classList.add('hidden'); | |
| document.body.style.overflow = 'auto'; | |
| } | |
| if (e.target === resultsModal) { | |
| resultsModal.classList.add('hidden'); | |
| document.body.style.overflow = 'auto'; | |
| } | |
| }); | |
| </script> | |
| <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=mohamed7869/learning-coding" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |