isaikr 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/cdn/api.js +19 -0
- package/cdn/character.js +254 -0
- package/cdn/chat.js +33 -0
- package/cdn/code-editor.js +1131 -0
- package/cdn/community-compose.js +270 -0
- package/cdn/games/2048/index.html +12 -0
- package/cdn/games/breakout/index.html +13 -0
- package/cdn/games/clicker/index.html +26 -0
- package/cdn/games/flappy/index.html +11 -0
- package/cdn/games/memory/index.html +34 -0
- package/cdn/games/pong/index.html +13 -0
- package/cdn/games/reaction/index.html +38 -0
- package/cdn/games/runner/index.html +11 -0
- package/cdn/games/snake/index.html +11 -0
- package/cdn/games/tetris/index.html +14 -0
- package/cdn/games/whack/index.html +8 -0
- package/cdn/go.js +126 -0
- package/cdn/go2.js +127 -0
- package/cdn/header3_behavior.js +1167 -0
- package/cdn/header3_layout.js +1004 -0
- package/cdn/header3_layout.js.bak +1004 -0
- package/cdn/header3_style.css +3524 -0
- package/cdn/header3_style.css.bak +3514 -0
- package/cdn/lang.js +198 -0
- package/cdn/loading.js +143 -0
- package/cdn/loading2.js +144 -0
- package/cdn/local-model.js +2941 -0
- package/cdn/main.js +4 -0
- package/cdn/main_asset.js +1849 -0
- package/cdn/main_asset.js.bak +6999 -0
- package/cdn/main_index.css +287 -0
- package/cdn/re_board3.css +733 -0
- package/cdn/re_board3.js +734 -0
- package/cdn/re_chat_tts.js +652 -0
- package/cdn/re_local_runtime.js +2246 -0
- package/cdn/re_local_runtime.js.bak +2246 -0
- package/cdn/re_share.js +577 -0
- package/cdn/re_voice.js +542 -0
- package/cdn/utils.js +36 -0
- package/cdn/view.js +321 -0
- package/header3_behavior.js +804 -0
- package/header3_layout.js +998 -0
- package/header3_style.css +2740 -0
- package/index.js +0 -0
- package/lang.js +179 -0
- package/main_asset.js +2416 -0
- package/main_index.css +274 -0
- package/package.json +14 -0
- package/re_chat_tts.js +1419 -0
- package/re_voice.js +430 -0
|
@@ -0,0 +1,1167 @@
|
|
|
1
|
+
function normalizeLegacyAiBubbleHtml(bubble) {
|
|
2
|
+
if (!bubble) return;
|
|
3
|
+
const raw = String(bubble.innerHTML ?? '');
|
|
4
|
+
if (!raw.includes('<') && !raw.includes('>') && !raw.includes('\n')) return;
|
|
5
|
+
bubble.innerHTML = raw
|
|
6
|
+
.replace(/<br\s*\/?>/gi, '<br>')
|
|
7
|
+
.replace(/\n/g, '<br>');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function cleanLegacyAiEntry(entry) {
|
|
11
|
+
if (!entry || entry.nodeType !== 1) return;
|
|
12
|
+
if (entry.dataset && entry.dataset.aicleaned === '1') return;
|
|
13
|
+
|
|
14
|
+
const avatar = entry.querySelector('.chat-entry-avatar, div.relative.flex-shrink-0');
|
|
15
|
+
if (avatar) avatar.remove();
|
|
16
|
+
|
|
17
|
+
const nameLabel = entry.querySelector('.chat-entry-name, div.flex.flex-col > span');
|
|
18
|
+
if (nameLabel) nameLabel.remove();
|
|
19
|
+
|
|
20
|
+
const textWrap = entry.querySelector('.chat-entry-body, div.flex.flex-col');
|
|
21
|
+
if (textWrap) textWrap.style.maxWidth = '85%';
|
|
22
|
+
|
|
23
|
+
const bubble = entry.querySelector('.chat-bubble-ai, .chat-entry-body > div, div.flex.flex-col > div');
|
|
24
|
+
if (bubble) normalizeLegacyAiBubbleHtml(bubble);
|
|
25
|
+
|
|
26
|
+
if (entry.dataset) entry.dataset.aicleaned = '1';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function stripLegacyAiProfiles(rootNode) {
|
|
30
|
+
const chatBox = document.getElementById('chat-box');
|
|
31
|
+
if (!chatBox) return;
|
|
32
|
+
|
|
33
|
+
const selector = 'div.group.w-full.items-start, .chat-entry.ai-entry';
|
|
34
|
+
if (rootNode && rootNode.nodeType === 1) {
|
|
35
|
+
if (rootNode.matches && rootNode.matches(selector)) cleanLegacyAiEntry(rootNode);
|
|
36
|
+
rootNode.querySelectorAll && rootNode.querySelectorAll(selector).forEach(cleanLegacyAiEntry);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
chatBox.querySelectorAll(selector).forEach(cleanLegacyAiEntry);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function scheduleLegacyCleanup(rootNode) {
|
|
44
|
+
if (window.__legacyCleanupPending) return;
|
|
45
|
+
window.__legacyCleanupPending = true;
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
window.__legacyCleanupPending = false;
|
|
48
|
+
stripLegacyAiProfiles(rootNode);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function handleInput(el) {
|
|
53
|
+
el.style.height = 'auto';
|
|
54
|
+
const maxHeight = window.innerWidth <= 900 ? 64 : 72;
|
|
55
|
+
const nextHeight = Math.min(el.scrollHeight, maxHeight);
|
|
56
|
+
el.style.height = nextHeight + 'px';
|
|
57
|
+
el.style.overflowY = el.scrollHeight > maxHeight ? 'auto' : 'hidden';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function toggleChatFullscreen() {
|
|
61
|
+
const island = document.querySelector('.island-box');
|
|
62
|
+
if (!island) return;
|
|
63
|
+
|
|
64
|
+
if (!document.fullscreenElement) {
|
|
65
|
+
if (island.requestFullscreen) island.requestFullscreen();
|
|
66
|
+
else if (island.webkitRequestFullscreen) island.webkitRequestFullscreen();
|
|
67
|
+
} else if (document.exitFullscreen) {
|
|
68
|
+
document.exitFullscreen();
|
|
69
|
+
} else if (document.webkitExitFullscreen) {
|
|
70
|
+
document.webkitExitFullscreen();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function syncFullscreenIcon() {
|
|
75
|
+
const icon = document.getElementById('icon-fullscreen');
|
|
76
|
+
if (!icon) return;
|
|
77
|
+
const fullscreenElement = document.fullscreenElement || document.webkitFullscreenElement;
|
|
78
|
+
icon.className = fullscreenElement
|
|
79
|
+
? 'ri-fullscreen-exit-line text-[14px]'
|
|
80
|
+
: 'ri-fullscreen-line text-[14px]';
|
|
81
|
+
}
|
|
82
|
+
function copyCodeEditorContent() {
|
|
83
|
+
const editor = document.getElementById('code-editor');
|
|
84
|
+
const text = editor ? String(editor.value || '') : '';
|
|
85
|
+
if (!text.trim()) return;
|
|
86
|
+
const onSuccess = () => {
|
|
87
|
+
if (typeof showToast === 'function') showToast('Copied');
|
|
88
|
+
};
|
|
89
|
+
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
90
|
+
navigator.clipboard.writeText(text).then(onSuccess).catch(function () {});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const helper = document.createElement('textarea');
|
|
94
|
+
helper.value = text;
|
|
95
|
+
helper.style.position = 'fixed';
|
|
96
|
+
helper.style.opacity = '0';
|
|
97
|
+
document.body.appendChild(helper);
|
|
98
|
+
helper.select();
|
|
99
|
+
try {
|
|
100
|
+
document.execCommand('copy');
|
|
101
|
+
onSuccess();
|
|
102
|
+
} catch (error) {}
|
|
103
|
+
helper.remove();
|
|
104
|
+
}
|
|
105
|
+
window.copyCodeEditorContent = copyCodeEditorContent;
|
|
106
|
+
const HTML_PREVIEW_STORAGE_KEY = 'ISAI_HTML_PREVIEW_ENABLED';
|
|
107
|
+
try { localStorage.setItem(HTML_PREVIEW_STORAGE_KEY, '0'); } catch (e) {}
|
|
108
|
+
function isHtmlPreviewEnabled() {
|
|
109
|
+
return localStorage.getItem(HTML_PREVIEW_STORAGE_KEY) === '1';
|
|
110
|
+
}
|
|
111
|
+
function looksLikeHtmlDocument(text) {
|
|
112
|
+
const value = String(text || '').trim().toLowerCase();
|
|
113
|
+
if (!value) return false;
|
|
114
|
+
return value.includes('<html') || value.includes('<body') || value.includes('<div') || value.includes('<script') || value.includes('<!doctype html');
|
|
115
|
+
}
|
|
116
|
+
function injectPreviewReset(htmlText) {
|
|
117
|
+
const resetStyle = '<style id="isai-preview-reset">html,body{margin:0!important;padding:0!important;width:100%!important;height:100%!important;}body{box-sizing:border-box;}*,*:before,*:after{box-sizing:inherit;}</style>';
|
|
118
|
+
const html = String(htmlText || '');
|
|
119
|
+
if (/<head[^>]*>/i.test(html)) {
|
|
120
|
+
return html.replace(/<head[^>]*>/i, function(match){ return match + resetStyle; });
|
|
121
|
+
}
|
|
122
|
+
if (/<html[^>]*>/i.test(html)) {
|
|
123
|
+
return html.replace(/<html[^>]*>/i, function(match){ return match + '<head>' + resetStyle + '</head>'; });
|
|
124
|
+
}
|
|
125
|
+
return '<!doctype html><html><head>' + resetStyle + '</head><body>' + html + '</body></html>';
|
|
126
|
+
}
|
|
127
|
+
function setHtmlPreviewButtonState(enabled) {
|
|
128
|
+
const btn = document.getElementById('code-html-preview-toggle');
|
|
129
|
+
if (!btn) return;
|
|
130
|
+
btn.classList.toggle('is-active', !!enabled);
|
|
131
|
+
}
|
|
132
|
+
function refreshHtmlPreview() {
|
|
133
|
+
const frame = document.getElementById('html-preview-frame');
|
|
134
|
+
const editor = document.getElementById('code-editor');
|
|
135
|
+
if (!frame || !editor) return;
|
|
136
|
+
const codeText = String(editor.value || '');
|
|
137
|
+
const previewHtml = looksLikeHtmlDocument(codeText)
|
|
138
|
+
? injectPreviewReset(codeText)
|
|
139
|
+
: `<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;width:100%;height:100%;background:#0f1115;color:#f3f4f6;font:14px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace}pre{margin:0;padding:0;white-space:pre-wrap;word-break:break-word}</style></head><body><pre>${codeText.replace(/[&<>]/g, function(ch){ return ({'&':'&','<':'<','>':'>'})[ch]; })}</pre></body></html>`;
|
|
140
|
+
frame.srcdoc = previewHtml;
|
|
141
|
+
}
|
|
142
|
+
function clearHtmlPreview() {
|
|
143
|
+
const frame = document.getElementById('html-preview-frame');
|
|
144
|
+
if (!frame) return;
|
|
145
|
+
frame.removeAttribute('src');
|
|
146
|
+
frame.srcdoc = '';
|
|
147
|
+
}
|
|
148
|
+
function applyHtmlPreviewState() {
|
|
149
|
+
const pane = document.getElementById('html-preview-pane');
|
|
150
|
+
const enabled = isHtmlPreviewEnabled();
|
|
151
|
+
if (document.body) document.body.classList.toggle('html-preview-active', enabled);
|
|
152
|
+
if (pane) pane.classList.toggle('hidden', !enabled);
|
|
153
|
+
setHtmlPreviewButtonState(enabled);
|
|
154
|
+
if (enabled) {
|
|
155
|
+
refreshHtmlPreview();
|
|
156
|
+
} else {
|
|
157
|
+
clearHtmlPreview();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function toggleHtmlPreview(forceValue) {
|
|
161
|
+
const next = typeof forceValue === 'boolean' ? forceValue : !isHtmlPreviewEnabled();
|
|
162
|
+
localStorage.setItem(HTML_PREVIEW_STORAGE_KEY, next ? '1' : '0');
|
|
163
|
+
applyHtmlPreviewState();
|
|
164
|
+
}
|
|
165
|
+
function bindHtmlPreviewEditor() {
|
|
166
|
+
const editor = document.getElementById('code-editor');
|
|
167
|
+
if (!editor || editor.dataset.previewBound === '1') return;
|
|
168
|
+
// Manual refresh mode: do not auto-render on editor input.
|
|
169
|
+
editor.dataset.previewBound = '1';
|
|
170
|
+
}
|
|
171
|
+
window.toggleHtmlPreview = toggleHtmlPreview;
|
|
172
|
+
window.refreshHtmlPreview = refreshHtmlPreview;
|
|
173
|
+
window.clearHtmlPreview = clearHtmlPreview;
|
|
174
|
+
function getGitHubSettings() {
|
|
175
|
+
return {
|
|
176
|
+
username: String(localStorage.getItem('ISAI_GH_USERNAME') || '').trim(),
|
|
177
|
+
repo: String(localStorage.getItem('ISAI_GH_REPO') || '').trim(),
|
|
178
|
+
token: String(localStorage.getItem('ISAI_GH_TOKEN') || '').trim()
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async function resolveGitHubIdentity(token, fallbackUsername) {
|
|
182
|
+
const fallback = String(fallbackUsername || '').trim();
|
|
183
|
+
if (!token) return fallback;
|
|
184
|
+
try {
|
|
185
|
+
const res = await fetch('https://api.github.com/user', {
|
|
186
|
+
headers: {
|
|
187
|
+
'Authorization': 'Bearer ' + token,
|
|
188
|
+
'Accept': 'application/vnd.github+json'
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
const json = await res.json();
|
|
192
|
+
const login = String((json && json.login) || '').trim();
|
|
193
|
+
return login || fallback;
|
|
194
|
+
} catch (e) {
|
|
195
|
+
return fallback;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function saveGitHubSettings() {
|
|
199
|
+
const usernameEl = document.getElementById('gh-username');
|
|
200
|
+
const repoEl = document.getElementById('gh-repo');
|
|
201
|
+
const tokenEl = document.getElementById('gh-token');
|
|
202
|
+
const username = usernameEl ? String(usernameEl.value || '').trim() : '';
|
|
203
|
+
const repo = repoEl ? String(repoEl.value || '').trim() : '';
|
|
204
|
+
const token = tokenEl ? String(tokenEl.value || '').trim() : '';
|
|
205
|
+
if (!token) {
|
|
206
|
+
if (typeof showToast === 'function') showToast('Token 필요');
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
localStorage.setItem('ISAI_GH_USERNAME', username);
|
|
210
|
+
localStorage.setItem('ISAI_GH_REPO', repo);
|
|
211
|
+
localStorage.setItem('ISAI_GH_TOKEN', token);
|
|
212
|
+
if (typeof showToast === 'function') showToast('GitHub settings saved');
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
function openGitHubConnectModal() {
|
|
216
|
+
const modal = document.getElementById('gh-connect-modal');
|
|
217
|
+
if (!modal) return;
|
|
218
|
+
const settings = getGitHubSettings();
|
|
219
|
+
const usernameEl = document.getElementById('gh-username');
|
|
220
|
+
const repoEl = document.getElementById('gh-repo');
|
|
221
|
+
const tokenEl = document.getElementById('gh-token');
|
|
222
|
+
if (usernameEl) usernameEl.value = settings.username || '';
|
|
223
|
+
if (repoEl) repoEl.value = settings.repo || '';
|
|
224
|
+
if (tokenEl) tokenEl.value = settings.token || '';
|
|
225
|
+
modal.classList.remove('hidden');
|
|
226
|
+
modal.classList.add('flex');
|
|
227
|
+
}
|
|
228
|
+
function closeGitHubConnectModal() {
|
|
229
|
+
const modal = document.getElementById('gh-connect-modal');
|
|
230
|
+
if (!modal) return;
|
|
231
|
+
modal.classList.add('hidden');
|
|
232
|
+
modal.classList.remove('flex');
|
|
233
|
+
}
|
|
234
|
+
async function ensureRepoExists(username, repo, token) {
|
|
235
|
+
const repoName = String(repo || '').trim() || 'isai-playground';
|
|
236
|
+
const checkRes = await fetch(`https://api.github.com/repos/${encodeURIComponent(username)}/${encodeURIComponent(repoName)}`, {
|
|
237
|
+
headers: { 'Authorization': 'Bearer ' + token, 'Accept': 'application/vnd.github+json' }
|
|
238
|
+
});
|
|
239
|
+
if (checkRes.ok) return repoName;
|
|
240
|
+
|
|
241
|
+
const createRes = await fetch('https://api.github.com/user/repos', {
|
|
242
|
+
method: 'POST',
|
|
243
|
+
headers: {
|
|
244
|
+
'Content-Type': 'application/json',
|
|
245
|
+
'Authorization': 'Bearer ' + token,
|
|
246
|
+
'Accept': 'application/vnd.github+json'
|
|
247
|
+
},
|
|
248
|
+
body: JSON.stringify({
|
|
249
|
+
name: repoName,
|
|
250
|
+
description: 'ISAI Playground Publish',
|
|
251
|
+
private: false,
|
|
252
|
+
auto_init: true
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
if (!createRes.ok) {
|
|
256
|
+
const raw = await createRes.text();
|
|
257
|
+
let err = {};
|
|
258
|
+
try { err = JSON.parse(raw); } catch (e) {}
|
|
259
|
+
throw new Error((err && err.message) ? err.message : 'Repository create failed');
|
|
260
|
+
}
|
|
261
|
+
return repoName;
|
|
262
|
+
}
|
|
263
|
+
async function publishCodeToGitHub(forceFromModal) {
|
|
264
|
+
const editor = document.getElementById('code-editor');
|
|
265
|
+
const codeText = editor ? String(editor.value || '').trim() : '';
|
|
266
|
+
if (!codeText) {
|
|
267
|
+
if (typeof showToast === 'function') showToast('Code is empty.');
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (forceFromModal === true) {
|
|
272
|
+
if (!saveGitHubSettings()) return;
|
|
273
|
+
}
|
|
274
|
+
const settings = getGitHubSettings();
|
|
275
|
+
if (!settings.token) {
|
|
276
|
+
openGitHubConnectModal();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const fileNameInput = window.prompt('File name (ex: app.js)', 'app.js');
|
|
281
|
+
if (fileNameInput === null) return;
|
|
282
|
+
const fileName = String(fileNameInput || '').trim() || 'app.js';
|
|
283
|
+
const path = 'playground/' + Date.now() + '-' + fileName.replace(/[^\w.\-]/g, '_');
|
|
284
|
+
|
|
285
|
+
try {
|
|
286
|
+
if (typeof showLoader === 'function') showLoader(true);
|
|
287
|
+
const owner = await resolveGitHubIdentity(settings.token, settings.username);
|
|
288
|
+
if (!owner) {
|
|
289
|
+
throw new Error('GitHub username not found');
|
|
290
|
+
}
|
|
291
|
+
localStorage.setItem('ISAI_GH_USERNAME', owner);
|
|
292
|
+
const repoName = await ensureRepoExists(owner, settings.repo, settings.token);
|
|
293
|
+
if (!settings.repo) localStorage.setItem('ISAI_GH_REPO', repoName);
|
|
294
|
+
|
|
295
|
+
const putRes = await fetch(`https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repoName)}/contents/${encodeURIComponent(path)}`, {
|
|
296
|
+
method: 'PUT',
|
|
297
|
+
headers: {
|
|
298
|
+
'Content-Type': 'application/json',
|
|
299
|
+
'Authorization': 'Bearer ' + settings.token,
|
|
300
|
+
'Accept': 'application/vnd.github+json'
|
|
301
|
+
},
|
|
302
|
+
body: JSON.stringify({
|
|
303
|
+
message: 'Publish from ISAI Playground',
|
|
304
|
+
content: btoa(unescape(encodeURIComponent(codeText)))
|
|
305
|
+
})
|
|
306
|
+
});
|
|
307
|
+
const putRaw = await putRes.text();
|
|
308
|
+
let putJson = {};
|
|
309
|
+
try { putJson = JSON.parse(String(putRaw || '{}')); } catch (e) {}
|
|
310
|
+
if (!putRes.ok) throw new Error((putJson && putJson.message) ? putJson.message : 'Publish failed');
|
|
311
|
+
|
|
312
|
+
const githubUrl = `https://github.com/${owner}/${repoName}/blob/main/${path}`;
|
|
313
|
+
const runUrl = `https://cdn.jsdelivr.net/gh/${encodeURIComponent(owner)}/${encodeURIComponent(repoName)}@main/${path}`;
|
|
314
|
+
try {
|
|
315
|
+
await fetch('re_store.php?action=save_code_publish', {
|
|
316
|
+
method: 'POST',
|
|
317
|
+
headers: { 'Content-Type': 'application/json' },
|
|
318
|
+
body: JSON.stringify({
|
|
319
|
+
gist_id: `${owner}/${repoName}:${path}`,
|
|
320
|
+
gist_url: githubUrl,
|
|
321
|
+
run_url: runUrl,
|
|
322
|
+
title: repoName,
|
|
323
|
+
file_name: fileName,
|
|
324
|
+
language: (fileName.split('.').pop() || 'txt').slice(0, 20),
|
|
325
|
+
source_type: 'github',
|
|
326
|
+
code: codeText
|
|
327
|
+
})
|
|
328
|
+
});
|
|
329
|
+
} catch (saveError) {}
|
|
330
|
+
|
|
331
|
+
closeGitHubConnectModal();
|
|
332
|
+
if (typeof showToast === 'function') showToast('Published to GitHub');
|
|
333
|
+
if ((fileName || '').toLowerCase().endsWith('.html')) {
|
|
334
|
+
window.open(runUrl, '_blank', 'noopener');
|
|
335
|
+
} else {
|
|
336
|
+
window.open(githubUrl, '_blank', 'noopener');
|
|
337
|
+
}
|
|
338
|
+
} catch (error) {
|
|
339
|
+
if (typeof showToast === 'function') showToast('Publish failed: ' + (error.message || 'Unknown'));
|
|
340
|
+
} finally {
|
|
341
|
+
if (typeof showLoader === 'function') showLoader(false);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
window.openGitHubConnectModal = openGitHubConnectModal;
|
|
345
|
+
window.closeGitHubConnectModal = closeGitHubConnectModal;
|
|
346
|
+
window.saveGitHubSettings = saveGitHubSettings;
|
|
347
|
+
window.publishCodeToGitHub = publishCodeToGitHub;
|
|
348
|
+
function setBoardRailActive(tab) {
|
|
349
|
+
document.querySelectorAll('#board-right-rail [data-board-tab]').forEach((button) => {
|
|
350
|
+
button.classList.toggle('active', button.dataset.boardTab === tab);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
function openBoardRailTab(tab) {
|
|
354
|
+
setBoardRailActive(tab);
|
|
355
|
+
if (window.$boardApp && typeof window.$boardApp.switchTab === 'function') {
|
|
356
|
+
window.$boardApp.switchTab(tab);
|
|
357
|
+
}
|
|
358
|
+
const boardContainer = document.getElementById('board-container');
|
|
359
|
+
if (boardContainer) {
|
|
360
|
+
window.scrollTo({
|
|
361
|
+
top: Math.max(0, boardContainer.getBoundingClientRect().top + window.scrollY - 12),
|
|
362
|
+
behavior: 'smooth'
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
window.addEventListener('board-tab-change', function (event) {
|
|
367
|
+
const tab = event && event.detail && event.detail.tab ? event.detail.tab : 'news';
|
|
368
|
+
setBoardRailActive(tab);
|
|
369
|
+
});
|
|
370
|
+
window.onload = () => {
|
|
371
|
+
const textarea = document.getElementById('prompt-input');
|
|
372
|
+
if(textarea) {
|
|
373
|
+
textarea.removeAttribute('placeholder');
|
|
374
|
+
textarea.placeholder = '';
|
|
375
|
+
handleInput(textarea);
|
|
376
|
+
}
|
|
377
|
+
stripLegacyAiProfiles();
|
|
378
|
+
|
|
379
|
+
const chatBox = document.getElementById('chat-box');
|
|
380
|
+
if (chatBox && !window.__legacyAiProfileObserver) {
|
|
381
|
+
const observer = new MutationObserver((mutations) => {
|
|
382
|
+
let targetNode = null;
|
|
383
|
+
for (const mutation of mutations) {
|
|
384
|
+
if (!mutation.addedNodes || mutation.addedNodes.length === 0) continue;
|
|
385
|
+
for (const node of mutation.addedNodes) {
|
|
386
|
+
if (node && node.nodeType === 1) {
|
|
387
|
+
targetNode = node;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (targetNode) break;
|
|
392
|
+
}
|
|
393
|
+
if (targetNode) scheduleLegacyCleanup(targetNode);
|
|
394
|
+
});
|
|
395
|
+
observer.observe(chatBox, { childList: true, subtree: false });
|
|
396
|
+
window.__legacyAiProfileObserver = observer;
|
|
397
|
+
}
|
|
398
|
+
__handleChatFullscreenChange();
|
|
399
|
+
setBoardRailActive('news');
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
let selectedMode = 'chat';
|
|
403
|
+
|
|
404
|
+
function syncInlineCodePanel(mode) {
|
|
405
|
+
mode = mode || 'chat';
|
|
406
|
+
if (document.body) document.body.setAttribute('data-ui-mode', mode);
|
|
407
|
+
const rightPanel = document.getElementById('right-panel');
|
|
408
|
+
const codeTabs = document.getElementById('code-tabs');
|
|
409
|
+
const codeEditor = document.getElementById('code-editor');
|
|
410
|
+
const topZone = document.getElementById('top-zone');
|
|
411
|
+
const chatBox = document.getElementById('chat-box');
|
|
412
|
+
const chatInputShell = document.getElementById('chat-input-shell');
|
|
413
|
+
const rightPanelOriginAnchor = document.getElementById('right-panel-origin-anchor');
|
|
414
|
+
const desktopCodePanelHost = document.getElementById('desktop-code-panel-host');
|
|
415
|
+
const isCodeMode = mode === 'code';
|
|
416
|
+
const vw = window.innerWidth || document.documentElement.clientWidth || 0;
|
|
417
|
+
const fullscreenElement = document.fullscreenElement || document.webkitFullscreenElement || null;
|
|
418
|
+
const fullscreenActive = !!(fullscreenElement && fullscreenElement.classList && fullscreenElement.classList.contains('island-box'));
|
|
419
|
+
const mobileCodeMode = isCodeMode && vw <= 900;
|
|
420
|
+
const desktopCodeMode = isCodeMode && vw > 900;
|
|
421
|
+
const codePanelGridColumn = vw <= 1180 ? '1 / span 2' : '1 / span 4';
|
|
422
|
+
const codePanelGridRow = vw <= 900 ? '2' : (vw <= 1180 ? '3' : '2');
|
|
423
|
+
const codePanelMinHeight = vw <= 900 ? '240px' : '320px';
|
|
424
|
+
const codePanelMaxHeight = vw <= 900 ? '360px' : '520px';
|
|
425
|
+
|
|
426
|
+
if (!rightPanel) {
|
|
427
|
+
if (typeof __applyMobileChatRailSafety === 'function') {
|
|
428
|
+
setTimeout(__applyMobileChatRailSafety, 0);
|
|
429
|
+
}
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (rightPanelOriginAnchor && rightPanelOriginAnchor.parentElement && desktopCodePanelHost) {
|
|
434
|
+
if (desktopCodeMode && !fullscreenActive) {
|
|
435
|
+
desktopCodePanelHost.style.display = 'block';
|
|
436
|
+
desktopCodePanelHost.style.width = '100%';
|
|
437
|
+
desktopCodePanelHost.style.minWidth = '0';
|
|
438
|
+
desktopCodePanelHost.style.minHeight = codePanelMinHeight;
|
|
439
|
+
desktopCodePanelHost.style.visibility = 'visible';
|
|
440
|
+
desktopCodePanelHost.style.opacity = '1';
|
|
441
|
+
if (rightPanel.parentElement !== desktopCodePanelHost) {
|
|
442
|
+
desktopCodePanelHost.appendChild(rightPanel);
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
desktopCodePanelHost.style.display = 'none';
|
|
446
|
+
desktopCodePanelHost.style.removeProperty('min-height');
|
|
447
|
+
desktopCodePanelHost.style.removeProperty('visibility');
|
|
448
|
+
desktopCodePanelHost.style.removeProperty('opacity');
|
|
449
|
+
desktopCodePanelHost.style.removeProperty('overflow');
|
|
450
|
+
if (rightPanel.parentElement !== rightPanelOriginAnchor.parentElement) {
|
|
451
|
+
rightPanelOriginAnchor.parentElement.insertBefore(rightPanel, rightPanelOriginAnchor.nextSibling);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
document.body.classList.toggle('mode-code', mobileCodeMode);
|
|
457
|
+
document.body.classList.toggle('desktop-code-open', desktopCodeMode);
|
|
458
|
+
document.body.classList.toggle('desktop-code-panel-mounted', desktopCodeMode && !fullscreenActive);
|
|
459
|
+
document.body.classList.remove('desktop-code-stage');
|
|
460
|
+
rightPanel.classList.toggle('mobile-active', mobileCodeMode);
|
|
461
|
+
|
|
462
|
+
if (isCodeMode) {
|
|
463
|
+
bindHtmlPreviewEditor();
|
|
464
|
+
if (codeTabs && !codeTabs.querySelector('.code-tab-btn')) {
|
|
465
|
+
codeTabs.innerHTML = '<div class="code-panel-empty"><span class="code-panel-empty-icon"><i class="ri-ai-generate-text text-sm"></i></span><span class="code-panel-empty-dots" aria-hidden="true"><span></span><span></span><span></span></span></div>';
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (codeEditor && !String(codeEditor.value || '').trim()) {
|
|
469
|
+
codeEditor.value = '// Describe the code you want and generated files will appear here.';
|
|
470
|
+
}
|
|
471
|
+
applyHtmlPreviewState();
|
|
472
|
+
|
|
473
|
+
rightPanel.classList.remove('hidden');
|
|
474
|
+
rightPanel.style.setProperty('display', 'flex', 'important');
|
|
475
|
+
rightPanel.style.setProperty('visibility', 'visible', 'important');
|
|
476
|
+
rightPanel.style.setProperty('opacity', '1', 'important');
|
|
477
|
+
rightPanel.style.setProperty('width', '100%', 'important');
|
|
478
|
+
rightPanel.style.setProperty('min-width', '0', 'important');
|
|
479
|
+
rightPanel.style.setProperty('max-width', '100%', 'important');
|
|
480
|
+
if (mobileCodeMode) {
|
|
481
|
+
rightPanel.style.setProperty('grid-row', codePanelGridRow, 'important');
|
|
482
|
+
rightPanel.style.setProperty('grid-column', codePanelGridColumn, 'important');
|
|
483
|
+
} else {
|
|
484
|
+
rightPanel.style.removeProperty('grid-row');
|
|
485
|
+
rightPanel.style.removeProperty('grid-column');
|
|
486
|
+
}
|
|
487
|
+
rightPanel.style.setProperty('height', 'auto', 'important');
|
|
488
|
+
rightPanel.style.setProperty('min-height', codePanelMinHeight, 'important');
|
|
489
|
+
rightPanel.style.setProperty('max-height', codePanelMaxHeight, 'important');
|
|
490
|
+
rightPanel.style.setProperty('overflow', 'hidden', 'important');
|
|
491
|
+
rightPanel.style.setProperty('border-top', '1px solid rgba(255, 255, 255, 0.06)', 'important');
|
|
492
|
+
if (topZone) {
|
|
493
|
+
topZone.style.setProperty('display', 'flex', 'important');
|
|
494
|
+
topZone.style.setProperty('visibility', 'visible', 'important');
|
|
495
|
+
topZone.style.setProperty('opacity', '1', 'important');
|
|
496
|
+
}
|
|
497
|
+
if (chatBox) {
|
|
498
|
+
chatBox.classList.remove('hidden');
|
|
499
|
+
chatBox.style.setProperty('display', 'flex', 'important');
|
|
500
|
+
chatBox.style.setProperty('visibility', 'visible', 'important');
|
|
501
|
+
chatBox.style.setProperty('opacity', '1', 'important');
|
|
502
|
+
}
|
|
503
|
+
if (chatInputShell) {
|
|
504
|
+
chatInputShell.classList.remove('hidden');
|
|
505
|
+
chatInputShell.style.setProperty('display', 'flex', 'important');
|
|
506
|
+
chatInputShell.style.setProperty('visibility', 'visible', 'important');
|
|
507
|
+
chatInputShell.style.setProperty('opacity', '1', 'important');
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
clearHtmlPreview();
|
|
511
|
+
if (document.body) document.body.classList.remove('html-preview-active');
|
|
512
|
+
document.body.classList.remove('desktop-code-stage');
|
|
513
|
+
document.body.classList.remove('desktop-code-open');
|
|
514
|
+
document.body.classList.remove('desktop-code-panel-mounted');
|
|
515
|
+
rightPanel.classList.remove('mobile-active');
|
|
516
|
+
rightPanel.classList.add('hidden');
|
|
517
|
+
if (typeof __resetChatFullscreenLayoutStyles === 'function') {
|
|
518
|
+
__resetChatFullscreenLayoutStyles();
|
|
519
|
+
}
|
|
520
|
+
if (desktopCodePanelHost) {
|
|
521
|
+
desktopCodePanelHost.style.display = 'none';
|
|
522
|
+
desktopCodePanelHost.style.removeProperty('min-height');
|
|
523
|
+
desktopCodePanelHost.style.removeProperty('visibility');
|
|
524
|
+
desktopCodePanelHost.style.removeProperty('opacity');
|
|
525
|
+
desktopCodePanelHost.style.removeProperty('overflow');
|
|
526
|
+
}
|
|
527
|
+
if (rightPanelOriginAnchor && rightPanelOriginAnchor.parentElement && rightPanel.parentElement !== rightPanelOriginAnchor.parentElement) {
|
|
528
|
+
rightPanelOriginAnchor.parentElement.insertBefore(rightPanel, rightPanelOriginAnchor.nextSibling);
|
|
529
|
+
}
|
|
530
|
+
__clearInlineStyleProps(rightPanel, ['display', 'visibility', 'opacity', 'width', 'min-width', 'max-width', 'grid-row', 'grid-column', 'height', 'min-height', 'max-height', 'overflow', 'border-top']);
|
|
531
|
+
__clearInlineStyleProps(topZone, ['display', 'visibility', 'opacity']);
|
|
532
|
+
__clearInlineStyleProps(chatBox, ['display', 'visibility', 'opacity']);
|
|
533
|
+
__clearInlineStyleProps(chatInputShell, ['display', 'visibility', 'opacity']);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (typeof __applyMobileChatRailSafety === 'function') {
|
|
537
|
+
[0, 60, 160, 360].forEach(function(delay) {
|
|
538
|
+
setTimeout(__applyMobileChatRailSafety, delay);
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
window.syncInlineCodePanel = syncInlineCodePanel;
|
|
543
|
+
|
|
544
|
+
function setStoreMenuState(open) {
|
|
545
|
+
const shouldOpen = !!open;
|
|
546
|
+
const chatStack = document.getElementById('chat-main-stack');
|
|
547
|
+
const topZone = document.getElementById('top-zone');
|
|
548
|
+
const storePanel = document.getElementById('store-panel');
|
|
549
|
+
const appPanel = document.getElementById('app-container');
|
|
550
|
+
const btnMenu = document.getElementById('btn-menu');
|
|
551
|
+
const iconMenu = document.getElementById('icon-menu');
|
|
552
|
+
const promptInput = document.getElementById('prompt-input');
|
|
553
|
+
|
|
554
|
+
if (chatStack) chatStack.classList.toggle('menu-mode', shouldOpen);
|
|
555
|
+
if (topZone) topZone.classList.toggle('menu-mode', shouldOpen);
|
|
556
|
+
if (storePanel) storePanel.classList.toggle('open', shouldOpen);
|
|
557
|
+
if (appPanel) appPanel.classList.remove('open');
|
|
558
|
+
if (chatStack) {
|
|
559
|
+
if (shouldOpen) {
|
|
560
|
+
chatStack.style.setProperty('height', '100%', 'important');
|
|
561
|
+
chatStack.style.setProperty('min-height', '0', 'important');
|
|
562
|
+
chatStack.style.setProperty('max-height', '100%', 'important');
|
|
563
|
+
} else {
|
|
564
|
+
chatStack.style.removeProperty('height');
|
|
565
|
+
chatStack.style.removeProperty('min-height');
|
|
566
|
+
chatStack.style.removeProperty('max-height');
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (topZone) {
|
|
570
|
+
if (shouldOpen) {
|
|
571
|
+
topZone.style.setProperty('display', 'none', 'important');
|
|
572
|
+
topZone.style.setProperty('height', '0', 'important');
|
|
573
|
+
topZone.style.setProperty('min-height', '0', 'important');
|
|
574
|
+
topZone.style.setProperty('max-height', '0', 'important');
|
|
575
|
+
topZone.style.setProperty('flex', '0 0 auto', 'important');
|
|
576
|
+
topZone.style.setProperty('padding', '0', 'important');
|
|
577
|
+
topZone.style.setProperty('margin', '0', 'important');
|
|
578
|
+
topZone.style.setProperty('overflow', 'hidden', 'important');
|
|
579
|
+
topZone.style.setProperty('visibility', 'hidden', 'important');
|
|
580
|
+
topZone.style.setProperty('opacity', '0', 'important');
|
|
581
|
+
} else {
|
|
582
|
+
topZone.style.removeProperty('display');
|
|
583
|
+
topZone.style.removeProperty('height');
|
|
584
|
+
topZone.style.removeProperty('min-height');
|
|
585
|
+
topZone.style.removeProperty('max-height');
|
|
586
|
+
topZone.style.removeProperty('flex');
|
|
587
|
+
topZone.style.removeProperty('padding');
|
|
588
|
+
topZone.style.removeProperty('margin');
|
|
589
|
+
topZone.style.removeProperty('overflow');
|
|
590
|
+
topZone.style.removeProperty('visibility');
|
|
591
|
+
topZone.style.removeProperty('opacity');
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (btnMenu) {
|
|
595
|
+
btnMenu.classList.toggle('menu-open', shouldOpen);
|
|
596
|
+
btnMenu.classList.toggle('text-white', shouldOpen);
|
|
597
|
+
}
|
|
598
|
+
if (iconMenu) {
|
|
599
|
+
iconMenu.className = shouldOpen ? 'ri-draggable text-xl' : 'ri-draggable text-lg';
|
|
600
|
+
}
|
|
601
|
+
if (typeof isMenuOpen !== 'undefined') isMenuOpen = shouldOpen;
|
|
602
|
+
window.isMenuOpen = shouldOpen;
|
|
603
|
+
|
|
604
|
+
if (shouldOpen && typeof fetchStoreApps === 'function') {
|
|
605
|
+
const query = promptInput ? promptInput.value.trim() : '';
|
|
606
|
+
fetchStoreApps(query, false);
|
|
607
|
+
}
|
|
608
|
+
if (typeof __applyMobileChatRailSafety === 'function') {
|
|
609
|
+
[0, 40, 120, 260].forEach(function(delay) {
|
|
610
|
+
setTimeout(__applyMobileChatRailSafety, delay);
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
window.setStoreMenuState = setStoreMenuState;
|
|
615
|
+
|
|
616
|
+
function setMode(mode) {
|
|
617
|
+
mode = mode || 'chat';
|
|
618
|
+
if (mode === 'chat' && !window.ISAI_CHAT_PAGE) {
|
|
619
|
+
const redirectUrl = new URL('/chat.php', window.location.origin);
|
|
620
|
+
try {
|
|
621
|
+
const cdnMode = new URL(window.location.href).searchParams.get('jsdelivr');
|
|
622
|
+
if (cdnMode !== null) redirectUrl.searchParams.set('jsdelivr', cdnMode);
|
|
623
|
+
} catch (error) {}
|
|
624
|
+
window.location.href = redirectUrl.toString();
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (mode !== 'chat' && typeof window.clearCharacterChatSession === 'function') {
|
|
628
|
+
try { window.clearCharacterChatSession(); } catch (error) {}
|
|
629
|
+
}
|
|
630
|
+
if (document.body) document.body.setAttribute('data-ui-mode', mode);
|
|
631
|
+
if (typeof window.setStoreMenuState === 'function') {
|
|
632
|
+
window.setStoreMenuState(false);
|
|
633
|
+
}
|
|
634
|
+
selectedMode = mode;
|
|
635
|
+
try { if (typeof currentMode !== 'undefined') currentMode = mode; } catch (e) {}
|
|
636
|
+
window.currentMode = mode;
|
|
637
|
+
window.selectedMode = mode;
|
|
638
|
+
document.querySelectorAll('.btn-icon').forEach(b => b.classList.remove('active', 'text-white', 'bg-[#262626]'));
|
|
639
|
+
const btn = document.getElementById('btn-' + mode);
|
|
640
|
+
if(btn) btn.classList.add('active', 'text-white', 'bg-[#262626]');
|
|
641
|
+
|
|
642
|
+
const commTools = document.getElementById('community-tools');
|
|
643
|
+
if(commTools) commTools.style.display = (mode === 'community') ? 'flex' : 'none';
|
|
644
|
+
|
|
645
|
+
const musicWrap = document.getElementById('music-duration-wrapper');
|
|
646
|
+
const transLeft = document.getElementById('translation-left-wrapper');
|
|
647
|
+
const transRight = document.getElementById('translation-right-wrapper');
|
|
648
|
+
|
|
649
|
+
if(musicWrap) musicWrap.style.display = (mode === 'music') ? 'flex' : 'none';
|
|
650
|
+
if(transLeft) transLeft.style.display = (mode === 'translate') ? 'block' : 'none';
|
|
651
|
+
if(transRight) transRight.style.display = (mode === 'translate') ? 'block' : 'none';
|
|
652
|
+
|
|
653
|
+
syncInlineCodePanel(mode);
|
|
654
|
+
if (typeof window.syncLocalModelTierVisibility === 'function') {
|
|
655
|
+
window.syncLocalModelTierVisibility(mode);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (mode === 'code') {
|
|
659
|
+
if (typeof window.exitAppMode === 'function' && window.activeApp) {
|
|
660
|
+
try { window.exitAppMode(); } catch (error) {}
|
|
661
|
+
}
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if(typeof window.setAppMode === 'function') window.setAppMode(mode);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function toggleStoreMenu() {
|
|
669
|
+
const chatStack = document.getElementById('chat-main-stack');
|
|
670
|
+
const shouldOpen = !(chatStack && chatStack.classList.contains('menu-mode'));
|
|
671
|
+
if (shouldOpen && typeof window.currentMode !== 'undefined' && window.currentMode !== 'chat' && typeof window.setMode === 'function') {
|
|
672
|
+
window.setMode('chat');
|
|
673
|
+
}
|
|
674
|
+
if (typeof window.setStoreMenuState === 'function') {
|
|
675
|
+
window.setStoreMenuState(shouldOpen);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
async function executeAction(direction) {
|
|
680
|
+
const input = document.getElementById('prompt-input');
|
|
681
|
+
const val = input.value.trim();
|
|
682
|
+
if (!val) return;
|
|
683
|
+
|
|
684
|
+
const btn = document.getElementById('btn-submit');
|
|
685
|
+
const originalIcon = btn.innerHTML;
|
|
686
|
+
|
|
687
|
+
btn.innerHTML = '<i class="ri-loader-4-line animate-spin text-xl"></i>';
|
|
688
|
+
btn.disabled = true;
|
|
689
|
+
|
|
690
|
+
try {
|
|
691
|
+
if (selectedMode !== 'community') {
|
|
692
|
+
const targetUrl = `https://isai.kr/?${selectedMode}=${encodeURIComponent(val)}`;
|
|
693
|
+
window.location.href = targetUrl;
|
|
694
|
+
} else {
|
|
695
|
+
alert("Backend Logic needed for comment: " + val);
|
|
696
|
+
input.value = '';
|
|
697
|
+
handleInput(input);
|
|
698
|
+
}
|
|
699
|
+
} catch (e) {
|
|
700
|
+
console.error(e);
|
|
701
|
+
alert("Error occurred.");
|
|
702
|
+
} finally {
|
|
703
|
+
btn.innerHTML = originalIcon;
|
|
704
|
+
btn.disabled = false;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
const canvas = document.getElementById('star-canvas');
|
|
709
|
+
if(canvas) { /* Star Logic */ }
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
async function downloadCurrentImage() {
|
|
719
|
+
const img = document.getElementById('preview-img');
|
|
720
|
+
const promptText = document.getElementById('modal-prompt-text').innerText;
|
|
721
|
+
|
|
722
|
+
if (!img || !img.src || img.src.includes('isailogo2.png')) {
|
|
723
|
+
alert("Download failed: No image found.");
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
try {
|
|
728
|
+
const btn = event.currentTarget;
|
|
729
|
+
const originalContent = btn.innerHTML;
|
|
730
|
+
btn.innerHTML = '<i class="ri-loader-4-line animate-spin"></i> <span>SAVING...</span>';
|
|
731
|
+
btn.disabled = true;
|
|
732
|
+
|
|
733
|
+
const response = await fetch(img.src);
|
|
734
|
+
const blob = await response.blob();
|
|
735
|
+
const url = window.URL.createObjectURL(blob);
|
|
736
|
+
|
|
737
|
+
const a = document.createElement('a');
|
|
738
|
+
a.style.display = 'none';
|
|
739
|
+
a.href = url;
|
|
740
|
+
|
|
741
|
+
const fileName = promptText.substring(0, 20).replace(/[/\\?%*:|"<>]/g, '-') || 'isai-art';
|
|
742
|
+
a.download = `isai_${fileName}.png`;
|
|
743
|
+
|
|
744
|
+
document.body.appendChild(a);
|
|
745
|
+
a.click();
|
|
746
|
+
|
|
747
|
+
window.URL.revokeObjectURL(url);
|
|
748
|
+
document.body.removeChild(a);
|
|
749
|
+
|
|
750
|
+
btn.innerHTML = originalContent;
|
|
751
|
+
btn.disabled = false;
|
|
752
|
+
|
|
753
|
+
} catch (error) {
|
|
754
|
+
console.error("Download error:", error);
|
|
755
|
+
window.open(img.src, '_blank');
|
|
756
|
+
|
|
757
|
+
const btn = document.querySelector('button[onclick="downloadCurrentImage()"]');
|
|
758
|
+
if(btn) {
|
|
759
|
+
btn.innerHTML = '<i class="ri-download-2-line"></i> <span>DOWNLOAD</span>';
|
|
760
|
+
btn.disabled = false;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
window.addEventListener('load', () => {
|
|
766
|
+
const shareCtx = window.__ISAI_SHARE_CONTEXT__ || {};
|
|
767
|
+
const phpPrompt = String(shareCtx.prompt || "").trim();
|
|
768
|
+
const phpDate = String(shareCtx.date || "");
|
|
769
|
+
const sharedImg = String(shareCtx.image || "");
|
|
770
|
+
const isSharedView = shareCtx.isShared ? "true" : "false";
|
|
771
|
+
|
|
772
|
+
if (isSharedView === 'true' && sharedImg && !sharedImg.includes('isailogo2.png')) {
|
|
773
|
+
setTimeout(() => {
|
|
774
|
+
openImageModal(sharedImg, phpPrompt, phpDate);
|
|
775
|
+
|
|
776
|
+
if (typeof setMode === 'function') setMode('image');
|
|
777
|
+
}, 100);
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
function openImageModal(url, prompt = '', date = '') {
|
|
782
|
+
const modal = document.getElementById('image-modal');
|
|
783
|
+
const img = document.getElementById('preview-img');
|
|
784
|
+
const promptEl = document.getElementById('modal-prompt-text');
|
|
785
|
+
const dateEl = document.getElementById('modal-date-text');
|
|
786
|
+
|
|
787
|
+
if (!url || url.includes('_____________________isailogo2.png')) return;
|
|
788
|
+
|
|
789
|
+
img.src = url;
|
|
790
|
+
|
|
791
|
+
const finalPrompt = (prompt || window.currentImagePrompt || "AI Generated Art").replace('2x2 grid', '').trim();
|
|
792
|
+
const finalDate = date || new Date().toLocaleString();
|
|
793
|
+
|
|
794
|
+
if (promptEl) promptEl.innerText = finalPrompt;
|
|
795
|
+
if (dateEl) dateEl.innerText = finalDate;
|
|
796
|
+
|
|
797
|
+
modal.classList.remove('hidden');
|
|
798
|
+
document.body.style.overflow = 'hidden';
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function closeImageModal() {
|
|
802
|
+
const modal = document.getElementById('image-modal');
|
|
803
|
+
modal.classList.add('hidden');
|
|
804
|
+
document.body.style.overflow = '';
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
document.addEventListener('click', function(e) {
|
|
808
|
+
const targetImg = e.target.closest('img');
|
|
809
|
+
|
|
810
|
+
if (targetImg && (targetImg.closest('#chat-box') || targetImg.closest('#app-grid'))) {
|
|
811
|
+
|
|
812
|
+
if (targetImg.classList.contains('h-12') || targetImg.id === 'comm-preview-img') return;
|
|
813
|
+
|
|
814
|
+
const imgUrl = targetImg.src;
|
|
815
|
+
const imgPrompt = targetImg.getAttribute('data-prompt') || targetImg.alt || "";
|
|
816
|
+
|
|
817
|
+
openImageModal(imgUrl, imgPrompt);
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
window.addEventListener('load', () => {
|
|
822
|
+
const shareCtx = window.__ISAI_SHARE_CONTEXT__ || {};
|
|
823
|
+
const phpPrompt = String(shareCtx.prompt || "").trim();
|
|
824
|
+
const phpDate = String(shareCtx.date || "");
|
|
825
|
+
const sharedImg = String(shareCtx.image || "");
|
|
826
|
+
const isSharedView = shareCtx.isShared ? "true" : "false";
|
|
827
|
+
|
|
828
|
+
if (isSharedView === 'true' && sharedImg && !sharedImg.includes('isailogo2.png')) {
|
|
829
|
+
setTimeout(() => {
|
|
830
|
+
openImageModal(sharedImg, phpPrompt, phpDate);
|
|
831
|
+
if (typeof setMode === 'function') setMode('image');
|
|
832
|
+
}, 300);
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
const imgModalLayer = document.getElementById('image-modal');
|
|
837
|
+
if (imgModalLayer) {
|
|
838
|
+
imgModalLayer.addEventListener('click', function(e) {
|
|
839
|
+
if (e.target === this) closeImageModal();
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
function getImageReportI18n() {
|
|
844
|
+
return window.__ISAI_IMAGE_REPORT_I18N__ || {};
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function getCurrentShareContext() {
|
|
848
|
+
const ctx = window.__ISAI_SHARE_CONTEXT__ || {};
|
|
849
|
+
return {
|
|
850
|
+
id: Number(ctx.id || 0) || 0,
|
|
851
|
+
isShared: !!ctx.isShared
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
function openImageShareReportModal() {
|
|
856
|
+
const i18n = getImageReportI18n();
|
|
857
|
+
const context = getCurrentShareContext();
|
|
858
|
+
if (!context.isShared || !context.id) {
|
|
859
|
+
if (typeof showToast === 'function') showToast('Saved image post not found.');
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
const modal = document.getElementById('image-report-modal');
|
|
863
|
+
const typeSelect = document.getElementById('image-report-type');
|
|
864
|
+
const textarea = document.getElementById('image-report-reason');
|
|
865
|
+
if (typeSelect) typeSelect.value = '';
|
|
866
|
+
document.querySelectorAll('#image-report-modal .report-type-chip').forEach(function (chip) {
|
|
867
|
+
chip.classList.remove('active');
|
|
868
|
+
});
|
|
869
|
+
if (textarea) textarea.value = '';
|
|
870
|
+
if (modal) modal.classList.remove('hidden');
|
|
871
|
+
if (textarea) textarea.focus();
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
function closeImageShareReportModal() {
|
|
875
|
+
const modal = document.getElementById('image-report-modal');
|
|
876
|
+
if (modal) modal.classList.add('hidden');
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
async function submitImageShareReport() {
|
|
880
|
+
const i18n = getImageReportI18n();
|
|
881
|
+
const context = getCurrentShareContext();
|
|
882
|
+
const typeSelect = document.getElementById('image-report-type');
|
|
883
|
+
const textarea = document.getElementById('image-report-reason');
|
|
884
|
+
const reportType = String(typeSelect?.value || '').trim();
|
|
885
|
+
const reason = String(textarea?.value || '').trim();
|
|
886
|
+
if (!context.isShared || !context.id) {
|
|
887
|
+
if (typeof showToast === 'function') showToast('Saved image post not found.');
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
if (!reportType) {
|
|
891
|
+
if (typeof showToast === 'function') showToast(i18n.typeRequired || 'Please select a report type.');
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
if (!reason) {
|
|
895
|
+
if (typeof showToast === 'function') showToast(i18n.reasonRequired || 'Please enter a report reason.');
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
try {
|
|
899
|
+
const res = await fetch('/re_store.php?action=submit_content_report', {
|
|
900
|
+
method: 'POST',
|
|
901
|
+
headers: { 'Content-Type': 'application/json' },
|
|
902
|
+
body: JSON.stringify({
|
|
903
|
+
target_type: 'gallery',
|
|
904
|
+
target_id: context.id,
|
|
905
|
+
report_type: reportType,
|
|
906
|
+
reason
|
|
907
|
+
})
|
|
908
|
+
});
|
|
909
|
+
const data = await res.json();
|
|
910
|
+
if (!data || !data.success) {
|
|
911
|
+
throw new Error((data && data.error) || 'REPORT_FAILED');
|
|
912
|
+
}
|
|
913
|
+
closeImageShareReportModal();
|
|
914
|
+
if (data.deleted) {
|
|
915
|
+
if (typeof showToast === 'function') showToast(i18n.deleted || 'The post was removed after repeated reports.');
|
|
916
|
+
window.setTimeout(() => { window.location.href = '/'; }, 700);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
if (typeof showToast === 'function') {
|
|
920
|
+
showToast(data.reported ? (i18n.reported || 'Report submitted.') : (i18n.duplicate || 'You already reported this post this month.'));
|
|
921
|
+
}
|
|
922
|
+
} catch (error) {
|
|
923
|
+
console.error(error);
|
|
924
|
+
if (typeof showToast === 'function') showToast(i18n.error || 'An error occurred while submitting the report.');
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function chooseImageReportType(type, buttonEl) {
|
|
929
|
+
const input = document.getElementById('image-report-type');
|
|
930
|
+
if (input) input.value = String(type || '');
|
|
931
|
+
document.querySelectorAll('#image-report-modal .report-type-chip').forEach(function (chip) {
|
|
932
|
+
chip.classList.remove('active');
|
|
933
|
+
});
|
|
934
|
+
if (buttonEl && buttonEl.classList) buttonEl.classList.add('active');
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
window.openImageShareReportModal = openImageShareReportModal;
|
|
938
|
+
window.closeImageShareReportModal = closeImageShareReportModal;
|
|
939
|
+
window.submitImageShareReport = submitImageShareReport;
|
|
940
|
+
window.chooseImageReportType = chooseImageReportType;
|
|
941
|
+
|
|
942
|
+
function __getDefaultChatGreeting() {
|
|
943
|
+
const serverI18n = window.ISAI_SERVER_I18N || {};
|
|
944
|
+
if (serverI18n.welcomeMessage) return serverI18n.welcomeMessage;
|
|
945
|
+
return 'Hello! How can I help you?';
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
function __normalizeDefaultGreeting(message, localeHint) {
|
|
949
|
+
return String(message || "").replace(/\s+/g, " ").trim();
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
function __getDefaultChatGreeting() {
|
|
953
|
+
const serverI18n = window.ISAI_SERVER_I18N || {};
|
|
954
|
+
const localeHint = String(serverI18n.locale || document.documentElement?.lang || navigator.language || 'ko').toLowerCase();
|
|
955
|
+
if (serverI18n.welcomeMessage) {
|
|
956
|
+
const normalized = __normalizeDefaultGreeting(serverI18n.welcomeMessage, localeHint);
|
|
957
|
+
if (normalized) return normalized;
|
|
958
|
+
}
|
|
959
|
+
return 'Hello! How can I help you?';
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
function __normalizeDefaultGreeting(message, localeHint) {
|
|
963
|
+
const raw = String(message || "").replace(/\s+/g, " ").trim();
|
|
964
|
+
if (!raw) return "";
|
|
965
|
+
return raw;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
function __getDefaultChatGreeting() {
|
|
969
|
+
const serverI18n = window.ISAI_SERVER_I18N || {};
|
|
970
|
+
const localeHint = String(serverI18n.locale || document.documentElement?.lang || navigator.language || "ko").toLowerCase();
|
|
971
|
+
if (serverI18n.welcomeMessage) {
|
|
972
|
+
const normalized = __normalizeDefaultGreeting(serverI18n.welcomeMessage, localeHint);
|
|
973
|
+
if (normalized) return normalized;
|
|
974
|
+
}
|
|
975
|
+
return "Hello! How can I help you?";
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
function __normalizeDefaultGreeting(message, localeHint) {
|
|
983
|
+
const decodeEscaped = (value) => {
|
|
984
|
+
let text = String(value || "");
|
|
985
|
+
for (let i = 0; i < 3; i++) {
|
|
986
|
+
text = text
|
|
987
|
+
.replace(/\\\\u([0-9a-fA-F]{4})/g, function (_, hex) {
|
|
988
|
+
return String.fromCharCode(parseInt(hex, 16));
|
|
989
|
+
})
|
|
990
|
+
.replace(/\\u([0-9a-fA-F]{4})/g, function (_, hex) {
|
|
991
|
+
return String.fromCharCode(parseInt(hex, 16));
|
|
992
|
+
})
|
|
993
|
+
.replace(/\\\\x([0-9a-fA-F]{2})/g, function (_, hex) {
|
|
994
|
+
return String.fromCharCode(parseInt(hex, 16));
|
|
995
|
+
})
|
|
996
|
+
.replace(/\\x([0-9a-fA-F]{2})/g, function (_, hex) {
|
|
997
|
+
return String.fromCharCode(parseInt(hex, 16));
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
return text;
|
|
1001
|
+
};
|
|
1002
|
+
const raw = decodeEscaped(message).replace(/\s+/g, " ").trim();
|
|
1003
|
+
if (!raw) return "";
|
|
1004
|
+
const isKoreanLocale = String(localeHint || "").toLowerCase().startsWith("ko");
|
|
1005
|
+
const hasKoreanText = /[\u3131-\u318e\uac00-\ud7a3]/.test(raw);
|
|
1006
|
+
const hasLegacyPhrase = /\ub3c4\uc640\ub4dc\ub9b4\uae4c\uc694|\ubb50\s*\ub3c4\uc640\ub4dc\ub9b4\uae4c\uc694/.test(raw);
|
|
1007
|
+
const hasEnglishLegacy = /hello!\s*how can i help you\??/i.test(raw);
|
|
1008
|
+
if ((isKoreanLocale || hasKoreanText) && hasLegacyPhrase) {
|
|
1009
|
+
return "\ub85c\uceec\ub85c \ub354 \uc548\uc804\ud558\uac8c \ub300\ud654\ud558\uc138\uc694";
|
|
1010
|
+
}
|
|
1011
|
+
if (hasEnglishLegacy) {
|
|
1012
|
+
return "Chat more safely in local mode";
|
|
1013
|
+
}
|
|
1014
|
+
if (isKoreanLocale && !hasKoreanText) {
|
|
1015
|
+
return "Chat more safely in local mode";
|
|
1016
|
+
}
|
|
1017
|
+
return raw;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
function __getDefaultChatGreeting() {
|
|
1021
|
+
const serverI18n = window.ISAI_SERVER_I18N || {};
|
|
1022
|
+
const localeHint = String(serverI18n.locale || document.documentElement?.lang || navigator.language || "ko").toLowerCase();
|
|
1023
|
+
if (serverI18n.welcomeMessage) {
|
|
1024
|
+
const normalized = __normalizeDefaultGreeting(serverI18n.welcomeMessage, localeHint);
|
|
1025
|
+
if (normalized) return normalized;
|
|
1026
|
+
}
|
|
1027
|
+
if (localeHint.startsWith("ko")) {
|
|
1028
|
+
return "\ub85c\uceec\ub85c \ub354 \uc548\uc804\ud558\uac8c \ub300\ud654\ud558\uc138\uc694";
|
|
1029
|
+
}
|
|
1030
|
+
return "Chat more safely in local mode";
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
function __activateLocalModeFromGreeting() {
|
|
1034
|
+
if (window.isLocalActive) return;
|
|
1035
|
+
if (typeof window.handleLocalToggle !== "function") return;
|
|
1036
|
+
Promise.resolve(window.handleLocalToggle()).catch(function () {});
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
function __chatBoxHasContent(chatBox) {
|
|
1040
|
+
if (!chatBox) return false;
|
|
1041
|
+
return Array.from(chatBox.children).some(function(node) {
|
|
1042
|
+
if (!node || node.nodeType !== 1) return false;
|
|
1043
|
+
if (node.classList && node.classList.contains('chat-spacer')) return false;
|
|
1044
|
+
if (node.classList && node.classList.contains('__default-chat-greeting')) return true;
|
|
1045
|
+
return !!String(node.textContent || '').trim() || !!node.querySelector('img,video,audio,canvas,iframe,svg');
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
function __ensureChatSpacer(chatBox) {
|
|
1050
|
+
if (!chatBox) return null;
|
|
1051
|
+
let spacer = chatBox.querySelector('.chat-spacer');
|
|
1052
|
+
if (!spacer) {
|
|
1053
|
+
spacer = document.createElement('div');
|
|
1054
|
+
spacer.className = 'chat-spacer';
|
|
1055
|
+
spacer.setAttribute('aria-hidden', 'true');
|
|
1056
|
+
chatBox.prepend(spacer);
|
|
1057
|
+
}
|
|
1058
|
+
return spacer;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
function __ensureDefaultChatGreeting(force) {
|
|
1062
|
+
const chatBox = document.getElementById('chat-box');
|
|
1063
|
+
if (!chatBox) return;
|
|
1064
|
+
if (document.body && document.body.classList.contains('character-chat-active')) return;
|
|
1065
|
+
if (window.ISAI_CHARACTER_CHAT_SESSION && window.ISAI_CHARACTER_CHAT_SESSION.active) return;
|
|
1066
|
+
|
|
1067
|
+
if (force) {
|
|
1068
|
+
chatBox.querySelectorAll('.__default-chat-greeting').forEach(function(node) {
|
|
1069
|
+
node.remove();
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
__ensureChatSpacer(chatBox);
|
|
1074
|
+
if (__chatBoxHasContent(chatBox)) return;
|
|
1075
|
+
|
|
1076
|
+
const wrapper = document.createElement('div');
|
|
1077
|
+
const body = document.createElement('div');
|
|
1078
|
+
const bubble = document.createElement('div');
|
|
1079
|
+
const greetingText = __getDefaultChatGreeting();
|
|
1080
|
+
|
|
1081
|
+
wrapper.className = 'chat-entry ai-entry __default-chat-greeting';
|
|
1082
|
+
body.className = 'chat-entry-body';
|
|
1083
|
+
bubble.className = 'chat-bubble-ai';
|
|
1084
|
+
bubble.classList.add('chat-welcome-cta');
|
|
1085
|
+
bubble.style.display = 'inline-flex';
|
|
1086
|
+
bubble.style.alignItems = 'center';
|
|
1087
|
+
bubble.style.gap = '6px';
|
|
1088
|
+
bubble.innerHTML = '<span class="chat-welcome-cta-inner" style="display:inline-flex;align-items:center;gap:6px;"><i class="ri-ghost-4-line chat-welcome-cta-icon" aria-hidden="true" style="font-size:15px;line-height:1;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;"></i><span class="chat-welcome-cta-text">' + greetingText + '</span></span>';
|
|
1089
|
+
bubble.style.cursor = 'pointer';
|
|
1090
|
+
bubble.setAttribute('role', 'button');
|
|
1091
|
+
bubble.setAttribute('tabindex', '0');
|
|
1092
|
+
bubble.setAttribute('title', 'Enable local mode');
|
|
1093
|
+
bubble.addEventListener('click', function(event) {
|
|
1094
|
+
event.preventDefault();
|
|
1095
|
+
event.stopPropagation();
|
|
1096
|
+
__activateLocalModeFromGreeting();
|
|
1097
|
+
});
|
|
1098
|
+
bubble.addEventListener('keydown', function(event) {
|
|
1099
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
1100
|
+
event.preventDefault();
|
|
1101
|
+
__activateLocalModeFromGreeting();
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
body.appendChild(bubble);
|
|
1105
|
+
wrapper.appendChild(body);
|
|
1106
|
+
chatBox.appendChild(wrapper);
|
|
1107
|
+
|
|
1108
|
+
if (typeof scrollBottom === 'function') {
|
|
1109
|
+
scrollBottom();
|
|
1110
|
+
} else {
|
|
1111
|
+
chatBox.scrollTop = chatBox.scrollHeight;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
function __scheduleDefaultChatGreeting(force) {
|
|
1116
|
+
clearTimeout(window.__defaultChatGreetingTimer);
|
|
1117
|
+
window.__defaultChatGreetingTimer = setTimeout(function() {
|
|
1118
|
+
__ensureDefaultChatGreeting(!!force);
|
|
1119
|
+
}, 40);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if (typeof window.resetChat === 'function' && !window.__defaultGreetingResetWrapped) {
|
|
1123
|
+
const __originalResetChat = window.resetChat;
|
|
1124
|
+
window.resetChat = function() {
|
|
1125
|
+
const result = __originalResetChat.apply(this, arguments);
|
|
1126
|
+
__scheduleDefaultChatGreeting(true);
|
|
1127
|
+
return result;
|
|
1128
|
+
};
|
|
1129
|
+
window.__defaultGreetingResetWrapped = true;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if (typeof window.setMode === 'function' && !window.__defaultGreetingModeWrapped) {
|
|
1133
|
+
const __originalSetMode = window.setMode;
|
|
1134
|
+
window.setMode = function(mode) {
|
|
1135
|
+
const result = __originalSetMode.apply(this, arguments);
|
|
1136
|
+
if (mode === 'chat') {
|
|
1137
|
+
__scheduleDefaultChatGreeting(false);
|
|
1138
|
+
}
|
|
1139
|
+
return result;
|
|
1140
|
+
};
|
|
1141
|
+
window.__defaultGreetingModeWrapped = true;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
window.addEventListener('DOMContentLoaded', function() {
|
|
1145
|
+
__scheduleDefaultChatGreeting(false);
|
|
1146
|
+
});
|
|
1147
|
+
|
|
1148
|
+
window.addEventListener('load', function() {
|
|
1149
|
+
__scheduleDefaultChatGreeting(false);
|
|
1150
|
+
[120, 400, 900].forEach(function(delay) {
|
|
1151
|
+
setTimeout(function() {
|
|
1152
|
+
__scheduleDefaultChatGreeting(false);
|
|
1153
|
+
}, delay);
|
|
1154
|
+
});
|
|
1155
|
+
|
|
1156
|
+
const chatBox = document.getElementById('chat-box');
|
|
1157
|
+
if (chatBox && !window.__defaultChatGreetingObserver) {
|
|
1158
|
+
const observer = new MutationObserver(function() {
|
|
1159
|
+
if (!__chatBoxHasContent(chatBox)) {
|
|
1160
|
+
__scheduleDefaultChatGreeting(false);
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
observer.observe(chatBox, { childList: true });
|
|
1164
|
+
window.__defaultChatGreetingObserver = observer;
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
|