Spaces:
Running
Running
Update index.html
Browse files- index.html +24 -29
index.html
CHANGED
@@ -48,7 +48,7 @@
|
|
48 |
}
|
49 |
.main-container {
|
50 |
display: flex;
|
51 |
-
height: calc(100vh - 100px);
|
52 |
}
|
53 |
#sidebar {
|
54 |
width: 25%;
|
@@ -91,8 +91,10 @@
|
|
91 |
<a href="https://discord.gg/openfreeai" target="_blank">Community</a>
|
92 |
</div>
|
93 |
|
94 |
-
<!-- 필터 버튼 영역
|
95 |
-
<div class="filter-group" id="filter-group"
|
|
|
|
|
96 |
|
97 |
<div class="main-container">
|
98 |
<div id="sidebar"></div>
|
@@ -344,7 +346,7 @@
|
|
344 |
"ginigen/Multi-LoRAgen_BEST": "BEST"
|
345 |
};
|
346 |
|
347 |
-
// 3. URL 변환
|
348 |
function transformUrl(url) {
|
349 |
const prefix = "https://huggingface.co/spaces/";
|
350 |
if (url.startsWith(prefix)) {
|
@@ -354,15 +356,13 @@
|
|
354 |
return url;
|
355 |
}
|
356 |
|
357 |
-
// 4. 프로젝트
|
358 |
-
// projectList의 모든 key에 대해 customCategories에서 카테고리를 읽고, 없으면 기본 "Image Gen"
|
359 |
const keys = Object.keys(projectList);
|
360 |
const projects = keys.map(key => {
|
|
|
361 |
const url = projectList[key];
|
362 |
-
// primaryCategory가 없으면 "Image Gen"
|
363 |
-
let primaryCategory = customCategories[key] || "Image Gen";
|
364 |
|
365 |
-
//
|
366 |
let categories = [primaryCategory];
|
367 |
if (key.endsWith("_NEW")) {
|
368 |
categories.push("NEW");
|
@@ -371,7 +371,6 @@
|
|
371 |
categories.push("BEST");
|
372 |
}
|
373 |
|
374 |
-
// 실제 프로젝트명: "/" 뒤의 부분
|
375 |
let projectName = key;
|
376 |
if (!key.endsWith("_NEW") && !key.endsWith("_BEST")) {
|
377 |
projectName = key.split("/").slice(1).join("/");
|
@@ -380,33 +379,29 @@
|
|
380 |
return {
|
381 |
name: primaryCategory + "/" + projectName,
|
382 |
url: transformUrl(url),
|
383 |
-
categories
|
384 |
};
|
385 |
});
|
386 |
|
387 |
// 5. 카테고리별 그룹화
|
388 |
const grouped = {};
|
389 |
-
projects.forEach(
|
390 |
-
|
391 |
-
if (!grouped[cat])
|
392 |
-
|
393 |
-
}
|
394 |
-
grouped[cat].push(project);
|
395 |
});
|
396 |
});
|
397 |
|
398 |
-
// 6. 필터 버튼
|
399 |
const fixedGroups = ["NEW", "BEST", "Text", "Image Gen", "Image Edit", "Audio", "Video", "Productivity", "Utility", "Vision"];
|
400 |
const filterGroupDiv = document.getElementById("filter-group");
|
401 |
|
402 |
-
// All 버튼
|
403 |
const allButton = document.createElement("button");
|
404 |
allButton.className = "toggle-button active";
|
405 |
allButton.setAttribute("data-filter", "all");
|
406 |
allButton.textContent = "All";
|
407 |
filterGroupDiv.appendChild(allButton);
|
408 |
|
409 |
-
// 나머지 10개 카테고리 버튼
|
410 |
fixedGroups.forEach(category => {
|
411 |
const btn = document.createElement("button");
|
412 |
btn.className = "toggle-button";
|
@@ -421,38 +416,38 @@
|
|
421 |
sidebar.innerHTML = "";
|
422 |
let items = (filter === "all")
|
423 |
? projects
|
424 |
-
: projects.filter(
|
425 |
|
426 |
const ul = document.createElement("ul");
|
427 |
items.forEach(item => {
|
428 |
const li = document.createElement("li");
|
429 |
li.textContent = item.name;
|
430 |
li.addEventListener("click", () => {
|
431 |
-
document.getElementById("embed-frame").
|
432 |
});
|
433 |
ul.appendChild(li);
|
434 |
});
|
435 |
sidebar.appendChild(ul);
|
436 |
|
437 |
-
// 첫
|
438 |
if (items.length > 0) {
|
439 |
-
document.getElementById("embed-frame").
|
440 |
} else {
|
441 |
-
document.getElementById("embed-frame").
|
442 |
}
|
443 |
}
|
444 |
|
445 |
-
// 8. 버튼 클릭
|
446 |
document.querySelectorAll(".toggle-button").forEach(button => {
|
447 |
button.addEventListener("click", function() {
|
448 |
-
document.querySelectorAll(".toggle-button").forEach(
|
449 |
this.classList.add("active");
|
450 |
updateSidebar(this.getAttribute("data-filter"));
|
451 |
});
|
452 |
});
|
453 |
|
454 |
-
// 9.
|
455 |
updateSidebar("all");
|
456 |
</script>
|
457 |
</body>
|
458 |
-
</html>
|
|
|
48 |
}
|
49 |
.main-container {
|
50 |
display: flex;
|
51 |
+
height: calc(100vh - 100px); /* 상단 영역 제외 전체 높이 */
|
52 |
}
|
53 |
#sidebar {
|
54 |
width: 25%;
|
|
|
91 |
<a href="https://discord.gg/openfreeai" target="_blank">Community</a>
|
92 |
</div>
|
93 |
|
94 |
+
<!-- 필터 버튼 영역 -->
|
95 |
+
<div class="filter-group" id="filter-group">
|
96 |
+
<!-- JavaScript로 동적으로 버튼 생성 -->
|
97 |
+
</div>
|
98 |
|
99 |
<div class="main-container">
|
100 |
<div id="sidebar"></div>
|
|
|
346 |
"ginigen/Multi-LoRAgen_BEST": "BEST"
|
347 |
};
|
348 |
|
349 |
+
// 3. URL 변환
|
350 |
function transformUrl(url) {
|
351 |
const prefix = "https://huggingface.co/spaces/";
|
352 |
if (url.startsWith(prefix)) {
|
|
|
356 |
return url;
|
357 |
}
|
358 |
|
359 |
+
// 4. 프로젝트 배열 생성
|
|
|
360 |
const keys = Object.keys(projectList);
|
361 |
const projects = keys.map(key => {
|
362 |
+
const primaryCategory = customCategories[key] || "Image Gen";
|
363 |
const url = projectList[key];
|
|
|
|
|
364 |
|
365 |
+
// categories 배열
|
366 |
let categories = [primaryCategory];
|
367 |
if (key.endsWith("_NEW")) {
|
368 |
categories.push("NEW");
|
|
|
371 |
categories.push("BEST");
|
372 |
}
|
373 |
|
|
|
374 |
let projectName = key;
|
375 |
if (!key.endsWith("_NEW") && !key.endsWith("_BEST")) {
|
376 |
projectName = key.split("/").slice(1).join("/");
|
|
|
379 |
return {
|
380 |
name: primaryCategory + "/" + projectName,
|
381 |
url: transformUrl(url),
|
382 |
+
categories
|
383 |
};
|
384 |
});
|
385 |
|
386 |
// 5. 카테고리별 그룹화
|
387 |
const grouped = {};
|
388 |
+
projects.forEach(proj => {
|
389 |
+
proj.categories.forEach(cat => {
|
390 |
+
if (!grouped[cat]) grouped[cat] = [];
|
391 |
+
grouped[cat].push(proj);
|
|
|
|
|
392 |
});
|
393 |
});
|
394 |
|
395 |
+
// 6. 필터 버튼 (ALL + 10개)
|
396 |
const fixedGroups = ["NEW", "BEST", "Text", "Image Gen", "Image Edit", "Audio", "Video", "Productivity", "Utility", "Vision"];
|
397 |
const filterGroupDiv = document.getElementById("filter-group");
|
398 |
|
|
|
399 |
const allButton = document.createElement("button");
|
400 |
allButton.className = "toggle-button active";
|
401 |
allButton.setAttribute("data-filter", "all");
|
402 |
allButton.textContent = "All";
|
403 |
filterGroupDiv.appendChild(allButton);
|
404 |
|
|
|
405 |
fixedGroups.forEach(category => {
|
406 |
const btn = document.createElement("button");
|
407 |
btn.className = "toggle-button";
|
|
|
416 |
sidebar.innerHTML = "";
|
417 |
let items = (filter === "all")
|
418 |
? projects
|
419 |
+
: projects.filter(p => p.categories.includes(filter));
|
420 |
|
421 |
const ul = document.createElement("ul");
|
422 |
items.forEach(item => {
|
423 |
const li = document.createElement("li");
|
424 |
li.textContent = item.name;
|
425 |
li.addEventListener("click", () => {
|
426 |
+
document.getElementById("embed-frame").src = item.url;
|
427 |
});
|
428 |
ul.appendChild(li);
|
429 |
});
|
430 |
sidebar.appendChild(ul);
|
431 |
|
432 |
+
// 첫 항목 자동 로드
|
433 |
if (items.length > 0) {
|
434 |
+
document.getElementById("embed-frame").src = items[0].url;
|
435 |
} else {
|
436 |
+
document.getElementById("embed-frame").src = "";
|
437 |
}
|
438 |
}
|
439 |
|
440 |
+
// 8. 버튼 클릭 이벤트
|
441 |
document.querySelectorAll(".toggle-button").forEach(button => {
|
442 |
button.addEventListener("click", function() {
|
443 |
+
document.querySelectorAll(".toggle-button").forEach(b => b.classList.remove("active"));
|
444 |
this.classList.add("active");
|
445 |
updateSidebar(this.getAttribute("data-filter"));
|
446 |
});
|
447 |
});
|
448 |
|
449 |
+
// 9. 페이지 로드 시 All 필터
|
450 |
updateSidebar("all");
|
451 |
</script>
|
452 |
</body>
|
453 |
+
</html>
|