Update index.html
Browse files- index.html +17 -27
index.html
CHANGED
|
@@ -92,7 +92,7 @@
|
|
| 92 |
<a href="https://discord.gg/openfreeai" target="_blank">Community</a>
|
| 93 |
</div>
|
| 94 |
|
| 95 |
-
<!-- ํํฐ ๋ฒํผ ์์ญ (
|
| 96 |
<div class="filter-group" id="filter-group">
|
| 97 |
<!-- JavaScript๋ก ๋์ ์ผ๋ก ๋ฒํผ ์์ฑ -->
|
| 98 |
</div>
|
|
@@ -109,10 +109,8 @@
|
|
| 109 |
</div>
|
| 110 |
|
| 111 |
<script>
|
| 112 |
-
// 1.
|
| 113 |
const projectList = {
|
| 114 |
-
|
| 115 |
-
|
| 116 |
"fantos/Panorama": "https://huggingface.co/spaces/fantos/Panorama",
|
| 117 |
"ginigen/Multi-LoRAgen": "https://huggingface.co/spaces/ginigen/Multi-LoRAgen",
|
| 118 |
"ginigen/canvas-studio": "https://huggingface.co/spaces/ginigen/canvas-studio",
|
|
@@ -231,30 +229,30 @@
|
|
| 231 |
"aiqtech/FLUX-Ghibli-Studio-LoRA": "https://huggingface.co/spaces/aiqtech/FLUX-Ghibli-Studio-LoRA",
|
| 232 |
"aiqtech/flxgif": "https://huggingface.co/spaces/aiqtech/flxgif",
|
| 233 |
"aiqtech/imaginpaint": "https://huggingface.co/spaces/aiqtech/imaginpaint"
|
| 234 |
-
|
| 235 |
};
|
| 236 |
|
| 237 |
// 2. URL ๋ณํ ํจ์: "https://huggingface.co/spaces/{namespace}/{project}" โ "https://{namespace}-{project}.hf.space"
|
| 238 |
function transformUrl(url) {
|
| 239 |
const prefix = "https://huggingface.co/spaces/";
|
| 240 |
if (url.startsWith(prefix)) {
|
| 241 |
-
const rest = url.substring(prefix.length);
|
| 242 |
-
// ๋จ, key์ ์๋ "/"๋ ํ์ดํ(-)์ผ๋ก ๋ณ๊ฒฝ
|
| 243 |
return "https://" + rest.replace("/", "-") + ".hf.space";
|
| 244 |
}
|
| 245 |
return url;
|
| 246 |
}
|
| 247 |
|
| 248 |
-
// 3.
|
| 249 |
-
const
|
|
|
|
|
|
|
| 250 |
return {
|
| 251 |
-
name:
|
| 252 |
url: transformUrl(projectList[key]),
|
| 253 |
-
category:
|
| 254 |
};
|
| 255 |
});
|
| 256 |
|
| 257 |
-
// 4.
|
| 258 |
const grouped = {};
|
| 259 |
projects.forEach(project => {
|
| 260 |
const cat = project.category;
|
|
@@ -264,16 +262,15 @@
|
|
| 264 |
grouped[cat].push(project);
|
| 265 |
});
|
| 266 |
|
| 267 |
-
// 5. ํํฐ
|
|
|
|
| 268 |
const filterGroupDiv = document.getElementById("filter-group");
|
| 269 |
-
// "All" ๋ฒํผ ์์ฑ
|
| 270 |
const allButton = document.createElement("button");
|
| 271 |
allButton.className = "toggle-button active";
|
| 272 |
allButton.setAttribute("data-filter", "all");
|
| 273 |
allButton.textContent = "All";
|
| 274 |
filterGroupDiv.appendChild(allButton);
|
| 275 |
-
|
| 276 |
-
Object.keys(grouped).sort().forEach(category => {
|
| 277 |
const btn = document.createElement("button");
|
| 278 |
btn.className = "toggle-button";
|
| 279 |
btn.setAttribute("data-filter", category);
|
|
@@ -281,16 +278,11 @@
|
|
| 281 |
filterGroupDiv.appendChild(btn);
|
| 282 |
});
|
| 283 |
|
| 284 |
-
// 6. ์ฌ์ด๋๋ฐ ์
๋ฐ์ดํธ ํจ์: ์ ํํ ํํฐ์
|
| 285 |
function updateSidebar(filter) {
|
| 286 |
const sidebar = document.getElementById("sidebar");
|
| 287 |
-
sidebar.innerHTML = "";
|
| 288 |
-
let items =
|
| 289 |
-
if (filter === "all") {
|
| 290 |
-
items = projects;
|
| 291 |
-
} else {
|
| 292 |
-
items = grouped[filter] || [];
|
| 293 |
-
}
|
| 294 |
const ul = document.createElement("ul");
|
| 295 |
items.forEach(item => {
|
| 296 |
const li = document.createElement("li");
|
|
@@ -301,7 +293,6 @@
|
|
| 301 |
ul.appendChild(li);
|
| 302 |
});
|
| 303 |
sidebar.appendChild(ul);
|
| 304 |
-
// ๊ธฐ๋ณธ์ผ๋ก ์ฒซ ๋ฒ์งธ ํญ๋ชฉ ๋ก๋ (์์ผ๋ฉด)
|
| 305 |
if (items.length > 0) {
|
| 306 |
document.getElementById("embed-frame").setAttribute("src", items[0].url);
|
| 307 |
} else {
|
|
@@ -314,8 +305,7 @@
|
|
| 314 |
button.addEventListener("click", function() {
|
| 315 |
document.querySelectorAll(".toggle-button").forEach(btn => btn.classList.remove("active"));
|
| 316 |
this.classList.add("active");
|
| 317 |
-
|
| 318 |
-
updateSidebar(filter);
|
| 319 |
});
|
| 320 |
});
|
| 321 |
|
|
|
|
| 92 |
<a href="https://discord.gg/openfreeai" target="_blank">Community</a>
|
| 93 |
</div>
|
| 94 |
|
| 95 |
+
<!-- ํํฐ ๋ฒํผ ์์ญ (๋ฏธ๋ฆฌ ์ ์ํ 10๊ฐ์ง ๊ทธ๋ฃน ์ฌ์ฉ) -->
|
| 96 |
<div class="filter-group" id="filter-group">
|
| 97 |
<!-- JavaScript๋ก ๋์ ์ผ๋ก ๋ฒํผ ์์ฑ -->
|
| 98 |
</div>
|
|
|
|
| 109 |
</div>
|
| 110 |
|
| 111 |
<script>
|
| 112 |
+
// 1. ์ ๊ณต๋ ์ ์ฒด ํ๋ก์ ํธ ๋ฆฌ์คํธ (ํค: ํ๋ก์ ํธ ์ด๋ฆ, ๊ฐ: URL)
|
| 113 |
const projectList = {
|
|
|
|
|
|
|
| 114 |
"fantos/Panorama": "https://huggingface.co/spaces/fantos/Panorama",
|
| 115 |
"ginigen/Multi-LoRAgen": "https://huggingface.co/spaces/ginigen/Multi-LoRAgen",
|
| 116 |
"ginigen/canvas-studio": "https://huggingface.co/spaces/ginigen/canvas-studio",
|
|
|
|
| 229 |
"aiqtech/FLUX-Ghibli-Studio-LoRA": "https://huggingface.co/spaces/aiqtech/FLUX-Ghibli-Studio-LoRA",
|
| 230 |
"aiqtech/flxgif": "https://huggingface.co/spaces/aiqtech/flxgif",
|
| 231 |
"aiqtech/imaginpaint": "https://huggingface.co/spaces/aiqtech/imaginpaint"
|
|
|
|
| 232 |
};
|
| 233 |
|
| 234 |
// 2. URL ๋ณํ ํจ์: "https://huggingface.co/spaces/{namespace}/{project}" โ "https://{namespace}-{project}.hf.space"
|
| 235 |
function transformUrl(url) {
|
| 236 |
const prefix = "https://huggingface.co/spaces/";
|
| 237 |
if (url.startsWith(prefix)) {
|
| 238 |
+
const rest = url.substring(prefix.length);
|
|
|
|
| 239 |
return "https://" + rest.replace("/", "-") + ".hf.space";
|
| 240 |
}
|
| 241 |
return url;
|
| 242 |
}
|
| 243 |
|
| 244 |
+
// 3. ๋ชจ๋ ํญ๋ชฉ์ ์นดํ
๊ณ ๋ฆฌ๋ฅผ ๊ฐ์ ๋ก "Image Gen"์ผ๋ก ์ง์ ํ๊ณ , ์ด๋ฆ์ "Image Gen/ํ๋ก์ ํธ๋ช
" ํํ๋ก ๋ณ๊ฒฝ
|
| 245 |
+
const keys = Object.keys(projectList);
|
| 246 |
+
const projects = keys.map((key) => {
|
| 247 |
+
const projectName = key.split("/").slice(1).join("/");
|
| 248 |
return {
|
| 249 |
+
name: "Image Gen/" + projectName,
|
| 250 |
url: transformUrl(projectList[key]),
|
| 251 |
+
category: "Image Gen"
|
| 252 |
};
|
| 253 |
});
|
| 254 |
|
| 255 |
+
// 4. (ํ์ฌ ๋ชจ๋ ํญ๋ชฉ์ด "Image Gen"์ด์ง๋ง) ์นดํ
๊ณ ๋ฆฌ๋ณ ๊ทธ๋ฃนํ
|
| 256 |
const grouped = {};
|
| 257 |
projects.forEach(project => {
|
| 258 |
const cat = project.category;
|
|
|
|
| 262 |
grouped[cat].push(project);
|
| 263 |
});
|
| 264 |
|
| 265 |
+
// 5. ํํฐ ๋ฒํผ์ ๋ฏธ๋ฆฌ ์ ์ํ 10๊ฐ์ง ๊ทธ๋ฃน์ผ๋ก ์์ฑ (NEW, BEST, Text, Image Gen, Image Edit, Audio, Video, Productivity, Utility, Vision)
|
| 266 |
+
const fixedGroups = ["NEW", "BEST", "Text", "Image Gen", "Image Edit", "Audio", "Video", "Productivity", "Utility", "Vision"];
|
| 267 |
const filterGroupDiv = document.getElementById("filter-group");
|
|
|
|
| 268 |
const allButton = document.createElement("button");
|
| 269 |
allButton.className = "toggle-button active";
|
| 270 |
allButton.setAttribute("data-filter", "all");
|
| 271 |
allButton.textContent = "All";
|
| 272 |
filterGroupDiv.appendChild(allButton);
|
| 273 |
+
fixedGroups.forEach(category => {
|
|
|
|
| 274 |
const btn = document.createElement("button");
|
| 275 |
btn.className = "toggle-button";
|
| 276 |
btn.setAttribute("data-filter", category);
|
|
|
|
| 278 |
filterGroupDiv.appendChild(btn);
|
| 279 |
});
|
| 280 |
|
| 281 |
+
// 6. ์ฌ์ด๋๋ฐ ์
๋ฐ์ดํธ ํจ์: ์ ํํ ํํฐ์ ํญ๋ชฉ ์ถ๋ ฅ
|
| 282 |
function updateSidebar(filter) {
|
| 283 |
const sidebar = document.getElementById("sidebar");
|
| 284 |
+
sidebar.innerHTML = "";
|
| 285 |
+
let items = (filter === "all") ? projects : projects.filter(project => project.category === filter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
const ul = document.createElement("ul");
|
| 287 |
items.forEach(item => {
|
| 288 |
const li = document.createElement("li");
|
|
|
|
| 293 |
ul.appendChild(li);
|
| 294 |
});
|
| 295 |
sidebar.appendChild(ul);
|
|
|
|
| 296 |
if (items.length > 0) {
|
| 297 |
document.getElementById("embed-frame").setAttribute("src", items[0].url);
|
| 298 |
} else {
|
|
|
|
| 305 |
button.addEventListener("click", function() {
|
| 306 |
document.querySelectorAll(".toggle-button").forEach(btn => btn.classList.remove("active"));
|
| 307 |
this.classList.add("active");
|
| 308 |
+
updateSidebar(this.getAttribute("data-filter"));
|
|
|
|
| 309 |
});
|
| 310 |
});
|
| 311 |
|