616 lines
25 KiB
Markdown
Executable File
616 lines
25 KiB
Markdown
Executable File
---
|
|
layout: default
|
|
title: MMPSearch - Projetos
|
|
permalink: /projetos/
|
|
---
|
|
|
|
<div class="publication">
|
|
<div class="container">
|
|
<br />
|
|
|
|
<div class="tabs is-centered is-boxed is-medium mb-6">
|
|
{% include sidebar.html %}
|
|
</div>
|
|
|
|
<div class="has-text-centered mb-6">
|
|
<h1 class="title is-3 has-text-grey-dark">📁 Projetos Disponíveis</h1>
|
|
<p class="subtitle is-6 has-text-grey">
|
|
Explore, ouça e reutilize projetos da comunidade LMMS.
|
|
</p>
|
|
<div style="width: 60px; height: 4px; background-color: #3273dc; margin: 1rem auto; border-radius: 2px;"></div>
|
|
</div>
|
|
|
|
<div class="box has-background-white-ter mb-6 p-0" style="border: 1px solid #dbdbdb; overflow: hidden; height: auto !important; min-height: 0 !important;">
|
|
|
|
<div class="p-3 is-clickable" id="filter-toggle-btn" style="cursor: pointer; display: flex; align-items: center; justify-content: space-between; background-color: #f5f5f5;">
|
|
<div class="icon-text has-text-weight-bold has-text-grey-dark">
|
|
<span class="icon"><i class="fa-solid fa-sliders"></i></span>
|
|
<span>Filtros, Gêneros & Ordenação</span>
|
|
</div>
|
|
<span class="icon transition-icon">
|
|
<i class="fa-solid fa-chevron-down" id="filter-chevron"></i>
|
|
</span>
|
|
</div>
|
|
|
|
<div id="filter-content" style="display: none; border-top: 1px solid #e8e8e8;">
|
|
<div class="p-4">
|
|
<div class="columns is-vcentered is-multiline">
|
|
|
|
<div class="column is-narrow">
|
|
<span class="tag is-info is-light has-text-weight-bold">
|
|
<i class="fa-solid fa-robot mr-1"></i> Filtro IA:
|
|
</span>
|
|
</div>
|
|
|
|
<div class="column">
|
|
<div class="buttons" id="genre-filters">
|
|
<button class="button is-small is-rounded is-active is-info" data-genre="all">Todos</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="column is-narrow">
|
|
<div class="field has-addons" style="flex-wrap: wrap; gap: 5px;">
|
|
|
|
<div class="control has-icons-left">
|
|
<div class="select is-small is-rounded">
|
|
<select id="star-filter">
|
|
<option value="all">Todas Dificuldades</option>
|
|
<option value="5">🔥 Expert (Nível 5)</option>
|
|
<option value="4">⚡ Avançado (Nível 4)</option>
|
|
<option value="3">🔷 Intermediário (Nível 3)</option>
|
|
<option value="2">🟢 Básico (Nível 2)</option>
|
|
</select>
|
|
</div>
|
|
<div class="icon is-small is-left has-text-warning">
|
|
<i class="fa-solid fa-star"></i>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control has-icons-left">
|
|
<div class="select is-small is-rounded">
|
|
<select id="sort-select">
|
|
<option value="default">Ordem Padrão</option>
|
|
<option value="stars_desc">⭐ Mais Complexos</option>
|
|
<option value="stars_asc">⭐ Mais Simples</option>
|
|
<option value="intensity_desc">🔥 Mais Intensos</option>
|
|
<option value="intensity_asc">❄️ Mais Calmos</option>
|
|
<option value="bpm_desc">⚡ BPM (Rápido)</option>
|
|
</select>
|
|
</div>
|
|
<div class="icon is-small is-left">
|
|
<i class="fa-solid fa-sort"></i>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="columns is-multiline" id="projects-container">
|
|
{% assign project_pages = site.pages | where_exp: "page", "page.path contains 'projetos/'" | sort: "title" %}
|
|
{% for page in project_pages %}
|
|
{% if page.url != '/projetos/' %}
|
|
<div class="column is-12-mobile is-6-tablet is-4-desktop is-3-widescreen project-column">
|
|
|
|
<div class="card project-card"
|
|
data-title="{{ page.title | escape }}"
|
|
style="height: 100%; background-color: #f0f8ff; border: 1px solid #cfe8fc; border-radius: 12px; display: flex; flex-direction: column; position: relative;">
|
|
|
|
<a href="{{ page.url | relative_url }}" style="text-decoration: none; flex: 1; display: flex; flex-direction: column;">
|
|
<div class="card-content has-text-centered p-4" style="flex: 1; display: flex; flex-direction: column;">
|
|
|
|
<div style="width: 50px; height: 50px; background-color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 0.5rem auto; box-shadow: 0 2px 5px rgba(0,0,0,0.05);">
|
|
<span class="icon" style="color: #3273dc;">
|
|
<i class="fa-solid fa-music fa-lg"></i>
|
|
</span>
|
|
</div>
|
|
|
|
<p class="title is-6 mb-2" style="color: #205081; word-break: break-word; font-weight: 700; line-height: 1.2;">
|
|
{{ page.title | default: page.name | replace: '.html', '' }}
|
|
</p>
|
|
|
|
{% if page.bpm %}
|
|
<div class="mb-3 bpm-container">
|
|
<span class="tag is-dark is-rounded is-light" style="font-size: 0.7rem; font-weight: bold; border: 1px solid #ccc;">
|
|
🎵 {{ page.bpm }} BPM
|
|
</span>
|
|
</div>
|
|
{% else %}
|
|
<div class="mb-3 bpm-container" style="min-height: 24px;"></div>
|
|
{% endif %}
|
|
|
|
<div style="flex: 1;"></div>
|
|
|
|
{% if page.tags %}
|
|
<div class="mt-auto pt-2" style="width: 100%; border-top: 1px dashed #eef6fc;">
|
|
{% for category in page.tags %}
|
|
{% assign cat_name = category[0] %}
|
|
{% assign cat_items = category[1] %}
|
|
|
|
{% assign ignore_cat = false %}
|
|
{% if cat_name == 'TAG' or cat_name == 'tag' %}{% assign ignore_cat = true %}{% endif %}
|
|
|
|
{% assign has_items = false %}
|
|
{% for item in cat_items %}{% if item != "" %}{% assign has_items = true %}{% endif %}{% endfor %}
|
|
|
|
{% if ignore_cat == false and has_items %}
|
|
<details class="category-reveal mb-1" style="width: 100%;">
|
|
<summary class="tag is-white"
|
|
style="width: 100%; justify-content: space-between; cursor: pointer; border: 1px solid #deeaf6; color: #5b7da3; padding: 2px 8px; min-height: 22px; margin-bottom: 2px;">
|
|
|
|
<div style="display: flex; align-items: center; gap: 6px;">
|
|
<span style="font-size: 0.7rem;">
|
|
{% if cat_name == 'plugin' %}🔌
|
|
{% elsif cat_name == 'sample' %}🎤
|
|
{% elsif cat_name == 'bassline' %}🎹
|
|
{% elsif cat_name == 'automation' %}🎚️
|
|
{% else %}🏷️
|
|
{% endif %}
|
|
</span>
|
|
<span style="font-weight: 700; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.5px;">
|
|
{{ cat_name }}
|
|
</span>
|
|
</div>
|
|
|
|
<span class="icon is-small" style="font-size: 0.6rem; opacity: 0.7;">
|
|
<i class="fa-solid fa-chevron-down"></i>
|
|
</span>
|
|
</summary>
|
|
|
|
<div class="tags is-centered mt-1 mb-2 px-1" style="gap: 3px;">
|
|
{% for tag in cat_items %}
|
|
{% if tag != "" %}
|
|
{% assign tag_slug = tag | replace: ' ', '+' %}
|
|
{% assign search_url = '/search/?q=' | append: tag_slug | relative_url %}
|
|
|
|
{% if cat_name == 'plugin' %}{% assign search_url = '/plugin/?plugin=' | append: tag_slug | relative_url %}{% endif %}
|
|
{% if cat_name == 'sample' %}{% assign search_url = '/sample/?sample=' | append: tag_slug | relative_url %}{% endif %}
|
|
{% if cat_name == 'bassline' %}{% assign search_url = '/bassline/?bassline=' | append: tag_slug | relative_url %}{% endif %}
|
|
{% if cat_name == 'automation' %}{% assign search_url = '/automation/?automation=' | append: tag_slug | relative_url %}{% endif %}
|
|
|
|
<a href="{{ search_url }}"
|
|
class="tag is-light is-info clickable-tag"
|
|
style="font-size: 0.6rem; height: 1.5em; border: 1px solid #cfe8fc; text-decoration: none; padding: 0 6px;">
|
|
{{ tag | truncate: 18 }}
|
|
</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
</details>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</a>
|
|
|
|
<footer class="card-footer" style="border-top: 1px solid #cfe8fc; background-color: #fff; border-radius: 0 0 12px 12px; overflow: hidden;">
|
|
<a href="#" class="card-footer-item js-open-modal"
|
|
data-target-url="{{ page.url | relative_url }}"
|
|
data-modal-title="Detalhes: {{ page.file }}"
|
|
data-full-btn-text="Ir para Página"
|
|
data-full-btn-link="{{ page.url | relative_url }}"
|
|
style="color: #5b7da3; font-size: 0.8rem; font-weight: 600; border-right: 1px solid #eee; transition: background 0.2s;">
|
|
Ver
|
|
</a>
|
|
|
|
{% assign creation_url = '/mmpSearch/creation.html?project=' | append: page.file %}
|
|
{% assign embed_url = creation_url | append: '&embed=true' %}
|
|
|
|
<a href="#" class="card-footer-item js-open-modal"
|
|
data-target-url="{{ embed_url }}"
|
|
data-modal-title="Editor: {{ page.file }}"
|
|
data-full-btn-text="Abrir Editor"
|
|
data-full-btn-link="{{ creation_url }}"
|
|
style="color: #3273dc; font-size: 0.8rem; font-weight: 600; transition: background 0.2s;">
|
|
Editar
|
|
</a>
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<br><br>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="preview-modal" class="modal">
|
|
<div class="modal-background"></div>
|
|
<div class="modal-card" style="width: 90%; max-width: 800px;">
|
|
<header class="modal-card-head" style="background-color: #f0f8ff; border-bottom: 1px solid #cfe8fc;">
|
|
<p class="modal-card-title" id="modal-title" style="color: #205081; font-weight: bold;">Preview</p>
|
|
<button class="delete" aria-label="close"></button>
|
|
</header>
|
|
<section class="modal-card-body p-0" style="height: 500px; background-color: #fff;">
|
|
<iframe id="preview-iframe" src="" style="width: 100%; height: 100%; border: none;"></iframe>
|
|
</section>
|
|
<footer class="modal-card-foot" style="justify-content: flex-end; background-color: #fff; border-top: 1px solid #cfe8fc;">
|
|
<button class="button" id="close-modal-btn">Fechar</button>
|
|
<a href="#" id="full-edit-btn" target="_blank" class="button is-info">
|
|
<span>Abrir</span>
|
|
<span class="icon is-small ml-1"><i class="fa-solid fa-up-right-from-square"></i></span>
|
|
</a>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.project-card:hover {
|
|
transform: translateY(-5px);
|
|
box-shadow: 0 8px 20px rgba(50, 115, 220, 0.15);
|
|
border-color: #3273dc !important;
|
|
background-color: #fff !important;
|
|
}
|
|
.project-card:hover .title {
|
|
color: #3273dc !important;
|
|
}
|
|
.category-reveal summary {
|
|
list-style: none;
|
|
transition: all 0.2s ease;
|
|
}
|
|
.category-reveal summary::-webkit-details-marker { display: none; }
|
|
.category-reveal summary:hover {
|
|
background-color: #f8fbff;
|
|
border-color: #3273dc;
|
|
}
|
|
/* Correção para a barra não esticar */
|
|
.category-reveal {
|
|
width: 100%;
|
|
flex-shrink: 0; /* Impede que encolha demais */
|
|
flex-grow: 0; /* Impede que cresça para preencher espaço vazio */
|
|
}
|
|
|
|
.category-reveal summary {
|
|
list-style: none;
|
|
transition: all 0.2s ease;
|
|
height: auto !important; /* Força altura automática */
|
|
min-height: 22px;
|
|
white-space: normal; /* Permite que o texto quebre se for longo */
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
.category-reveal[open] summary {
|
|
background-color: #eef6fc !important;
|
|
border-color: #3273dc !important;
|
|
color: #3273dc !important;
|
|
}
|
|
.category-reveal[open] summary .fa-chevron-down { transform: rotate(180deg); }
|
|
.category-reveal summary .fa-chevron-down { transition: transform 0.2s ease; }
|
|
.clickable-tag { transition: all 0.2s ease; }
|
|
.clickable-tag:hover {
|
|
background-color: #3273dc !important;
|
|
color: #fff !important;
|
|
border-color: #3273dc !important;
|
|
transform: translateY(-1px);
|
|
}
|
|
/* Estilo para os botões de filtro */
|
|
#genre-filters .button {
|
|
margin-bottom: 0.5rem;
|
|
transition: all 0.2s;
|
|
}
|
|
#genre-filters .button:not(.is-active) {
|
|
background-color: white;
|
|
border-color: #dbdbdb;
|
|
color: #363636;
|
|
}
|
|
#genre-filters .button.is-active {
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
// ===============================================
|
|
// 1. CONFIGURAÇÃO VISUAL (MENU E MODAL)
|
|
// ===============================================
|
|
|
|
// --- Lógica do Menu Expansível ---
|
|
const filterBtn = document.getElementById('filter-toggle-btn');
|
|
const filterContent = document.getElementById('filter-content');
|
|
const filterChevron = document.getElementById('filter-chevron');
|
|
|
|
// Define estado inicial baseado na largura da tela
|
|
let isFilterOpen = window.innerWidth > 1024;
|
|
|
|
// Função para aplicar o estado visual
|
|
function updateFilterState() {
|
|
if(isFilterOpen) {
|
|
filterContent.style.display = 'block';
|
|
filterChevron.style.transform = 'rotate(180deg)';
|
|
} else {
|
|
filterContent.style.display = 'none';
|
|
filterChevron.style.transform = 'rotate(0deg)';
|
|
}
|
|
}
|
|
|
|
// Aplica estado inicial ao carregar
|
|
if (filterContent && filterChevron) {
|
|
updateFilterState();
|
|
}
|
|
|
|
if(filterBtn && filterContent) {
|
|
filterBtn.addEventListener('click', () => {
|
|
isFilterOpen = !isFilterOpen; // Inverte o estado
|
|
updateFilterState(); // Aplica a mudança
|
|
});
|
|
}
|
|
|
|
// --- Lógica do Modal (Preview) ---
|
|
const modal = document.getElementById('preview-modal');
|
|
const iframe = document.getElementById('preview-iframe');
|
|
const modalTitle = document.getElementById('modal-title');
|
|
const fullEditBtn = document.getElementById('full-edit-btn');
|
|
const closeButtons = document.querySelectorAll('.modal-background, .modal-card-head .delete, #close-modal-btn');
|
|
|
|
function normalizarChaveJS(str) {
|
|
if (!str) return "";
|
|
return str.toString().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]/g, "");
|
|
}
|
|
|
|
function openModal(url, title, btnText, btnLink) {
|
|
if(!modal) return;
|
|
modalTitle.textContent = title;
|
|
iframe.src = url;
|
|
fullEditBtn.textContent = btnText;
|
|
fullEditBtn.href = btnLink;
|
|
modal.classList.add('is-active');
|
|
document.documentElement.classList.add('is-clipped');
|
|
}
|
|
|
|
function closeModal() {
|
|
if(!modal) return;
|
|
modal.classList.remove('is-active');
|
|
document.documentElement.classList.remove('is-clipped');
|
|
iframe.src = "";
|
|
}
|
|
|
|
document.querySelectorAll('.js-open-modal').forEach(btn => {
|
|
btn.addEventListener('click', (e) => {
|
|
e.preventDefault();
|
|
openModal(btn.dataset.targetUrl, btn.dataset.modalTitle, btn.dataset.fullBtnText, btn.dataset.fullBtnLink);
|
|
});
|
|
});
|
|
|
|
closeButtons.forEach(el => el.addEventListener('click', closeModal));
|
|
document.addEventListener('keydown', (e) => { if (e.key === "Escape") closeModal(); });
|
|
|
|
|
|
// ===============================================
|
|
// 2. LÓGICA DE DADOS (IA / FILTROS)
|
|
// ===============================================
|
|
|
|
const JSON_URL = '/mmpSearch/src_mmpSearch/saida_analises/db_final_completo.json';
|
|
|
|
const cards = document.querySelectorAll('.project-card');
|
|
const genreContainer = document.getElementById('genre-filters');
|
|
const sortSelect = document.getElementById('sort-select');
|
|
const starFilterSelect = document.getElementById('star-filter');
|
|
const projectsContainer = document.getElementById('projects-container');
|
|
|
|
let currentGenre = 'all';
|
|
let currentMinStars = 'all';
|
|
|
|
fetch(JSON_URL)
|
|
.then(r => r.ok ? r.json() : Promise.reject("Erro JSON"))
|
|
.then(data => {
|
|
enrichCards(data);
|
|
createGenreButtons(data);
|
|
})
|
|
.catch(console.warn);
|
|
|
|
// Função atualizada para Badge de Dificuldade
|
|
function renderizarDificuldade(num) {
|
|
const n = Math.round(num) || 1;
|
|
let label = "Básico";
|
|
let icon = "fa-leaf"; // Ícone padrão
|
|
let colorClass = "is-success"; // Verde
|
|
|
|
if (n >= 4.5) {
|
|
label = "Expert";
|
|
icon = "fa-fire";
|
|
colorClass = "is-danger"; // Vermelho
|
|
} else if (n >= 3.5) {
|
|
label = "Avançado";
|
|
icon = "fa-bolt";
|
|
colorClass = "is-warning"; // Amarelo/Laranja
|
|
} else if (n >= 2.5) {
|
|
label = "Intermediário";
|
|
icon = "fa-layer-group";
|
|
colorClass = "is-info"; // Azul
|
|
}
|
|
|
|
// Retorna uma tag HTML bonita e visível
|
|
return `
|
|
<span class="tag ${colorClass} is-light is-rounded" title="Complexidade: ${n}/5" style="border: 1px solid rgba(0,0,0,0.1);">
|
|
<i class="fa-solid ${icon} mr-1"></i> ${label}
|
|
</span>
|
|
`;
|
|
}
|
|
|
|
function enrichCards(data) {
|
|
const mapDados = {};
|
|
data.forEach(item => {
|
|
const k1 = normalizarChaveJS(item.arquivo.replace('.wav','').replace('.mp3',''));
|
|
mapDados[k1] = item;
|
|
if(item.dados_projeto?.titulo) mapDados[normalizarChaveJS(item.dados_projeto.titulo)] = item;
|
|
});
|
|
|
|
cards.forEach(card => {
|
|
const info = mapDados[normalizarChaveJS(card.dataset.title)];
|
|
|
|
// Defaults
|
|
let genero = "Unknown";
|
|
let estrelas = 0;
|
|
let intensidade = -100;
|
|
let bpm = 0;
|
|
let tomHtml = "";
|
|
|
|
if (info) {
|
|
genero = info.analise_ia?.genero_macro || "Unknown";
|
|
intensidade = parseFloat(info.analise_tecnica?.intensidade_db || -100);
|
|
bpm = parseFloat(info.analise_tecnica?.bpm || 0);
|
|
estrelas = Math.round(info.analise_tecnica?.complexidade?.estrelas || 0);
|
|
|
|
// HTML do Tom
|
|
if (info.analise_tecnica?.tom) {
|
|
const t = info.analise_tecnica.tom;
|
|
const e = info.analise_tecnica.escala === 'minor' ? 'm' : '';
|
|
tomHtml = `<span class="tag is-white is-rounded border-tag">🎹 ${t}${e}</span>`;
|
|
}
|
|
}
|
|
|
|
// Salva no dataset para filtros
|
|
card.dataset.genre = genero;
|
|
card.dataset.stars = estrelas;
|
|
card.dataset.intensity = intensidade;
|
|
card.dataset.bpm_real = bpm;
|
|
|
|
// Injeta HTML
|
|
const bpmContainer = card.querySelector('.bpm-container');
|
|
if (bpmContainer) {
|
|
// Limpa conteúdo anterior injetado via JS se houver (opcional)
|
|
// bpmContainer.innerHTML = ''; // Cuidado se tiver o BPM original do Liquid aqui.
|
|
|
|
const iaDiv = document.createElement('div');
|
|
iaDiv.style.display = "flex";
|
|
iaDiv.style.flexDirection = "column";
|
|
iaDiv.style.alignItems = "center";
|
|
iaDiv.style.gap = "6px"; // Aumentei um pouco o gap
|
|
iaDiv.className = "mt-3"; // Margem topo para separar do título
|
|
|
|
// 1. Renderiza a Dificuldade (Nova função)
|
|
const diffDiv = document.createElement('div');
|
|
diffDiv.innerHTML = renderizarDificuldade(estrelas);
|
|
iaDiv.appendChild(diffDiv);
|
|
|
|
// 2. Tags (Gênero + Tom)
|
|
const tagsRow = document.createElement('div');
|
|
tagsRow.className = "tags is-centered mb-0";
|
|
tagsRow.style.gap = "4px";
|
|
|
|
if(genero !== "Unknown") {
|
|
let color = 'is-primary';
|
|
if(genero === 'Electronic') color = 'is-info';
|
|
if(genero === 'Hip Hop') color = 'is-warning';
|
|
if(genero === 'Rock') color = 'is-danger';
|
|
|
|
// Tag de Gênero
|
|
tagsRow.innerHTML += `<span class="tag ${color} is-light is-rounded" style="font-size: 0.7rem;">🤖 ${genero}</span>`;
|
|
}
|
|
|
|
// Adiciona o Tom se existir
|
|
tagsRow.innerHTML += tomHtml;
|
|
|
|
iaDiv.appendChild(tagsRow);
|
|
|
|
// Limpa o container antes de adicionar para evitar duplicatas se rodar 2x
|
|
bpmContainer.innerHTML = '';
|
|
// Re-adiciona o BPM original se necessário, ou apenas adiciona o novo bloco IA
|
|
if(card.dataset.bpm_real > 0) {
|
|
bpmContainer.innerHTML = `<span class="tag is-dark is-rounded is-light mb-1" style="font-size: 0.7rem; font-weight: bold; border: 1px solid #ccc;">🎵 ${Math.round(card.dataset.bpm_real)} BPM</span>`;
|
|
}
|
|
bpmContainer.appendChild(iaDiv);
|
|
}
|
|
});
|
|
}
|
|
|
|
function createGenreButtons(data) {
|
|
const genres = new Set();
|
|
data.forEach(i => {
|
|
if(i.analise_ia?.genero_macro && i.analise_ia.genero_macro !== "Unknown")
|
|
genres.add(i.analise_ia.genero_macro);
|
|
});
|
|
|
|
Array.from(genres).sort().forEach(g => {
|
|
const btn = document.createElement('button');
|
|
btn.className = 'button is-small is-rounded is-white';
|
|
btn.textContent = g;
|
|
btn.onclick = () => {
|
|
document.querySelectorAll('#genre-filters .button').forEach(b => {
|
|
b.classList.remove('is-active', 'is-info');
|
|
b.classList.add('is-white');
|
|
});
|
|
btn.classList.remove('is-white');
|
|
btn.classList.add('is-active', 'is-info');
|
|
currentGenre = g;
|
|
applyFilters();
|
|
};
|
|
genreContainer.appendChild(btn);
|
|
});
|
|
|
|
// Reset All Button
|
|
const allBtn = genreContainer.querySelector('[data-genre="all"]');
|
|
allBtn.onclick = () => {
|
|
document.querySelectorAll('#genre-filters .button').forEach(b => {
|
|
b.classList.remove('is-active', 'is-info');
|
|
b.classList.add('is-white');
|
|
});
|
|
allBtn.classList.remove('is-white');
|
|
allBtn.classList.add('is-active', 'is-info');
|
|
currentGenre = 'all';
|
|
applyFilters();
|
|
};
|
|
}
|
|
|
|
function applyFilters() {
|
|
cards.forEach(c => {
|
|
const col = c.closest('.project-column');
|
|
const g = c.dataset.genre;
|
|
const s = parseInt(c.dataset.stars || 0);
|
|
|
|
const matchG = (currentGenre === 'all' || g === currentGenre);
|
|
const matchS = (currentMinStars === 'all' || s === parseInt(currentMinStars));
|
|
|
|
col.style.display = (matchG && matchS) ? 'block' : 'none';
|
|
});
|
|
}
|
|
|
|
if(starFilterSelect) {
|
|
starFilterSelect.addEventListener('change', (e) => {
|
|
currentMinStars = e.target.value;
|
|
applyFilters();
|
|
});
|
|
}
|
|
|
|
sortSelect.addEventListener('change', (e) => {
|
|
const crit = e.target.value;
|
|
const cols = Array.from(projectsContainer.children);
|
|
|
|
cols.sort((a, b) => {
|
|
const cA = a.querySelector('.project-card');
|
|
const cB = b.querySelector('.project-card');
|
|
|
|
const getVal = (el, k) => parseFloat(el.dataset[k] || 0);
|
|
|
|
if(crit === 'stars_desc') return getVal(cB, 'stars') - getVal(cA, 'stars');
|
|
if(crit === 'stars_asc') return getVal(cA, 'stars') - getVal(cB, 'stars');
|
|
if(crit === 'bpm_desc') return getVal(cB, 'bpm_real') - getVal(cA, 'bpm_real');
|
|
if(crit === 'intensity_desc') return getVal(cB, 'intensity') - getVal(cA, 'intensity');
|
|
if(crit === 'intensity_asc') return getVal(cA, 'intensity') - getVal(cB, 'intensity');
|
|
|
|
return cA.dataset.title.localeCompare(cB.dataset.title);
|
|
});
|
|
|
|
cols.forEach(c => projectsContainer.appendChild(c));
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
.transition-icon i {
|
|
transition: transform 0.3s ease;
|
|
}
|
|
.border-tag {
|
|
border: 1px solid #dbdbdb;
|
|
color: #555;
|
|
}
|
|
</style>
|