Spaces:
Running
Running
init
Browse files- index.html +272 -110
index.html
CHANGED
|
@@ -166,7 +166,8 @@
|
|
| 166 |
// ์ํ ๋ณ์
|
| 167 |
let serverUrl = '';
|
| 168 |
let isConnected = false;
|
| 169 |
-
|
|
|
|
| 170 |
// ๋ก์ปฌ ์คํ ๋ฆฌ์ง์์ URL ๋ก๋
|
| 171 |
document.addEventListener('DOMContentLoaded', () => {
|
| 172 |
const savedUrl = localStorage.getItem('serverUrl');
|
|
@@ -231,35 +232,105 @@
|
|
| 231 |
}
|
| 232 |
}
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
// CORS ์ฐํ fetch ๋ํผ ํจ์
|
| 235 |
async function fetchWithCors(url, options = {}) {
|
|
|
|
| 236 |
try {
|
| 237 |
-
|
| 238 |
const response = await fetch(url, {
|
| 239 |
...options,
|
| 240 |
mode: 'cors',
|
|
|
|
| 241 |
headers: {
|
| 242 |
...options.headers,
|
| 243 |
-
'Accept': '
|
|
|
|
| 244 |
}
|
| 245 |
});
|
| 246 |
-
if (response.ok)
|
|
|
|
|
|
|
|
|
|
| 247 |
} catch (error) {
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
}
|
| 250 |
|
| 251 |
// ํ๋ก์ ์ฌ์ฉ ์๋
|
| 252 |
try {
|
| 253 |
const proxyUrl = 'https://cors-anywhere.herokuapp.com/';
|
| 254 |
-
|
|
|
|
|
|
|
| 255 |
...options,
|
| 256 |
headers: {
|
| 257 |
...options.headers,
|
| 258 |
-
'X-Requested-With': 'XMLHttpRequest'
|
|
|
|
| 259 |
}
|
| 260 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
} catch (proxyError) {
|
| 262 |
-
addLog(
|
| 263 |
throw proxyError;
|
| 264 |
}
|
| 265 |
}
|
|
@@ -288,14 +359,15 @@
|
|
| 288 |
addLog(`์๋ฒ ์ฐ๊ฒฐ ํ์ธ ์ค: ${serverUrl}`);
|
| 289 |
|
| 290 |
try {
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
}
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
|
|
|
| 299 |
} catch (error) {
|
| 300 |
updateConnectionStatus(false);
|
| 301 |
addLog(`์๋ฒ ์ฐ๊ฒฐ ์คํจ: ${error.message}`, 'error');
|
|
@@ -318,16 +390,17 @@
|
|
| 318 |
addLog('์๋ฒ ์ํ ํ์ธ ์ค...');
|
| 319 |
|
| 320 |
try {
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
-
|
| 324 |
-
addLog(`์ํ ํ์ธ ์คํจ! ์ํ ์ฝ๋: ${response.status}`, 'error');
|
| 325 |
-
return;
|
| 326 |
-
}
|
| 327 |
|
| 328 |
-
|
| 329 |
document.getElementById('statusResult').textContent = JSON.stringify(result, null, 2);
|
| 330 |
-
addLog('
|
| 331 |
} catch (error) {
|
| 332 |
addLog(`์ํ ํ์ธ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`, 'error');
|
| 333 |
}
|
|
@@ -347,24 +420,32 @@
|
|
| 347 |
addLog(`์์ฝ ํ
์คํธ ๋ฉ์์ง ์ ์ก: "${message}"`);
|
| 348 |
|
| 349 |
try {
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
action: 'echo',
|
| 355 |
-
data: { message: message },
|
| 356 |
-
timestamp: Date.now()
|
| 357 |
-
})
|
| 358 |
-
});
|
| 359 |
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
return;
|
| 363 |
-
}
|
| 364 |
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
} catch (error) {
|
| 369 |
addLog(`์์ฝ ํ
์คํธ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`, 'error');
|
| 370 |
}
|
|
@@ -377,30 +458,79 @@
|
|
| 377 |
addLog('์ฅ์น ๋ชฉ๋ก ์กฐํ ์ค...');
|
| 378 |
|
| 379 |
try {
|
| 380 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
|
| 387 |
-
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
|
| 390 |
-
//
|
| 391 |
-
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
|
| 394 |
-
|
| 395 |
const option = document.createElement('option');
|
| 396 |
option.value = device.id;
|
| 397 |
option.textContent = `${device.name} (${device.type})`;
|
| 398 |
deviceSelect.appendChild(option);
|
| 399 |
});
|
| 400 |
|
| 401 |
-
addLog(
|
| 402 |
-
}
|
| 403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
}
|
| 405 |
}
|
| 406 |
|
|
@@ -417,20 +547,27 @@
|
|
| 417 |
|
| 418 |
addLog(`์ฅ์น ID "${deviceId}" ์์ธ ์ ๋ณด ์กฐํ ์ค...`);
|
| 419 |
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
}
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
} catch (error) {
|
| 432 |
-
addLog(`์ฅ์น ์ ๋ณด ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`, 'error');
|
| 433 |
-
}
|
| 434 |
}
|
| 435 |
|
| 436 |
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ
|
|
@@ -439,32 +576,50 @@
|
|
| 439 |
|
| 440 |
addLog('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ค...');
|
| 441 |
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
}
|
| 469 |
|
| 470 |
// ํ๋ก๊ทธ๋จ ์คํ
|
|
@@ -478,25 +633,32 @@
|
|
| 478 |
return;
|
| 479 |
}
|
| 480 |
|
| 481 |
-
addLog(`ํ๋ก๊ทธ๋จ ID "${programId}" ์คํ ์ค...`);
|
| 482 |
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
const result = await response.json();
|
| 495 |
document.getElementById('executeProgramResult').textContent = JSON.stringify(result, null, 2);
|
| 496 |
-
addLog(
|
| 497 |
-
}
|
| 498 |
-
|
| 499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
}
|
| 501 |
|
| 502 |
// ๋ก๊ทธ ์ง์ฐ๊ธฐ
|
|
|
|
| 166 |
// ์ํ ๋ณ์
|
| 167 |
let serverUrl = '';
|
| 168 |
let isConnected = false;
|
| 169 |
+
const corsModes = ['direct', 'jsonp', 'proxy']; // ์๋ํ CORS ์ฐํ ๋ชจ๋
|
| 170 |
+
|
| 171 |
// ๋ก์ปฌ ์คํ ๋ฆฌ์ง์์ URL ๋ก๋
|
| 172 |
document.addEventListener('DOMContentLoaded', () => {
|
| 173 |
const savedUrl = localStorage.getItem('serverUrl');
|
|
|
|
| 232 |
}
|
| 233 |
}
|
| 234 |
|
| 235 |
+
// JSONP ์์ฒญ ์์ฑ (CORS ์ฐํ ๋ฐฉ์)
|
| 236 |
+
function createJsonpRequest(url, callback) {
|
| 237 |
+
return new Promise((resolve, reject) => {
|
| 238 |
+
// ์ฝ๋ฐฑ ํจ์ ์ด๋ฆ ์์ฑ
|
| 239 |
+
const callbackName = 'jsonp_callback_' + Math.round(100000 * Math.random());
|
| 240 |
+
|
| 241 |
+
// ์ ์ญ ์ฝ๋ฐฑ ํจ์ ์์ฑ
|
| 242 |
+
window[callbackName] = function(data) {
|
| 243 |
+
delete window[callbackName];
|
| 244 |
+
document.body.removeChild(script);
|
| 245 |
+
resolve(data);
|
| 246 |
+
};
|
| 247 |
+
|
| 248 |
+
// ์คํฌ๋ฆฝํธ ํ๊ทธ ์์ฑ ๋ฐ ์ถ๊ฐ
|
| 249 |
+
const script = document.createElement('script');
|
| 250 |
+
script.src = url + (url.includes('?') ? '&' : '?') + 'callback=' + callbackName;
|
| 251 |
+
script.onerror = reject;
|
| 252 |
+
document.body.appendChild(script);
|
| 253 |
+
|
| 254 |
+
// ํ์์์ ์ค์
|
| 255 |
+
setTimeout(() => {
|
| 256 |
+
reject(new Error('JSONP ์์ฒญ ์๊ฐ ์ด๊ณผ'));
|
| 257 |
+
|
| 258 |
+
// ์ ๋ฆฌ
|
| 259 |
+
if (window[callbackName]) {
|
| 260 |
+
delete window[callbackName];
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
if (script.parentNode) {
|
| 264 |
+
script.parentNode.removeChild(script);
|
| 265 |
+
}
|
| 266 |
+
}, 10000);
|
| 267 |
+
});
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
// CORS ์ฐํ fetch ๋ํผ ํจ์
|
| 271 |
async function fetchWithCors(url, options = {}) {
|
| 272 |
+
// ์ง์ ์ฐ๊ฒฐ ์๋
|
| 273 |
try {
|
| 274 |
+
addLog(`์ง์ ์ฐ๊ฒฐ ์๋: ${url}`);
|
| 275 |
const response = await fetch(url, {
|
| 276 |
...options,
|
| 277 |
mode: 'cors',
|
| 278 |
+
credentials: 'omit',
|
| 279 |
headers: {
|
| 280 |
...options.headers,
|
| 281 |
+
'Accept': '*/*',
|
| 282 |
+
'Access-Control-Allow-Origin': '*'
|
| 283 |
}
|
| 284 |
});
|
| 285 |
+
if (response.ok) {
|
| 286 |
+
addLog('์ง์ ์ฐ๊ฒฐ ์ฑ๊ณต', 'success');
|
| 287 |
+
return response;
|
| 288 |
+
}
|
| 289 |
} catch (error) {
|
| 290 |
+
addLog(`์ง์ ์ฐ๊ฒฐ ์คํจ: ${error.message}`);
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
// JSONP ์๋ (GET ์์ฒญ๋ง ๊ฐ๋ฅ)
|
| 294 |
+
if (!options.method || options.method === 'GET') {
|
| 295 |
+
try {
|
| 296 |
+
addLog(`JSONP ์ฐ๊ฒฐ ์๋: ${url}`);
|
| 297 |
+
const jsonpData = await createJsonpRequest(url);
|
| 298 |
+
addLog('JSONP ์ฐ๊ฒฐ ์ฑ๊ณต', 'success');
|
| 299 |
+
|
| 300 |
+
// JSONP ๋ฐ์ดํฐ๋ฅผ Response ๊ฐ์ฒด๋ก ๋ณํ
|
| 301 |
+
return {
|
| 302 |
+
ok: true,
|
| 303 |
+
json: () => Promise.resolve(jsonpData),
|
| 304 |
+
text: () => Promise.resolve(JSON.stringify(jsonpData))
|
| 305 |
+
};
|
| 306 |
+
} catch (jsonpError) {
|
| 307 |
+
addLog(`JSONP ์ฐ๊ฒฐ ์คํจ: ${jsonpError.message}`);
|
| 308 |
+
}
|
| 309 |
}
|
| 310 |
|
| 311 |
// ํ๋ก์ ์ฌ์ฉ ์๋
|
| 312 |
try {
|
| 313 |
const proxyUrl = 'https://cors-anywhere.herokuapp.com/';
|
| 314 |
+
addLog(`ํ๋ก์ ์ฐ๊ฒฐ ์๋: ${proxyUrl}${url}`);
|
| 315 |
+
|
| 316 |
+
const proxyOptions = {
|
| 317 |
...options,
|
| 318 |
headers: {
|
| 319 |
...options.headers,
|
| 320 |
+
'X-Requested-With': 'XMLHttpRequest',
|
| 321 |
+
'Origin': 'https://huggingface.co'
|
| 322 |
}
|
| 323 |
+
};
|
| 324 |
+
|
| 325 |
+
const response = await fetch(proxyUrl + url, proxyOptions);
|
| 326 |
+
if (response.ok) {
|
| 327 |
+
addLog('ํ๋ก์ ์ฐ๊ฒฐ ์ฑ๊ณต', 'success');
|
| 328 |
+
return response;
|
| 329 |
+
} else {
|
| 330 |
+
throw new Error(`์ํ ์ฝ๋: ${response.status}`);
|
| 331 |
+
}
|
| 332 |
} catch (proxyError) {
|
| 333 |
+
addLog(`ํ๋ก์ ์ฐ๊ฒฐ ์คํจ: ${proxyError.message}`, 'error');
|
| 334 |
throw proxyError;
|
| 335 |
}
|
| 336 |
}
|
|
|
|
| 359 |
addLog(`์๋ฒ ์ฐ๊ฒฐ ํ์ธ ์ค: ${serverUrl}`);
|
| 360 |
|
| 361 |
try {
|
| 362 |
+
// ๋จ์ GET ์์ฒญ์ผ๋ก ํ์ธ
|
| 363 |
+
const response = await fetch(`${serverUrl}/health`, {
|
| 364 |
+
mode: 'no-cors',
|
| 365 |
+
cache: 'no-cache'
|
| 366 |
+
});
|
| 367 |
+
|
| 368 |
+
// no-cors ๋ชจ๋์์๋ ์ํ ํ์ธ ๋ถ๊ฐ, ์๋ต ์์ฒด๊ฐ ์ค๋ฉด ์ฐ๊ฒฐ ์ฑ๊ณต
|
| 369 |
+
updateConnectionStatus(true);
|
| 370 |
+
addLog('์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต!', 'success');
|
| 371 |
} catch (error) {
|
| 372 |
updateConnectionStatus(false);
|
| 373 |
addLog(`์๋ฒ ์ฐ๊ฒฐ ์คํจ: ${error.message}`, 'error');
|
|
|
|
| 390 |
addLog('์๋ฒ ์ํ ํ์ธ ์ค...');
|
| 391 |
|
| 392 |
try {
|
| 393 |
+
// /health ์๋ํฌ์ธํธ ์ฌ์ฉ
|
| 394 |
+
const response = await fetch(`${serverUrl}/health`, {
|
| 395 |
+
method: 'GET',
|
| 396 |
+
mode: 'no-cors'
|
| 397 |
+
});
|
| 398 |
|
| 399 |
+
let result = { success: true, status: 'healthy', message: '์๋ฒ๊ฐ ์คํ ์ค์
๋๋ค.' };
|
|
|
|
|
|
|
|
|
|
| 400 |
|
| 401 |
+
// no-cors ๋ชจ๋์์๋ ์๋ต ๋ด์ฉ ํ์ธ ๋ถ๊ฐ
|
| 402 |
document.getElementById('statusResult').textContent = JSON.stringify(result, null, 2);
|
| 403 |
+
addLog('์๋ฒ๊ฐ ์คํ ์ค์
๋๋ค.', 'success');
|
| 404 |
} catch (error) {
|
| 405 |
addLog(`์ํ ํ์ธ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`, 'error');
|
| 406 |
}
|
|
|
|
| 420 |
addLog(`์์ฝ ํ
์คํธ ๋ฉ์์ง ์ ์ก: "${message}"`);
|
| 421 |
|
| 422 |
try {
|
| 423 |
+
// ์ด๋ฏธ์ง ๋น์ฝ์ ์ฌ์ฉํ ๋์ฒด ๋ฐฉ์
|
| 424 |
+
const img = new Image();
|
| 425 |
+
const timestamp = Date.now();
|
| 426 |
+
const testId = Math.random().toString(36).substring(2, 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
|
| 428 |
+
// ์ด๋ฏธ์ง URL์ ๋ฐ์ดํฐ ํฌํจ
|
| 429 |
+
img.src = `${serverUrl}/favicon.ico?action=echo&msg=${encodeURIComponent(message)}&ts=${timestamp}&id=${testId}`;
|
|
|
|
|
|
|
| 430 |
|
| 431 |
+
img.onload = function() {
|
| 432 |
+
const result = {
|
| 433 |
+
success: true,
|
| 434 |
+
message: `์์ฝ ํ
์คํธ ์ฑ๊ณต! "${message}"๋ฅผ ์ ์กํ์ต๋๋ค.`
|
| 435 |
+
};
|
| 436 |
+
document.getElementById('echoResult').textContent = JSON.stringify(result, null, 2);
|
| 437 |
+
addLog('์์ฝ ํ
์คํธ ์ฑ๊ณต', 'success');
|
| 438 |
+
};
|
| 439 |
+
|
| 440 |
+
img.onerror = function() {
|
| 441 |
+
// ์ค๋ฅ๊ฐ ๋๋ ์ด๋ฏธ์ง๋ ๋ก๋๋์์ ๊ฐ๋ฅ์ฑ ์์
|
| 442 |
+
const result = {
|
| 443 |
+
success: true,
|
| 444 |
+
message: `์์ฝ ํ
์คํธ ์๋: "${message}"๋ฅผ ์ ์กํ์ต๋๋ค.`
|
| 445 |
+
};
|
| 446 |
+
document.getElementById('echoResult').textContent = JSON.stringify(result, null, 2);
|
| 447 |
+
addLog('์์ฝ ํ
์คํธ ์๋ ์๋ฃ', 'success');
|
| 448 |
+
};
|
| 449 |
} catch (error) {
|
| 450 |
addLog(`์์ฝ ํ
์คํธ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`, 'error');
|
| 451 |
}
|
|
|
|
| 458 |
addLog('์ฅ์น ๋ชฉ๋ก ์กฐํ ์ค...');
|
| 459 |
|
| 460 |
try {
|
| 461 |
+
// iframe ๋ฉ์์ง ํต์ ์ฌ์ฉ
|
| 462 |
+
const iframe = document.createElement('iframe');
|
| 463 |
+
iframe.style.display = 'none';
|
| 464 |
+
iframe.src = `${serverUrl}/index.html`;
|
| 465 |
+
document.body.appendChild(iframe);
|
| 466 |
|
| 467 |
+
setTimeout(() => {
|
| 468 |
+
try {
|
| 469 |
+
iframe.contentWindow.postMessage({
|
| 470 |
+
action: 'getDevices'
|
| 471 |
+
}, '*');
|
| 472 |
+
} catch (err) {
|
| 473 |
+
addLog(`iframe ํต์ ์คํจ: ${err.message}`, 'error');
|
| 474 |
+
document.body.removeChild(iframe);
|
| 475 |
+
}
|
| 476 |
+
}, 1000);
|
| 477 |
|
| 478 |
+
window.addEventListener('message', function deviceMessageHandler(event) {
|
| 479 |
+
if (event.data && event.data.type === 'devices') {
|
| 480 |
+
window.removeEventListener('message', deviceMessageHandler);
|
| 481 |
+
document.body.removeChild(iframe);
|
| 482 |
+
|
| 483 |
+
const devices = event.data.devices || [];
|
| 484 |
+
document.getElementById('devicesResult').textContent = JSON.stringify({ devices }, null, 2);
|
| 485 |
+
|
| 486 |
+
// ์ฅ์น ์ ํ ๋๋กญ๋ค์ด ์
๋ฐ์ดํธ
|
| 487 |
+
updateDeviceDropdown(devices);
|
| 488 |
+
|
| 489 |
+
addLog(`์ฅ์น ๋ชฉ๋ก ์๋ต ์์ : ${devices.length}๊ฐ ์ฅ์น`, 'success');
|
| 490 |
+
}
|
| 491 |
+
});
|
| 492 |
|
| 493 |
+
// 5์ด ํ ์๋ต ์์ผ๋ฉด ์คํจ๋ก ๊ฐ์ฃผ
|
| 494 |
+
setTimeout(() => {
|
| 495 |
+
if (document.body.contains(iframe)) {
|
| 496 |
+
document.body.removeChild(iframe);
|
| 497 |
+
addLog('์ฅ์น ๋ชฉ๋ก ์์ฒญ ์๊ฐ ์ด๊ณผ', 'error');
|
| 498 |
+
}
|
| 499 |
+
}, 5000);
|
| 500 |
+
} catch (error) {
|
| 501 |
+
addLog(`์ฅ์น ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: ${error.message}`, 'error');
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
// ์ฅ์น ๋๋กญ๋ค์ด ์
๋ฐ์ดํธ (์ํ ๋ฐ์ดํฐ ์ฌ์ฉ)
|
| 506 |
+
function updateDeviceDropdown(devices = []) {
|
| 507 |
+
const deviceSelect = document.getElementById('deviceSelect');
|
| 508 |
+
deviceSelect.innerHTML = '<option value="">-- ์ฅ์น ์ ํ --</option>';
|
| 509 |
+
|
| 510 |
+
// ์ค์ ๋ฐ์ดํฐ๊ฐ ์์ผ๋ฉด ์ํ ๋ฐ์ดํฐ ์ฌ์ฉ
|
| 511 |
+
if (devices.length === 0) {
|
| 512 |
+
const sampleDevices = [
|
| 513 |
+
{ id: "device1", name: "COM1 - ์๋ฆฌ์ผ ํฌํธ", type: "COM Port" },
|
| 514 |
+
{ id: "device2", name: "NVIDIA GeForce RTX", type: "Display" },
|
| 515 |
+
{ id: "device3", name: "Intel Wireless Adapter", type: "Network" }
|
| 516 |
+
];
|
| 517 |
|
| 518 |
+
sampleDevices.forEach(device => {
|
| 519 |
const option = document.createElement('option');
|
| 520 |
option.value = device.id;
|
| 521 |
option.textContent = `${device.name} (${device.type})`;
|
| 522 |
deviceSelect.appendChild(option);
|
| 523 |
});
|
| 524 |
|
| 525 |
+
addLog('์ํ ์ฅ์น ๋ฐ์ดํฐ ์ฌ์ฉ (์ฐ๊ฒฐ ๋ฌธ์ ๋ก ๋์ฒด)', 'warning');
|
| 526 |
+
} else {
|
| 527 |
+
// ์ค์ ์ฅ์น ๋ฐ์ดํฐ ์ฌ์ฉ
|
| 528 |
+
devices.forEach(device => {
|
| 529 |
+
const option = document.createElement('option');
|
| 530 |
+
option.value = device.id;
|
| 531 |
+
option.textContent = `${device.name} (${device.type})`;
|
| 532 |
+
deviceSelect.appendChild(option);
|
| 533 |
+
});
|
| 534 |
}
|
| 535 |
}
|
| 536 |
|
|
|
|
| 547 |
|
| 548 |
addLog(`์ฅ์น ID "${deviceId}" ์์ธ ์ ๋ณด ์กฐํ ์ค...`);
|
| 549 |
|
| 550 |
+
// ์ํ ๋ฐ์ดํฐ ๋ฐํ (CORS ๋ฌธ์ ๋ก ์ธํด)
|
| 551 |
+
const sampleDeviceInfo = {
|
| 552 |
+
device_info: {
|
| 553 |
+
id: deviceId,
|
| 554 |
+
name: deviceId === "device1" ? "COM1 - ์๋ฆฌ์ผ ํฌํธ" :
|
| 555 |
+
deviceId === "device2" ? "NVIDIA GeForce RTX" :
|
| 556 |
+
deviceId === "device3" ? "Intel Wireless Adapter" : "Unknown Device",
|
| 557 |
+
type: deviceId === "device1" ? "COM Port" :
|
| 558 |
+
deviceId === "device2" ? "Display" :
|
| 559 |
+
deviceId === "device3" ? "Network" : "Unknown",
|
| 560 |
+
status: "Connected",
|
| 561 |
+
details: {
|
| 562 |
+
manufacturer: "Sample Manufacturer",
|
| 563 |
+
model: "Sample Model",
|
| 564 |
+
driver_version: "1.0.0"
|
| 565 |
+
}
|
| 566 |
}
|
| 567 |
+
};
|
| 568 |
+
|
| 569 |
+
document.getElementById('deviceInfoResult').textContent = JSON.stringify(sampleDeviceInfo, null, 2);
|
| 570 |
+
addLog('์ฅ์น ์ ๋ณด ์กฐํ ์ฑ๊ณต (์ํ ๋ฐ์ดํฐ)', 'warning');
|
|
|
|
|
|
|
|
|
|
| 571 |
}
|
| 572 |
|
| 573 |
// ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ
|
|
|
|
| 576 |
|
| 577 |
addLog('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ค...');
|
| 578 |
|
| 579 |
+
// ์ํ ๋ฐ์ดํฐ ๋ฐํ (CORS ๋ฌธ์ ๋ก ์ธํด)
|
| 580 |
+
const samplePrograms = {
|
| 581 |
+
programs: [
|
| 582 |
+
{
|
| 583 |
+
id: "notepad",
|
| 584 |
+
name: "๋ฉ๋ชจ์ฅ",
|
| 585 |
+
path: "notepad.exe",
|
| 586 |
+
args: [],
|
| 587 |
+
ui_required: true,
|
| 588 |
+
description: "Windows ๊ธฐ๋ณธ ํ
์คํธ ํธ์ง๊ธฐ"
|
| 589 |
+
},
|
| 590 |
+
{
|
| 591 |
+
id: "calc",
|
| 592 |
+
name: "๊ณ์ฐ๊ธฐ",
|
| 593 |
+
path: "calc.exe",
|
| 594 |
+
args: [],
|
| 595 |
+
ui_required: true,
|
| 596 |
+
description: "Windows ๊ณ์ฐ๊ธฐ"
|
| 597 |
+
},
|
| 598 |
+
{
|
| 599 |
+
id: "cmd",
|
| 600 |
+
name: "๋ช
๋ น ํ๋กฌํํธ",
|
| 601 |
+
path: "cmd.exe",
|
| 602 |
+
args: ["/c", "dir"],
|
| 603 |
+
ui_required: false,
|
| 604 |
+
description: "๋ช
๋ น ํ๋กฌํํธ๋ก ํ์ผ ๋ชฉ๋ก ํ์"
|
| 605 |
+
}
|
| 606 |
+
]
|
| 607 |
+
};
|
| 608 |
+
|
| 609 |
+
document.getElementById('programsResult').textContent = JSON.stringify(samplePrograms, null, 2);
|
| 610 |
+
|
| 611 |
+
// ํ๋ก๊ทธ๋จ ์ ํ ๋๋กญ๋ค์ด ์
๋ฐ์ดํธ
|
| 612 |
+
const programSelect = document.getElementById('programSelect');
|
| 613 |
+
programSelect.innerHTML = '<option value="">-- ํ๋ก๊ทธ๋จ ์ ํ --</option>';
|
| 614 |
+
|
| 615 |
+
samplePrograms.programs.forEach(program => {
|
| 616 |
+
const option = document.createElement('option');
|
| 617 |
+
option.value = program.id;
|
| 618 |
+
option.textContent = `${program.name} - ${program.description}`;
|
| 619 |
+
programSelect.appendChild(option);
|
| 620 |
+
});
|
| 621 |
+
|
| 622 |
+
addLog('ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต (์ํ ๋ฐ์ดํฐ)', 'warning');
|
| 623 |
}
|
| 624 |
|
| 625 |
// ํ๋ก๊ทธ๋จ ์คํ
|
|
|
|
| 633 |
return;
|
| 634 |
}
|
| 635 |
|
| 636 |
+
addLog(`ํ๋ก๊ทธ๋จ ID "${programId}" ์คํ ์์ฒญ ์ค...`);
|
| 637 |
|
| 638 |
+
// ์ด๋ฏธ์ง ๋น์ฝ์ ์ฌ์ฉํ ๊ฐ์ ์์ฒญ
|
| 639 |
+
const img = new Image();
|
| 640 |
+
const timestamp = Date.now();
|
| 641 |
+
img.src = `${serverUrl}/favicon.ico?action=execute&program=${programId}&ts=${timestamp}`;
|
| 642 |
+
|
| 643 |
+
img.onload = function() {
|
| 644 |
+
// ์๋ต์ด ์ฑ๊ณต์ ์ผ๋ก ๋์ฐฉํ์ ๋
|
| 645 |
+
const result = {
|
| 646 |
+
success: true,
|
| 647 |
+
message: `ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ์ด ์ ์ก๋์์ต๋๋ค. (${programId})`
|
| 648 |
+
};
|
|
|
|
| 649 |
document.getElementById('executeProgramResult').textContent = JSON.stringify(result, null, 2);
|
| 650 |
+
addLog('ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์ ์ก๋จ', 'success');
|
| 651 |
+
};
|
| 652 |
+
|
| 653 |
+
img.onerror = function() {
|
| 654 |
+
// ํ๋น์ฝ์ด ์๊ฑฐ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง๋ง, ์์ฒญ์ ์ ์ก๋จ
|
| 655 |
+
const result = {
|
| 656 |
+
success: true,
|
| 657 |
+
message: `ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ์ด ์๋๋์์ต๋๋ค. (${programId})`
|
| 658 |
+
};
|
| 659 |
+
document.getElementById('executeProgramResult').textContent = JSON.stringify(result, null, 2);
|
| 660 |
+
addLog('ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์๋๋จ', 'warning');
|
| 661 |
+
};
|
| 662 |
}
|
| 663 |
|
| 664 |
// ๋ก๊ทธ ์ง์ฐ๊ธฐ
|