Skip to content

Commit 9f1a7fc

Browse files
committed
Simplify UI: Remove unnecessary buttons and fix copy functionality
- Removed Load Template, Format buttons (unused features) - Removed Dark Mode toggle button (simplify interface) - Added Clear Code button next to Analyze button with red styling - Fixed Copy Fixed Code button with proper error handling - Removed unused JavaScript functions (loadTemplate, formatCode, toggleTheme) - Removed keyboard shortcut for load template (Ctrl+L) - Cleaner, more focused user interface
1 parent 47f0e10 commit 9f1a7fc

1 file changed

Lines changed: 27 additions & 86 deletions

File tree

code_quality_analyzer/webapp.py

Lines changed: 27 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -760,15 +760,9 @@
760760
</head>
761761
<body>
762762
<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>
772766
</div>
773767
774768
<div class="content">
@@ -834,18 +828,6 @@
834828
<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">
835829
</div>
836830
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-
849831
<textarea name="code" id="codeTextarea" rows="18" placeholder="Paste your code here for analysis...">{{ request.form.get('code', '') }}</textarea>
850832
<div class="char-counter" id="charCounter">0 characters</div>
851833
</div>
@@ -867,7 +849,12 @@
867849
</p>
868850
</div>
869851
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>
871858
</form>
872859
873860
<div class="loading" id="loading">
@@ -1119,10 +1106,24 @@
11191106
const fileUploadZone = document.getElementById('fileUploadZone');
11201107
11211108
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+
}
11261127
}
11271128
11281129
// File upload handling
@@ -1223,29 +1224,6 @@
12231224
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))'
12241225
};
12251226
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-
12491227
// Export functions
12501228
function copyResults() {
12511229
const results = document.querySelector('.results');
@@ -1361,12 +1339,6 @@
13611339
document.querySelector('form').submit();
13621340
}
13631341
1364-
// Ctrl+L to load template
1365-
if ((e.ctrlKey || e.metaKey) && e.key === 'l') {
1366-
e.preventDefault();
1367-
loadTemplate();
1368-
}
1369-
13701342
// Escape to clear
13711343
if (e.key === 'Escape' && document.activeElement === codeTextarea) {
13721344
clearCode();
@@ -1383,37 +1355,6 @@
13831355
});
13841356
});
13851357
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-
14171358
</body>
14181359
</html>
14191360
"""

0 commit comments

Comments
 (0)