Spaces:
Running
Running
Update index.html
Browse files- index.html +209 -72
index.html
CHANGED
@@ -47,8 +47,8 @@
|
|
47 |
color: white;
|
48 |
-webkit-text-stroke: 1px #333;
|
49 |
}
|
50 |
-
/*
|
51 |
-
.
|
52 |
padding: 1rem;
|
53 |
margin-bottom: 1rem;
|
54 |
background-color: #f0f0f0;
|
@@ -57,6 +57,24 @@
|
|
57 |
justify-content: space-between;
|
58 |
align-items: center;
|
59 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
/* ๋ก๋ฉ ํ์ */
|
61 |
.loading {
|
62 |
position: fixed;
|
@@ -70,26 +88,42 @@
|
|
70 |
align-items: center;
|
71 |
z-index: 1000;
|
72 |
font-size: 1.5rem;
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
</style>
|
76 |
</head>
|
77 |
<body>
|
78 |
-
<!--
|
79 |
-
<div class="
|
80 |
<div>
|
81 |
-
<span
|
82 |
-
<span id="
|
83 |
</div>
|
84 |
<div>
|
85 |
-
<input type="
|
86 |
-
<button id="
|
87 |
-
<button id="logoutButton" style="display: none;">๋ก๊ทธ์์</button>
|
88 |
</div>
|
89 |
</div>
|
90 |
|
|
|
|
|
|
|
91 |
<!-- ๋ก๋ฉ ํ์ -->
|
92 |
-
<div class="loading" id="loadingIndicator">
|
93 |
๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์ค๋ ์ค...
|
94 |
</div>
|
95 |
|
@@ -97,21 +131,26 @@
|
|
97 |
<div class="container" id="cardsContainer"></div>
|
98 |
|
99 |
<script>
|
|
|
|
|
|
|
100 |
// ์ํ ๊ด๋ฆฌ
|
101 |
const state = {
|
102 |
-
|
103 |
-
|
|
|
104 |
isLoading: false
|
105 |
};
|
106 |
|
107 |
// DOM ์์ ์ฐธ์กฐ
|
108 |
const elements = {
|
109 |
-
|
110 |
-
|
111 |
-
loginButton: document.getElementById('loginButton'),
|
112 |
logoutButton: document.getElementById('logoutButton'),
|
|
|
113 |
cardsContainer: document.getElementById('cardsContainer'),
|
114 |
-
loadingIndicator: document.getElementById('loadingIndicator')
|
|
|
115 |
};
|
116 |
|
117 |
// Hugging Face์ spaces/models URL ๋ชฉ๋ก
|
@@ -125,10 +164,18 @@
|
|
125 |
"https://huggingface.co/spaces/VIDraft/PHI4-Multimodal",
|
126 |
"https://huggingface.co/spaces/ginigen/Ovis2-8B",
|
127 |
"https://huggingface.co/spaces/ginigen/Graph-Mind",
|
128 |
-
//
|
129 |
-
// ... ๋๋จธ์ง URL
|
130 |
];
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
// URL์ ๋ง์ง๋ง ๋ถ๋ถ์ ์ ๋ชฉ์ผ๋ก ์ถ์ถ (์ธ๋๋ฐ, ํ์ดํ์ ๊ณต๋ฐฑ์ผ๋ก ๋ณํ)
|
133 |
function extractTitle(url) {
|
134 |
const parts = url.split("/");
|
@@ -142,54 +189,124 @@
|
|
142 |
elements.loadingIndicator.style.display = isLoading ? 'flex' : 'none';
|
143 |
}
|
144 |
|
145 |
-
//
|
146 |
-
function
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
153 |
}
|
154 |
|
155 |
-
//
|
156 |
-
function
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
});
|
163 |
}
|
164 |
|
165 |
-
//
|
166 |
-
async function
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
return;
|
170 |
}
|
171 |
|
172 |
setLoading(true);
|
173 |
|
174 |
try {
|
175 |
-
//
|
176 |
-
|
177 |
|
178 |
-
//
|
179 |
-
|
180 |
-
state.
|
|
|
|
|
|
|
181 |
|
182 |
// UI ์
๋ฐ์ดํธ
|
183 |
-
elements.
|
184 |
-
elements.
|
185 |
-
elements.
|
186 |
elements.logoutButton.style.display = 'inline-block';
|
187 |
|
|
|
|
|
188 |
// ์นด๋ ๋ค์ ๋ ๋๋ง
|
189 |
renderCards();
|
190 |
} catch (error) {
|
191 |
-
|
192 |
-
|
|
|
193 |
} finally {
|
194 |
setLoading(false);
|
195 |
}
|
@@ -198,45 +315,54 @@
|
|
198 |
// ๋ก๊ทธ์์ ์ฒ๋ฆฌ
|
199 |
function logout() {
|
200 |
// ์ํ ์ด๊ธฐํ
|
201 |
-
state.
|
202 |
-
state.
|
|
|
203 |
|
204 |
// UI ์
๋ฐ์ดํธ
|
205 |
-
elements.
|
206 |
-
elements.
|
207 |
-
elements.
|
208 |
-
elements.
|
209 |
elements.logoutButton.style.display = 'none';
|
210 |
|
|
|
|
|
211 |
// ์นด๋ ๋ค์ ๋ ๋๋ง
|
212 |
renderCards();
|
213 |
}
|
214 |
|
215 |
// ์ข์์ ํ ๊ธ ์ฒ๋ฆฌ
|
216 |
async function toggleLike(url, button) {
|
217 |
-
if (!state.
|
218 |
-
|
219 |
return;
|
220 |
}
|
221 |
|
|
|
|
|
|
|
|
|
222 |
setLoading(true);
|
223 |
|
224 |
try {
|
225 |
-
//
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
228 |
button.classList.remove("liked");
|
229 |
button.classList.add("not-liked");
|
|
|
230 |
} else {
|
231 |
-
state.
|
232 |
button.classList.add("liked");
|
233 |
button.classList.remove("not-liked");
|
|
|
234 |
}
|
235 |
-
|
236 |
-
// ๋ณ๊ฒฝ์ฌํญ ์ ์ฅ
|
237 |
-
await saveLikes(state.currentUser, state.likedUrls);
|
238 |
} catch (error) {
|
239 |
-
|
240 |
console.error('์ข์์ ์ค๋ฅ:', error);
|
241 |
} finally {
|
242 |
setLoading(false);
|
@@ -269,11 +395,22 @@
|
|
269 |
const likeBtn = document.createElement("button");
|
270 |
likeBtn.className = "like-button";
|
271 |
likeBtn.textContent = "โฅ";
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
likeBtn.classList.add("not-liked");
|
276 |
}
|
|
|
277 |
likeBtn.addEventListener("click", function(e) {
|
278 |
e.preventDefault(); // ๋งํฌ ํด๋ฆญ ๋ฐฉ์ง
|
279 |
toggleLike(url, likeBtn);
|
@@ -285,16 +422,16 @@
|
|
285 |
}
|
286 |
|
287 |
// ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ค์
|
288 |
-
elements.
|
289 |
-
|
290 |
});
|
291 |
|
292 |
elements.logoutButton.addEventListener('click', logout);
|
293 |
|
294 |
-
// ์ํฐ ํค๋ก
|
295 |
-
elements.
|
296 |
if (event.key === 'Enter') {
|
297 |
-
|
298 |
}
|
299 |
});
|
300 |
|
|
|
47 |
color: white;
|
48 |
-webkit-text-stroke: 1px #333;
|
49 |
}
|
50 |
+
/* ํ ํฐ ์
๋ ฅ ๋ฐ ์ํ ํ์ ์์ญ */
|
51 |
+
.auth-controls {
|
52 |
padding: 1rem;
|
53 |
margin-bottom: 1rem;
|
54 |
background-color: #f0f0f0;
|
|
|
57 |
justify-content: space-between;
|
58 |
align-items: center;
|
59 |
}
|
60 |
+
.auth-controls input {
|
61 |
+
padding: 0.5rem;
|
62 |
+
width: 300px;
|
63 |
+
border: 1px solid #ccc;
|
64 |
+
border-radius: 4px;
|
65 |
+
}
|
66 |
+
.auth-controls button {
|
67 |
+
padding: 0.5rem 1rem;
|
68 |
+
margin-left: 0.5rem;
|
69 |
+
background-color: #4CAF50;
|
70 |
+
color: white;
|
71 |
+
border: none;
|
72 |
+
border-radius: 4px;
|
73 |
+
cursor: pointer;
|
74 |
+
}
|
75 |
+
.auth-controls button:hover {
|
76 |
+
background-color: #45a049;
|
77 |
+
}
|
78 |
/* ๋ก๋ฉ ํ์ */
|
79 |
.loading {
|
80 |
position: fixed;
|
|
|
88 |
align-items: center;
|
89 |
z-index: 1000;
|
90 |
font-size: 1.5rem;
|
91 |
+
}
|
92 |
+
/* ์ํ ๋ฉ์์ง */
|
93 |
+
.status-message {
|
94 |
+
margin: 1rem;
|
95 |
+
padding: 1rem;
|
96 |
+
border-radius: 4px;
|
97 |
+
}
|
98 |
+
.success {
|
99 |
+
background-color: #dff0d8;
|
100 |
+
color: #3c763d;
|
101 |
+
}
|
102 |
+
.error {
|
103 |
+
background-color: #f2dede;
|
104 |
+
color: #a94442;
|
105 |
}
|
106 |
</style>
|
107 |
</head>
|
108 |
<body>
|
109 |
+
<!-- ํ ํฐ ์
๋ ฅ ๋ฐ ์ธ์ฆ ์ปจํธ๋กค -->
|
110 |
+
<div class="auth-controls" id="authControls">
|
111 |
<div>
|
112 |
+
<span>Hugging Face ์ธ์ฆ: </span>
|
113 |
+
<span id="authStatus">์ธ์ฆ๋์ง ์์</span>
|
114 |
</div>
|
115 |
<div>
|
116 |
+
<input type="password" id="tokenInput" placeholder="Hugging Face API ํ ํฐ ์
๋ ฅ" />
|
117 |
+
<button id="authButton">์ธ์ฆํ๊ธฐ</button>
|
118 |
+
<button id="logoutButton" style="display: none; background-color: #f44336;">๋ก๊ทธ์์</button>
|
119 |
</div>
|
120 |
</div>
|
121 |
|
122 |
+
<!-- ์ํ ๋ฉ์์ง -->
|
123 |
+
<div id="statusMessage" class="status-message" style="display: none;"></div>
|
124 |
+
|
125 |
<!-- ๋ก๋ฉ ํ์ -->
|
126 |
+
<div class="loading" id="loadingIndicator" style="display: none;">
|
127 |
๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์ค๋ ์ค...
|
128 |
</div>
|
129 |
|
|
|
131 |
<div class="container" id="cardsContainer"></div>
|
132 |
|
133 |
<script>
|
134 |
+
// API ์๋ํฌ์ธํธ
|
135 |
+
const HF_API_BASE = 'https://huggingface.co/api';
|
136 |
+
|
137 |
// ์ํ ๊ด๋ฆฌ
|
138 |
const state = {
|
139 |
+
token: null,
|
140 |
+
username: null,
|
141 |
+
likedModels: {},
|
142 |
isLoading: false
|
143 |
};
|
144 |
|
145 |
// DOM ์์ ์ฐธ์กฐ
|
146 |
const elements = {
|
147 |
+
tokenInput: document.getElementById('tokenInput'),
|
148 |
+
authButton: document.getElementById('authButton'),
|
|
|
149 |
logoutButton: document.getElementById('logoutButton'),
|
150 |
+
authStatus: document.getElementById('authStatus'),
|
151 |
cardsContainer: document.getElementById('cardsContainer'),
|
152 |
+
loadingIndicator: document.getElementById('loadingIndicator'),
|
153 |
+
statusMessage: document.getElementById('statusMessage')
|
154 |
};
|
155 |
|
156 |
// Hugging Face์ spaces/models URL ๋ชฉ๋ก
|
|
|
164 |
"https://huggingface.co/spaces/VIDraft/PHI4-Multimodal",
|
165 |
"https://huggingface.co/spaces/ginigen/Ovis2-8B",
|
166 |
"https://huggingface.co/spaces/ginigen/Graph-Mind",
|
167 |
+
// ๋๋จธ์ง URL ๋ชฉ๋ก... ์ค์ ๋ก๋ ๋ชจ๋ URL์ ํฌํจํด์ผ ํจ
|
|
|
168 |
];
|
169 |
|
170 |
+
// URL์์ ๋ชจ๋ธ/์คํ์ด์ค ID ์ถ์ถ
|
171 |
+
function extractModelInfo(url) {
|
172 |
+
const parts = url.split('/');
|
173 |
+
const type = parts[3]; // spaces ๋๋ models
|
174 |
+
const owner = parts[4];
|
175 |
+
const repo = parts[5];
|
176 |
+
return { type, owner, repo, fullId: `${owner}/${repo}` };
|
177 |
+
}
|
178 |
+
|
179 |
// URL์ ๋ง์ง๋ง ๋ถ๋ถ์ ์ ๋ชฉ์ผ๋ก ์ถ์ถ (์ธ๋๋ฐ, ํ์ดํ์ ๊ณต๋ฐฑ์ผ๋ก ๋ณํ)
|
180 |
function extractTitle(url) {
|
181 |
const parts = url.split("/");
|
|
|
189 |
elements.loadingIndicator.style.display = isLoading ? 'flex' : 'none';
|
190 |
}
|
191 |
|
192 |
+
// ์ํ ๋ฉ์์ง ํ์ ํจ์
|
193 |
+
function showMessage(message, isError = false) {
|
194 |
+
elements.statusMessage.textContent = message;
|
195 |
+
elements.statusMessage.className = `status-message ${isError ? 'error' : 'success'}`;
|
196 |
+
elements.statusMessage.style.display = 'block';
|
197 |
+
|
198 |
+
// 3์ด ํ ๋ฉ์์ง ์ฌ๋ผ์ง
|
199 |
+
setTimeout(() => {
|
200 |
+
elements.statusMessage.style.display = 'none';
|
201 |
+
}, 3000);
|
202 |
}
|
203 |
|
204 |
+
// Hugging Face API ํธ์ถ ํจ์
|
205 |
+
async function fetchWithToken(endpoint, options = {}) {
|
206 |
+
if (!state.token) {
|
207 |
+
throw new Error('์ธ์ฆ ํ ํฐ์ด ์์ต๋๋ค.');
|
208 |
+
}
|
209 |
+
|
210 |
+
const url = `${HF_API_BASE}${endpoint}`;
|
211 |
+
const headers = {
|
212 |
+
'Authorization': `Bearer ${state.token}`,
|
213 |
+
'Content-Type': 'application/json',
|
214 |
+
...options.headers
|
215 |
+
};
|
216 |
+
|
217 |
+
return fetch(url, {
|
218 |
+
...options,
|
219 |
+
headers
|
220 |
});
|
221 |
}
|
222 |
|
223 |
+
// ์ฌ์ฉ์ ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
|
224 |
+
async function fetchUserInfo() {
|
225 |
+
const response = await fetchWithToken('/whoami-v2');
|
226 |
+
if (!response.ok) {
|
227 |
+
throw new Error('์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ค๋๋ฐ ์คํจํ์ต๋๋ค.');
|
228 |
+
}
|
229 |
+
return response.json();
|
230 |
+
}
|
231 |
+
|
232 |
+
// ์ฌ์ฉ์๊ฐ ์ข์์ํ ๋ชจ๋ธ/์คํ์ด์ค ๋ชฉ๋ก ๊ฐ์ ธ์ค๊ธฐ
|
233 |
+
async function fetchLikedRepos() {
|
234 |
+
try {
|
235 |
+
// ์ข์์ํ ๋ชจ๋ธ ๊ฐ์ ธ์ค๊ธฐ
|
236 |
+
const modelsResponse = await fetchWithToken('/me/likes');
|
237 |
+
|
238 |
+
if (!modelsResponse.ok) {
|
239 |
+
throw new Error('์ข์์ ๋ชฉ๋ก์ ๊ฐ์ ธ์ค๋๋ฐ ์คํจํ์ต๋๋ค.');
|
240 |
+
}
|
241 |
+
|
242 |
+
const likedModels = await modelsResponse.json();
|
243 |
+
|
244 |
+
// ๊ฒฐ๊ณผ๋ฅผ ๊ฐ์ฒด๋ก ๋ณํ (๋น ๋ฅธ ๊ฒ์์ ์ํด)
|
245 |
+
const likedMap = {};
|
246 |
+
likedModels.forEach(model => {
|
247 |
+
likedMap[`${model.owner}/${model.name}`] = true;
|
248 |
+
});
|
249 |
+
|
250 |
+
return likedMap;
|
251 |
+
} catch (error) {
|
252 |
+
console.error('์ข์์ ๋ชฉ๋ก ๊ฐ์ ธ์ค๊ธฐ ์ค๋ฅ:', error);
|
253 |
+
throw error;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
// ์ข์์ ํ ๊ธ API ํธ์ถ
|
258 |
+
async function toggleLikeAPI(type, owner, repo, isLiked) {
|
259 |
+
try {
|
260 |
+
const method = isLiked ? 'DELETE' : 'POST';
|
261 |
+
const response = await fetchWithToken(`/${type}/${owner}/${repo}/like`, {
|
262 |
+
method
|
263 |
+
});
|
264 |
+
|
265 |
+
if (!response.ok) {
|
266 |
+
throw new Error(`์ข์์ ${isLiked ? '์ทจ์' : '์ถ๊ฐ'} ์คํจ`);
|
267 |
+
}
|
268 |
+
|
269 |
+
return response.ok;
|
270 |
+
} catch (error) {
|
271 |
+
console.error('์ข์์ ํ ๊ธ API ์ค๋ฅ:', error);
|
272 |
+
throw error;
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
// ์ธ์ฆ ์ฒ๋ฆฌ
|
277 |
+
async function authenticate(token) {
|
278 |
+
if (!token.trim()) {
|
279 |
+
showMessage('ํ ํฐ์ ์
๋ ฅํด์ฃผ์ธ์.', true);
|
280 |
return;
|
281 |
}
|
282 |
|
283 |
setLoading(true);
|
284 |
|
285 |
try {
|
286 |
+
// ํ ํฐ ์ ์ฅ
|
287 |
+
state.token = token;
|
288 |
|
289 |
+
// ์ฌ์ฉ์ ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
|
290 |
+
const userInfo = await fetchUserInfo();
|
291 |
+
state.username = userInfo.name || userInfo.user.username;
|
292 |
+
|
293 |
+
// ์ข์์ ๋ชฉ๋ก ๊ฐ์ ธ์ค๊ธฐ
|
294 |
+
state.likedModels = await fetchLikedRepos();
|
295 |
|
296 |
// UI ์
๋ฐ์ดํธ
|
297 |
+
elements.authStatus.textContent = `${state.username}๋์ผ๋ก ์ธ์ฆ๋จ`;
|
298 |
+
elements.tokenInput.style.display = 'none';
|
299 |
+
elements.authButton.style.display = 'none';
|
300 |
elements.logoutButton.style.display = 'inline-block';
|
301 |
|
302 |
+
showMessage('์ธ์ฆ ์ฑ๊ณต! ์ข์์ ์ ๋ณด๋ฅผ ๋ถ๋ฌ์์ต๋๋ค.');
|
303 |
+
|
304 |
// ์นด๋ ๋ค์ ๋ ๋๋ง
|
305 |
renderCards();
|
306 |
} catch (error) {
|
307 |
+
console.error('์ธ์ฆ ์ค๋ฅ:', error);
|
308 |
+
showMessage('์ธ์ฆ์ ์คํจํ์ต๋๋ค. ํ ํฐ์ ํ์ธํด์ฃผ์ธ์.', true);
|
309 |
+
state.token = null;
|
310 |
} finally {
|
311 |
setLoading(false);
|
312 |
}
|
|
|
315 |
// ๋ก๊ทธ์์ ์ฒ๋ฆฌ
|
316 |
function logout() {
|
317 |
// ์ํ ์ด๊ธฐํ
|
318 |
+
state.token = null;
|
319 |
+
state.username = null;
|
320 |
+
state.likedModels = {};
|
321 |
|
322 |
// UI ์
๋ฐ์ดํธ
|
323 |
+
elements.authStatus.textContent = '์ธ์ฆ๋์ง ์์';
|
324 |
+
elements.tokenInput.style.display = 'inline-block';
|
325 |
+
elements.tokenInput.value = '';
|
326 |
+
elements.authButton.style.display = 'inline-block';
|
327 |
elements.logoutButton.style.display = 'none';
|
328 |
|
329 |
+
showMessage('๋ก๊ทธ์์๋์์ต๋๋ค.');
|
330 |
+
|
331 |
// ์นด๋ ๋ค์ ๋ ๋๋ง
|
332 |
renderCards();
|
333 |
}
|
334 |
|
335 |
// ์ข์์ ํ ๊ธ ์ฒ๋ฆฌ
|
336 |
async function toggleLike(url, button) {
|
337 |
+
if (!state.token) {
|
338 |
+
showMessage('์ข์์๋ฅผ ํ๋ ค๋ฉด HF ํ ํฐ์ผ๋ก ์ธ์ฆ์ด ํ์ํฉ๋๋ค.', true);
|
339 |
return;
|
340 |
}
|
341 |
|
342 |
+
const modelInfo = extractModelInfo(url);
|
343 |
+
const modelId = modelInfo.fullId;
|
344 |
+
const isCurrentlyLiked = state.likedModels[modelId] || false;
|
345 |
+
|
346 |
setLoading(true);
|
347 |
|
348 |
try {
|
349 |
+
// API ํธ์ถ
|
350 |
+
await toggleLikeAPI(modelInfo.type, modelInfo.owner, modelInfo.repo, isCurrentlyLiked);
|
351 |
+
|
352 |
+
// ์ํ ์
๋ฐ์ดํธ
|
353 |
+
if (isCurrentlyLiked) {
|
354 |
+
delete state.likedModels[modelId];
|
355 |
button.classList.remove("liked");
|
356 |
button.classList.add("not-liked");
|
357 |
+
showMessage(`${modelInfo.repo}์ ๋ํ ์ข์์๋ฅผ ์ทจ์ํ์ต๋๋ค.`);
|
358 |
} else {
|
359 |
+
state.likedModels[modelId] = true;
|
360 |
button.classList.add("liked");
|
361 |
button.classList.remove("not-liked");
|
362 |
+
showMessage(`${modelInfo.repo}๋ฅผ ์ข์์ ํ์ต๋๋ค.`);
|
363 |
}
|
|
|
|
|
|
|
364 |
} catch (error) {
|
365 |
+
showMessage('์ข์์ ์ฒ๋ฆฌ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.', true);
|
366 |
console.error('์ข์์ ์ค๋ฅ:', error);
|
367 |
} finally {
|
368 |
setLoading(false);
|
|
|
395 |
const likeBtn = document.createElement("button");
|
396 |
likeBtn.className = "like-button";
|
397 |
likeBtn.textContent = "โฅ";
|
398 |
+
|
399 |
+
// ์ข์์ ์ํ ์ค์
|
400 |
+
try {
|
401 |
+
const modelInfo = extractModelInfo(url);
|
402 |
+
const isLiked = state.token && state.likedModels[modelInfo.fullId];
|
403 |
+
|
404 |
+
if (isLiked) {
|
405 |
+
likeBtn.classList.add("liked");
|
406 |
+
} else {
|
407 |
+
likeBtn.classList.add("not-liked");
|
408 |
+
}
|
409 |
+
} catch (e) {
|
410 |
+
// URL ํ์ฑ ์ค๋ฅ ๋ฑ ์์ธ ์ฒ๋ฆฌ
|
411 |
likeBtn.classList.add("not-liked");
|
412 |
}
|
413 |
+
|
414 |
likeBtn.addEventListener("click", function(e) {
|
415 |
e.preventDefault(); // ๋งํฌ ํด๋ฆญ ๋ฐฉ์ง
|
416 |
toggleLike(url, likeBtn);
|
|
|
422 |
}
|
423 |
|
424 |
// ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ค์
|
425 |
+
elements.authButton.addEventListener('click', () => {
|
426 |
+
authenticate(elements.tokenInput.value);
|
427 |
});
|
428 |
|
429 |
elements.logoutButton.addEventListener('click', logout);
|
430 |
|
431 |
+
// ์ํฐ ํค๋ก ์ธ์ฆ ๊ฐ๋ฅํ๊ฒ
|
432 |
+
elements.tokenInput.addEventListener('keypress', (event) => {
|
433 |
if (event.key === 'Enter') {
|
434 |
+
authenticate(elements.tokenInput.value);
|
435 |
}
|
436 |
});
|
437 |
|