Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +549 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 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: codesearch
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: green
|
| 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,549 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>CodeSearch AI - Programming Knowledge Engine</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 |
+
.code-container {
|
| 11 |
+
background-color: #1e293b;
|
| 12 |
+
border-radius: 0.5rem;
|
| 13 |
+
padding: 1rem;
|
| 14 |
+
position: relative;
|
| 15 |
+
}
|
| 16 |
+
.copy-btn {
|
| 17 |
+
position: absolute;
|
| 18 |
+
top: 0.5rem;
|
| 19 |
+
right: 0.5rem;
|
| 20 |
+
background-color: #3b82f6;
|
| 21 |
+
color: white;
|
| 22 |
+
border: none;
|
| 23 |
+
border-radius: 0.25rem;
|
| 24 |
+
padding: 0.25rem 0.5rem;
|
| 25 |
+
cursor: pointer;
|
| 26 |
+
font-size: 0.75rem;
|
| 27 |
+
}
|
| 28 |
+
.copy-btn:hover {
|
| 29 |
+
background-color: #2563eb;
|
| 30 |
+
}
|
| 31 |
+
.knowledge-item {
|
| 32 |
+
transition: all 0.2s ease;
|
| 33 |
+
}
|
| 34 |
+
.knowledge-item:hover {
|
| 35 |
+
transform: translateY(-2px);
|
| 36 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 37 |
+
}
|
| 38 |
+
.tab-content {
|
| 39 |
+
display: none;
|
| 40 |
+
}
|
| 41 |
+
.tab-content.active {
|
| 42 |
+
display: block;
|
| 43 |
+
animation: fadeIn 0.3s ease;
|
| 44 |
+
}
|
| 45 |
+
@keyframes fadeIn {
|
| 46 |
+
from { opacity: 0; }
|
| 47 |
+
to { opacity: 1; }
|
| 48 |
+
}
|
| 49 |
+
.search-box {
|
| 50 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
| 51 |
+
}
|
| 52 |
+
.result-card {
|
| 53 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 54 |
+
}
|
| 55 |
+
</style>
|
| 56 |
+
</head>
|
| 57 |
+
<body class="bg-gray-50 min-h-screen">
|
| 58 |
+
<div class="container mx-auto px-4 py-8">
|
| 59 |
+
<!-- Header -->
|
| 60 |
+
<header class="mb-8 text-center">
|
| 61 |
+
<h1 class="text-4xl font-bold text-blue-600 mb-2">CodeSearch AI</h1>
|
| 62 |
+
<p class="text-gray-600">Your intelligent programming knowledge engine</p>
|
| 63 |
+
</header>
|
| 64 |
+
|
| 65 |
+
<!-- Main Content -->
|
| 66 |
+
<div class="flex flex-col lg:flex-row gap-8">
|
| 67 |
+
<!-- Search Section -->
|
| 68 |
+
<div class="lg:w-2/3">
|
| 69 |
+
<div class="search-box bg-white rounded-xl p-6 mb-6">
|
| 70 |
+
<div class="flex items-center mb-4">
|
| 71 |
+
<div class="w-full relative">
|
| 72 |
+
<input type="text" id="searchInput" placeholder="Ask anything about programming... (e.g. 'How to sort an array in JavaScript?' or 'What's the best way to handle user authentication?')" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 73 |
+
<button id="searchBtn" class="absolute right-2 top-1/2 transform -translate-y-1/2 bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-600 transition">
|
| 74 |
+
<i class="fas fa-search"></i> Search
|
| 75 |
+
</button>
|
| 76 |
+
</div>
|
| 77 |
+
</div>
|
| 78 |
+
<div class="flex flex-wrap gap-2 mb-4">
|
| 79 |
+
<span class="text-sm text-gray-500">Try:</span>
|
| 80 |
+
<button class="quick-query text-xs bg-gray-100 hover:bg-gray-200 px-3 py-1 rounded-full">array sorting methods</button>
|
| 81 |
+
<button class="quick-query text-xs bg-gray-100 hover:bg-gray-200 px-3 py-1 rounded-full">Python web frameworks</button>
|
| 82 |
+
<button class="quick-query text-xs bg-gray-100 hover:bg-gray-200 px-3 py-1 rounded-full">React hooks examples</button>
|
| 83 |
+
<button class="quick-query text-xs bg-gray-100 hover:bg-gray-200 px-3 py-1 rounded-full">SQL joins explained</button>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<!-- Results Section -->
|
| 88 |
+
<div id="resultsContainer" class="space-y-6">
|
| 89 |
+
<!-- Sample result (will be populated by JavaScript) -->
|
| 90 |
+
<div class="result-card bg-white rounded-xl p-6 hidden" id="sampleResult">
|
| 91 |
+
<div class="flex justify-between items-start mb-4">
|
| 92 |
+
<h2 class="text-xl font-semibold text-gray-800">Result Title</h2>
|
| 93 |
+
<div class="flex gap-2">
|
| 94 |
+
<button class="simplify-btn text-xs bg-blue-100 text-blue-600 hover:bg-blue-200 px-3 py-1 rounded-full">
|
| 95 |
+
<i class="fas fa-simplify mr-1"></i> Simplify
|
| 96 |
+
</button>
|
| 97 |
+
<button class="detail-btn text-xs bg-green-100 text-green-600 hover:bg-green-200 px-3 py-1 rounded-full">
|
| 98 |
+
<i class="fas fa-info-circle mr-1"></i> Details
|
| 99 |
+
</button>
|
| 100 |
+
<button class="examples-btn text-xs bg-purple-100 text-purple-600 hover:bg-purple-200 px-3 py-1 rounded-full">
|
| 101 |
+
<i class="fas fa-code mr-1"></i> Examples
|
| 102 |
+
</button>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
<div class="tab-content active" id="basicInfo">
|
| 107 |
+
<p class="text-gray-700 mb-4">Basic information about the concept...</p>
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
+
<div class="tab-content" id="detailedInfo">
|
| 111 |
+
<div class="space-y-4">
|
| 112 |
+
<div>
|
| 113 |
+
<h3 class="font-medium text-gray-800 mb-1">1. What it is</h3>
|
| 114 |
+
<p class="text-gray-700">Detailed definition...</p>
|
| 115 |
+
</div>
|
| 116 |
+
<div>
|
| 117 |
+
<h3 class="font-medium text-gray-800 mb-1">2. How it's used</h3>
|
| 118 |
+
<p class="text-gray-700">Usage information...</p>
|
| 119 |
+
</div>
|
| 120 |
+
<div>
|
| 121 |
+
<h3 class="font-medium text-gray-800 mb-1">3. Why it's important</h3>
|
| 122 |
+
<p class="text-gray-700">Importance explanation...</p>
|
| 123 |
+
</div>
|
| 124 |
+
<div>
|
| 125 |
+
<h3 class="font-medium text-gray-800 mb-1">4. When it's used</h3>
|
| 126 |
+
<p class="text-gray-700">Hierarchy and relational info...</p>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
</div>
|
| 130 |
+
|
| 131 |
+
<div class="tab-content" id="examplesInfo">
|
| 132 |
+
<div class="space-y-4">
|
| 133 |
+
<div>
|
| 134 |
+
<h3 class="font-medium text-gray-800 mb-2">Live Web Examples</h3>
|
| 135 |
+
<div class="space-y-4">
|
| 136 |
+
<div class="code-container">
|
| 137 |
+
<button class="copy-btn"><i class="fas fa-copy mr-1"></i> Copy</button>
|
| 138 |
+
<pre><code class="language-javascript text-white">// Example code will appear here</code></pre>
|
| 139 |
+
</div>
|
| 140 |
+
<div class="code-container">
|
| 141 |
+
<button class="copy-btn"><i class="fas fa-copy mr-1"></i> Copy</button>
|
| 142 |
+
<pre><code class="language-python text-white"># Another example in different language</code></pre>
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
</div>
|
| 146 |
+
</div>
|
| 147 |
+
</div>
|
| 148 |
+
|
| 149 |
+
<div class="mt-4 flex justify-between items-center">
|
| 150 |
+
<div class="text-sm text-gray-500">
|
| 151 |
+
<span>Source: </span>
|
| 152 |
+
<span class="text-blue-500">MDN Web Docs</span>
|
| 153 |
+
</div>
|
| 154 |
+
<button class="send-it-btn bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg flex items-center">
|
| 155 |
+
<i class="fas fa-paper-plane mr-2"></i> Send to My Codebase
|
| 156 |
+
</button>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
|
| 162 |
+
<!-- Knowledge Base Section -->
|
| 163 |
+
<div class="lg:w-1/3">
|
| 164 |
+
<div class="bg-white rounded-xl p-6 sticky top-4">
|
| 165 |
+
<div class="flex justify-between items-center mb-4">
|
| 166 |
+
<h2 class="text-xl font-semibold text-gray-800">My Codebase Knowledge</h2>
|
| 167 |
+
<button id="clearKnowledge" class="text-xs text-red-500 hover:text-red-700">
|
| 168 |
+
<i class="fas fa-trash-alt mr-1"></i> Clear All
|
| 169 |
+
</button>
|
| 170 |
+
</div>
|
| 171 |
+
|
| 172 |
+
<div class="tabs flex border-b mb-4">
|
| 173 |
+
<button class="tab-btn active px-4 py-2 text-blue-600 border-b-2 border-blue-500">Saved Items</button>
|
| 174 |
+
<button class="tab-btn px-4 py-2 text-gray-500 hover:text-gray-700">History</button>
|
| 175 |
+
</div>
|
| 176 |
+
|
| 177 |
+
<div id="knowledgeContent" class="space-y-4">
|
| 178 |
+
<div class="tab-content active" id="savedItems">
|
| 179 |
+
<div id="knowledgeList" class="space-y-3">
|
| 180 |
+
<!-- Sample knowledge item -->
|
| 181 |
+
<div class="knowledge-item bg-gray-50 p-4 rounded-lg border border-gray-200 cursor-pointer">
|
| 182 |
+
<div class="flex justify-between items-start">
|
| 183 |
+
<h3 class="font-medium text-gray-800">Array.prototype.map()</h3>
|
| 184 |
+
<button class="delete-knowledge text-red-400 hover:text-red-600 text-xs">
|
| 185 |
+
<i class="fas fa-times"></i>
|
| 186 |
+
</button>
|
| 187 |
+
</div>
|
| 188 |
+
<p class="text-sm text-gray-600 mt-1">Asked: "How to transform array elements in JavaScript?"</p>
|
| 189 |
+
<div class="mt-2 flex justify-between items-center">
|
| 190 |
+
<span class="text-xs text-gray-500">Saved: 2 days ago</span>
|
| 191 |
+
<button class="view-btn text-xs text-blue-500 hover:text-blue-700">
|
| 192 |
+
<i class="fas fa-eye mr-1"></i> View
|
| 193 |
+
</button>
|
| 194 |
+
</div>
|
| 195 |
+
</div>
|
| 196 |
+
</div>
|
| 197 |
+
<p id="emptyKnowledge" class="text-center text-gray-500 py-4 hidden">Your knowledge base is empty. Save items from search results to build your personal library.</p>
|
| 198 |
+
</div>
|
| 199 |
+
|
| 200 |
+
<div class="tab-content" id="historyItems">
|
| 201 |
+
<div id="historyList" class="space-y-3">
|
| 202 |
+
<!-- Sample history item -->
|
| 203 |
+
<div class="knowledge-item bg-gray-50 p-4 rounded-lg border border-gray-200 cursor-pointer">
|
| 204 |
+
<h3 class="font-medium text-gray-800">Promise.all()</h3>
|
| 205 |
+
<p class="text-sm text-gray-600 mt-1">Searched: "How to handle multiple promises in JavaScript?"</p>
|
| 206 |
+
<div class="mt-2 flex justify-between items-center">
|
| 207 |
+
<span class="text-xs text-gray-500">2 hours ago</span>
|
| 208 |
+
<button class="save-btn text-xs text-green-500 hover:text-green-700">
|
| 209 |
+
<i class="fas fa-save mr-1"></i> Save
|
| 210 |
+
</button>
|
| 211 |
+
</div>
|
| 212 |
+
</div>
|
| 213 |
+
</div>
|
| 214 |
+
<p id="emptyHistory" class="text-center text-gray-500 py-4 hidden">Your search history is empty.</p>
|
| 215 |
+
</div>
|
| 216 |
+
</div>
|
| 217 |
+
</div>
|
| 218 |
+
</div>
|
| 219 |
+
</div>
|
| 220 |
+
</div>
|
| 221 |
+
|
| 222 |
+
<script>
|
| 223 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 224 |
+
// Tab functionality
|
| 225 |
+
const tabButtons = document.querySelectorAll('.tab-btn');
|
| 226 |
+
tabButtons.forEach(button => {
|
| 227 |
+
button.addEventListener('click', () => {
|
| 228 |
+
const tabType = button.textContent.trim();
|
| 229 |
+
tabButtons.forEach(btn => btn.classList.remove('active', 'text-blue-600', 'border-blue-500'));
|
| 230 |
+
button.classList.add('active', 'text-blue-600', 'border-blue-500');
|
| 231 |
+
|
| 232 |
+
// Show corresponding content
|
| 233 |
+
if (tabType === 'Saved Items') {
|
| 234 |
+
document.querySelector('#savedItems').classList.add('active');
|
| 235 |
+
document.querySelector('#historyItems').classList.remove('active');
|
| 236 |
+
} else {
|
| 237 |
+
document.querySelector('#historyItems').classList.add('active');
|
| 238 |
+
document.querySelector('#savedItems').classList.remove('active');
|
| 239 |
+
}
|
| 240 |
+
});
|
| 241 |
+
});
|
| 242 |
+
|
| 243 |
+
// Result tab functionality
|
| 244 |
+
function setupResultTabs(resultElement) {
|
| 245 |
+
const simplifyBtn = resultElement.querySelector('.simplify-btn');
|
| 246 |
+
const detailBtn = resultElement.querySelector('.detail-btn');
|
| 247 |
+
const examplesBtn = resultElement.querySelector('.examples-btn');
|
| 248 |
+
|
| 249 |
+
const basicInfo = resultElement.querySelector('#basicInfo');
|
| 250 |
+
const detailedInfo = resultElement.querySelector('#detailedInfo');
|
| 251 |
+
const examplesInfo = resultElement.querySelector('#examplesInfo');
|
| 252 |
+
|
| 253 |
+
simplifyBtn.addEventListener('click', () => {
|
| 254 |
+
[basicInfo, detailedInfo, examplesInfo].forEach(tab => tab.classList.remove('active'));
|
| 255 |
+
basicInfo.classList.add('active');
|
| 256 |
+
});
|
| 257 |
+
|
| 258 |
+
detailBtn.addEventListener('click', () => {
|
| 259 |
+
[basicInfo, detailedInfo, examplesInfo].forEach(tab => tab.classList.remove('active'));
|
| 260 |
+
detailedInfo.classList.add('active');
|
| 261 |
+
});
|
| 262 |
+
|
| 263 |
+
examplesBtn.addEventListener('click', () => {
|
| 264 |
+
[basicInfo, detailedInfo, examplesInfo].forEach(tab => tab.classList.remove('active'));
|
| 265 |
+
examplesInfo.classList.add('active');
|
| 266 |
+
});
|
| 267 |
+
|
| 268 |
+
// Copy button functionality
|
| 269 |
+
const copyButtons = resultElement.querySelectorAll('.copy-btn');
|
| 270 |
+
copyButtons.forEach(button => {
|
| 271 |
+
button.addEventListener('click', () => {
|
| 272 |
+
const codeBlock = button.parentElement.querySelector('code');
|
| 273 |
+
navigator.clipboard.writeText(codeBlock.textContent);
|
| 274 |
+
button.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
| 275 |
+
setTimeout(() => {
|
| 276 |
+
button.innerHTML = '<i class="fas fa-copy mr-1"></i> Copy';
|
| 277 |
+
}, 2000);
|
| 278 |
+
});
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
// Send to codebase button
|
| 282 |
+
const sendItBtn = resultElement.querySelector('.send-it-btn');
|
| 283 |
+
sendItBtn.addEventListener('click', () => {
|
| 284 |
+
// In a real app, this would save to local storage or a database
|
| 285 |
+
alert('This item has been added to your codebase knowledge!');
|
| 286 |
+
addToKnowledgeBase(resultElement);
|
| 287 |
+
});
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
// Quick query buttons
|
| 291 |
+
document.querySelectorAll('.quick-query').forEach(button => {
|
| 292 |
+
button.addEventListener('click', () => {
|
| 293 |
+
document.getElementById('searchInput').value = button.textContent;
|
| 294 |
+
performSearch(button.textContent);
|
| 295 |
+
});
|
| 296 |
+
});
|
| 297 |
+
|
| 298 |
+
// Search functionality
|
| 299 |
+
document.getElementById('searchBtn').addEventListener('click', () => {
|
| 300 |
+
const query = document.getElementById('searchInput').value.trim();
|
| 301 |
+
if (query) {
|
| 302 |
+
performSearch(query);
|
| 303 |
+
}
|
| 304 |
+
});
|
| 305 |
+
|
| 306 |
+
// Also trigger search on Enter key
|
| 307 |
+
document.getElementById('searchInput').addEventListener('keypress', (e) => {
|
| 308 |
+
if (e.key === 'Enter') {
|
| 309 |
+
const query = document.getElementById('searchInput').value.trim();
|
| 310 |
+
if (query) {
|
| 311 |
+
performSearch(query);
|
| 312 |
+
}
|
| 313 |
+
}
|
| 314 |
+
});
|
| 315 |
+
|
| 316 |
+
// Clear knowledge base
|
| 317 |
+
document.getElementById('clearKnowledge').addEventListener('click', () => {
|
| 318 |
+
if (confirm('Are you sure you want to clear your entire knowledge base?')) {
|
| 319 |
+
document.getElementById('knowledgeList').innerHTML = '';
|
| 320 |
+
document.getElementById('emptyKnowledge').classList.remove('hidden');
|
| 321 |
+
}
|
| 322 |
+
});
|
| 323 |
+
|
| 324 |
+
// Sample data for demonstration
|
| 325 |
+
const sampleData = {
|
| 326 |
+
"array sorting methods": {
|
| 327 |
+
title: "Array Sorting Methods",
|
| 328 |
+
basic: "Array sorting methods allow you to order elements in an array based on specific criteria.",
|
| 329 |
+
details: {
|
| 330 |
+
what: "Array sorting refers to the process of arranging elements in an array in a particular order (ascending, descending, or based on custom criteria).",
|
| 331 |
+
how: "In JavaScript, arrays have a built-in sort() method. Other languages like Python use sorted() function or list.sort() method.",
|
| 332 |
+
why: "Sorting is fundamental for efficient data retrieval, presentation, and many algorithms rely on sorted data.",
|
| 333 |
+
when: "Used when you need ordered data for display, searching (binary search), or when preparing data for algorithms that require sorted input."
|
| 334 |
+
},
|
| 335 |
+
examples: [
|
| 336 |
+
{
|
| 337 |
+
language: "JavaScript",
|
| 338 |
+
code: "// Basic sort\nconst numbers = [3, 1, 4, 1, 5, 9];\nnumbers.sort((a, b) => a - b); // [1, 1, 3, 4, 5, 9]\n\n// Sort objects\nconst users = [{name: 'John', age: 30}, {name: 'Jane', age: 25}];\nusers.sort((a, b) => a.age - b.age); // Sorted by age"
|
| 339 |
+
},
|
| 340 |
+
{
|
| 341 |
+
language: "Python",
|
| 342 |
+
code: "# Basic sort\nnumbers = [3, 1, 4, 1, 5, 9]\nsorted_numbers = sorted(numbers) # [1, 1, 3, 4, 5, 9]\n\n# Sort with key\nusers = [{'name': 'John', 'age': 30}, {'name': 'Jane', 'age': 25}]\nsorted_users = sorted(users, key=lambda x: x['age'])"
|
| 343 |
+
}
|
| 344 |
+
],
|
| 345 |
+
source: "MDN Web Docs, Python Documentation"
|
| 346 |
+
},
|
| 347 |
+
"Python web frameworks": {
|
| 348 |
+
title: "Python Web Frameworks",
|
| 349 |
+
basic: "Python offers several web frameworks for building web applications of varying complexity.",
|
| 350 |
+
details: {
|
| 351 |
+
what: "Python web frameworks are collections of modules that help developers build web applications faster by providing common functionality.",
|
| 352 |
+
how: "Popular frameworks include Django (batteries-included), Flask (microframework), FastAPI (async), and Pyramid. They're used by importing their modules and following their patterns.",
|
| 353 |
+
why: "Frameworks handle common tasks (routing, templating, DB interaction) so developers can focus on application logic.",
|
| 354 |
+
when: "Used when building web applications, APIs, or any HTTP-based service in Python. Choice depends on project size and requirements."
|
| 355 |
+
},
|
| 356 |
+
examples: [
|
| 357 |
+
{
|
| 358 |
+
language: "Python (Flask)",
|
| 359 |
+
code: "from flask import Flask\napp = Flask(__name__)\n\[email protected]('/')\ndef hello():\n return 'Hello, World!'\n\nif __name__ == '__main__':\n app.run()"
|
| 360 |
+
},
|
| 361 |
+
{
|
| 362 |
+
language: "Python (Django)",
|
| 363 |
+
code: "# Django view example\nfrom django.http import HttpResponse\nfrom django.shortcuts import render\n\ndef index(request):\n return HttpResponse('Hello, World!')\n\n# In urls.py\nfrom django.urls import path\nfrom . import views\n\nurlpatterns = [\n path('', views.index, name='index'),\n]"
|
| 364 |
+
}
|
| 365 |
+
],
|
| 366 |
+
source: "Flask Documentation, Django Documentation"
|
| 367 |
+
}
|
| 368 |
+
};
|
| 369 |
+
|
| 370 |
+
function performSearch(query) {
|
| 371 |
+
const resultsContainer = document.getElementById('resultsContainer');
|
| 372 |
+
resultsContainer.innerHTML = '';
|
| 373 |
+
|
| 374 |
+
// Show loading
|
| 375 |
+
const loadingDiv = document.createElement('div');
|
| 376 |
+
loadingDiv.className = 'text-center py-8';
|
| 377 |
+
loadingDiv.innerHTML = '<i class="fas fa-spinner fa-spin text-3xl text-blue-500"></i><p class="mt-2 text-gray-600">Analyzing your query...</p>';
|
| 378 |
+
resultsContainer.appendChild(loadingDiv);
|
| 379 |
+
|
| 380 |
+
// Simulate API call with timeout
|
| 381 |
+
setTimeout(() => {
|
| 382 |
+
resultsContainer.innerHTML = '';
|
| 383 |
+
|
| 384 |
+
// Check if we have sample data for this query
|
| 385 |
+
const lowerQuery = query.toLowerCase();
|
| 386 |
+
let resultData = null;
|
| 387 |
+
|
| 388 |
+
for (const key in sampleData) {
|
| 389 |
+
if (lowerQuery.includes(key)) {
|
| 390 |
+
resultData = sampleData[key];
|
| 391 |
+
break;
|
| 392 |
+
}
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
if (!resultData) {
|
| 396 |
+
// Default response if no sample data matches
|
| 397 |
+
resultData = {
|
| 398 |
+
title: "Understanding Your Query",
|
| 399 |
+
basic: "I've analyzed your query about '" + query + "'. While I don't have a specific response for this exact question, here's how I would typically structure information about programming concepts.",
|
| 400 |
+
details: {
|
| 401 |
+
what: "A programming concept would be defined here, explaining its purpose and functionality.",
|
| 402 |
+
how: "This section would detail how to implement or use the concept, including language specifics.",
|
| 403 |
+
why: "Here we'd explain the importance and problems this concept solves.",
|
| 404 |
+
when: "This part would describe typical use cases and architectural placement."
|
| 405 |
+
},
|
| 406 |
+
examples: [
|
| 407 |
+
{
|
| 408 |
+
language: "JavaScript",
|
| 409 |
+
code: "// Example code would appear here\nfunction example() {\n console.log('This is a sample implementation');\n}"
|
| 410 |
+
},
|
| 411 |
+
{
|
| 412 |
+
language: "Python",
|
| 413 |
+
code: "# Another example in a different language\ndef example():\n print('This is a sample implementation')"
|
| 414 |
+
}
|
| 415 |
+
],
|
| 416 |
+
source: "General Programming Knowledge"
|
| 417 |
+
};
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
// Clone the sample result template
|
| 421 |
+
const resultElement = document.getElementById('sampleResult').cloneNode(true);
|
| 422 |
+
resultElement.classList.remove('hidden');
|
| 423 |
+
|
| 424 |
+
// Populate with data
|
| 425 |
+
resultElement.querySelector('h2').textContent = resultData.title;
|
| 426 |
+
resultElement.querySelector('#basicInfo p').textContent = resultData.basic;
|
| 427 |
+
|
| 428 |
+
const detailedInfo = resultElement.querySelector('#detailedInfo');
|
| 429 |
+
detailedInfo.querySelector('div:nth-child(1) p').textContent = resultData.details.what;
|
| 430 |
+
detailedInfo.querySelector('div:nth-child(2) p').textContent = resultData.details.how;
|
| 431 |
+
detailedInfo.querySelector('div:nth-child(3) p').textContent = resultData.details.why;
|
| 432 |
+
detailedInfo.querySelector('div:nth-child(4) p').textContent = resultData.details.when;
|
| 433 |
+
|
| 434 |
+
const examplesContainer = resultElement.querySelector('#examplesInfo .space-y-4');
|
| 435 |
+
examplesContainer.innerHTML = '<h3 class="font-medium text-gray-800 mb-2">Live Web Examples</h3><div class="space-y-4">';
|
| 436 |
+
|
| 437 |
+
resultData.examples.forEach((example, index) => {
|
| 438 |
+
examplesContainer.innerHTML += `
|
| 439 |
+
<div class="code-container">
|
| 440 |
+
<button class="copy-btn"><i class="fas fa-copy mr-1"></i> Copy</button>
|
| 441 |
+
<pre><code class="language-${example.language.toLowerCase()} text-white">${example.code}</code></pre>
|
| 442 |
+
<div class="text-xs text-gray-400 mt-1">${example.language} Example ${index + 1}</div>
|
| 443 |
+
</div>
|
| 444 |
+
`;
|
| 445 |
+
});
|
| 446 |
+
|
| 447 |
+
examplesContainer.innerHTML += '</div>';
|
| 448 |
+
resultElement.querySelector('.text-blue-500').textContent = resultData.source;
|
| 449 |
+
|
| 450 |
+
// Set up the tabs and buttons for this result
|
| 451 |
+
setupResultTabs(resultElement);
|
| 452 |
+
|
| 453 |
+
// Add to results container
|
| 454 |
+
resultsContainer.appendChild(resultElement);
|
| 455 |
+
|
| 456 |
+
// Add to history
|
| 457 |
+
addToHistory(query, resultData.title);
|
| 458 |
+
|
| 459 |
+
}, 1500);
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
// Knowledge base functionality
|
| 463 |
+
function addToKnowledgeBase(resultElement) {
|
| 464 |
+
const title = resultElement.querySelector('h2').textContent;
|
| 465 |
+
const query = document.getElementById('searchInput').value.trim();
|
| 466 |
+
|
| 467 |
+
const knowledgeList = document.getElementById('knowledgeList');
|
| 468 |
+
const emptyKnowledge = document.getElementById('emptyKnowledge');
|
| 469 |
+
|
| 470 |
+
// Create new knowledge item
|
| 471 |
+
const knowledgeItem = document.createElement('div');
|
| 472 |
+
knowledgeItem.className = 'knowledge-item bg-gray-50 p-4 rounded-lg border border-gray-200 cursor-pointer';
|
| 473 |
+
knowledgeItem.innerHTML = `
|
| 474 |
+
<div class="flex justify-between items-start">
|
| 475 |
+
<h3 class="font-medium text-gray-800">${title}</h3>
|
| 476 |
+
<button class="delete-knowledge text-red-400 hover:text-red-600 text-xs">
|
| 477 |
+
<i class="fas fa-times"></i>
|
| 478 |
+
</button>
|
| 479 |
+
</div>
|
| 480 |
+
<p class="text-sm text-gray-600 mt-1">Asked: "${query}"</p>
|
| 481 |
+
<div class="mt-2 flex justify-between items-center">
|
| 482 |
+
<span class="text-xs text-gray-500">Saved: Just now</span>
|
| 483 |
+
<button class="view-btn text-xs text-blue-500 hover:text-blue-700">
|
| 484 |
+
<i class="fas fa-eye mr-1"></i> View
|
| 485 |
+
</button>
|
| 486 |
+
</div>
|
| 487 |
+
`;
|
| 488 |
+
|
| 489 |
+
// Add delete functionality
|
| 490 |
+
knowledgeItem.querySelector('.delete-knowledge').addEventListener('click', (e) => {
|
| 491 |
+
e.stopPropagation();
|
| 492 |
+
knowledgeItem.remove();
|
| 493 |
+
if (knowledgeList.children.length === 0) {
|
| 494 |
+
emptyKnowledge.classList.remove('hidden');
|
| 495 |
+
}
|
| 496 |
+
});
|
| 497 |
+
|
| 498 |
+
// Add view functionality
|
| 499 |
+
knowledgeItem.querySelector('.view-btn').addEventListener('click', () => {
|
| 500 |
+
// In a real app, this would show the full saved result
|
| 501 |
+
alert('Viewing saved item: ' + title);
|
| 502 |
+
});
|
| 503 |
+
|
| 504 |
+
// Add to knowledge list
|
| 505 |
+
knowledgeList.prepend(knowledgeItem);
|
| 506 |
+
emptyKnowledge.classList.add('hidden');
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
// History functionality
|
| 510 |
+
function addToHistory(query, title) {
|
| 511 |
+
const historyList = document.getElementById('historyList');
|
| 512 |
+
const emptyHistory = document.getElementById('emptyHistory');
|
| 513 |
+
|
| 514 |
+
// Create new history item
|
| 515 |
+
const historyItem = document.createElement('div');
|
| 516 |
+
historyItem.className = 'knowledge-item bg-gray-50 p-4 rounded-lg border border-gray-200 cursor-pointer';
|
| 517 |
+
historyItem.innerHTML = `
|
| 518 |
+
<h3 class="font-medium text-gray-800">${title}</h3>
|
| 519 |
+
<p class="text-sm text-gray-600 mt-1">Searched: "${query}"</p>
|
| 520 |
+
<div class="mt-2 flex justify-between items-center">
|
| 521 |
+
<span class="text-xs text-gray-500">Just now</span>
|
| 522 |
+
<button class="save-btn text-xs text-green-500 hover:text-green-700">
|
| 523 |
+
<i class="fas fa-save mr-1"></i> Save
|
| 524 |
+
</button>
|
| 525 |
+
</div>
|
| 526 |
+
`;
|
| 527 |
+
|
| 528 |
+
// Add save functionality
|
| 529 |
+
historyItem.querySelector('.save-btn').addEventListener('click', () => {
|
| 530 |
+
// In a real app, this would save to knowledge base
|
| 531 |
+
alert('Saved to knowledge base: ' + title);
|
| 532 |
+
});
|
| 533 |
+
|
| 534 |
+
// Add to history list
|
| 535 |
+
historyList.prepend(historyItem);
|
| 536 |
+
emptyHistory.classList.add('hidden');
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
// Initialize with some sample knowledge if empty
|
| 540 |
+
if (document.getElementById('knowledgeList').children.length === 0) {
|
| 541 |
+
document.getElementById('emptyKnowledge').classList.remove('hidden');
|
| 542 |
+
}
|
| 543 |
+
if (document.getElementById('historyList').children.length === 0) {
|
| 544 |
+
document.getElementById('emptyHistory').classList.remove('hidden');
|
| 545 |
+
}
|
| 546 |
+
});
|
| 547 |
+
</script>
|
| 548 |
+
<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=Its3sticks/codesearch" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 549 |
+
</html>
|