-
Quick Actions
- - - - - -Analysis
- - - - -Monitor
- - - +
+
+
+
- Quick Trade
+
+
+
+
+
+
-
-
-
+ π€
- Hey! I'm NOFXi, your AI trading agent. π
-
-Ask me anything about markets, or use quick actions on the left.
-
-Type /help to see all commands.
-
+
-
+function timeNow() {
+ return new Date().toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
+}
+
+function addMsg(role, text) {
+ const div = document.createElement('div');
+ const isUser = role === 'user';
+ div.className = 'msg ' + (isUser ? 'user' : 'bot');
+
+ const avatar = isUser ? 'π€' : 'β‘';
+ const name = isUser ? 'You' : 'NOFXi';
+
+ div.innerHTML = `
+ Portfolio
+
+
+
+
- NOFXi is thinking
-
-
+
+
-
-
-
+
+
+
+ Monitor
+
+
+
+
+
+
+
Strategy
+
+
+
${avatar}
+
+
`;
+
+ messagesEl.appendChild(div);
+ messagesEl.scrollTop = messagesEl.scrollHeight;
+}
+
+function escHtml(t) {
+ const d = document.createElement('div');
+ d.textContent = t;
+ return d.innerHTML;
+}
+
+async function send(text) {
+ if (!text) {
+ text = inputEl.value.trim();
+ if (!text) return;
+ inputEl.value = '';
+ }
+
+ addMsg('user', text);
+ typingEl.classList.add('active');
+ sendBtn.disabled = true;
+ inputEl.focus();
+
+ try {
+ const r = await fetch(API + '/api/chat', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ message: text, user_id: 1 })
+ });
+ const d = await r.json();
+ addMsg('bot', d.response || d.error || 'No response');
+ } catch (e) {
+ addMsg('bot', 'β οΈ Connection error: ' + e.message);
+ }
+
+ typingEl.classList.remove('active');
+ sendBtn.disabled = false;
+ inputEl.focus();
+}
+
+inputEl.focus();
+
${name}
+ ${escHtml(text)}
+ ${timeNow()}
+