remove mindless dev comments

This commit is contained in:
overcuriousity
2025-08-02 12:13:16 +02:00
parent 3973479ae4
commit 57c507915f
12 changed files with 13 additions and 200 deletions

View File

@@ -211,12 +211,6 @@ const domainAgnosticSoftware = data['domain-agnostic-software'] || [];
</section>
<script define:vars={{ tools, phases, domainAgnosticSoftware }}>
// ===================================================================
// SIMPLIFIED AI QUERY INTERFACE - CONSOLIDATED & MAINTAINABLE
// ===================================================================
// Enhanced AI Interface JavaScript - Fix for text rendering issues in AIQueryInterface.astro
// This code replaces the existing <script> section in AIQueryInterface.astro
class AIQueryInterface {
constructor() {
@@ -234,7 +228,6 @@ class AIQueryInterface {
}
initializeElements() {
// Core elements
this.elements = {
input: document.getElementById('ai-query-input'),
submitBtn: document.getElementById('ai-submit-btn'),
@@ -247,13 +240,11 @@ class AIQueryInterface {
results: document.getElementById('ai-results'),
charCounter: document.getElementById('ai-char-counter'),
// Mode toggle
toggleSwitch: document.querySelector('.toggle-switch'),
toggleSlider: document.querySelector('.toggle-slider'),
workflowLabel: document.getElementById('workflow-label'),
toolLabel: document.getElementById('tool-label'),
// Smart prompting
promptingContainer: document.getElementById('smart-prompting-container'),
promptingStatus: document.getElementById('prompting-status'),
promptingSpinner: document.getElementById('prompting-spinner'),
@@ -262,7 +253,6 @@ class AIQueryInterface {
dismissSuggestions: document.getElementById('dismiss-suggestions'),
smartHint: document.getElementById('smart-prompting-hint'),
// Queue status
queueStatus: document.getElementById('queue-status'),
queueLength: document.getElementById('queue-length'),
estimatedTime: document.getElementById('estimated-time'),
@@ -273,7 +263,6 @@ class AIQueryInterface {
microTaskCounter: document.getElementById('micro-task-counter')
};
// Validate critical elements
if (!this.elements.input || !this.elements.submitBtn || !this.elements.results) {
console.error('[AI Interface] Critical elements not found');
return false;
@@ -282,12 +271,10 @@ class AIQueryInterface {
}
setupEventListeners() {
// Mode toggle
this.elements.toggleSwitch?.addEventListener('click', () => this.toggleMode());
this.elements.workflowLabel?.addEventListener('click', () => this.setMode('workflow'));
this.elements.toolLabel?.addEventListener('click', () => this.setMode('tool'));
// Input handling
this.elements.input?.addEventListener('input', () => this.handleInputChange());
this.elements.input?.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
@@ -296,17 +283,11 @@ class AIQueryInterface {
}
});
// Submit
this.elements.submitBtn?.addEventListener('click', () => this.handleSubmit());
// Smart prompting
this.elements.dismissSuggestions?.addEventListener('click', () => this.hideSmartPrompting());
}
// ===================================================================
// MODE MANAGEMENT
// ===================================================================
getModeConfig() {
return {
workflow: {
@@ -345,7 +326,6 @@ class AIQueryInterface {
if (this.elements.submitBtnText) this.elements.submitBtnText.textContent = config.submitText;
if (this.elements.loadingText) this.elements.loadingText.textContent = config.loadingText;
// Update toggle UI
if (this.currentMode === 'workflow') {
if (this.elements.toggleSlider) this.elements.toggleSlider.style.transform = 'translateX(0)';
if (this.elements.toggleSwitch) this.elements.toggleSwitch.style.backgroundColor = 'var(--color-primary)';
@@ -371,8 +351,6 @@ class AIQueryInterface {
}
}
// [Previous methods remain the same until displayResults...]
handleInputChange() {
this.updateCharacterCount();
@@ -493,10 +471,6 @@ class AIQueryInterface {
if (this.elements.smartHint) this.showElement(this.elements.smartHint);
}
// ===================================================================
// MAIN SUBMIT HANDLER
// ===================================================================
async handleSubmit() {
const query = this.elements.input.value.trim();
@@ -512,14 +486,12 @@ class AIQueryInterface {
const taskId = `ai_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`;
// Reset state
this.hideSmartPrompting();
this.hideResults();
this.hideError();
this.showLoading();
this.startQueueMonitoring(taskId);
// Disable submit
this.elements.submitBtn.disabled = true;
this.elements.submitBtnText.textContent = this.currentMode === 'workflow' ?
'Generiere Empfehlungen...' : 'Suche passende Methode...';
@@ -545,7 +517,6 @@ class AIQueryInterface {
throw new Error(data.error || 'Unknown error');
}
// Store and display results
this.currentRecommendation = data.recommendation;
this.displayResults(data.recommendation, query);
@@ -579,8 +550,6 @@ class AIQueryInterface {
}
}
// [Queue monitoring methods remain the same...]
startQueueMonitoring(taskId) {
if (this.elements.queueStatus) {
this.showElement(this.elements.queueStatus);
@@ -592,7 +561,6 @@ class AIQueryInterface {
this.startMicroTaskProgress();
// Start polling queue status
setTimeout(() => {
this.updateQueueStatus(taskId);
this.statusInterval = setInterval(() => this.updateQueueStatus(taskId), 1000);
@@ -606,14 +574,12 @@ class AIQueryInterface {
const data = await response.json();
// Update queue display
if (this.elements.queueLength) this.elements.queueLength.textContent = data.queueLength || 0;
if (this.elements.estimatedTime) {
this.elements.estimatedTime.textContent = data.estimatedWaitTime > 0 ?
this.formatDuration(data.estimatedWaitTime) : 'Verarbeitung läuft...';
}
// Update position
if (this.elements.positionBadge) {
if (data.currentPosition) {
this.elements.positionBadge.textContent = data.currentPosition;
@@ -622,7 +588,6 @@ class AIQueryInterface {
this.elements.progressBar.style.width = `${progress}%`;
}
} else {
// Handle processing states
const stateIcons = {
processing: '⚡',
completed: '✅',
@@ -664,14 +629,12 @@ class AIQueryInterface {
const steps = ['scenario', 'approach', 'considerations', 'tools', 'knowledge', 'final'];
const stepElements = this.elements.microTaskProgress.querySelectorAll('.micro-step');
// Reset all steps
stepElements.forEach(step => {
step.classList.remove('active', 'completed', 'failed');
});
this.microTaskInterval = setInterval(() => {
if (this.currentMicroTaskStep < steps.length) {
// Complete previous step
if (this.currentMicroTaskStep > 0) {
const prevStep = this.elements.microTaskProgress.querySelector(`[data-step="${steps[this.currentMicroTaskStep - 1]}"]`);
if (prevStep) {
@@ -680,20 +643,17 @@ class AIQueryInterface {
}
}
// Activate current step
const currentStep = this.elements.microTaskProgress.querySelector(`[data-step="${steps[this.currentMicroTaskStep]}"]`);
if (currentStep) {
currentStep.classList.add('active');
}
// Update counter
if (this.elements.microTaskCounter) {
this.elements.microTaskCounter.textContent = `${this.currentMicroTaskStep + 1}/${steps.length}`;
}
this.currentMicroTaskStep++;
} else {
// Complete final step
const lastStep = this.elements.microTaskProgress.querySelector(`[data-step="${steps[steps.length - 1]}"]`);
if (lastStep) {
lastStep.classList.remove('active');
@@ -710,10 +670,6 @@ class AIQueryInterface {
}, 2000);
}
// ===================================================================
// RESULTS DISPLAY - ENHANCED with proper text formatting
// ===================================================================
displayResults(recommendation, originalQuery) {
if (this.currentMode === 'workflow') {
this.displayWorkflowResults(recommendation, originalQuery);
@@ -725,7 +681,6 @@ class AIQueryInterface {
}
displayWorkflowResults(recommendation, originalQuery) {
// Group tools by phase
const toolsByPhase = {};
const phaseOrder = phases.map(phase => phase.id);
const phaseNames = phases.reduce((acc, phase) => {
@@ -787,7 +742,6 @@ class AIQueryInterface {
`;
}
// ENHANCED: Fixed text rendering to prevent markdown/list interpretation
renderContextualAnalysis(recommendation, mode) {
let html = '';
@@ -1052,15 +1006,9 @@ class AIQueryInterface {
return badges;
}
// ===================================================================
// ENHANCED UTILITY METHODS with proper text sanitization
// ===================================================================
// CRITICAL: Sanitize text to prevent markdown interpretation
sanitizeText(text) {
if (typeof text !== 'string') return '';
// Remove/escape potential markdown and HTML
return text
// Remove markdown headers
.replace(/^#{1,6}\s+/gm, '')
@@ -1096,13 +1044,11 @@ class AIQueryInterface {
const hasValidProjectUrl = this.isToolHosted(tool);
if (context === 'recommendation') {
// For tool-recommendation elements, use simple class names
if (isMethod) return 'method';
if (hasValidProjectUrl) return 'hosted';
if (tool.license !== 'Proprietary') return 'oss';
return '';
} else {
// For card elements, use card- prefixed class names
if (isMethod) return 'card-method';
if (hasValidProjectUrl) return 'card-hosted';
if (tool.license !== 'Proprietary') return 'card-oss';
@@ -1137,7 +1083,6 @@ class AIQueryInterface {
return `${Math.ceil(ms / 60000)}m`;
}
// State management
showElement(element) {
if (element) {
element.style.display = 'block';
@@ -1179,14 +1124,9 @@ class AIQueryInterface {
}
}
// ===================================================================
// INITIALIZATION
// ===================================================================
document.addEventListener('DOMContentLoaded', () => {
const aiInterface = new AIQueryInterface();
// Global restore function for compatibility
window.restoreAIResults = () => {
if (aiInterface.currentRecommendation && aiInterface.elements.results) {
aiInterface.showResults();

View File

@@ -77,41 +77,33 @@ const displayedScenarios = scenarios.slice(0, maxDisplayed);
if (!mainSearchInput) return;
// Check if this scenario is already active (allow deselection)
if (clickedChip && clickedChip.classList.contains('active')) {
// Deselect: clear search and remove active state
mainSearchInput.value = '';
document.querySelectorAll('.suggestion-chip').forEach(chip => {
chip.classList.remove('active');
});
// Clear the targeted search input too
const targetedInput = document.getElementById('targeted-search-input');
if (targetedInput) {
targetedInput.value = '';
}
// Trigger search to show all results
const inputEvent = new Event('input', { bubbles: true });
mainSearchInput.dispatchEvent(inputEvent);
return;
}
// Apply new search
mainSearchInput.value = scenarioId;
// Trigger existing search functionality
const inputEvent = new Event('input', { bubbles: true });
mainSearchInput.dispatchEvent(inputEvent);
// Switch to grid view
const gridToggle = document.querySelector('.view-toggle[data-view="grid"]');
if (gridToggle && !gridToggle.classList.contains('active')) {
gridToggle.click();
}
// Visual feedback
document.querySelectorAll('.suggestion-chip').forEach(chip => {
chip.classList.remove('active');
});
@@ -119,17 +111,14 @@ const displayedScenarios = scenarios.slice(0, maxDisplayed);
clickedChip.classList.add('active');
}
// Scroll to results with better positioning
window.scrollToElementById('tools-grid');
};
// Toggle showing all scenarios
window.toggleAllScenarios = function() {
const suggestionsContainer = document.getElementById('scenario-suggestions');
const moreBtn = document.getElementById('more-scenarios-btn');
if (!showingAllScenarios) {
// Show additional scenarios
const additionalScenarios = allScenarios.slice(maxDisplay);
additionalScenarios.forEach(scenario => {
const chip = document.createElement('div');
@@ -146,14 +135,12 @@ const displayedScenarios = scenarios.slice(0, maxDisplayed);
moreBtn.textContent = 'Weniger anzeigen';
showingAllScenarios = true;
} else {
// Hide additional scenarios
document.querySelectorAll('.additional-scenario').forEach(chip => chip.remove());
moreBtn.textContent = `+ ${allScenarios.length - maxDisplay} weitere Szenarien`;
showingAllScenarios = false;
}
};
// Handle targeted search input
document.addEventListener('DOMContentLoaded', () => {
const targetedInput = document.getElementById('targeted-search-input');
if (targetedInput) {

View File

@@ -5,7 +5,6 @@ const data = await getToolsData();
const domains = data.domains;
const phases = data.phases;
// Extract unique values dynamically - NO HARD-CODING
const skillLevels = [...new Set(data.tools.map(tool => tool.skillLevel))].filter(Boolean).sort();
const platforms = [...new Set(data.tools.flatMap(tool => tool.platforms || []))].filter(Boolean).sort();
const licenses = [...new Set(data.tools.map(tool => tool.license))].filter(Boolean).sort();
@@ -287,7 +286,6 @@ const sortedTags = Object.entries(tagFrequency)
window.toolsData = toolsData;
document.addEventListener('DOMContentLoaded', () => {
// Cache DOM elements
const elements = {
searchInput: document.getElementById('search-input'),
clearSearch: document.getElementById('clear-search'),
@@ -312,25 +310,21 @@ const sortedTags = Object.entries(tagFrequency)
tags: document.getElementById('reset-tags'),
all: document.getElementById('reset-all-filters')
},
// Collapsible elements
toggleAdvanced: document.getElementById('toggle-advanced'),
toggleTags: document.getElementById('toggle-tags'),
advancedContent: document.getElementById('advanced-filters-content'),
tagContent: document.getElementById('tag-filters-content')
};
// Verify critical elements exist
if (!elements.searchInput || !elements.domainSelect) {
console.error('Critical filter elements not found');
return;
}
// State management
let selectedTags = new Set();
let selectedPhase = '';
let isTagCloudExpanded = false;
// Collapsible functionality
function toggleCollapsible(toggleBtn, content, storageKey) {
const isCollapsed = toggleBtn.getAttribute('data-collapsed') === 'true';
const newState = !isCollapsed;
@@ -338,22 +332,17 @@ const sortedTags = Object.entries(tagFrequency)
toggleBtn.setAttribute('data-collapsed', newState.toString());
if (newState) {
// Collapse
content.classList.add('hidden');
toggleBtn.style.transform = 'rotate(0deg)';
} else {
// Expand
content.classList.remove('hidden');
toggleBtn.style.transform = 'rotate(180deg)';
}
// Store state in sessionStorage
sessionStorage.setItem(storageKey, newState.toString());
}
// Initialize collapsible sections (collapsed by default)
function initializeCollapsible() {
// Advanced filters
const advancedCollapsed = sessionStorage.getItem('advanced-collapsed') !== 'false';
elements.toggleAdvanced.setAttribute('data-collapsed', advancedCollapsed.toString());
if (advancedCollapsed) {
@@ -364,7 +353,6 @@ const sortedTags = Object.entries(tagFrequency)
elements.toggleAdvanced.style.transform = 'rotate(180deg)';
}
// Tag filters
const tagsCollapsed = sessionStorage.getItem('tags-collapsed') !== 'false';
elements.toggleTags.setAttribute('data-collapsed', tagsCollapsed.toString());
if (tagsCollapsed) {
@@ -376,7 +364,6 @@ const sortedTags = Object.entries(tagFrequency)
}
}
// Helper function to check if tool is hosted
function isToolHosted(tool) {
return tool.projectUrl !== undefined &&
tool.projectUrl !== null &&
@@ -384,7 +371,6 @@ const sortedTags = Object.entries(tagFrequency)
tool.projectUrl.trim() !== "";
}
// Initialize tag cloud
function initTagCloud() {
const visibleCount = 20;
elements.tagCloudItems.forEach((item, index) => {
@@ -394,7 +380,6 @@ const sortedTags = Object.entries(tagFrequency)
});
}
// Toggle tag cloud expansion
function toggleTagCloud() {
isTagCloudExpanded = !isTagCloudExpanded;
const visibleCount = 20;
@@ -428,7 +413,6 @@ const sortedTags = Object.entries(tagFrequency)
}
}
// Filter tag cloud based on search
function filterTagCloud() {
const searchTerm = elements.searchInput.value.toLowerCase();
let visibleCount = 0;
@@ -458,7 +442,6 @@ const sortedTags = Object.entries(tagFrequency)
elements.tagCloudToggle.style.display = hasHiddenTags ? 'block' : 'none';
}
// Update selected tags display
function updateSelectedTags() {
if (selectedTags.size === 0) {
elements.selectedTags.style.display = 'none';
@@ -478,7 +461,6 @@ const sortedTags = Object.entries(tagFrequency)
</div>
`;
// Add event listeners for remove buttons
elements.selectedTags.querySelectorAll('.remove-tag').forEach(btn => {
btn.addEventListener('click', () => {
const tag = btn.getAttribute('data-tag');
@@ -487,10 +469,8 @@ const sortedTags = Object.entries(tagFrequency)
});
}
// Add/remove tags - FIXED: Update ALL matching elements
function addTag(tag) {
selectedTags.add(tag);
// FIXED: Use querySelectorAll to update ALL matching tag elements
document.querySelectorAll(`[data-tag="${tag}"]`).forEach(element => {
element.classList.add('active');
});
@@ -500,7 +480,6 @@ const sortedTags = Object.entries(tagFrequency)
function removeTag(tag) {
selectedTags.delete(tag);
// FIXED: Use querySelectorAll to update ALL matching tag elements
document.querySelectorAll(`[data-tag="${tag}"]`).forEach(element => {
element.classList.remove('active');
});
@@ -508,7 +487,6 @@ const sortedTags = Object.entries(tagFrequency)
filterTools();
}
// Update results counter
function updateResultsCounter(count) {
const total = window.toolsData.length;
elements.resultsCounter.textContent = count === total
@@ -516,7 +494,6 @@ const sortedTags = Object.entries(tagFrequency)
: `${count} von ${total} Tools`;
}
// Main filter function
function filterTools() {
const searchTerm = elements.searchInput.value.trim().toLowerCase();
const selectedDomain = elements.domainSelect.value;
@@ -529,11 +506,9 @@ const sortedTags = Object.entries(tagFrequency)
const hostedOnly = elements.hostedOnly.checked;
const knowledgebaseOnly = elements.knowledgebaseOnly.checked;
// Use phase from either dropdown or button selection
const activePhase = selectedPhaseFromSelect || selectedPhase;
const filtered = window.toolsData.filter(tool => {
// Search filter
if (searchTerm && !(
tool.name.toLowerCase().includes(searchTerm) ||
tool.description.toLowerCase().includes(searchTerm) ||
@@ -542,52 +517,42 @@ const sortedTags = Object.entries(tagFrequency)
return false;
}
// Domain filter
if (selectedDomain && !(tool.domains || []).includes(selectedDomain)) {
return false;
}
// Phase filter
if (activePhase && !(tool.phases || []).includes(activePhase)) {
return false;
}
// Type filter
if (selectedType && tool.type !== selectedType) {
return false;
}
// Skill level filter
if (selectedSkill && tool.skillLevel !== selectedSkill) {
return false;
}
// Platform filter
if (selectedPlatform && !(tool.platforms || []).includes(selectedPlatform)) {
return false;
}
// License filter - NO MORE HARD-CODED LOGIC
if (selectedLicense && tool.license !== selectedLicense) {
return false;
}
// Access type filter
if (selectedAccess && tool.accessType !== selectedAccess) {
return false;
}
// Hosted only filter (CC24-Server tools)
if (hostedOnly && !isToolHosted(tool)) {
return false;
}
// Knowledgebase only filter
if (knowledgebaseOnly && !tool.knowledgebase) {
return false;
}
// Tag filter
if (selectedTags.size > 0 && !Array.from(selectedTags).every(tag => (tool.tags || []).includes(tag))) {
return false;
}
@@ -595,18 +560,15 @@ const sortedTags = Object.entries(tagFrequency)
return true;
});
// Apply search prioritization if there's a search term
const finalResults = searchTerm && window.prioritizeSearchResults
? window.prioritizeSearchResults(filtered, searchTerm)
: filtered;
updateResultsCounter(finalResults.length);
// Dispatch event for other components
window.dispatchEvent(new CustomEvent('toolsFiltered', { detail: finalResults }));
}
// Reset functions
function resetPrimaryFilters() {
elements.domainSelect.value = '';
elements.phaseSelect.value = '';
@@ -627,7 +589,6 @@ const sortedTags = Object.entries(tagFrequency)
function resetTags() {
selectedTags.clear();
// FIXED: Update ALL tag elements
document.querySelectorAll('.tag-cloud-item').forEach(item => {
item.classList.remove('active');
});
@@ -644,7 +605,6 @@ const sortedTags = Object.entries(tagFrequency)
filterTagCloud();
}
// Event listeners
elements.searchInput.addEventListener('input', (e) => {
const hasValue = e.target.value.length > 0;
elements.clearSearch.classList.toggle('hidden', !hasValue);
@@ -685,7 +645,6 @@ const sortedTags = Object.entries(tagFrequency)
btn.addEventListener('click', () => {
const view = btn.getAttribute('data-view');
// Simple toggle like the old version
elements.viewToggles.forEach(b => {
b.classList.toggle('active', b.getAttribute('data-view') === view);
});
@@ -701,13 +660,11 @@ const sortedTags = Object.entries(tagFrequency)
});
});
// Reset button listeners
elements.resetButtons.primary.addEventListener('click', resetPrimaryFilters);
elements.resetButtons.advanced.addEventListener('click', resetAdvancedFilters);
elements.resetButtons.tags.addEventListener('click', resetTags);
elements.resetButtons.all.addEventListener('click', resetAllFilters);
// Collapsible toggle listeners
elements.toggleAdvanced.addEventListener('click', () => {
toggleCollapsible(elements.toggleAdvanced, elements.advancedContent, 'advanced-collapsed');
});
@@ -716,11 +673,9 @@ const sortedTags = Object.entries(tagFrequency)
toggleCollapsible(elements.toggleTags, elements.tagContent, 'tags-collapsed');
});
// Expose functions globally for backwards compatibility
window.clearTagFilters = resetTags;
window.clearAllFilters = resetAllFilters;
// Initialize
initializeCollapsible();
initTagCloud();
filterTagCloud();

View File

@@ -716,7 +716,6 @@ domains.forEach((domain: any) => {
const primaryModal = document.getElementById('tool-details-primary');
const secondaryModal = document.getElementById('tool-details-secondary');
// Debounce rapid calls
if (window.modalHideInProgress) return;
window.modalHideInProgress = true;
@@ -753,19 +752,15 @@ domains.forEach((domain: any) => {
if (contributeButtonSecondary) contributeButtonSecondary.style.display = 'none';
}
// Consolidated state checking with safety checks
const primaryActive = primaryModal && primaryModal.classList.contains('active');
const secondaryActive = secondaryModal && secondaryModal.classList.contains('active');
// Update overlay and body classes atomically
if (!primaryActive && !secondaryActive) {
if (overlay) overlay.classList.remove('active');
document.body.classList.remove('modals-side-by-side');
} else if (primaryActive && secondaryActive) {
// Both active - ensure side-by-side class
document.body.classList.add('modals-side-by-side');
} else {
// Only one active - remove side-by-side class
document.body.classList.remove('modals-side-by-side');
}
};