fix share btn
This commit is contained in:
@@ -510,6 +510,8 @@ if (aiAuthRequired) {
|
||||
};
|
||||
|
||||
function handleSharedURL() {
|
||||
console.log('[SHARE] Handling shared URL:', window.location.search);
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const toolParam = urlParams.get('tool');
|
||||
const viewParam = urlParams.get('view');
|
||||
@@ -521,13 +523,19 @@ if (aiAuthRequired) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!window.findToolByIdentifier) {
|
||||
console.error('[SHARE] findToolByIdentifier not available, retrying...');
|
||||
setTimeout(() => handleSharedURL(), 200);
|
||||
return;
|
||||
}
|
||||
|
||||
const tool = window.findToolByIdentifier(window.toolsData, toolParam);
|
||||
if (!tool) {
|
||||
console.warn('Shared tool not found:', toolParam);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const cleanUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
||||
window.history.replaceState({}, document.title, cleanUrl);
|
||||
|
||||
@@ -549,125 +557,125 @@ if (aiAuthRequired) {
|
||||
default:
|
||||
window.navigateToGrid(tool.name);
|
||||
}
|
||||
}, 100);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
window.addEventListener('toolsFiltered', (event) => {
|
||||
const { tools: filtered, semanticSearch } = event.detail;
|
||||
const currentView = document.querySelector('.view-toggle.active')?.getAttribute('data-view');
|
||||
|
||||
if (currentView === 'matrix' || currentView === 'ai') {
|
||||
return;
|
||||
}
|
||||
|
||||
const allToolCards = document.querySelectorAll('.tool-card');
|
||||
const filteredNames = new Set(filtered.map(tool => tool.name.toLowerCase()));
|
||||
const toolsContainer = document.getElementById('tools-container');
|
||||
|
||||
let visibleCount = 0;
|
||||
|
||||
if (semanticSearch && filtered.length > 0) {
|
||||
console.log('[SEMANTIC] Reordering tools by semantic similarity');
|
||||
window.addEventListener('toolsFiltered', (event) => {
|
||||
const { tools: filtered, semanticSearch } = event.detail;
|
||||
const currentView = document.querySelector('.view-toggle.active')?.getAttribute('data-view');
|
||||
|
||||
const orderedCards = [];
|
||||
const remainingCards = [];
|
||||
if (currentView === 'matrix' || currentView === 'ai') {
|
||||
return;
|
||||
}
|
||||
|
||||
filtered.forEach(tool => {
|
||||
const toolName = tool.name.toLowerCase();
|
||||
const matchingCard = Array.from(allToolCards).find(card =>
|
||||
card.getAttribute('data-tool-name') === toolName
|
||||
);
|
||||
const allToolCards = document.querySelectorAll('.tool-card');
|
||||
const filteredNames = new Set(filtered.map(tool => tool.name.toLowerCase()));
|
||||
const toolsContainer = document.getElementById('tools-container');
|
||||
|
||||
let visibleCount = 0;
|
||||
|
||||
if (semanticSearch && filtered.length > 0) {
|
||||
console.log('[SEMANTIC] Reordering tools by semantic similarity');
|
||||
|
||||
if (matchingCard) {
|
||||
matchingCard.style.display = 'block';
|
||||
orderedCards.push(matchingCard);
|
||||
visibleCount++;
|
||||
const orderedCards = [];
|
||||
const remainingCards = [];
|
||||
|
||||
filtered.forEach(tool => {
|
||||
const toolName = tool.name.toLowerCase();
|
||||
const matchingCard = Array.from(allToolCards).find(card =>
|
||||
card.getAttribute('data-tool-name') === toolName
|
||||
);
|
||||
|
||||
if (tool._semanticSimilarity) {
|
||||
matchingCard.setAttribute('data-semantic-similarity', tool._semanticSimilarity.toFixed(3));
|
||||
matchingCard.setAttribute('data-semantic-rank', tool._semanticRank || '');
|
||||
if (matchingCard) {
|
||||
matchingCard.style.display = 'block';
|
||||
orderedCards.push(matchingCard);
|
||||
visibleCount++;
|
||||
|
||||
const header = matchingCard.querySelector('.tool-card-header h3');
|
||||
if (header && tool._semanticRank <= 3) {
|
||||
const existingIndicator = header.querySelector('.semantic-rank-indicator');
|
||||
if (existingIndicator) {
|
||||
existingIndicator.remove();
|
||||
}
|
||||
if (tool._semanticSimilarity) {
|
||||
matchingCard.setAttribute('data-semantic-similarity', tool._semanticSimilarity.toFixed(3));
|
||||
matchingCard.setAttribute('data-semantic-rank', tool._semanticRank || '');
|
||||
|
||||
const indicator = document.createElement('span');
|
||||
indicator.className = 'semantic-rank-indicator';
|
||||
indicator.style.cssText = `
|
||||
display: inline-block;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background-color: var(--color-accent);
|
||||
border-radius: 50%;
|
||||
margin-left: 0.5rem;
|
||||
opacity: ${1 - (tool._semanticRank - 1) * 0.3};
|
||||
`;
|
||||
indicator.title = `Semantische Relevanz: ${tool._semanticSimilarity.toFixed(3)}`;
|
||||
header.appendChild(indicator);
|
||||
const header = matchingCard.querySelector('.tool-card-header h3');
|
||||
if (header && tool._semanticRank <= 3) {
|
||||
const existingIndicator = header.querySelector('.semantic-rank-indicator');
|
||||
if (existingIndicator) {
|
||||
existingIndicator.remove();
|
||||
}
|
||||
|
||||
const indicator = document.createElement('span');
|
||||
indicator.className = 'semantic-rank-indicator';
|
||||
indicator.style.cssText = `
|
||||
display: inline-block;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background-color: var(--color-accent);
|
||||
border-radius: 50%;
|
||||
margin-left: 0.5rem;
|
||||
opacity: ${1 - (tool._semanticRank - 1) * 0.3};
|
||||
`;
|
||||
indicator.title = `Semantische Relevanz: ${tool._semanticSimilarity.toFixed(3)}`;
|
||||
header.appendChild(indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
allToolCards.forEach(card => {
|
||||
const toolName = card.getAttribute('data-tool-name');
|
||||
if (!filteredNames.has(toolName)) {
|
||||
card.style.display = 'none';
|
||||
remainingCards.push(card);
|
||||
}
|
||||
});
|
||||
|
||||
const allCards = [...orderedCards, ...remainingCards];
|
||||
allCards.forEach(card => {
|
||||
toolsContainer.appendChild(card);
|
||||
});
|
||||
|
||||
} else {
|
||||
allToolCards.forEach(card => {
|
||||
const toolName = card.getAttribute('data-tool-name');
|
||||
|
||||
card.removeAttribute('data-semantic-similarity');
|
||||
card.removeAttribute('data-semantic-rank');
|
||||
const semanticIndicator = card.querySelector('.semantic-rank-indicator');
|
||||
if (semanticIndicator) {
|
||||
semanticIndicator.remove();
|
||||
}
|
||||
|
||||
if (filteredNames.has(toolName)) {
|
||||
card.style.display = 'block';
|
||||
visibleCount++;
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
if (!semanticSearch) {
|
||||
const originalOrder = Array.from(allToolCards).sort((a, b) => {
|
||||
const aIndex = Array.from(allToolCards).indexOf(a);
|
||||
const bIndex = Array.from(allToolCards).indexOf(b);
|
||||
return aIndex - bIndex;
|
||||
});
|
||||
|
||||
originalOrder.forEach(card => {
|
||||
allToolCards.forEach(card => {
|
||||
const toolName = card.getAttribute('data-tool-name');
|
||||
if (!filteredNames.has(toolName)) {
|
||||
card.style.display = 'none';
|
||||
remainingCards.push(card);
|
||||
}
|
||||
});
|
||||
|
||||
const allCards = [...orderedCards, ...remainingCards];
|
||||
allCards.forEach(card => {
|
||||
toolsContainer.appendChild(card);
|
||||
});
|
||||
|
||||
} else {
|
||||
allToolCards.forEach(card => {
|
||||
const toolName = card.getAttribute('data-tool-name');
|
||||
|
||||
card.removeAttribute('data-semantic-similarity');
|
||||
card.removeAttribute('data-semantic-rank');
|
||||
const semanticIndicator = card.querySelector('.semantic-rank-indicator');
|
||||
if (semanticIndicator) {
|
||||
semanticIndicator.remove();
|
||||
}
|
||||
|
||||
if (filteredNames.has(toolName)) {
|
||||
card.style.display = 'block';
|
||||
visibleCount++;
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
if (!semanticSearch) {
|
||||
const originalOrder = Array.from(allToolCards).sort((a, b) => {
|
||||
const aIndex = Array.from(allToolCards).indexOf(a);
|
||||
const bIndex = Array.from(allToolCards).indexOf(b);
|
||||
return aIndex - bIndex;
|
||||
});
|
||||
|
||||
originalOrder.forEach(card => {
|
||||
toolsContainer.appendChild(card);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (visibleCount === 0) {
|
||||
noResults.style.display = 'block';
|
||||
} else {
|
||||
noResults.style.display = 'none';
|
||||
}
|
||||
|
||||
if (semanticSearch) {
|
||||
console.log(`[SEMANTIC] Displayed ${visibleCount} tools in semantic order`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (visibleCount === 0) {
|
||||
noResults.style.display = 'block';
|
||||
} else {
|
||||
noResults.style.display = 'none';
|
||||
}
|
||||
|
||||
if (semanticSearch) {
|
||||
console.log(`[SEMANTIC] Displayed ${visibleCount} tools in semantic order`);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('viewChanged', (event) => {
|
||||
const view = event.detail;
|
||||
if (!event.triggeredByButton) {
|
||||
@@ -678,7 +686,11 @@ if (aiAuthRequired) {
|
||||
window.switchToAIView = () => switchToView('ai');
|
||||
window.switchToView = switchToView;
|
||||
|
||||
handleSharedURL();
|
||||
// CRITICAL: Handle shared URLs AFTER everything is set up
|
||||
// Increased timeout to ensure all components and utility functions are loaded
|
||||
setTimeout(() => {
|
||||
handleSharedURL();
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
||||
</BaseLayout>
|
||||
Reference in New Issue
Block a user