reformula buscas
Deploy / Deploy (push) Successful in 1m23s Details

This commit is contained in:
JotaChina 2025-12-16 20:35:56 -03:00
parent fd61245d52
commit 5ea3ad0110
1 changed files with 109 additions and 132 deletions

View File

@ -12,7 +12,11 @@ permalink: /projetos/
{% assign list_automation = "" %} {% assign list_automation = "" %}
{% for p in site.data.all %} {% for p in site.data.all %}
{% if p.bpm %}{% assign list_bpm = list_bpm | append: p.bpm | append: "|||" %}{% endif %} {% assign raw_bpm = p.bpm | append: "" %}
{% if raw_bpm != "" and raw_bpm != "N/A" and raw_bpm != "nil" %}
{% assign list_bpm = list_bpm | append: raw_bpm | append: "|||" %}
{% endif %}
{% for item in p.tags.plugin %}{% if item != "" %}{% assign list_plugins = list_plugins | append: item | append: "|||" %}{% endif %}{% endfor %} {% for item in p.tags.plugin %}{% if item != "" %}{% assign list_plugins = list_plugins | append: item | append: "|||" %}{% endif %}{% endfor %}
{% if p.tags.bassline %}{% for item in p.tags.bassline %}{% if item != "" %}{% assign list_bassline = list_bassline | append: item | append: "|||" %}{% endif %}{% endfor %}{% endif %} {% if p.tags.bassline %}{% for item in p.tags.bassline %}{% if item != "" %}{% assign list_bassline = list_bassline | append: item | append: "|||" %}{% endif %}{% endfor %}{% endif %}
{% if p.tags.automation %}{% for item in p.tags.automation %}{% if item != "" %}{% assign list_automation = list_automation | append: item | append: "|||" %}{% endif %}{% endfor %}{% endif %} {% if p.tags.automation %}{% for item in p.tags.automation %}{% if item != "" %}{% assign list_automation = list_automation | append: item | append: "|||" %}{% endif %}{% endfor %}{% endif %}
@ -35,8 +39,8 @@ permalink: /projetos/
{% assign min_limit = 0 %} {% assign min_limit = 0 %}
{% assign max_limit = 300 %} {% assign max_limit = 300 %}
{% if unique_bpm_array.size > 0 %} {% if unique_bpm_array.size > 0 %}
{% assign min_limit = unique_bpm_array | first | minus: 0 %} {% assign last_bpm = unique_bpm_array | last | plus: 0 %}
{% assign max_limit = unique_bpm_array | last | plus: 0 %} {% if last_bpm > max_limit %}{% assign max_limit = last_bpm %}{% endif %}
{% endif %} {% endif %}
<div class="publication"> <div class="publication">
@ -165,66 +169,37 @@ permalink: /projetos/
</details> </details>
<hr class="my-3"> <hr class="my-3">
<details> {% assign filter_groups = "instruments|Instrumentos,plugins|Plugins,bassline|Bassline,automation|Automação,samples|Samples" | split: "," %}
<summary class="menu-label has-text-weight-bold mb-2 clickable-summary">Instrumentos</summary> {% for group in filter_groups %}
<div class="filter-header-actions"> {% assign parts = group | split: "|" %}
<button class="button is-ghost is-small p-0 js-clear-group" data-target="instruments" style="height: auto; font-size: 0.65rem;"> {% assign cat_key = parts[0] %}
<span class="icon"><i class="fa-solid fa-eraser"></i></span> <span>Limpar</span> {% assign cat_label = parts[1] %}
</button>
</div> <details {% if cat_key == 'instruments' or cat_key == 'plugins' %}open{% endif %}>
<div class="filter-content" style="max-height: 200px; overflow-y: auto;"> <summary class="menu-label has-text-weight-bold mb-2 clickable-summary">{{ cat_label }}</summary>
{% for item in unique_instruments %}{% if item != "" %} <div class="filter-header-actions">
<label class="checkbox is-block mb-1 is-size-7"> <button class="button is-ghost is-small p-0 js-clear-group" data-target="{{ cat_key }}" style="height: auto; font-size: 0.65rem;">
<input type="checkbox" class="filter-checkbox" data-category="instruments" value="{{ item }}"> {{ item }} <span class="icon"><i class="fa-solid fa-eraser"></i></span> <span>Limpar</span>
</label> </button>
{% endif %}{% endfor %} </div>
</div> <div class="filter-content" style="max-height: 200px; overflow-y: auto;">
</details> {% assign current_list = "" %}
<hr class="my-3"> {% if cat_key == 'instruments' %}{% assign current_list = unique_instruments %}
{% elsif cat_key == 'plugins' %}{% assign current_list = unique_plugins %}
{% elsif cat_key == 'bassline' %}{% assign current_list = unique_bassline %}
{% elsif cat_key == 'automation' %}{% assign current_list = unique_automation %}
{% elsif cat_key == 'samples' %}{% assign current_list = unique_samples %}
{% endif %}
<details> {% for item in current_list %}{% if item != "" %}
<summary class="menu-label has-text-weight-bold mb-2 clickable-summary">Plugins</summary> <label class="checkbox is-block mb-1 is-size-7">
<div class="filter-header-actions"> <input type="checkbox" class="filter-checkbox" data-category="{{ cat_key }}" value="{{ item }}"> {{ item }}
<button class="button is-ghost is-small p-0 js-clear-group" data-target="plugins" style="height: auto; font-size: 0.65rem;"> </label>
<span class="icon"><i class="fa-solid fa-eraser"></i></span> <span>Limpar</span> {% endif %}{% endfor %}
</button> </div>
</div> </details>
<div class="filter-content" style="max-height: 200px; overflow-y: auto;"> <hr class="my-3">
{% for item in unique_plugins %}{% if item != "" %} {% endfor %}
<label class="checkbox is-block mb-1 is-size-7">
<input type="checkbox" class="filter-checkbox" data-category="plugins" value="{{ item }}"> {{ item }}
</label>
{% endif %}{% endfor %}
</div>
</details>
<hr class="my-3">
<details><summary class="menu-label has-text-weight-bold mb-2 clickable-summary">Bassline</summary>
<div class="filter-header-actions">
<button class="button is-ghost is-small p-0 js-clear-group" data-target="bassline" style="height: auto; font-size: 0.65rem;"><span class="icon"><i class="fa-solid fa-eraser"></i></span> <span>Limpar</span></button>
</div>
<div class="filter-content" style="max-height: 200px; overflow-y: auto;">
{% for item in unique_bassline %}{% if item != "" %}<label class="checkbox is-block mb-1 is-size-7"><input type="checkbox" class="filter-checkbox" data-category="bassline" value="{{ item }}"> {{ item }}</label>{% endif %}{% endfor %}
</div>
</details>
<hr class="my-3">
<details><summary class="menu-label has-text-weight-bold mb-2 clickable-summary">Automação</summary>
<div class="filter-header-actions">
<button class="button is-ghost is-small p-0 js-clear-group" data-target="automation" style="height: auto; font-size: 0.65rem;"><span class="icon"><i class="fa-solid fa-eraser"></i></span> <span>Limpar</span></button>
</div>
<div class="filter-content" style="max-height: 200px; overflow-y: auto;">
{% for item in unique_automation %}{% if item != "" %}<label class="checkbox is-block mb-1 is-size-7"><input type="checkbox" class="filter-checkbox" data-category="automation" value="{{ item }}"> {{ item }}</label>{% endif %}{% endfor %}
</div>
</details>
<hr class="my-3">
<details><summary class="menu-label has-text-weight-bold mb-2 clickable-summary">Samples</summary>
<div class="filter-header-actions">
<button class="button is-ghost is-small p-0 js-clear-group" data-target="samples" style="height: auto; font-size: 0.65rem;"><span class="icon"><i class="fa-solid fa-eraser"></i></span> <span>Limpar</span></button>
</div>
<div class="filter-content" style="max-height: 200px; overflow-y: auto;">
{% for item in unique_samples %}{% if item != "" %}<label class="checkbox is-block mb-1 is-size-7"><input type="checkbox" class="filter-checkbox" data-category="samples" value="{{ item }}"> {{ item | truncate: 25 }}</label>{% endif %}{% endfor %}
</div>
</details>
</div> </div>
</div> </div>
@ -240,13 +215,20 @@ permalink: /projetos/
{% for page in project_pages %} {% for page in project_pages %}
{% if page.url != '/projetos/' %} {% if page.url != '/projetos/' %}
{% assign raw_bpm = page.bpm | append: "" %}
{% if raw_bpm == "" or raw_bpm == "N/A" or raw_bpm == "nil" %}
{% assign p_bpm = 0 %}
{% else %}
{% assign p_bpm = raw_bpm | plus: 0 %}
{% endif %}
{% assign p_insts_array = "" | split: "," %} {% assign p_insts_array = "" | split: "," %}
{% for track in page.tracks %} {% for track in page.tracks %}
{% if track.instruments %}{% for inst in track.instruments %}{% if inst.instrument_name %}{% assign p_insts_array = p_insts_array | push: inst.instrument_name %}{% endif %}{% endfor %} {% if track.instruments %}{% for inst in track.instruments %}{% if inst.instrument_name %}{% assign p_insts_array = p_insts_array | push: inst.instrument_name %}{% endif %}{% endfor %}
{% elsif track.instrument_name %}{% assign p_insts_array = p_insts_array | push: track.instrument_name %}{% endif %} {% elsif track.instrument_name %}{% assign p_insts_array = p_insts_array | push: track.instrument_name %}{% endif %}
{% endfor %} {% endfor %}
{% assign p_instruments_str = p_insts_array | uniq | join: ',' %} {% assign p_instruments_str = p_insts_array | uniq | join: ',' %}
{% assign p_bpm = page.bpm | default: 0 %}
{% assign p_plugins = page.tags.plugin | join: ',' %} {% assign p_plugins = page.tags.plugin | join: ',' %}
{% assign p_bassline = page.tags.bassline | join: ',' %} {% assign p_bassline = page.tags.bassline | join: ',' %}
{% assign p_automation = page.tags.automation | join: ',' %} {% assign p_automation = page.tags.automation | join: ',' %}
@ -279,9 +261,13 @@ permalink: /projetos/
</p> </p>
<div class="bpm-container mb-3" style="min-height: 25px;"> <div class="bpm-container mb-3" style="min-height: 25px;">
{% if page.bpm %} {% if p_bpm > 0 %}
<span class="tag is-dark is-rounded is-light" style="font-size: 0.7rem; font-weight: bold; border: 1px solid #ccc;"> <span class="tag is-dark is-rounded is-light" style="font-size: 0.7rem; font-weight: bold; border: 1px solid #ccc;">
🎵 {{ page.bpm }} BPM 🎵 {{ p_bpm }} BPM
</span>
{% else %}
<span class="tag is-white is-rounded border-tag" style="font-size: 0.65rem; color: #999;">
⚠️ BPM N/A
</span> </span>
{% endif %} {% endif %}
</div> </div>
@ -289,7 +275,10 @@ permalink: /projetos/
<div style="flex: 1;"></div> <div style="flex: 1;"></div>
<div class="mt-auto pt-2" style="width: 100%; border-top: 1px dashed #eef6fc;"> <div class="mt-auto pt-2" style="width: 100%; border-top: 1px dashed #eef6fc;">
{% assign tags_list = "" %}
{% assign unique_insts_page = p_insts_array | uniq | sort %} {% assign unique_insts_page = p_insts_array | uniq | sort %}
{% if unique_insts_page.size > 0 %} {% if unique_insts_page.size > 0 %}
<details class="category-reveal mb-1" style="width: 100%;"> <details class="category-reveal mb-1" style="width: 100%;">
<summary class="tag is-white summary-btn"> <summary class="tag is-white summary-btn">
@ -298,9 +287,7 @@ permalink: /projetos/
</summary> </summary>
<div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;"> <div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;">
{% for tag in unique_insts_page %}{% if tag != "" %} {% for tag in unique_insts_page %}{% if tag != "" %}
<a href="{{ '/instruments/?instrument=' | append: tag | relative_url }}" <a href="{{ '/instruments/?instrument=' | append: tag | relative_url }}" class="tag is-light is-info clickable-tag" data-tag-value="{{ tag }}">
class="tag is-light is-info clickable-tag"
data-tag-value="{{ tag }}">
{{ tag | truncate: 18 }} {{ tag | truncate: 18 }}
</a> </a>
{% endif %}{% endfor %} {% endif %}{% endfor %}
@ -308,7 +295,7 @@ permalink: /projetos/
</details> </details>
{% endif %} {% endif %}
{% if page.tags.plugin and page.tags.plugin.size > 0 %} {% if page.tags.plugin.size > 0 %}
<details class="category-reveal mb-1" style="width: 100%;"> <details class="category-reveal mb-1" style="width: 100%;">
<summary class="tag is-white summary-btn"> <summary class="tag is-white summary-btn">
<div class="tag-label"><span>🔌</span> <span class="tag-text">PLUGINS</span></div> <div class="tag-label"><span>🔌</span> <span class="tag-text">PLUGINS</span></div>
@ -316,9 +303,7 @@ permalink: /projetos/
</summary> </summary>
<div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;"> <div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;">
{% for tag in page.tags.plugin %}{% if tag != "" %} {% for tag in page.tags.plugin %}{% if tag != "" %}
<a href="{{ '/plugin/?plugin=' | append: tag | relative_url }}" <a href="{{ '/plugin/?plugin=' | append: tag | relative_url }}" class="tag is-light is-info clickable-tag" data-tag-value="{{ tag }}">
class="tag is-light is-info clickable-tag"
data-tag-value="{{ tag }}">
{{ tag | truncate: 18 }} {{ tag | truncate: 18 }}
</a> </a>
{% endif %}{% endfor %} {% endif %}{% endfor %}
@ -326,7 +311,7 @@ permalink: /projetos/
</details> </details>
{% endif %} {% endif %}
{% if page.tags.bassline and page.tags.bassline.size > 0 %} {% if page.tags.bassline.size > 0 %}
<details class="category-reveal mb-1" style="width: 100%;"> <details class="category-reveal mb-1" style="width: 100%;">
<summary class="tag is-white summary-btn"> <summary class="tag is-white summary-btn">
<div class="tag-label"><span>🎹</span> <span class="tag-text">BASSLINE</span></div> <div class="tag-label"><span>🎹</span> <span class="tag-text">BASSLINE</span></div>
@ -334,9 +319,7 @@ permalink: /projetos/
</summary> </summary>
<div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;"> <div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;">
{% for tag in page.tags.bassline %}{% if tag != "" %} {% for tag in page.tags.bassline %}{% if tag != "" %}
<a href="{{ '/bassline/?bassline=' | append: tag | relative_url }}" <a href="{{ '/bassline/?bassline=' | append: tag | relative_url }}" class="tag is-light is-info clickable-tag" data-tag-value="{{ tag }}">
class="tag is-light is-info clickable-tag"
data-tag-value="{{ tag }}">
{{ tag | truncate: 18 }} {{ tag | truncate: 18 }}
</a> </a>
{% endif %}{% endfor %} {% endif %}{% endfor %}
@ -344,7 +327,7 @@ permalink: /projetos/
</details> </details>
{% endif %} {% endif %}
{% if page.tags.automation and page.tags.automation.size > 0 %} {% if page.tags.automation.size > 0 %}
<details class="category-reveal mb-1" style="width: 100%;"> <details class="category-reveal mb-1" style="width: 100%;">
<summary class="tag is-white summary-btn"> <summary class="tag is-white summary-btn">
<div class="tag-label"><span>🎚️</span> <span class="tag-text">AUTOMATION</span></div> <div class="tag-label"><span>🎚️</span> <span class="tag-text">AUTOMATION</span></div>
@ -352,9 +335,7 @@ permalink: /projetos/
</summary> </summary>
<div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;"> <div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;">
{% for tag in page.tags.automation %}{% if tag != "" %} {% for tag in page.tags.automation %}{% if tag != "" %}
<a href="{{ '/automation/?automation=' | append: tag | relative_url }}" <a href="{{ '/automation/?automation=' | append: tag | relative_url }}" class="tag is-light is-info clickable-tag" data-tag-value="{{ tag }}">
class="tag is-light is-info clickable-tag"
data-tag-value="{{ tag }}">
{{ tag | truncate: 18 }} {{ tag | truncate: 18 }}
</a> </a>
{% endif %}{% endfor %} {% endif %}{% endfor %}
@ -362,7 +343,7 @@ permalink: /projetos/
</details> </details>
{% endif %} {% endif %}
{% if page.tags.sample and page.tags.sample.size > 0 %} {% if page.tags.sample.size > 0 %}
<details class="category-reveal mb-1" style="width: 100%;"> <details class="category-reveal mb-1" style="width: 100%;">
<summary class="tag is-white summary-btn"> <summary class="tag is-white summary-btn">
<div class="tag-label"><span>🎤</span> <span class="tag-text">SAMPLES</span></div> <div class="tag-label"><span>🎤</span> <span class="tag-text">SAMPLES</span></div>
@ -370,9 +351,7 @@ permalink: /projetos/
</summary> </summary>
<div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;"> <div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;">
{% for tag in page.tags.sample %}{% if tag != "" %} {% for tag in page.tags.sample %}{% if tag != "" %}
<a href="{{ '/sample/?sample=' | append: tag | relative_url }}" <a href="{{ '/sample/?sample=' | append: tag | relative_url }}" class="tag is-light is-info clickable-tag" data-tag-value="{{ tag }}">
class="tag is-light is-info clickable-tag"
data-tag-value="{{ tag }}">
{{ tag | truncate: 18 }} {{ tag | truncate: 18 }}
</a> </a>
{% endif %}{% endfor %} {% endif %}{% endfor %}
@ -517,7 +496,7 @@ document.addEventListener('DOMContentLoaded', function () {
let currentMinStars = 'all'; let currentMinStars = 'all';
let searchText = ""; let searchText = "";
// Definição Inicial BPM // Definição Inicial BPM (Do HTML)
let defMin = parseInt(inputMin.value), defMax = parseInt(inputMax.value); let defMin = parseInt(inputMin.value), defMax = parseInt(inputMax.value);
// --- 2. LÓGICA DO SLIDER DE BPM (Dual) --- // --- 2. LÓGICA DO SLIDER DE BPM (Dual) ---
@ -555,6 +534,18 @@ document.addEventListener('DOMContentLoaded', function () {
.then(data => { .then(data => {
enrichCards(data); enrichCards(data);
createGenreCheckboxes(data); createGenreCheckboxes(data);
// Recalcula limites de BPM com base nos dados reais (Opcional, mas ajusta o maximo)
const bpms = data.map(i => parseFloat(i.analise_tecnica?.bpm || 0)).filter(b => b > 0);
if(bpms.length > 0) {
const maxData = Math.ceil(Math.max(...bpms));
if(maxData > parseInt(sliderMax.max)) {
sliderMax.max = maxData;
inputMax.max = maxData;
sliderMin.max = maxData;
inputMin.max = maxData;
}
}
applyGlobalFilters(); applyGlobalFilters();
}) })
.catch(console.warn); .catch(console.warn);
@ -585,7 +576,6 @@ document.addEventListener('DOMContentLoaded', function () {
const titleKey = normalizarChaveJS(item.getAttribute('data-title')); const titleKey = normalizarChaveJS(item.getAttribute('data-title'));
const info = mapDados[titleKey]; const info = mapDados[titleKey];
// Padrões
let genero = "Unknown", subgeneros = [], estrelas = 0, intensidade = -100, bpm = 0, tomHtml = "", tomRaw = "all", subTagsHTML = ""; let genero = "Unknown", subgeneros = [], estrelas = 0, intensidade = -100, bpm = 0, tomHtml = "", tomRaw = "all", subTagsHTML = "";
if (info) { if (info) {
@ -611,18 +601,33 @@ document.addEventListener('DOMContentLoaded', function () {
} }
} }
// Atributos
item.setAttribute('data-genre', genero); item.setAttribute('data-genre', genero);
item.setAttribute('data-subgenres', subgeneros.join(',').toLowerCase()); item.setAttribute('data-subgenres', subgeneros.join(',').toLowerCase());
item.setAttribute('data-stars', estrelas); item.setAttribute('data-stars', estrelas);
item.setAttribute('data-intensity', intensidade); item.setAttribute('data-intensity', intensidade);
item.setAttribute('data-key', tomRaw); item.setAttribute('data-key', tomRaw);
if(bpm > 0) item.setAttribute('data-bpm-real', bpm);
// Se o JSON tiver um BPM real, usamos ele (sobrescrevendo o do Liquid se precisar)
// Se o projeto for 0, mas o JSON tiver valor, atualizamos.
if(bpm > 0) {
item.setAttribute('data-bpm-real', bpm);
// Atualiza o atributo usado no filtro se o liquid falhou
if(item.getAttribute('data-bpm') == "0") item.setAttribute('data-bpm', Math.round(bpm));
}
// Visual
const bpmContainer = card.querySelector('.bpm-container'); const bpmContainer = card.querySelector('.bpm-container');
if(bpmContainer) { if(bpmContainer) {
const existingBpm = bpmContainer.innerHTML; // Mantém o BPM original se existir, ou o novo do JSON
let bpmDisplay = "";
if(bpm > 0) {
bpmDisplay = `<span class="tag is-dark is-rounded is-light" style="font-size: 0.7rem; font-weight: bold; border: 1px solid #ccc;">🎵 ${Math.round(bpm)} BPM</span>`;
} else if (item.getAttribute('data-bpm') != "0") {
// Mantém o que veio do Liquid se for válido
bpmDisplay = bpmContainer.innerHTML;
} else {
bpmDisplay = `<span class="tag is-white is-rounded border-tag" style="font-size: 0.65rem; color: #999;">⚠️ BPM N/A</span>`;
}
let newHtml = `<div class="mt-2" style="display:flex; flex-direction:column; align-items:center; gap:4px;">`; let newHtml = `<div class="mt-2" style="display:flex; flex-direction:column; align-items:center; gap:4px;">`;
newHtml += `<div>${renderizarDificuldade(estrelas)}</div>`; newHtml += `<div>${renderizarDificuldade(estrelas)}</div>`;
newHtml += `<div class="tags is-centered mb-0" style="gap:4px;">`; newHtml += `<div class="tags is-centered mb-0" style="gap:4px;">`;
@ -637,7 +642,8 @@ document.addEventListener('DOMContentLoaded', function () {
newHtml += `</div>`; newHtml += `</div>`;
if(subTagsHTML) newHtml += `<div style="display:flex; flex-wrap:wrap; justify-content:center; gap:2px;">${subTagsHTML}</div>`; if(subTagsHTML) newHtml += `<div style="display:flex; flex-wrap:wrap; justify-content:center; gap:2px;">${subTagsHTML}</div>`;
newHtml += `</div>`; newHtml += `</div>`;
bpmContainer.innerHTML = existingBpm + newHtml;
bpmContainer.innerHTML = bpmDisplay + newHtml;
} }
}); });
} }
@ -649,7 +655,7 @@ document.addEventListener('DOMContentLoaded', function () {
if(Array.isArray(i.analise_ia?.nuvem_tags)) i.analise_ia.nuvem_tags.forEach(t => genres.add(t.tag)); if(Array.isArray(i.analise_ia?.nuvem_tags)) i.analise_ia.nuvem_tags.forEach(t => genres.add(t.tag));
}); });
sidebarGenreContainer.innerHTML = ""; // Clear loader sidebarGenreContainer.innerHTML = "";
Array.from(genres).sort().forEach(g => { Array.from(genres).sort().forEach(g => {
const label = document.createElement('label'); const label = document.createElement('label');
label.className = "checkbox is-block mb-1 is-size-7"; label.className = "checkbox is-block mb-1 is-size-7";
@ -657,13 +663,11 @@ document.addEventListener('DOMContentLoaded', function () {
sidebarGenreContainer.appendChild(label); sidebarGenreContainer.appendChild(label);
}); });
// Re-attach listeners to new checkboxes
document.querySelectorAll('#sidebar-genres .filter-checkbox').forEach(cb => { document.querySelectorAll('#sidebar-genres .filter-checkbox').forEach(cb => {
cb.addEventListener('change', updateActiveSidebar); cb.addEventListener('change', updateActiveSidebar);
}); });
} }
// --- 4. GESTÃO DE FILTROS ---
function updateActiveSidebar() { function updateActiveSidebar() {
activeSidebar = { instruments: [], plugins: [], samples: [], bassline: [], automation: [], keys: [], genres: [] }; activeSidebar = { instruments: [], plugins: [], samples: [], bassline: [], automation: [], keys: [], genres: [] };
document.querySelectorAll('.filter-checkbox').forEach(bx => { document.querySelectorAll('.filter-checkbox').forEach(bx => {
@ -677,15 +681,12 @@ document.addEventListener('DOMContentLoaded', function () {
applyGlobalFilters(); applyGlobalFilters();
} }
// --- MAIN FILTER LOGIC WITH HIGHLIGHTING ---
function applyGlobalFilters() { function applyGlobalFilters() {
let visibleCount = 0; let visibleCount = 0;
let minBpm = parseInt(inputMin.value); let minBpm = parseInt(inputMin.value);
let maxBpm = parseInt(inputMax.value); let maxBpm = parseInt(inputMax.value);
if(minBpm > maxBpm) { let t = minBpm; minBpm = maxBpm; maxBpm = t; } if(minBpm > maxBpm) { let t = minBpm; minBpm = maxBpm; maxBpm = t; }
// Coleta todos os termos de busca para o highlight
// (Junta todos os filtros de texto ativos em um único set para performance)
const allActiveTags = new Set([ const allActiveTags = new Set([
...activeSidebar.instruments, ...activeSidebar.instruments,
...activeSidebar.plugins, ...activeSidebar.plugins,
@ -696,27 +697,26 @@ document.addEventListener('DOMContentLoaded', function () {
...activeSidebar.keys ...activeSidebar.keys
].map(s => s.toLowerCase())); ].map(s => s.toLowerCase()));
// Check if any filter (except stars/bpm) is active to trigger auto-open
const hasActiveTypeFilter = allActiveTags.size > 0 || (searchText.length > 2); const hasActiveTypeFilter = allActiveTags.size > 0 || (searchText.length > 2);
document.querySelectorAll('.project-item').forEach(item => { document.querySelectorAll('.project-item').forEach(item => {
// Leitura
const pName = item.getAttribute('data-name') || ""; const pName = item.getAttribute('data-name') || "";
const pBpm = parseInt(item.getAttribute('data-bpm')) || 0; // Garante que é número. Se "0" ou "NaN", vira 0.
let pBpm = parseInt(item.getAttribute('data-bpm'));
if(isNaN(pBpm)) pBpm = 0;
const pInsts = (item.getAttribute('data-instruments') || "").split(','); const pInsts = (item.getAttribute('data-instruments') || "").split(',');
const pPlugins = (item.getAttribute('data-plugins') || "").split(','); const pPlugins = (item.getAttribute('data-plugins') || "").split(',');
const pSamples = (item.getAttribute('data-samples') || "").split(','); const pSamples = (item.getAttribute('data-samples') || "").split(',');
const pBassline = (item.getAttribute('data-bassline') || "").split(','); const pBassline = (item.getAttribute('data-bassline') || "").split(',');
const pAutomation = (item.getAttribute('data-automation') || "").split(','); const pAutomation = (item.getAttribute('data-automation') || "").split(',');
// Novos (IA/Sidebar)
const pGenre = (item.getAttribute('data-genre') || "").toLowerCase(); const pGenre = (item.getAttribute('data-genre') || "").toLowerCase();
const pSubs = (item.getAttribute('data-subgenres') || "").toLowerCase(); const pSubs = (item.getAttribute('data-subgenres') || "").toLowerCase();
const pTagsIA = pGenre + "," + pSubs; const pTagsIA = pGenre + "," + pSubs;
const pKey = item.getAttribute('data-key') || 'all'; const pKey = item.getAttribute('data-key') || 'all';
const pStars = parseInt(item.getAttribute('data-stars') || 0); const pStars = parseInt(item.getAttribute('data-stars') || 0);
// Matches
const matchInst = activeSidebar.instruments.length === 0 || activeSidebar.instruments.some(f => pInsts.includes(f)); const matchInst = activeSidebar.instruments.length === 0 || activeSidebar.instruments.some(f => pInsts.includes(f));
const matchPlugin = activeSidebar.plugins.length === 0 || activeSidebar.plugins.some(f => pPlugins.includes(f)); const matchPlugin = activeSidebar.plugins.length === 0 || activeSidebar.plugins.some(f => pPlugins.includes(f));
const matchSample = activeSidebar.samples.length === 0 || activeSidebar.samples.some(f => pSamples.includes(f)); const matchSample = activeSidebar.samples.length === 0 || activeSidebar.samples.some(f => pSamples.includes(f));
@ -736,34 +736,26 @@ document.addEventListener('DOMContentLoaded', function () {
item.style.display = 'block'; item.style.display = 'block';
visibleCount++; visibleCount++;
// --- HIGHLIGHT LOGIC --- // Highlight
// 1. Reset highlights
const clickableTags = item.querySelectorAll('.clickable-tag'); const clickableTags = item.querySelectorAll('.clickable-tag');
clickableTags.forEach(t => t.classList.remove('is-matched-tag')); clickableTags.forEach(t => t.classList.remove('is-matched-tag'));
// 2. Apply matches & Auto-open
if(hasActiveTypeFilter) { if(hasActiveTypeFilter) {
// Close all details first to reduce noise (optional strategy)
item.querySelectorAll('details').forEach(d => d.open = false); item.querySelectorAll('details').forEach(d => d.open = false);
clickableTags.forEach(tagEl => { clickableTags.forEach(tagEl => {
const tagVal = (tagEl.dataset.tagValue || "").trim().toLowerCase(); const tagVal = (tagEl.dataset.tagValue || "").trim().toLowerCase();
// Check exact match from filters OR text search partial match
const isFilterMatch = allActiveTags.has(tagVal); const isFilterMatch = allActiveTags.has(tagVal);
const isTextMatch = searchText.length > 2 && tagVal.includes(searchText); const isTextMatch = searchText.length > 2 && tagVal.includes(searchText);
if (isFilterMatch || isTextMatch) { if (isFilterMatch || isTextMatch) {
tagEl.classList.add('is-matched-tag'); tagEl.classList.add('is-matched-tag');
const parentDetails = tagEl.closest('details'); const parentDetails = tagEl.closest('details');
if(parentDetails) parentDetails.open = true; // Auto-open! if(parentDetails) parentDetails.open = true;
} }
}); });
} } else {
// If no filters active, maybe leave default open state (usually instruments open)
else {
// Reset to default (Instruments open, others closed)
item.querySelectorAll('details').forEach(d => d.open = false); item.querySelectorAll('details').forEach(d => d.open = false);
const instDetail = item.querySelector('details:first-of-type'); // Assuming instruments is first const instDetail = item.querySelector('details:first-of-type');
if(instDetail) instDetail.open = true; if(instDetail) instDetail.open = true;
} }
@ -777,15 +769,11 @@ document.addEventListener('DOMContentLoaded', function () {
noResults.classList.toggle('is-hidden', visibleCount > 0); noResults.classList.toggle('is-hidden', visibleCount > 0);
} }
// --- 5. EVENT LISTENERS GERAIS ---
checkboxes.forEach(cb => cb.addEventListener('change', updateActiveSidebar)); checkboxes.forEach(cb => cb.addEventListener('change', updateActiveSidebar));
searchInput.addEventListener('input', (e) => { searchText = e.target.value.toLowerCase().trim(); applyGlobalFilters(); }); searchInput.addEventListener('input', (e) => { searchText = e.target.value.toLowerCase().trim(); applyGlobalFilters(); });
clearInputBtn.addEventListener('click', () => { searchInput.value = ""; searchText = ""; applyGlobalFilters(); }); clearInputBtn.addEventListener('click', () => { searchInput.value = ""; searchText = ""; applyGlobalFilters(); });
if(starFilterSelect) starFilterSelect.addEventListener('change', (e) => { currentMinStars = e.target.value; applyGlobalFilters(); }); if(starFilterSelect) starFilterSelect.addEventListener('change', (e) => { currentMinStars = e.target.value; applyGlobalFilters(); });
// Sort
if(sortSelect) sortSelect.addEventListener('change', (e) => { if(sortSelect) sortSelect.addEventListener('change', (e) => {
const crit = e.target.value; const crit = e.target.value;
const cols = Array.from(projectsContainer.children); const cols = Array.from(projectsContainer.children);
@ -801,19 +789,13 @@ document.addEventListener('DOMContentLoaded', function () {
cols.forEach(c => projectsContainer.appendChild(c)); cols.forEach(c => projectsContainer.appendChild(c));
}); });
// Limpeza Individual de Grupos
clearGroupBtns.forEach(btn => { clearGroupBtns.forEach(btn => {
btn.addEventListener('click', (e) => { btn.addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault(); e.stopPropagation();
e.stopPropagation(); // Não fechar o details
const target = btn.dataset.target; const target = btn.dataset.target;
// Reseta BPM especificamente ou checkboxes
if(target === 'bpm') { if(target === 'bpm') {
sliderMin.value = sliderMin.min; sliderMax.value = sliderMax.max; sliderMin.value = sliderMin.min; sliderMax.value = sliderMax.max; updateSlider();
updateSlider();
} else { } else {
// Desmarca checkboxes daquela categoria
document.querySelectorAll(`.filter-checkbox[data-category="${target}"]`).forEach(cb => { document.querySelectorAll(`.filter-checkbox[data-category="${target}"]`).forEach(cb => {
cb.checked = false; cb.checked = false;
if(cb.parentElement.classList.contains('tag')) cb.parentElement.classList.remove('is-checked'); if(cb.parentElement.classList.contains('tag')) cb.parentElement.classList.remove('is-checked');
@ -823,19 +805,14 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
}); });
// Reset Total
resetBtn.addEventListener('click', () => { resetBtn.addEventListener('click', () => {
document.querySelectorAll('.filter-checkbox').forEach(cb => { cb.checked = false; cb.parentElement.classList.remove('is-checked'); }); document.querySelectorAll('.filter-checkbox').forEach(cb => { cb.checked = false; cb.parentElement.classList.remove('is-checked'); });
searchInput.value = ""; searchText = ""; searchInput.value = ""; searchText = "";
sliderMin.value = sliderMin.min; sliderMax.value = sliderMax.max; updateSlider(); sliderMin.value = sliderMin.min; sliderMax.value = sliderMax.max; updateSlider();
starFilterSelect.value = 'all'; currentMinStars = 'all'; starFilterSelect.value = 'all'; currentMinStars = 'all'; sortSelect.value = 'default';
sortSelect.value = 'default';
updateActiveSidebar(); updateActiveSidebar();
}); });
// Modal
const modal = document.getElementById('preview-modal'); const modal = document.getElementById('preview-modal');
const iframe = document.getElementById('preview-iframe'); const iframe = document.getElementById('preview-iframe');
const modalTitle = document.getElementById('modal-title'); const modalTitle = document.getElementById('modal-title');