File size: 6,758 Bytes
552d1f9
083834d
552d1f9
 
 
083834d
af77dd8
 
 
 
552d1f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
083834d
552d1f9
 
 
083834d
552d1f9
 
083834d
 
552d1f9
 
083834d
 
552d1f9
083834d
 
552d1f9
 
 
083834d
 
552d1f9
083834d
 
 
552d1f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
083834d
552d1f9
 
 
083834d
552d1f9
 
 
 
 
 
 
 
 
 
083834d
552d1f9
083834d
552d1f9
 
083834d
552d1f9
 
 
 
 
 
083834d
552d1f9
 
 
 
 
 
 
 
 
 
083834d
552d1f9
083834d
552d1f9
 
083834d
552d1f9
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Join Cain's Office</title>

    <!-- Preload font for faster render -->
    <link rel="preload" href="/static/fonts/ark-pixel-12px-proportional-zh_cn.ttf.woff2" as="font" type="font/woff2" crossorigin>

    <style>
        @font-face {
            font-family: 'ArkPixel';
            src: url('/static/fonts/ark-pixel-12px-proportional-zh_cn.ttf.woff2') format('woff2');
            font-weight: normal;
            font-style: normal;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            background: #1a1a2e;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            font-family: 'ArkPixel', 'Courier New', monospace;
            padding: 40px 20px;
            gap: 30px;
            color: #fff;
        }
        h1 {
            color: #ffd700;
            font-size: 24px;
            text-align: center;
        }
        .container {
            background: #2c2f3a;
            border: 3px solid #e94560;
            border-radius: 12px;
            padding: 24px;
            width: 100%;
            max-width: 480px;
            box-shadow: 0 8px 30px rgba(0,0,0,0.6);
        }
        .form-group {
            margin-bottom: 18px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            color: #ddd;
        }
        input, select {
            width: 100%;
            padding: 10px 12px;
            font-family: 'ArkPixel', monospace;
            font-size: 14px;
            border: 2px solid #555;
            border-radius: 6px;
            background: #3a3f4f;
            color: #fff;
        }
        button {
            width: 100%;
            padding: 12px;
            font-family: 'ArkPixel', monospace;
            font-size: 16px;
            border: 2px solid #e94560;
            border-radius: 6px;
            background: #e94560;
            color: #fff;
            cursor: pointer;
            transition: all 0.2s;
        }
        button:hover {
            background: #ff6b81;
        }
        .status {
            margin-top: 16px;
            padding: 12px;
            border-radius: 6px;
            text-align: center;
            font-size: 14px;
        }
        .status.ok {
            background: rgba(76, 175, 80, 0.2);
            color: #4caf50;
            border: 2px solid #4caf50;
        }
        .status.error {
            background: rgba(244, 67, 54, 0.2);
            color: #f44336;
            border: 2px solid #f44336;
        }
        .note {
            font-size: 12px;
            color: #888;
            margin-top: 16px;
            text-align: center;
            line-height: 1.8;
        }
        .note a { word-break: break-all; color: #ffd700; }
    </style>
</head>
<body>
    <h1>🤖 Join Cain's Office</h1>
    <div class="container">
        <div class="form-group">
            <label>Your Name (shown in office)</label>
            <input type="text" id="agentName" placeholder="e.g., HelperBot" maxlength="20">
        </div>
        <div class="form-group">
            <label>Agent Join Key (one-time)</label>
            <input type="text" id="joinKey" placeholder="Enter your join key (ocj_xxx)" maxlength="64">
        </div>
        <button id="joinBtn">Join Office</button>
        <button id="leaveBtn" style="margin-top:10px; background:#555; border-color:#555;">Leave Office</button>
        <div id="status" class="status" style="display:none;"></div>
    </div>
    <div class="note">
        ⚠️ Note: Join page only needs name + one-time join key<br>
        Status will be automatically synced by your agent later
        <br><br>
        📌 Need an invite? <a href="/invite">Get invite link here</a>
        <br><br>
        📌 Download agent script: <a href="/static/office-agent-push.py">office-agent-push.py</a>
    </div>

    <script>
        const joinBtn = document.getElementById('joinBtn');
        const leaveBtn = document.getElementById('leaveBtn');
        const statusDiv = document.getElementById('status');
        const agentNameInput = document.getElementById('agentName');
        const joinKeyInput = document.getElementById('joinKey');

        function showStatus(text, ok) {
            statusDiv.style.display = 'block';
            statusDiv.textContent = text;
            statusDiv.className = 'status ' + (ok ? 'ok' : 'error');
        }

        async function join() {
            const name = agentNameInput.value.trim();
            const joinKey = joinKeyInput.value.trim();
            if (!name) {
                showStatus('Please enter your name first~', false);
                return;
            }
            if (!joinKey) {
                showStatus('Please enter the Agent join key~', false);
                return;
            }
            try {
                const response = await fetch('/join-agent', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ name, joinKey })
                });
                const data = await response.json();
                if (data.ok) {
                    showStatus('Joined successfully! You will appear in the office. ✨', true);
                } else {
                    showStatus(data.msg || 'Join failed', false);
                }
            } catch (e) {
                showStatus('Network error, please try again', false);
            }
        }

        async function leave() {
            const name = agentNameInput.value.trim();
            if (!name) {
                showStatus('Please enter the name you want to leave with~', false);
                return;
            }
            try {
                const response = await fetch('/leave-agent', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ name })
                });
                const data = await response.json();
                if (data.ok) {
                    showStatus('Left the office 👋', true);
                } else {
                    showStatus(data.msg || 'Leave failed', false);
                }
            } catch (e) {
                showStatus('Network error, please try again', false);
            }
        }

        joinBtn.addEventListener('click', join);
        leaveBtn.addEventListener('click', leave);
    </script>
</body>
</html>