|
760 | 760 | </head> |
761 | 761 | <body> |
762 | 762 | <div class="container"> |
763 | | - <div class="header" style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;"> |
764 | | - <button class="theme-toggle" onclick="toggleTheme()" title="Toggle Dark Mode" style="background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.3); color: white; padding: 10px 15px; border-radius: 50px; cursor: pointer; transition: all 0.3s ease; font-size: 1.2em; backdrop-filter: blur(10px);"> |
765 | | - <i class="fas fa-moon" id="themeIcon"></i> |
766 | | - </button> |
767 | | - <div style="flex: 1; text-align: center;"> |
768 | | - <h1><i class="fas fa-code"></i> Code Quality Analyzer</h1> |
769 | | - <p><i class="fas fa-brain"></i> AI-Powered Static Code Analysis</p> |
770 | | - </div> |
771 | | - <div style="width: 50px;"></div> |
| 763 | + <div class="header"> |
| 764 | + <h1><i class="fas fa-code"></i> Code Quality Analyzer</h1> |
| 765 | + <p><i class="fas fa-brain"></i> AI-Powered Static Code Analysis</p> |
772 | 766 | </div> |
773 | 767 | |
774 | 768 | <div class="content"> |
|
834 | 828 | <input type="file" id="fileInput" accept=".py,.js,.ts,.java,.cpp,.c,.h,.hpp,.go,.rs,.rb,.php,.swift,.kt,.scala,.pl,.r,.m,.dart,.ex,.hs,.lua,.sh,.ps1,.sql,.html,.css,.xml,.yaml,.yml,.json,.md,.clj,.erl,.fs,.groovy,.jl,.vb,.asm,.f,.f90,.cob,.pas,.sol"> |
835 | 829 | </div> |
836 | 830 | |
837 | | - <div class="code-actions"> |
838 | | - <button type="button" class="btn-action" onclick="loadTemplate()"> |
839 | | - <i class="fas fa-file-code"></i> Load Template |
840 | | - </button> |
841 | | - <button type="button" class="btn-action" onclick="clearCode()"> |
842 | | - <i class="fas fa-eraser"></i> Clear |
843 | | - </button> |
844 | | - <button type="button" class="btn-action" onclick="formatCode()"> |
845 | | - <i class="fas fa-indent"></i> Format |
846 | | - </button> |
847 | | - </div> |
848 | | - |
849 | 831 | <textarea name="code" id="codeTextarea" rows="18" placeholder="Paste your code here for analysis...">{{ request.form.get('code', '') }}</textarea> |
850 | 832 | <div class="char-counter" id="charCounter">0 characters</div> |
851 | 833 | </div> |
|
867 | 849 | </p> |
868 | 850 | </div> |
869 | 851 | |
870 | | - <button type="submit" class="btn-analyze"><i class="fas fa-rocket"></i> Analyze Code</button> |
| 852 | + <div style="display: flex; gap: 10px; flex-wrap: wrap;"> |
| 853 | + <button type="submit" class="btn-analyze" style="flex: 1; min-width: 200px;"><i class="fas fa-rocket"></i> Analyze Code</button> |
| 854 | + <button type="button" class="btn-action" onclick="clearCode()" style="padding: 15px 30px; background: #ff6b6b; color: white; border: none; border-radius: 10px; font-size: 1.1em; cursor: pointer; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(255,107,107,0.3);"> |
| 855 | + <i class="fas fa-trash-alt"></i> Clear Code |
| 856 | + </button> |
| 857 | + </div> |
871 | 858 | </form> |
872 | 859 | |
873 | 860 | <div class="loading" id="loading"> |
|
1119 | 1106 | const fileUploadZone = document.getElementById('fileUploadZone'); |
1120 | 1107 |
|
1121 | 1108 | function copyFixedCode() { |
1122 | | - const code = document.getElementById('fixedCode').textContent; |
1123 | | - navigator.clipboard.writeText(code).then(() => { |
1124 | | - showToast('Fixed code copied to clipboard!'); |
1125 | | - }); |
| 1109 | + const codeElement = document.getElementById('fixedCode'); |
| 1110 | + if (codeElement) { |
| 1111 | + const code = codeElement.textContent; |
| 1112 | + navigator.clipboard.writeText(code).then(() => { |
| 1113 | + showToast('Fixed code copied to clipboard!'); |
| 1114 | + }).catch(err => { |
| 1115 | + console.error('Failed to copy:', err); |
| 1116 | + showToast('Failed to copy code', 'error'); |
| 1117 | + }); |
| 1118 | + } |
| 1119 | +} |
| 1120 | +
|
| 1121 | +function clearCode() { |
| 1122 | + if (codeTextarea) { |
| 1123 | + codeTextarea.value = ''; |
| 1124 | + updateCharCounter(); |
| 1125 | + showToast('Code cleared'); |
| 1126 | + } |
1126 | 1127 | } |
1127 | 1128 |
|
1128 | 1129 | // File upload handling |
|
1223 | 1224 | r: 'calculate_sum <- function(numbers) {\\n total <- 0\\n for (num in numbers) {\\n total <- total + num\\n }\\n return(total)\\n}\\n\\n# Example usage\\nresult <- calculate_sum(c(1, 2, 3, 4, 5))\\nprint(paste(\\\"Sum:\\\", result))' |
1224 | 1225 | }; |
1225 | 1226 |
|
1226 | | -function loadTemplate() { |
1227 | | - const langSelector = document.getElementById('langSelect'); |
1228 | | - const lang = langSelector ? langSelector.value : 'python'; |
1229 | | - const template = codeTemplates[lang] || codeTemplates['python']; |
1230 | | - codeTextarea.value = template; |
1231 | | - updateCharCounter(); |
1232 | | - showToast('Loaded ' + lang + ' template'); |
1233 | | -} |
1234 | | -
|
1235 | | -function clearCode() { |
1236 | | - codeTextarea.value = ''; |
1237 | | - updateCharCounter(); |
1238 | | - showToast('Code cleared'); |
1239 | | -} |
1240 | | -
|
1241 | | -function formatCode() { |
1242 | | - // Simple formatting: trim lines and ensure consistent indentation |
1243 | | - const lines = codeTextarea.value.split('\\n'); |
1244 | | - const formatted = lines.map(line => line.trimEnd()).join('\\n'); |
1245 | | - codeTextarea.value = formatted; |
1246 | | - showToast('Code formatted'); |
1247 | | -} |
1248 | | -
|
1249 | 1227 | // Export functions |
1250 | 1228 | function copyResults() { |
1251 | 1229 | const results = document.querySelector('.results'); |
|
1361 | 1339 | document.querySelector('form').submit(); |
1362 | 1340 | } |
1363 | 1341 | |
1364 | | - // Ctrl+L to load template |
1365 | | - if ((e.ctrlKey || e.metaKey) && e.key === 'l') { |
1366 | | - e.preventDefault(); |
1367 | | - loadTemplate(); |
1368 | | - } |
1369 | | - |
1370 | 1342 | // Escape to clear |
1371 | 1343 | if (e.key === 'Escape' && document.activeElement === codeTextarea) { |
1372 | 1344 | clearCode(); |
|
1383 | 1355 | }); |
1384 | 1356 | }); |
1385 | 1357 |
|
1386 | | -function toggleTheme() { |
1387 | | - const html = document.documentElement; |
1388 | | - const icon = document.getElementById('themeIcon'); |
1389 | | - |
1390 | | - if (html.classList.contains('dark-mode')) { |
1391 | | - html.classList.remove('dark-mode'); |
1392 | | - icon.classList.remove('fa-sun'); |
1393 | | - icon.classList.add('fa-moon'); |
1394 | | - localStorage.setItem('theme', 'light'); |
1395 | | - } else { |
1396 | | - html.classList.add('dark-mode'); |
1397 | | - icon.classList.remove('fa-moon'); |
1398 | | - icon.classList.add('fa-sun'); |
1399 | | - localStorage.setItem('theme', 'dark'); |
1400 | | - } |
1401 | | -} |
1402 | | -
|
1403 | | -// Load saved theme |
1404 | | -window.addEventListener('DOMContentLoaded', function() { |
1405 | | - const savedTheme = localStorage.getItem('theme'); |
1406 | | - const icon = document.getElementById('themeIcon'); |
1407 | | - |
1408 | | - if (savedTheme === 'dark') { |
1409 | | - document.documentElement.classList.add('dark-mode'); |
1410 | | - if (icon) { |
1411 | | - icon.classList.remove('fa-moon'); |
1412 | | - icon.classList.add('fa-sun'); |
1413 | | - } |
1414 | | - } |
1415 | | -}); |
1416 | | -
|
1417 | 1358 | </body> |
1418 | 1359 | </html> |
1419 | 1360 | """ |
|
0 commit comments