adjust styles

This commit is contained in:
overcuriousity 2025-07-14 21:55:09 +02:00
parent 0667180da5
commit 8540687b47

View File

@ -213,6 +213,14 @@ const sortedTags = Object.entries(tagFrequency)
tagCloudToggle.style.display = hasHiddenTags ? 'block' : 'none';
}
// Check if tool is hosted (has valid projectUrl)
function isToolHosted(tool) {
return tool.projectUrl !== undefined &&
tool.projectUrl !== null &&
tool.projectUrl !== "" &&
tool.projectUrl.trim() !== "";
}
// Filter function
function filterTools() {
const searchTerm = searchInput.value.toLowerCase();
@ -252,16 +260,29 @@ const sortedTags = Object.entries(tagFrequency)
return true;
});
// Emit custom event with filtered results
window.dispatchEvent(new CustomEvent('toolsFiltered', { detail: filtered }));
// Sort filtered results: self-hosted first, proprietary last
filtered.sort((a, b) => {
const aHosted = isToolHosted(a);
const bHosted = isToolHosted(b);
const aProprietary = a.license === 'Proprietary';
const bProprietary = b.license === 'Proprietary';
// Self-hosted tools first (regardless of license)
if (aHosted && !bHosted) return -1;
if (!aHosted && bHosted) return 1;
// If both have same hosting status, proprietary tools go last
if (aHosted === bHosted) {
if (!aProprietary && bProprietary) return -1;
if (aProprietary && !bProprietary) return 1;
}
// Check if tool is hosted (has valid projectUrl)
function isToolHosted(tool) {
return tool.projectUrl !== undefined &&
tool.projectUrl !== null &&
tool.projectUrl !== "" &&
tool.projectUrl.trim() !== "";
// Maintain existing order within same priority group
return 0;
});
// Emit custom event with filtered results
window.dispatchEvent(new CustomEvent('toolsFiltered', { detail: filtered }));
}
// Handle tag cloud clicks
@ -309,6 +330,19 @@ const sortedTags = Object.entries(tagFrequency)
if (view === 'hosted') {
// Filter for hosted tools only (tools with valid projectUrl)
const hosted = window.toolsData.filter(tool => isToolHosted(tool));
// Apply same sorting logic for consistency
hosted.sort((a, b) => {
const aProprietary = a.license === 'Proprietary';
const bProprietary = b.license === 'Proprietary';
// Since all are hosted, just sort by proprietary status
if (!aProprietary && bProprietary) return -1;
if (aProprietary && !bProprietary) return 1;
return 0;
});
window.dispatchEvent(new CustomEvent('toolsFiltered', { detail: hosted }));
} else {
filterTools();
@ -361,6 +395,10 @@ const sortedTags = Object.entries(tagFrequency)
// Initialize
initTagCloud();
filterTagCloud();
// Delay initial filter to ensure all event listeners are ready
setTimeout(() => {
filterTools();
}, 100);
});
</script>