sharing mechanic with eye-watering animation
This commit is contained in:
@@ -93,15 +93,31 @@ const tools = data.tools;
|
||||
</BaseLayout>
|
||||
|
||||
<script>
|
||||
// Extend Window interface for custom properties
|
||||
declare global {
|
||||
interface Window {
|
||||
toolsData: any[];
|
||||
showToolDetails: (toolName: string, modalType?: string) => void;
|
||||
hideToolDetails: (modalType?: string) => void;
|
||||
hideAllToolDetails: () => void;
|
||||
clearAllFilters?: () => void;
|
||||
restoreAIResults?: () => void;
|
||||
switchToAIView?: () => void;
|
||||
showShareDialog: (shareButton: HTMLElement) => void;
|
||||
navigateToGrid: (toolName: string) => void;
|
||||
navigateToMatrix: (toolName: string) => void;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle view changes and filtering
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const toolsContainer = document.getElementById('tools-container');
|
||||
const toolsGrid = document.getElementById('tools-grid');
|
||||
const matrixContainer = document.getElementById('matrix-container');
|
||||
const aiInterface = document.getElementById('ai-interface');
|
||||
const filtersSection = document.getElementById('filters-section');
|
||||
const noResults = document.getElementById('no-results');
|
||||
const aiQueryBtn = document.getElementById('ai-query-btn');
|
||||
const toolsContainer = document.getElementById('tools-container') as HTMLElement;
|
||||
const toolsGrid = document.getElementById('tools-grid') as HTMLElement;
|
||||
const matrixContainer = document.getElementById('matrix-container') as HTMLElement;
|
||||
const aiInterface = document.getElementById('ai-interface') as HTMLElement;
|
||||
const filtersSection = document.getElementById('filters-section') as HTMLElement;
|
||||
const noResults = document.getElementById('no-results') as HTMLElement;
|
||||
const aiQueryBtn = document.getElementById('ai-query-btn') as HTMLButtonElement;
|
||||
|
||||
// Guard against null elements
|
||||
if (!toolsContainer || !toolsGrid || !matrixContainer || !noResults || !aiInterface || !filtersSection) {
|
||||
@@ -109,12 +125,9 @@ const tools = data.tools;
|
||||
return;
|
||||
}
|
||||
|
||||
// Initial tools HTML
|
||||
const initialToolsHTML = toolsContainer.innerHTML;
|
||||
|
||||
// Simple sorting function - no external imports needed
|
||||
function sortTools(tools, sortBy = 'default') {
|
||||
const sorted = [...tools]; // Don't mutate original array
|
||||
// Simple sorting function
|
||||
function sortTools(tools: any[], sortBy = 'default') {
|
||||
const sorted = [...tools];
|
||||
|
||||
switch (sortBy) {
|
||||
case 'alphabetical':
|
||||
@@ -122,16 +135,16 @@ const tools = data.tools;
|
||||
case 'difficulty':
|
||||
const difficultyOrder = { 'novice': 0, 'beginner': 1, 'intermediate': 2, 'advanced': 3, 'expert': 4 };
|
||||
return sorted.sort((a, b) =>
|
||||
(difficultyOrder[a.skillLevel] || 999) - (difficultyOrder[b.skillLevel] || 999)
|
||||
(difficultyOrder[a.skillLevel as keyof typeof difficultyOrder] || 999) - (difficultyOrder[b.skillLevel as keyof typeof difficultyOrder] || 999)
|
||||
);
|
||||
case 'type':
|
||||
const typeOrder = { 'concept': 0, 'method': 1, 'software': 2 };
|
||||
return sorted.sort((a, b) =>
|
||||
(typeOrder[a.type] || 999) - (typeOrder[b.type] || 999)
|
||||
(typeOrder[a.type as keyof typeof typeOrder] || 999) - (typeOrder[b.type as keyof typeof typeOrder] || 999)
|
||||
);
|
||||
case 'default':
|
||||
default:
|
||||
return sorted; // No sorting - embrace the entropy
|
||||
return sorted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,31 +172,21 @@ const tools = data.tools;
|
||||
const authStatus = await checkAuthentication();
|
||||
|
||||
if (authStatus.authRequired && !authStatus.authenticated) {
|
||||
// Redirect to login, then back to AI view
|
||||
const returnUrl = `${window.location.pathname}?view=ai`;
|
||||
window.location.href = `/api/auth/login?returnTo=${encodeURIComponent(returnUrl)}`;
|
||||
} else {
|
||||
// Switch to AI view directly
|
||||
switchToView('ai');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check URL parameters on page load for view switching
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const viewParam = urlParams.get('view');
|
||||
if (viewParam === 'ai') {
|
||||
// User was redirected after authentication, switch to AI view
|
||||
switchToView('ai');
|
||||
}
|
||||
|
||||
// Function to switch between different views
|
||||
function switchToView(view) {
|
||||
// Hide all views first (using non-null assertions since we've already checked)
|
||||
toolsGrid!.style.display = 'none';
|
||||
matrixContainer!.style.display = 'none';
|
||||
aiInterface!.style.display = 'none';
|
||||
filtersSection!.style.display = 'none';
|
||||
// Function to switch between different views
|
||||
function switchToView(view: string) {
|
||||
// Hide all views first
|
||||
toolsGrid.style.display = 'none';
|
||||
matrixContainer.style.display = 'none';
|
||||
aiInterface.style.display = 'none';
|
||||
filtersSection.style.display = 'none';
|
||||
|
||||
// Update view toggle buttons
|
||||
const viewToggles = document.querySelectorAll('.view-toggle');
|
||||
@@ -191,128 +194,29 @@ const tools = data.tools;
|
||||
btn.classList.toggle('active', btn.getAttribute('data-view') === view);
|
||||
});
|
||||
|
||||
// Show appropriate view
|
||||
// Show appropriate view and manage filter visibility
|
||||
switch (view) {
|
||||
case 'ai':
|
||||
aiInterface!.style.display = 'block';
|
||||
// Keep filters visible in AI mode for view switching
|
||||
filtersSection!.style.display = 'block';
|
||||
|
||||
// Hide filter controls in AI mode - AGGRESSIVE APPROACH
|
||||
const domainPhaseContainer = document.querySelector('.domain-phase-container') as HTMLElement;
|
||||
const searchInput = document.getElementById('search-input') as HTMLElement;
|
||||
const tagCloud = document.querySelector('.tag-cloud') as HTMLElement;
|
||||
// Hide all checkbox wrappers
|
||||
const checkboxWrappers = document.querySelectorAll('.checkbox-wrapper');
|
||||
// Hide the "Nach Tags filtern" header and button
|
||||
const tagHeader = document.querySelector('.tag-header') as HTMLElement;
|
||||
// Hide any elements containing "Proprietäre Software" or "Nach Tags filtern"
|
||||
const filterLabels = document.querySelectorAll('label, .tag-header, h4, h3');
|
||||
// Hide ALL input elements in the filters section (more aggressive)
|
||||
const allInputs = filtersSection!.querySelectorAll('input, select, textarea');
|
||||
|
||||
|
||||
if (domainPhaseContainer) domainPhaseContainer.style.display = 'none';
|
||||
if (searchInput) searchInput.style.display = 'none';
|
||||
if (tagCloud) tagCloud.style.display = 'none';
|
||||
if (tagHeader) tagHeader.style.display = 'none';
|
||||
|
||||
// Hide ALL inputs in the filters section
|
||||
allInputs.forEach(input => {
|
||||
(input as HTMLElement).style.display = 'none';
|
||||
});
|
||||
|
||||
checkboxWrappers.forEach(wrapper => {
|
||||
(wrapper as HTMLElement).style.display = 'none';
|
||||
});
|
||||
|
||||
// Hide specific filter section elements by text content
|
||||
filterLabels.forEach(element => {
|
||||
const text = element.textContent?.toLowerCase() || '';
|
||||
if (text.includes('proprietäre') || text.includes('tags filtern') || text.includes('nach tags') || text.includes('suchen') || text.includes('search')) {
|
||||
(element as HTMLElement).style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Restore previous AI results if they exist
|
||||
if ((window as any).restoreAIResults) {
|
||||
(window as any).restoreAIResults();
|
||||
aiInterface.style.display = 'block';
|
||||
filtersSection.style.display = 'block';
|
||||
hideFilterControls();
|
||||
if (window.restoreAIResults) {
|
||||
window.restoreAIResults();
|
||||
}
|
||||
// Focus on the input
|
||||
const aiInput = document.getElementById('ai-query-input');
|
||||
const aiInput = document.getElementById('ai-query-input') as HTMLTextAreaElement;
|
||||
if (aiInput) {
|
||||
setTimeout(() => aiInput.focus(), 100);
|
||||
}
|
||||
break;
|
||||
case 'matrix':
|
||||
matrixContainer!.style.display = 'block';
|
||||
filtersSection!.style.display = 'block';
|
||||
|
||||
// Show filter controls in matrix mode
|
||||
const domainPhaseContainerMatrix = document.querySelector('.domain-phase-container') as HTMLElement;
|
||||
const searchInputMatrix = document.getElementById('search-input') as HTMLElement;
|
||||
const tagCloudMatrix = document.querySelector('.tag-cloud') as HTMLElement;
|
||||
const checkboxWrappersMatrix = document.querySelectorAll('.checkbox-wrapper');
|
||||
const tagHeaderMatrix = document.querySelector('.tag-header') as HTMLElement;
|
||||
const filterLabelsMatrix = document.querySelectorAll('label, .tag-header, h4, h3');
|
||||
const allInputsMatrix = filtersSection!.querySelectorAll('input, select, textarea');
|
||||
|
||||
if (domainPhaseContainerMatrix) domainPhaseContainerMatrix.style.display = 'grid';
|
||||
if (searchInputMatrix) searchInputMatrix.style.display = 'block';
|
||||
if (tagCloudMatrix) tagCloudMatrix.style.display = 'flex';
|
||||
if (tagHeaderMatrix) tagHeaderMatrix.style.display = 'flex';
|
||||
|
||||
// Restore ALL inputs in the filters section
|
||||
allInputsMatrix.forEach(input => {
|
||||
(input as HTMLElement).style.display = 'block';
|
||||
});
|
||||
|
||||
checkboxWrappersMatrix.forEach(wrapper => {
|
||||
(wrapper as HTMLElement).style.display = 'flex';
|
||||
});
|
||||
|
||||
// Restore filter section elements
|
||||
filterLabelsMatrix.forEach(element => {
|
||||
const text = element.textContent?.toLowerCase() || '';
|
||||
if (text.includes('proprietäre') || text.includes('tags filtern') || text.includes('nach tags') || text.includes('suchen') || text.includes('search')) {
|
||||
(element as HTMLElement).style.display = 'block';
|
||||
}
|
||||
});
|
||||
matrixContainer.style.display = 'block';
|
||||
filtersSection.style.display = 'block';
|
||||
showFilterControls();
|
||||
break;
|
||||
default: // grid
|
||||
toolsGrid!.style.display = 'block';
|
||||
filtersSection!.style.display = 'block';
|
||||
|
||||
// Show filter controls in grid mode
|
||||
const domainPhaseContainerGrid = document.querySelector('.domain-phase-container') as HTMLElement;
|
||||
const searchInputGrid = document.getElementById('search-input') as HTMLElement;
|
||||
const tagCloudGrid = document.querySelector('.tag-cloud') as HTMLElement;
|
||||
const checkboxWrappersGrid = document.querySelectorAll('.checkbox-wrapper');
|
||||
const tagHeaderGrid = document.querySelector('.tag-header') as HTMLElement;
|
||||
const filterLabelsGrid = document.querySelectorAll('label, .tag-header, h4, h3');
|
||||
const allInputsGrid = filtersSection!.querySelectorAll('input, select, textarea');
|
||||
|
||||
if (domainPhaseContainerGrid) domainPhaseContainerGrid.style.display = 'grid';
|
||||
if (searchInputGrid) searchInputGrid.style.display = 'block';
|
||||
if (tagCloudGrid) tagCloudGrid.style.display = 'flex';
|
||||
if (tagHeaderGrid) tagHeaderGrid.style.display = 'flex';
|
||||
|
||||
// Restore ALL inputs in the filters section
|
||||
allInputsGrid.forEach(input => {
|
||||
(input as HTMLElement).style.display = 'block';
|
||||
});
|
||||
|
||||
checkboxWrappersGrid.forEach(wrapper => {
|
||||
(wrapper as HTMLElement).style.display = 'flex';
|
||||
});
|
||||
|
||||
// Restore filter section elements
|
||||
filterLabelsGrid.forEach(element => {
|
||||
const text = element.textContent?.toLowerCase() || '';
|
||||
if (text.includes('proprietäre') || text.includes('tags filtern') || text.includes('nach tags') || text.includes('suchen') || text.includes('search')) {
|
||||
(element as HTMLElement).style.display = 'block';
|
||||
}
|
||||
});
|
||||
toolsGrid.style.display = 'block';
|
||||
filtersSection.style.display = 'block';
|
||||
showFilterControls();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -321,15 +225,205 @@ const tools = data.tools;
|
||||
window.history.replaceState({}, '', window.location.pathname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Helper functions for filter control visibility
|
||||
function hideFilterControls() {
|
||||
const elements = [
|
||||
'.domain-phase-container',
|
||||
'#search-input',
|
||||
'.tag-cloud',
|
||||
'.tag-header',
|
||||
'.checkbox-wrapper'
|
||||
];
|
||||
|
||||
elements.forEach(selector => {
|
||||
const element = document.querySelector(selector) as HTMLElement;
|
||||
if (element) element.style.display = 'none';
|
||||
});
|
||||
|
||||
const allInputs = filtersSection.querySelectorAll('input, select, textarea');
|
||||
allInputs.forEach(input => (input as HTMLElement).style.display = 'none');
|
||||
}
|
||||
|
||||
function showFilterControls() {
|
||||
const domainPhaseContainer = document.querySelector('.domain-phase-container') as HTMLElement;
|
||||
const searchInput = document.getElementById('search-input') as HTMLElement;
|
||||
const tagCloud = document.querySelector('.tag-cloud') as HTMLElement;
|
||||
const tagHeader = document.querySelector('.tag-header') as HTMLElement;
|
||||
const checkboxWrappers = document.querySelectorAll('.checkbox-wrapper');
|
||||
const allInputs = filtersSection.querySelectorAll('input, select, textarea');
|
||||
|
||||
if (domainPhaseContainer) domainPhaseContainer.style.display = 'grid';
|
||||
if (searchInput) searchInput.style.display = 'block';
|
||||
if (tagCloud) tagCloud.style.display = 'flex';
|
||||
if (tagHeader) tagHeader.style.display = 'flex';
|
||||
|
||||
allInputs.forEach(input => (input as HTMLElement).style.display = 'block');
|
||||
checkboxWrappers.forEach(wrapper => (wrapper as HTMLElement).style.display = 'flex');
|
||||
}
|
||||
|
||||
// Create tool slug from name
|
||||
function createToolSlug(toolName: string): string {
|
||||
return toolName.toLowerCase()
|
||||
.replace(/[^a-z0-9\s-]/g, '')
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/-+/g, '-')
|
||||
.replace(/^-|-$/g, '');
|
||||
}
|
||||
|
||||
// Find tool by name or slug
|
||||
function findTool(identifier: string) {
|
||||
return window.toolsData.find(tool =>
|
||||
tool.name === identifier ||
|
||||
createToolSlug(tool.name) === identifier.toLowerCase()
|
||||
);
|
||||
}
|
||||
|
||||
// Navigation functions for sharing
|
||||
window.navigateToGrid = function(toolName: string) {
|
||||
console.log('Navigating to grid for tool:', toolName);
|
||||
|
||||
// Switch to grid view first
|
||||
switchToView('grid');
|
||||
|
||||
// Wait for view switch, then find and scroll to tool
|
||||
setTimeout(() => {
|
||||
// Clear any filters first
|
||||
if (window.clearAllFilters) {
|
||||
window.clearAllFilters();
|
||||
}
|
||||
|
||||
// Wait for filters to clear and re-render
|
||||
setTimeout(() => {
|
||||
const toolCards = document.querySelectorAll('.tool-card');
|
||||
let targetCard: Element | null = null;
|
||||
|
||||
toolCards.forEach(card => {
|
||||
const cardTitle = card.querySelector('h3');
|
||||
if (cardTitle) {
|
||||
// Clean title text (remove icons and extra spaces)
|
||||
const titleText = cardTitle.textContent?.replace(/[^\w\s\-\.]/g, '').trim();
|
||||
if (titleText === toolName) {
|
||||
targetCard = card;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (targetCard) {
|
||||
console.log('Found target card, scrolling...');
|
||||
// Cast to Element to fix TypeScript issue
|
||||
(targetCard as Element).scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
(targetCard as HTMLElement).style.animation = 'highlight-flash 2s ease-out';
|
||||
|
||||
setTimeout(() => {
|
||||
if (targetCard) {
|
||||
(targetCard as HTMLElement).style.animation = '';
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
console.warn('Tool card not found in grid:', toolName);
|
||||
}
|
||||
}, 300);
|
||||
}, 200);
|
||||
};
|
||||
|
||||
window.navigateToMatrix = function(toolName: string) {
|
||||
console.log('Navigating to matrix for tool:', toolName);
|
||||
|
||||
// Switch to matrix view
|
||||
switchToView('matrix');
|
||||
|
||||
// Wait for view switch and matrix to render
|
||||
setTimeout(() => {
|
||||
const toolChips = document.querySelectorAll('.tool-chip');
|
||||
let firstMatch: Element | null = null;
|
||||
let matchCount = 0;
|
||||
|
||||
toolChips.forEach(chip => {
|
||||
// Clean the chip text (remove emoji and extra spaces)
|
||||
const chipText = chip.textContent?.replace(/📖/g, '').replace(/[^\w\s\-\.]/g, '').trim();
|
||||
if (chipText === toolName) {
|
||||
// Highlight this occurrence
|
||||
(chip as HTMLElement).style.animation = 'highlight-flash 2s ease-out';
|
||||
matchCount++;
|
||||
|
||||
// Remember the first match for scrolling
|
||||
if (!firstMatch) {
|
||||
firstMatch = chip;
|
||||
}
|
||||
|
||||
// Clean up animation after it completes
|
||||
setTimeout(() => {
|
||||
(chip as HTMLElement).style.animation = '';
|
||||
}, 8000);
|
||||
}
|
||||
});
|
||||
|
||||
if (firstMatch) {
|
||||
console.log(`Found ${matchCount} occurrences of tool, highlighting all and scrolling to first`);
|
||||
// Cast to Element to fix TypeScript issue
|
||||
(firstMatch as Element).scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
} else {
|
||||
console.warn('Tool chip not found in matrix:', toolName);
|
||||
}
|
||||
}, 500);
|
||||
};
|
||||
|
||||
// Handle URL parameters on page load
|
||||
function handleSharedURL() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const toolParam = urlParams.get('tool');
|
||||
const viewParam = urlParams.get('view');
|
||||
const modalParam = urlParams.get('modal');
|
||||
|
||||
if (!toolParam) {
|
||||
// Check for AI view parameter
|
||||
if (viewParam === 'ai') {
|
||||
switchToView('ai');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the tool by name or slug
|
||||
const tool = findTool(toolParam);
|
||||
if (!tool) {
|
||||
console.warn('Shared tool not found:', toolParam);
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear URL parameters to avoid re-triggering
|
||||
const cleanUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
||||
window.history.replaceState({}, document.title, cleanUrl);
|
||||
|
||||
// Handle different view types
|
||||
setTimeout(() => {
|
||||
switch (viewParam) {
|
||||
case 'grid':
|
||||
window.navigateToGrid(tool.name);
|
||||
break;
|
||||
case 'matrix':
|
||||
window.navigateToMatrix(tool.name);
|
||||
break;
|
||||
case 'modal':
|
||||
if (modalParam === 'secondary') {
|
||||
window.showToolDetails(tool.name, 'secondary');
|
||||
} else {
|
||||
window.showToolDetails(tool.name, 'primary');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
window.navigateToGrid(tool.name);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// Handle filtered results
|
||||
window.addEventListener('toolsFiltered', (event: Event) => {
|
||||
window.addEventListener('toolsFiltered', (event) => {
|
||||
const customEvent = event as CustomEvent;
|
||||
const filtered = customEvent.detail;
|
||||
const currentView = document.querySelector('.view-toggle.active')?.getAttribute('data-view');
|
||||
|
||||
if (currentView === 'matrix' || currentView === 'ai') {
|
||||
// Matrix and AI views handle their own rendering
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -341,11 +435,8 @@ const tools = data.tools;
|
||||
} else {
|
||||
noResults.style.display = 'none';
|
||||
|
||||
// Apply sorting here - single place for all sorting logic
|
||||
const currentSortOption = 'default'; // Will be dynamic later
|
||||
const sortedTools = sortTools(filtered, currentSortOption);
|
||||
const sortedTools = sortTools(filtered, 'default');
|
||||
|
||||
// Render sorted tools
|
||||
sortedTools.forEach((tool: any) => {
|
||||
const toolCard = createToolCard(tool);
|
||||
toolsContainer.appendChild(toolCard);
|
||||
@@ -354,112 +445,133 @@ const tools = data.tools;
|
||||
});
|
||||
|
||||
// Handle view changes
|
||||
window.addEventListener('viewChanged', (event: Event) => {
|
||||
window.addEventListener('viewChanged', (event) => {
|
||||
const customEvent = event as CustomEvent;
|
||||
const view = customEvent.detail;
|
||||
switchToView(view);
|
||||
});
|
||||
|
||||
// Make switchToView available globally for the AI button
|
||||
(window as any).switchToAIView = () => switchToView('ai');
|
||||
// Make switchToView available globally
|
||||
window.switchToAIView = () => switchToView('ai');
|
||||
|
||||
function createToolCard(tool) {
|
||||
const isMethod = tool.type === 'method';
|
||||
const isConcept = tool.type === 'concept';
|
||||
const hasValidProjectUrl = tool.projectUrl !== undefined &&
|
||||
tool.projectUrl !== null &&
|
||||
tool.projectUrl !== "" &&
|
||||
tool.projectUrl.trim() !== "";
|
||||
|
||||
const hasKnowledgebase = tool.knowledgebase === true;
|
||||
|
||||
const cardDiv = document.createElement('div');
|
||||
const cardClass = isConcept ? 'card card-concept tool-card' :
|
||||
isMethod ? 'card card-method tool-card' :
|
||||
hasValidProjectUrl ? 'card card-hosted tool-card' :
|
||||
(tool.license !== 'Proprietary' ? 'card card-oss tool-card' : 'card tool-card');
|
||||
cardDiv.className = cardClass;
|
||||
cardDiv.style.cursor = 'pointer';
|
||||
cardDiv.onclick = () => (window as any).showToolDetails(tool.name);
|
||||
|
||||
// Tool card creation function
|
||||
function createToolCard(tool: any): HTMLElement {
|
||||
const isMethod = tool.type === 'method';
|
||||
const isConcept = tool.type === 'concept';
|
||||
const hasValidProjectUrl = tool.projectUrl !== undefined &&
|
||||
tool.projectUrl !== null &&
|
||||
tool.projectUrl !== "" &&
|
||||
tool.projectUrl.trim() !== "";
|
||||
|
||||
const hasKnowledgebase = tool.knowledgebase === true;
|
||||
|
||||
const cardDiv = document.createElement('div');
|
||||
const cardClass = isConcept ? 'card card-concept tool-card' :
|
||||
isMethod ? 'card card-method tool-card' :
|
||||
hasValidProjectUrl ? 'card card-hosted tool-card' :
|
||||
(tool.license !== 'Proprietary' ? 'card card-oss tool-card' : 'card tool-card');
|
||||
cardDiv.className = cardClass;
|
||||
cardDiv.style.cursor = 'pointer';
|
||||
cardDiv.onclick = () => window.showToolDetails(tool.name);
|
||||
|
||||
// Create tool slug for share button
|
||||
const toolSlug = createToolSlug(tool.name);
|
||||
|
||||
cardDiv.innerHTML = `
|
||||
<div class="tool-card-header">
|
||||
<h3>${tool.icon ? `<span style="margin-right: 0.5rem; font-size: 1.125rem;">${tool.icon}</span>` : ''}${tool.name}</h3>
|
||||
<div class="tool-card-badges">
|
||||
${!isMethod && !isConcept && hasValidProjectUrl ? '<span class="badge badge-primary">CC24-Server</span>' : ''}
|
||||
${hasKnowledgebase ? '<span class="badge badge-error">📖</span>' : ''}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-muted">
|
||||
${tool.description}
|
||||
</p>
|
||||
|
||||
<div class="tool-card-metadata" style="display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; line-height: 1;">
|
||||
<div class="metadata-item" style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--color-text-secondary); flex-shrink: 1; min-width: 0;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="flex-shrink: 0;">
|
||||
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
||||
<line x1="9" y1="9" x2="15" y2="9"></line>
|
||||
<line x1="9" y1="15" x2="15" y2="15"></line>
|
||||
</svg>
|
||||
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;">
|
||||
${(tool.platforms || []).slice(0, 2).join(', ')}${tool.platforms && tool.platforms.length > 2 ? '...' : ''}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="metadata-item" style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--color-text-secondary); flex-shrink: 1; min-width: 0;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="flex-shrink: 0;">
|
||||
<circle cx="12" cy="12" r="10"></circle>
|
||||
<path d="M12 6v6l4 2"></path>
|
||||
</svg>
|
||||
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;">
|
||||
${tool.skillLevel}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="metadata-item" style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--color-text-secondary); flex-shrink: 1; min-width: 0;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="flex-shrink: 0;">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
||||
<polyline points="14 2 14 8 20 8"></polyline>
|
||||
</svg>
|
||||
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;">
|
||||
${isConcept ? 'Konzept' : isMethod ? 'Methode' : tool.license === 'Proprietary' ? 'Prop.' : tool.license?.split(' ')[0] || 'N/A'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tool-tags-container">
|
||||
${(tool.tags || []).slice(0, 8).map(tag => `<span class="tag">${tag}</span>`).join('')}
|
||||
</div>
|
||||
|
||||
<div class="tool-card-buttons" onclick="event.stopPropagation();">
|
||||
${isConcept ? `
|
||||
<a href="${tool.url}" target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button" style="background-color: var(--color-concept); border-color: var(--color-concept);">
|
||||
Mehr erfahren
|
||||
</a>
|
||||
` : isMethod ? `
|
||||
<a href="${tool.projectUrl || tool.url}" target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button" style="background-color: var(--color-method); border-color: var(--color-method);">
|
||||
Zur Methode
|
||||
</a>
|
||||
` : hasValidProjectUrl ? `
|
||||
<div class="button-row">
|
||||
<a href="${tool.url}" target="_blank" rel="noopener noreferrer" class="btn btn-secondary">
|
||||
Homepage
|
||||
</a>
|
||||
<a href="${tool.projectUrl}" target="_blank" rel="noopener noreferrer" class="btn btn-primary">
|
||||
Zugreifen
|
||||
</a>
|
||||
cardDiv.innerHTML = `
|
||||
<div class="tool-card-header">
|
||||
<h3>${tool.icon ? `<span style="margin-right: 0.5rem; font-size: 1.125rem;">${tool.icon}</span>` : ''}${tool.name}</h3>
|
||||
<div class="tool-card-badges">
|
||||
${!isMethod && !isConcept && hasValidProjectUrl ? '<span class="badge badge-primary">CC24-Server</span>' : ''}
|
||||
${hasKnowledgebase ? '<span class="badge badge-error">📖</span>' : ''}
|
||||
<button class="share-btn share-btn--small"
|
||||
data-tool-name="${tool.name}"
|
||||
data-tool-slug="${toolSlug}"
|
||||
data-context="card"
|
||||
onclick="event.stopPropagation(); window.showShareDialog(this)"
|
||||
title="${tool.name} teilen"
|
||||
aria-label="${tool.name} teilen">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="18" cy="5" r="3"/>
|
||||
<circle cx="6" cy="12" r="3"/>
|
||||
<circle cx="18" cy="19" r="3"/>
|
||||
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/>
|
||||
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
` : `
|
||||
<a href="${tool.url}" target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button">
|
||||
Software-Homepage
|
||||
</a>
|
||||
`}
|
||||
</div>
|
||||
`;
|
||||
|
||||
return cardDiv;
|
||||
}
|
||||
|
||||
<p class="text-muted">
|
||||
${tool.description}
|
||||
</p>
|
||||
|
||||
<div class="tool-card-metadata" style="display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; line-height: 1;">
|
||||
<div class="metadata-item" style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--color-text-secondary); flex-shrink: 1; min-width: 0;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="flex-shrink: 0;">
|
||||
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
||||
<line x1="9" y1="9" x2="15" y2="9"></line>
|
||||
<line x1="9" y1="15" x2="15" y2="15"></line>
|
||||
</svg>
|
||||
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;">
|
||||
${(tool.platforms || []).slice(0, 2).join(', ')}${tool.platforms && tool.platforms.length > 2 ? '...' : ''}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="metadata-item" style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--color-text-secondary); flex-shrink: 1; min-width: 0;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="flex-shrink: 0;">
|
||||
<circle cx="12" cy="12" r="10"></circle>
|
||||
<path d="M12 6v6l4 2"></path>
|
||||
</svg>
|
||||
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;">
|
||||
${tool.skillLevel}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="metadata-item" style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--color-text-secondary); flex-shrink: 1; min-width: 0;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="flex-shrink: 0;">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
||||
<polyline points="14 2 14 8 20 8"></polyline>
|
||||
</svg>
|
||||
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;">
|
||||
${isConcept ? 'Konzept' : isMethod ? 'Methode' : tool.license === 'Proprietary' ? 'Prop.' : tool.license?.split(' ')[0] || 'N/A'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tool-tags-container">
|
||||
${(tool.tags || []).slice(0, 8).map((tag: string) => `<span class="tag">${tag}</span>`).join('')}
|
||||
</div>
|
||||
|
||||
<div class="tool-card-buttons" onclick="event.stopPropagation();">
|
||||
${isConcept ? `
|
||||
<a href="${tool.url}" target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button" style="background-color: var(--color-concept); border-color: var(--color-concept);">
|
||||
Mehr erfahren
|
||||
</a>
|
||||
` : isMethod ? `
|
||||
<a href="${tool.projectUrl || tool.url}" target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button" style="background-color: var(--color-method); border-color: var(--color-method);">
|
||||
Zur Methode
|
||||
</a>
|
||||
` : hasValidProjectUrl ? `
|
||||
<div class="button-row">
|
||||
<a href="${tool.url}" target="_blank" rel="noopener noreferrer" class="btn btn-secondary">
|
||||
Homepage
|
||||
</a>
|
||||
<a href="${tool.projectUrl}" target="_blank" rel="noopener noreferrer" class="btn btn-primary">
|
||||
Zugreifen
|
||||
</a>
|
||||
</div>
|
||||
` : `
|
||||
<a href="${tool.url}" target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button">
|
||||
Software-Homepage
|
||||
</a>
|
||||
`}
|
||||
</div>
|
||||
`;
|
||||
|
||||
return cardDiv;
|
||||
}
|
||||
|
||||
// Initialize URL handling
|
||||
handleSharedURL();
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user