Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +461 -19
- prompts.txt +1 -0
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: code-master
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: red
|
| 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,461 @@
|
|
| 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="fr">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>CodeMaster - Correcteur de Code Puissant</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/atom-one-dark.min.css">
|
| 9 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
| 10 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/javascript.min.js"></script>
|
| 11 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/css.min.js"></script>
|
| 12 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/xml.min.js"></script>
|
| 13 |
+
<style>
|
| 14 |
+
.editor-container {
|
| 15 |
+
position: relative;
|
| 16 |
+
height: 500px;
|
| 17 |
+
}
|
| 18 |
+
.editor {
|
| 19 |
+
position: absolute;
|
| 20 |
+
top: 0;
|
| 21 |
+
right: 0;
|
| 22 |
+
bottom: 0;
|
| 23 |
+
left: 0;
|
| 24 |
+
font-family: 'Fira Code', monospace;
|
| 25 |
+
font-size: 14px;
|
| 26 |
+
line-height: 1.5;
|
| 27 |
+
tab-size: 2;
|
| 28 |
+
}
|
| 29 |
+
.error-marker {
|
| 30 |
+
position: absolute;
|
| 31 |
+
background-color: rgba(255, 0, 0, 0.2);
|
| 32 |
+
}
|
| 33 |
+
.warning-marker {
|
| 34 |
+
position: absolute;
|
| 35 |
+
background-color: rgba(255, 165, 0, 0.2);
|
| 36 |
+
}
|
| 37 |
+
.suggestion-marker {
|
| 38 |
+
position: absolute;
|
| 39 |
+
background-color: rgba(100, 149, 237, 0.2);
|
| 40 |
+
}
|
| 41 |
+
.hljs {
|
| 42 |
+
background: transparent !important;
|
| 43 |
+
}
|
| 44 |
+
.custom-scrollbar::-webkit-scrollbar {
|
| 45 |
+
width: 8px;
|
| 46 |
+
height: 8px;
|
| 47 |
+
}
|
| 48 |
+
.custom-scrollbar::-webkit-scrollbar-track {
|
| 49 |
+
background: #2d3748;
|
| 50 |
+
}
|
| 51 |
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
| 52 |
+
background: #4a5568;
|
| 53 |
+
border-radius: 4px;
|
| 54 |
+
}
|
| 55 |
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
| 56 |
+
background: #718096;
|
| 57 |
+
}
|
| 58 |
+
</style>
|
| 59 |
+
</head>
|
| 60 |
+
<body class="bg-gray-900 text-gray-100 min-h-screen">
|
| 61 |
+
<div class="container mx-auto px-4 py-8">
|
| 62 |
+
<header class="mb-8">
|
| 63 |
+
<div class="flex items-center justify-between">
|
| 64 |
+
<div class="flex items-center space-x-4">
|
| 65 |
+
<div class="w-10 h-10 bg-indigo-600 rounded-lg flex items-center justify-center">
|
| 66 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 67 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
|
| 68 |
+
</svg>
|
| 69 |
+
</div>
|
| 70 |
+
<h1 class="text-3xl font-bold bg-gradient-to-r from-indigo-400 to-purple-600 bg-clip-text text-transparent">CodeMaster</h1>
|
| 71 |
+
</div>
|
| 72 |
+
<div class="flex items-center space-x-4">
|
| 73 |
+
<button id="run-btn" class="px-4 py-2 bg-green-600 hover:bg-green-700 rounded-lg font-medium flex items-center space-x-2 transition-colors">
|
| 74 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
| 75 |
+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clip-rule="evenodd" />
|
| 76 |
+
</svg>
|
| 77 |
+
<span>Exécuter</span>
|
| 78 |
+
</button>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
<p class="mt-2 text-gray-400">Correcteur de code intelligent avec analyse en temps réel</p>
|
| 82 |
+
</header>
|
| 83 |
+
|
| 84 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
| 85 |
+
<div class="space-y-6">
|
| 86 |
+
<div class="bg-gray-800 rounded-xl overflow-hidden shadow-lg">
|
| 87 |
+
<div class="px-4 py-3 bg-gray-700 flex items-center justify-between">
|
| 88 |
+
<div class="flex items-center space-x-2">
|
| 89 |
+
<div class="w-3 h-3 rounded-full bg-red-500"></div>
|
| 90 |
+
<div class="w-3 h-3 rounded-full bg-yellow-500"></div>
|
| 91 |
+
<div class="w-3 h-3 rounded-full bg-green-500"></div>
|
| 92 |
+
</div>
|
| 93 |
+
<div class="flex items-center space-x-4">
|
| 94 |
+
<select id="language-select" class="bg-gray-800 text-gray-300 text-sm rounded px-2 py-1 focus:outline-none">
|
| 95 |
+
<option value="javascript">JavaScript</option>
|
| 96 |
+
<option value="html">HTML</option>
|
| 97 |
+
<option value="css">CSS</option>
|
| 98 |
+
<option value="python">Python</option>
|
| 99 |
+
<option value="php">PHP</option>
|
| 100 |
+
</select>
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
<div class="editor-container">
|
| 104 |
+
<pre id="editor" class="editor">function example() {
|
| 105 |
+
// Votre code ici
|
| 106 |
+
let x = 10;
|
| 107 |
+
if (x == "10") {
|
| 108 |
+
console.log("Égalité faible");
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
const unusedVar = "Je ne suis pas utilisé";
|
| 112 |
+
|
| 113 |
+
return x * 2;
|
| 114 |
+
}</pre>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<div class="bg-gray-800 rounded-xl overflow-hidden shadow-lg">
|
| 119 |
+
<div class="px-4 py-3 bg-gray-700">
|
| 120 |
+
<h3 class="font-medium">Analyse du code</h3>
|
| 121 |
+
</div>
|
| 122 |
+
<div id="analysis-results" class="p-4 max-h-64 overflow-y-auto custom-scrollbar">
|
| 123 |
+
<div class="text-gray-400 italic">Le code sera analysé automatiquement...</div>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<div class="bg-gray-800 rounded-xl overflow-hidden shadow-lg">
|
| 129 |
+
<div class="px-4 py-3 bg-gray-700 flex items-center justify-between">
|
| 130 |
+
<h3 class="font-medium">Résultat / Sortie</h3>
|
| 131 |
+
<div class="flex items-center space-x-2">
|
| 132 |
+
<button id="clear-output" class="text-gray-400 hover:text-white transition-colors">
|
| 133 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
| 134 |
+
<path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
|
| 135 |
+
</svg>
|
| 136 |
+
</button>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
<div id="output" class="p-4 h-full min-h-96 overflow-y-auto custom-scrollbar">
|
| 140 |
+
<div class="text-gray-400 italic">La sortie s'affichera ici...</div>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
<div class="mt-8 bg-gray-800 rounded-xl overflow-hidden shadow-lg">
|
| 146 |
+
<div class="px-4 py-3 bg-gray-700">
|
| 147 |
+
<h3 class="font-medium">Suggestions d'amélioration</h3>
|
| 148 |
+
</div>
|
| 149 |
+
<div id="suggestions" class="p-4">
|
| 150 |
+
<div class="text-gray-400 italic">Les suggestions apparaîtront après l'analyse...</div>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
</div>
|
| 154 |
+
|
| 155 |
+
<script>
|
| 156 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 157 |
+
// Initialisation de Highlight.js
|
| 158 |
+
hljs.highlightAll();
|
| 159 |
+
|
| 160 |
+
const editor = document.getElementById('editor');
|
| 161 |
+
const languageSelect = document.getElementById('language-select');
|
| 162 |
+
const runBtn = document.getElementById('run-btn');
|
| 163 |
+
const clearOutput = document.getElementById('clear-output');
|
| 164 |
+
const output = document.getElementById('output');
|
| 165 |
+
const analysisResults = document.getElementById('analysis-results');
|
| 166 |
+
const suggestions = document.getElementById('suggestions');
|
| 167 |
+
|
| 168 |
+
let markers = [];
|
| 169 |
+
|
| 170 |
+
// Détection automatique des erreurs
|
| 171 |
+
editor.addEventListener('input', debounce(analyzeCode, 500));
|
| 172 |
+
|
| 173 |
+
// Changement de langage
|
| 174 |
+
languageSelect.addEventListener('change', function() {
|
| 175 |
+
analyzeCode();
|
| 176 |
+
});
|
| 177 |
+
|
| 178 |
+
// Exécution du code
|
| 179 |
+
runBtn.addEventListener('click', executeCode);
|
| 180 |
+
|
| 181 |
+
// Effacer la sortie
|
| 182 |
+
clearOutput.addEventListener('click', function() {
|
| 183 |
+
output.innerHTML = '<div class="text-gray-400 italic">La sortie s\'affichera ici...</div>';
|
| 184 |
+
});
|
| 185 |
+
|
| 186 |
+
// Analyse du code
|
| 187 |
+
function analyzeCode() {
|
| 188 |
+
// Effacer les marqueurs précédents
|
| 189 |
+
clearMarkers();
|
| 190 |
+
|
| 191 |
+
const code = editor.textContent;
|
| 192 |
+
const language = languageSelect.value;
|
| 193 |
+
let errors = [];
|
| 194 |
+
let warnings = [];
|
| 195 |
+
let suggestionsList = [];
|
| 196 |
+
|
| 197 |
+
// Analyse basique (simulée)
|
| 198 |
+
if (language === 'javascript') {
|
| 199 |
+
// Détection d'égalité faible
|
| 200 |
+
const weakEqualRegex = /==/g;
|
| 201 |
+
let match;
|
| 202 |
+
while ((match = weakEqualRegex.exec(code)) !== null) {
|
| 203 |
+
warnings.push({
|
| 204 |
+
message: "Utilisation d'égalité faible (==). Préférez l'égalité stricte (===).",
|
| 205 |
+
line: getLineNumber(code, match.index),
|
| 206 |
+
column: match.index - getLineStartIndex(code, getLineNumber(code, match.index)) + 1,
|
| 207 |
+
index: match.index,
|
| 208 |
+
length: match[0].length
|
| 209 |
+
});
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
// Détection de variables non utilisées
|
| 213 |
+
const unusedVarRegex = /(const|let|var)\s+([a-zA-Z_$][0-9a-zA-Z_$]*)(?![^(]*\))(?!\s*=[^=])[^;]*?(?=;|$)/g;
|
| 214 |
+
while ((match = unusedVarRegex.exec(code)) !== null) {
|
| 215 |
+
const varName = match[2];
|
| 216 |
+
const varRegex = new RegExp(`\\b${varName}\\b(?!\\s*=[^=])`, 'g');
|
| 217 |
+
const usageCount = (code.match(varRegex) || []).length;
|
| 218 |
+
|
| 219 |
+
if (usageCount <= 1) {
|
| 220 |
+
warnings.push({
|
| 221 |
+
message: `Variable '${varName}' déclarée mais jamais utilisée.`,
|
| 222 |
+
line: getLineNumber(code, match.index),
|
| 223 |
+
column: match.index - getLineStartIndex(code, getLineNumber(code, match.index)) + 1,
|
| 224 |
+
index: match.index,
|
| 225 |
+
length: match[0].length
|
| 226 |
+
});
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
// Détection de return sans valeur
|
| 231 |
+
const emptyReturnRegex = /return\s*;(?!\s*$)/g;
|
| 232 |
+
while ((match = emptyReturnRegex.exec(code)) !== null) {
|
| 233 |
+
errors.push({
|
| 234 |
+
message: "Return sans valeur spécifiée.",
|
| 235 |
+
line: getLineNumber(code, match.index),
|
| 236 |
+
column: match.index - getLineStartIndex(code, getLineNumber(code, match.index)) + 1,
|
| 237 |
+
index: match.index,
|
| 238 |
+
length: match[0].length
|
| 239 |
+
});
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
// Suggestions d'amélioration
|
| 243 |
+
if (code.includes('console.log')) {
|
| 244 |
+
suggestionsList.push({
|
| 245 |
+
message: "Pour un meilleur suivi, envisagez d'utiliser des librairies de logging comme Winston ou Pino en production.",
|
| 246 |
+
category: "Best Practice"
|
| 247 |
+
});
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
if (code.includes('function') && !code.includes('arrow function')) {
|
| 251 |
+
suggestionsList.push({
|
| 252 |
+
message: "Pour un code plus concis, envisagez d'utiliser les fonctions fléchées (=>) lorsque c'est approprié.",
|
| 253 |
+
category: "Modern Syntax"
|
| 254 |
+
});
|
| 255 |
+
}
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// Mise à jour de l'interface
|
| 259 |
+
updateMarkers([...errors, ...warnings]);
|
| 260 |
+
updateAnalysisResults(errors, warnings);
|
| 261 |
+
updateSuggestions(suggestionsList);
|
| 262 |
+
|
| 263 |
+
// Re-highlight le code
|
| 264 |
+
hljs.highlightElement(editor);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
// Exécution du code
|
| 268 |
+
function executeCode() {
|
| 269 |
+
const code = editor.textContent;
|
| 270 |
+
const language = languageSelect.value;
|
| 271 |
+
|
| 272 |
+
output.innerHTML = '';
|
| 273 |
+
|
| 274 |
+
try {
|
| 275 |
+
if (language === 'javascript') {
|
| 276 |
+
// Crée un contexte sécurisé pour l'exécution
|
| 277 |
+
const originalConsoleLog = console.log;
|
| 278 |
+
let logs = [];
|
| 279 |
+
|
| 280 |
+
console.log = function() {
|
| 281 |
+
logs.push(Array.from(arguments).join(' '));
|
| 282 |
+
originalConsoleLog.apply(console, arguments);
|
| 283 |
+
};
|
| 284 |
+
|
| 285 |
+
// Exécute le code dans un contexte sécurisé
|
| 286 |
+
const result = new Function(code)();
|
| 287 |
+
|
| 288 |
+
// Restaure la console originale
|
| 289 |
+
console.log = originalConsoleLog;
|
| 290 |
+
|
| 291 |
+
// Affiche les logs
|
| 292 |
+
if (logs.length > 0) {
|
| 293 |
+
const logsDiv = document.createElement('div');
|
| 294 |
+
logsDiv.className = 'mb-4';
|
| 295 |
+
logsDiv.innerHTML = `<div class="text-gray-400 mb-1">Sortie console:</div>
|
| 296 |
+
<div class="bg-gray-700 p-3 rounded-lg font-mono text-sm">${logs.join('<br>')}</div>`;
|
| 297 |
+
output.appendChild(logsDiv);
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
// Affiche le résultat
|
| 301 |
+
if (result !== undefined) {
|
| 302 |
+
const resultDiv = document.createElement('div');
|
| 303 |
+
resultDiv.className = 'mb-4';
|
| 304 |
+
resultDiv.innerHTML = `<div class="text-gray-400 mb-1">Résultat retourné:</div>
|
| 305 |
+
<div class="bg-gray-700 p-3 rounded-lg font-mono text-sm">${JSON.stringify(result)}</div>`;
|
| 306 |
+
output.appendChild(resultDiv);
|
| 307 |
+
}
|
| 308 |
+
} else {
|
| 309 |
+
output.innerHTML = '<div class="text-yellow-400">L\'exécution directe n\'est disponible que pour JavaScript.</div>';
|
| 310 |
+
}
|
| 311 |
+
} catch (error) {
|
| 312 |
+
output.innerHTML = `<div class="text-red-400 font-mono">Erreur d'exécution: ${error.message}</div>`;
|
| 313 |
+
}
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
// Fonctions utilitaires
|
| 317 |
+
function getLineNumber(text, index) {
|
| 318 |
+
return text.substring(0, index).split('\n').length;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
function getLineStartIndex(text, lineNumber) {
|
| 322 |
+
const lines = text.split('\n');
|
| 323 |
+
if (lineNumber < 1 || lineNumber > lines.length) return 0;
|
| 324 |
+
|
| 325 |
+
let index = 0;
|
| 326 |
+
for (let i = 0; i < lineNumber - 1; i++) {
|
| 327 |
+
index += lines[i].length + 1; // +1 pour le saut de ligne
|
| 328 |
+
}
|
| 329 |
+
return index;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
function updateMarkers(issues) {
|
| 333 |
+
clearMarkers();
|
| 334 |
+
|
| 335 |
+
const editorRect = editor.getBoundingClientRect();
|
| 336 |
+
const lineHeight = parseInt(getComputedStyle(editor).lineHeight);
|
| 337 |
+
const charWidth = 8; // Approximation de la largeur d'un caractère
|
| 338 |
+
|
| 339 |
+
issues.forEach(issue => {
|
| 340 |
+
const lineNumber = issue.line;
|
| 341 |
+
const column = issue.column;
|
| 342 |
+
|
| 343 |
+
// Crée un marqueur visuel
|
| 344 |
+
const marker = document.createElement('div');
|
| 345 |
+
marker.className = issue.message.includes('Utilisation') || issue.message.includes('Variable') ?
|
| 346 |
+
'warning-marker' : 'error-marker';
|
| 347 |
+
|
| 348 |
+
// Positionne le marqueur
|
| 349 |
+
const top = (lineNumber - 1) * lineHeight;
|
| 350 |
+
const left = (column - 1) * charWidth;
|
| 351 |
+
|
| 352 |
+
marker.style.top = `${top}px`;
|
| 353 |
+
marker.style.left = `${left}px`;
|
| 354 |
+
marker.style.width = `${issue.length * charWidth}px`;
|
| 355 |
+
marker.style.height = `${lineHeight}px`;
|
| 356 |
+
|
| 357 |
+
// Ajoute un tooltip
|
| 358 |
+
marker.title = issue.message;
|
| 359 |
+
|
| 360 |
+
// Ajoute le marqueur à l'éditeur
|
| 361 |
+
editor.parentNode.appendChild(marker);
|
| 362 |
+
markers.push(marker);
|
| 363 |
+
});
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
function clearMarkers() {
|
| 367 |
+
markers.forEach(marker => marker.remove());
|
| 368 |
+
markers = [];
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
function updateAnalysisResults(errors, warnings) {
|
| 372 |
+
if (errors.length === 0 && warnings.length === 0) {
|
| 373 |
+
analysisResults.innerHTML = '<div class="text-green-400">Aucun problème détecté. Code propre!</div>';
|
| 374 |
+
return;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
let html = '';
|
| 378 |
+
|
| 379 |
+
if (errors.length > 0) {
|
| 380 |
+
html += '<div class="mb-4">';
|
| 381 |
+
html += '<div class="text-red-400 font-medium mb-2">Erreurs:</div>';
|
| 382 |
+
html += '<ul class="space-y-2">';
|
| 383 |
+
errors.forEach(error => {
|
| 384 |
+
html += `<li class="flex items-start">
|
| 385 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-red-500 mt-0.5 mr-2 flex-shrink-0" viewBox="0 0 20 20" fill="currentColor">
|
| 386 |
+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
|
| 387 |
+
</svg>
|
| 388 |
+
<div>
|
| 389 |
+
<span class="font-mono">Ligne ${error.line}:${error.column}</span> - ${error.message}
|
| 390 |
+
</div>
|
| 391 |
+
</li>`;
|
| 392 |
+
});
|
| 393 |
+
html += '</ul>';
|
| 394 |
+
html += '</div>';
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
if (warnings.length > 0) {
|
| 398 |
+
html += '<div>';
|
| 399 |
+
html += '<div class="text-yellow-400 font-medium mb-2">Avertissements:</div>';
|
| 400 |
+
html += '<ul class="space-y-2">';
|
| 401 |
+
warnings.forEach(warning => {
|
| 402 |
+
html += `<li class="flex items-start">
|
| 403 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-yellow-500 mt-0.5 mr-2 flex-shrink-0" viewBox="0 0 20 20" fill="currentColor">
|
| 404 |
+
<path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
|
| 405 |
+
</svg>
|
| 406 |
+
<div>
|
| 407 |
+
<span class="font-mono">Ligne ${warning.line}:${warning.column}</span> - ${warning.message}
|
| 408 |
+
</div>
|
| 409 |
+
</li>`;
|
| 410 |
+
});
|
| 411 |
+
html += '</ul>';
|
| 412 |
+
html += '</div>';
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
analysisResults.innerHTML = html;
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
function updateSuggestions(suggestionsList) {
|
| 419 |
+
if (suggestionsList.length === 0) {
|
| 420 |
+
suggestions.innerHTML = '<div class="text-gray-400 italic">Aucune suggestion pour le moment. Continuez votre bon travail!</div>';
|
| 421 |
+
return;
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
let html = '<div class="grid grid-cols-1 gap-4">';
|
| 425 |
+
|
| 426 |
+
suggestionsList.forEach(suggestion => {
|
| 427 |
+
html += `<div class="bg-gray-700 p-4 rounded-lg">
|
| 428 |
+
<div class="flex items-start">
|
| 429 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-blue-400 mt-0.5 mr-2 flex-shrink-0" viewBox="0 0 20 20" fill="currentColor">
|
| 430 |
+
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
|
| 431 |
+
</svg>
|
| 432 |
+
<div>
|
| 433 |
+
<div class="text-blue-400 text-sm font-medium mb-1">${suggestion.category}</div>
|
| 434 |
+
<div>${suggestion.message}</div>
|
| 435 |
+
</div>
|
| 436 |
+
</div>
|
| 437 |
+
</div>`;
|
| 438 |
+
});
|
| 439 |
+
|
| 440 |
+
html += '</div>';
|
| 441 |
+
suggestions.innerHTML = html;
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
function debounce(func, wait) {
|
| 445 |
+
let timeout;
|
| 446 |
+
return function() {
|
| 447 |
+
const context = this;
|
| 448 |
+
const args = arguments;
|
| 449 |
+
clearTimeout(timeout);
|
| 450 |
+
timeout = setTimeout(() => {
|
| 451 |
+
func.apply(context, args);
|
| 452 |
+
}, wait);
|
| 453 |
+
};
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
// Analyse initiale
|
| 457 |
+
analyzeCode();
|
| 458 |
+
});
|
| 459 |
+
</script>
|
| 460 |
+
<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=docto41/code-master" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 461 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
je veux un puissant correcteur de code, script etc
|