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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<!DOCTYPE html>
<html lang="zh-TW">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hugging Face Space Demo</title>
    <style>

        * {

            margin: 0;

            padding: 0;

            box-sizing: border-box;

        }



        body {

            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

            min-height: 100vh;

            display: flex;

            align-items: center;

            justify-content: center;

        }



        /* 登入頁面樣式 */

        .login-container {

            background: white;

            padding: 40px;

            border-radius: 15px;

            box-shadow: 0 20px 40px rgba(0,0,0,0.1);

            width: 100%;

            max-width: 400px;

            text-align: center;

        }



        .login-title {

            color: #333;

            margin-bottom: 10px;

            font-size: 28px;

            font-weight: 600;

        }



        .login-subtitle {

            color: #666;

            margin-bottom: 30px;

            font-size: 14px;

        }



        .form-group {

            margin-bottom: 20px;

            text-align: left;

        }



        .form-group label {

            display: block;

            margin-bottom: 5px;

            color: #333;

            font-weight: 500;

        }



        .form-group input {

            width: 100%;

            padding: 12px;

            border: 2px solid #e1e5e9;

            border-radius: 8px;

            font-size: 16px;

            transition: border-color 0.3s;

        }



        .form-group input:focus {

            outline: none;

            border-color: #667eea;

        }



        .captcha-container {

            display: flex;

            align-items: center;

            gap: 10px;

            margin-bottom: 20px;

        }



        .captcha-code {

            background: #f8f9fa;

            border: 2px solid #e1e5e9;

            border-radius: 8px;

            padding: 12px;

            font-size: 18px;

            font-weight: bold;

            color: #333;

            letter-spacing: 2px;

            min-width: 100px;

            text-align: center;

            cursor: pointer;

            user-select: none;

        }



        .captcha-input {

            flex: 1;

            padding: 12px;

            border: 2px solid #e1e5e9;

            border-radius: 8px;

            font-size: 16px;

        }



        .captcha-refresh {

            background: #667eea;

            color: white;

            border: none;

            border-radius: 8px;

            padding: 12px;

            cursor: pointer;

            font-size: 14px;

            transition: background-color 0.3s;

        }



        .captcha-refresh:hover {

            background: #5a6fd8;

        }



        .login-btn {

            width: 100%;

            padding: 12px;

            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

            color: white;

            border: none;

            border-radius: 8px;

            font-size: 16px;

            font-weight: 600;

            cursor: pointer;

            transition: transform 0.2s, box-shadow 0.2s;

        }



        .login-btn:hover {

            transform: translateY(-2px);

            box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);

        }



        .error-message {

            color: #e74c3c;

            margin-top: 10px;

            font-size: 14px;

        }



        /* 主應用程式樣式 */

        .app-container {

            display: none;

            width: 100vw;

            height: 100vh;

            background: #f5f7fa;

        }



        .app-header {

            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

            color: white;

            padding: 20px;

            text-align: center;

            position: relative;

        }



        .app-title {

            font-size: 32px;

            font-weight: 700;

            margin-bottom: 5px;

        }



        .app-subtitle {

            font-size: 14px;

            opacity: 0.9;

        }



        .logout-btn {

            position: absolute;

            top: 20px;

            right: 20px;

            background: rgba(255,255,255,0.2);

            color: white;

            border: 2px solid rgba(255,255,255,0.3);

            padding: 8px 16px;

            border-radius: 20px;

            cursor: pointer;

            font-size: 14px;

            transition: all 0.3s;

        }



        .logout-btn:hover {

            background: rgba(255,255,255,0.3);

            border-color: rgba(255,255,255,0.5);

        }



        .main-content {

            display: flex;

            height: calc(100vh - 120px);

        }



        .sidebar {

            width: 250px;

            background: white;

            box-shadow: 2px 0 10px rgba(0,0,0,0.1);

            padding: 20px 0;

        }



        .tab {

            display: block;

            width: 100%;

            padding: 15px 25px;

            background: none;

            border: none;

            text-align: left;

            cursor: pointer;

            font-size: 16px;

            color: #333;

            border-left: 4px solid transparent;

            transition: all 0.3s;

        }



        .tab:hover {

            background: #f8f9fa;

            color: #667eea;

        }



        .tab.active {

            background: #f0f3ff;

            color: #667eea;

            border-left-color: #667eea;

            font-weight: 600;

        }



        .content-area {

            flex: 1;

            padding: 20px;

        }



        .iframe-container {

            display: none;

            width: 100%;

            height: 100%;

            border-radius: 10px;

            overflow: hidden;

            box-shadow: 0 5px 15px rgba(0,0,0,0.1);

        }



        .iframe-container.active {

            display: block;

        }



        .iframe-container iframe {

            width: 100%;

            height: 100%;

            border: none;

        }



        .welcome-content {

            display: flex;

            align-items: center;

            justify-content: center;

            height: 100%;

            flex-direction: column;

            color: #666;

        }



        .welcome-content h2 {

            font-size: 24px;

            margin-bottom: 10px;

            color: #333;

        }



        .welcome-content p {

            font-size: 16px;

            line-height: 1.6;

        }

    </style>
</head>
<body>
    <!-- 登入頁面 -->
    <div id="loginPage" class="login-container">
        <h1 class="login-title">Hugging Face Space Demo</h1>
        <p class="login-subtitle">cjhuang@2025copyright</p>
        
        <form id="loginForm">
            <div class="form-group">
                <label for="username">帳號</label>
                <input type="text" id="username" name="username" required>
            </div>
            
            <div class="form-group">
                <label for="password">密碼</label>
                <input type="password" id="password" name="password" required>
            </div>
            
            <div class="form-group">
                <label for="captcha">驗證碼</label>
                <div class="captcha-container">
                    <div class="captcha-code" id="captchaCode" onclick="generateCaptcha()"></div>
                    <input type="text" id="captchaInput" class="captcha-input" placeholder="請輸入驗證碼" required>
                    <button type="button" class="captcha-refresh" onclick="generateCaptcha()">刷新</button>
                </div>
            </div>
            
            <button type="submit" class="login-btn">登入</button>
            <div id="errorMessage" class="error-message"></div>
        </form>
    </div>

    <!-- 主應用程式 -->
    <div id="appContainer" class="app-container">
        <header class="app-header">
            <h1 class="app-title">Hugging Face Space Demo</h1>
            <p class="app-subtitle">cjhuang@2025copyright</p>
            <button class="logout-btn" onclick="logout()">登出</button>
        </header>
        
        <div class="main-content">
            <nav class="sidebar">
                <button class="tab active" onclick="showTab('welcome')">歡迎頁面</button>
                <button class="tab" onclick="showTab('multimodal')">多模態API</button>
                <button class="tab" onclick="showTab('webcam')">WEBCAM_LineBot</button>
            </nav>
            
            <main class="content-area">
                <div id="welcomeContent" class="iframe-container active">
                    <div class="welcome-content">
                        <h2>歡迎使用 Hugging Face Space Demo</h2>
                        <p>請選擇左側選單來瀏覽不同的應用程式。</p>
                    </div>
                </div>
                
                <div id="multimodalContent" class="iframe-container">
                    <iframe src="https://cjian2025-groq-api-gradio.hf.space" title="多模態API"></iframe>
                </div>
                
                <div id="webcamContent" class="iframe-container">
                    <iframe src="https://cjian2025-webcam-groq-linebot-application.hf.space" title="WEBCAM_LineBot"></iframe>
                </div>
            </main>
        </div>
    </div>

    <script>

        let currentCaptcha = '';



        // 生成驗證碼

        function generateCaptcha() {

            const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789';

            let captcha = '';

            for (let i = 0; i < 5; i++) {

                captcha += chars.charAt(Math.floor(Math.random() * chars.length));

            }

            currentCaptcha = captcha;

            document.getElementById('captchaCode').textContent = captcha;

        }



        // 初始化驗證碼

        generateCaptcha();



        // 登入表單處理

        document.getElementById('loginForm').addEventListener('submit', function(e) {

            e.preventDefault();

            

            const username = document.getElementById('username').value;

            const password = document.getElementById('password').value;

            const captchaInput = document.getElementById('captchaInput').value;

            const errorDiv = document.getElementById('errorMessage');

            

            // 清除之前的錯誤訊息

            errorDiv.textContent = '';

            

            // 驗證帳號密碼

            if (username !== 'ROOT2025') {

                errorDiv.textContent = '帳號錯誤!';

                return;

            }

            

            if (password !== '123456') {

                errorDiv.textContent = '密碼錯誤!';

                return;

            }

            

            // 驗證驗證碼(不區分大小寫)

            if (captchaInput.toLowerCase() !== currentCaptcha.toLowerCase()) {

                errorDiv.textContent = '驗證碼錯誤!';

                generateCaptcha(); // 重新生成驗證碼

                document.getElementById('captchaInput').value = '';

                return;

            }

            

            // 登入成功

            document.getElementById('loginPage').style.display = 'none';

            document.getElementById('appContainer').style.display = 'block';

        });



        // 頁籤切換功能

        function showTab(tabName) {

            // 隱藏所有內容

            const contents = document.querySelectorAll('.iframe-container');

            contents.forEach(content => {

                content.classList.remove('active');

            });

            

            // 移除所有頁籤的active狀態

            const tabs = document.querySelectorAll('.tab');

            tabs.forEach(tab => {

                tab.classList.remove('active');

            });

            

            // 顯示選中的內容

            if (tabName === 'welcome') {

                document.getElementById('welcomeContent').classList.add('active');

                tabs[0].classList.add('active');

            } else if (tabName === 'multimodal') {

                document.getElementById('multimodalContent').classList.add('active');

                tabs[1].classList.add('active');

            } else if (tabName === 'webcam') {

                document.getElementById('webcamContent').classList.add('active');

                tabs[2].classList.add('active');

            }

        }



        // 登出功能

        function logout() {

            // 重置表單

            document.getElementById('loginForm').reset();

            document.getElementById('errorMessage').textContent = '';

            generateCaptcha();

            

            // 切換回登入頁面

            document.getElementById('appContainer').style.display = 'none';

            document.getElementById('loginPage').style.display = 'block';

            

            // 重置到歡迎頁面

            showTab('welcome');

        }



        // 頁面載入時生成驗證碼

        window.addEventListener('load', function() {

            generateCaptcha();

        });

    </script>
</body>
</html>