Repository navigation
Expand file tree
/
Copy pathBrowser_MoodBoard..alpha.html
More file actions
278 lines (255 loc) · 8.89 KB
/
Copy pathBrowser_MoodBoard..alpha.html
File metadata and controls
278 lines (255 loc) · 8.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bibliothèque de Moodboards Krea2</title>
<style>
:root {
--bg: #121212;
--surface: #1e1e1e;
--primary: #3b82f6;
--text: #f3f4f6;
--text-muted: #9ca3af;
}
body {
font-family: system-ui, -apple-system, sans-serif;
background-color: var(--bg);
color: var(--text);
margin: 0;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
header {
display: flex;
gap: 15px;
margin-bottom: 30px;
flex-wrap: wrap;
align-items: center;
}
input[type="file"] {
background: var(--surface);
padding: 10px;
border-radius: 6px;
border: 1px solid #333;
color: var(--text);
cursor: pointer;
}
input[type="text"] {
flex-grow: 1;
padding: 12px;
border-radius: 6px;
border: 1px solid #333;
background: var(--surface);
color: var(--text);
font-size: 16px;
}
input[type="text"]:focus {
outline: 2px solid var(--primary);
border-color: transparent;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 20px;
}
.card {
background: var(--surface);
border-radius: 10px;
overflow: hidden;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
border: 1px solid #2a2a2a;
}
.card:hover {
transform: translateY(-4px);
box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}
.card img {
width: 100%;
height: 220px;
object-fit: cover;
}
.card-content {
padding: 15px;
}
.card-title {
margin: 0 0 10px 0;
font-size: 1.1em;
line-height: 1.3;
}
.tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.tag {
background: #374151;
color: #d1d5db;
padding: 4px 8px;
border-radius: 4px;
font-size: 0.75em;
}
/* Fenêtre Modale */
.modal-overlay {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.85);
display: none;
justify-content: center;
align-items: center;
padding: 20px;
z-index: 100;
}
.modal-content {
background: var(--surface);
padding: 25px;
border-radius: 12px;
max-width: 900px;
width: 100%;
max-height: 90vh;
overflow-y: auto;
position: relative;
border: 1px solid #333;
}
.close-btn {
position: absolute;
top: 15px; right: 20px;
background: none;
border: none;
color: var(--text-muted);
font-size: 28px;
cursor: pointer;
}
.close-btn:hover { color: #fff; }
.modal-img {
width: 100%;
max-height: 450px;
object-fit: contain;
background: #000;
border-radius: 8px;
margin-bottom: 20px;
}
.section-title {
color: var(--primary);
font-size: 0.85em;
text-transform: uppercase;
letter-spacing: 1px;
margin-top: 25px;
margin-bottom: 8px;
font-weight: bold;
}
.modal-text {
line-height: 1.6;
color: #d1d5db;
margin: 0;
}
</style>
</head>
<body>
<div class="container">
<header>
<input type="file" id="fileInput" accept=".json" title="Charger le fichier JSON">
<input type="text" id="searchInput" placeholder="Rechercher par titre, mot-clé ou ambiance...">
</header>
<div id="gallery" class="grid">
<!-- Les cartes seront injectées ici -->
</div>
</div>
<div id="modal" class="modal-overlay">
<div class="modal-content">
<button class="close-btn" id="closeModal">×</button>
<img id="modalImg" class="modal-img" src="" alt="">
<h2 id="modalTitle" style="margin-top:0;"></h2>
<div class="tags" id="modalTags"></div>
<div class="section-title">Profil Visuel (Taste Profile)</div>
<p class="modal-text" id="modalProfile"></p>
<div class="section-title">Prompt Positif</div>
<p class="modal-text" id="modalPrompt"></p>
<div class="section-title">Prompt Négatif</div>
<p class="modal-text" id="modalNegative"></p>
<div class="section-title">Axes de Style</div>
<div class="tags" id="modalAxes" style="margin-top: 10px;"></div>
</div>
</div>
<script>
let moodboards = [];
const fileInput = document.getElementById('fileInput');
const searchInput = document.getElementById('searchInput');
const gallery = document.getElementById('gallery');
const modal = document.getElementById('modal');
// Chargement local du fichier
fileInput.addEventListener('change', (e) => {
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = (event) => {
try {
const data = JSON.parse(event.target.result);
moodboards = data.moodboards || [];
renderGallery(moodboards);
} catch (error) {
alert("Erreur: Le fichier JSON est invalide.");
}
};
reader.readAsText(file);
});
// Moteur de recherche en temps réel
searchInput.addEventListener('input', (e) => {
const term = e.target.value.toLowerCase();
const filtered = moodboards.filter(mb => {
const titleMatch = mb.title?.toLowerCase().includes(term);
const keywordsMatch = mb.keywords?.some(kw => kw.toLowerCase().includes(term));
const profileMatch = mb.taste_profile?.toLowerCase().includes(term);
return titleMatch || keywordsMatch || profileMatch;
});
renderGallery(filtered);
});
// Affichage des cartes
function renderGallery(items) {
gallery.innerHTML = '';
if(items.length === 0) {
gallery.innerHTML = '<p style="color: #9ca3af;">Aucun moodboard trouvé.</p>';
return;
}
items.forEach(mb => {
const card = document.createElement('div');
card.className = 'card';
card.onclick = () => openModal(mb);
// On affiche seulement les 3 premiers mots-clés sur la carte
const keywordsHtml = (mb.keywords || []).slice(0, 3)
.map(kw => `<span class="tag">${kw}</span>`).join('');
card.innerHTML = `
<img src="${mb.primary_image_url}" alt="${mb.title}" loading="lazy">
<div class="card-content">
<h3 class="card-title">${mb.title}</h3>
<div class="tags">${keywordsHtml}</div>
</div>
`;
gallery.appendChild(card);
});
}
// Gestion de la modale détaillée
function openModal(mb) {
document.getElementById('modalImg').src = mb.primary_image_url || '';
document.getElementById('modalTitle').textContent = mb.title || 'Sans titre';
document.getElementById('modalTags').innerHTML = (mb.keywords || [])
.map(kw => `<span class="tag">${kw}</span>`).join('');
document.getElementById('modalProfile').textContent = mb.taste_profile || 'Non spécifié';
const qwen = mb.qwen_guidance || {};
document.getElementById('modalPrompt').textContent = qwen.prompt_guidance || 'Non spécifié';
document.getElementById('modalNegative').textContent = qwen.negative_guidance || 'Non spécifié';
document.getElementById('modalAxes').innerHTML = (qwen.style_axes || [])
.map(axis => `<span class="tag">${axis}</span>`).join('');
modal.style.display = 'flex';
}
// Fermeture de la modale
document.getElementById('closeModal').onclick = () => modal.style.display = 'none';
modal.onclick = (e) => { if (e.target === modal) modal.style.display = 'none'; };
document.addEventListener('keydown', (e) => { if (e.key === "Escape") modal.style.display = 'none'; });
</script>
</body>
</html>