Team Ai
Apppublic

chansung/code-explainer-pilot

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
2likes
index.html107 linesDownload Raw Back to root
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>Interactive Code Explorer - V5 Grouped Outline - Mobile Friendly (Refined V1)</title>7    <!-- Tailwind CSS CDN -->8    <script src="https://cdn.tailwindcss.com"></script>9    <!-- Inter Font -->10    <link rel="stylesheet" href="https://rsms.me/inter/inter.css">11    <!-- Prism.js CSS (Okaidia Theme) -->12    <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-okaidia.min.css" rel="stylesheet" />13    <link rel="stylesheet" href="style.css">14</head>15<body class="min-h-screen flex flex-col items-center justify-center antialiased">16 17    <!-- Main Container for the Code Explorer -->18    <div class="container mx-auto p-4 md:p-6 max-w-7xl w-full">19      <header class="mb-6 md:mb-8 text-center">20        <h1 class="text-3xl sm:text-4xl font-bold text-slate-800">Interactive Code Journey</h1>21        <p class="text-md sm:text-lg text-slate-600 mt-2">Step through the code, understand by doing. Click on code lines or outline to navigate.</p>22      </header>23 24      <div class="flex flex-col md:flex-row gap-4 md:items-stretch">25 26        <!-- ASIDE: Steps Outline Container -->27        <aside id="stepsOutlineContainer" class="w-full md:w-1/3 lg:w-1/4 bg-white shadow-xl rounded-xl flex flex-col overflow-hidden md:max-h-[calc(65vh+136px)]">28            <!-- Desktop Title -->29            <div class="p-4 border-b border-slate-200 hidden md:block">30                <h3 class="text-lg font-semibold text-slate-700">Journey Outline</h3>31            </div>32            <!-- Mobile Active Group/Step Info -->33            <div id="mobileCurrentStepDisplayContainer" class="p-3 border-b border-slate-200 md:hidden">34                <h4 class="text-xs sm:text-sm font-semibold text-slate-700">Current Section: <span id="mobileCurrentGroupText" class="text-sky-600 font-bold"></span></h4>35                <p class="text-sm text-slate-600 mt-1">Step: <span id="mobileCurrentStepText" class="text-sky-700 font-medium"></span></p>36            </div>37            <nav class="hidden md:block flex-grow overflow-y-auto custom-scrollbar p-3 sm:p-4">38                <ul id="stepsOutline" class="space-y-0"> <!-- Reduced space-y for tighter group layout -->39                </ul>40            </nav>41        </aside>42 43        <!-- MAIN: Code Explorer Content -->44        <main id="codeExplorer" class="w-full md:w-2/3 lg:w-3/4 bg-white shadow-2xl rounded-xl overflow-hidden flex flex-col">45          <div class="bg-slate-800 text-white p-3 sm:p-4 flex justify-between items-center border-b border-slate-700">46            <h2 id="snippetTitle" class="text-lg sm:text-xl font-semibold truncate pr-2">JS Snippet: Interactive Counter</h2>47            <div class="flex items-center space-x-2 sm:space-x-3">48              <button id="resetBtn" title="Reset to Start" class="p-2 rounded-full hover:bg-slate-700 focus:outline-none focus:ring-2 focus:ring-sky-500 transition-colors">49                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">50                  <path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" />51                </svg>52              </button>53              <span id="progressIndicator" class="text-xs sm:text-sm bg-slate-700 px-2 py-1 rounded-md">Step 1 / N</span>54            </div>55          </div>56 57          <div class="md:flex flex-1 min-h-0"> <!-- This flex container handles code/explanation layout -->58            <!-- Code View Pane -->59            <div class="md:w-3/5 bg-gray-900 text-gray-300 font-mono text-xs sm:text-sm relative overflow-y-auto custom-scrollbar max-h-[45vh] md:max-h-[65vh]">60              <div id="codeLinesContainer" class="p-2">61                <!-- Code lines will be rendered here by JS -->62              </div>63            </div>64 65            <!-- Explanation Pane -->66            <div class="md:w-2/5 bg-slate-100 p-4 sm:p-6 overflow-y-auto custom-scrollbar max-h-[45vh] md:max-h-[65vh]">67              <div id="explanationStepCategoryContainer" class="mb-2 empty:hidden">68                <!-- Category badge will be inserted here by JS -->69              </div>70              <h3 id="explanationStepTitle" class="text-lg sm:text-xl font-semibold text-sky-700 mb-1 sm:mb-2">Loading...</h3>71              <p id="explanationMeta" class="text-xs text-slate-500 mb-3 sm:mb-4">Initializing explorer...</p>72              <div id="explanationText" class="text-slate-700 text-sm space-y-3 leading-relaxed prose prose-sm max-w-none">73                <p>Please wait while the code explorer initializes.</p>74              </div>75            </div>76          </div>77 78          <div class="bg-slate-200 p-3 sm:p-4 flex justify-between items-center border-t border-slate-300">79            <button id="prevBtn" class="px-4 py-2 sm:px-5 sm:py-2.5 bg-slate-600 text-white rounded-lg hover:bg-slate-700 focus:outline-none focus:ring-2 focus:ring-slate-500 focus:ring-offset-2 transition-all duration-150 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2 shadow-md hover:shadow-lg disabled:shadow-none text-sm sm:text-base">80              <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-4 h-4 sm:w-5 sm:h-5">81                <path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18" />82              </svg>83              <span>Previous</span>84            </button>85            <button id="nextBtn" class="px-4 py-2 sm:px-5 sm:py-2.5 bg-sky-600 text-white rounded-lg hover:bg-sky-700 focus:outline-none focus:ring-2 focus:ring-sky-500 focus:ring-offset-2 transition-all duration-150 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2 shadow-md hover:shadow-lg disabled:shadow-none text-sm sm:text-base">86              <span>Next</span>87              <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-4 h-4 sm:w-5 sm:h-5">88                <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />89              </svg>90            </button>91          </div>92        </main>93      </div>94 95      <footer class="mt-6 md:mt-8 text-center text-xs sm:text-sm text-slate-500">96        <p>Variation 5 (Grouped Outline): Interactive Code Walkthrough. Crafted with Tailwind CSS & Vanilla JS. Syntax highlighting by Prism.js.</p>97      </footer>98    </div>99 100    <!-- Prism.js Core (must be before language components and your script) -->101    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>102    <!-- Prism.js JavaScript Language Component -->103    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-javascript.min.js"></script>104    <script src="script.js" defer></script>105 106</body>107</html>