mirror of
https://github.com/wasrusgen/zashita-brandbook.git
synced 2026-06-03 15:44:47 +00:00
fix: permanent chat bar replaces dynamic input injection
This commit is contained in:
parent
1182c56f2f
commit
82b60cb191
79
mockup.html
79
mockup.html
@ -1415,6 +1415,17 @@ body{font-family:var(--font-ui);background:var(--surf);color:var(--ink);line-hei
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="actbar" id="el-actbar" style="display:none"><div class="inner"><button class="btn btn-p" style="flex:1" onclick="go('pay')">Получить полный разбор</button></div></div>
|
<div class="actbar" id="el-actbar" style="display:none"><div class="inner"><button class="btn btn-p" style="flex:1" onclick="go('pay')">Получить полный разбор</button></div></div>
|
||||||
|
|
||||||
|
<!-- Постоянный чат-бар — показывается когда el-step1 скрыт -->
|
||||||
|
<div id="el-chat-bar" style="display:none;position:sticky;bottom:0;background:#fff;border-top:1.5px solid var(--line);padding:12px 18px;z-index:10">
|
||||||
|
<div class="elena-dialog-row">
|
||||||
|
<input class="elena-main-inp" id="el-chat-inp"
|
||||||
|
placeholder="Напишите вопрос или описание ситуации..."
|
||||||
|
onkeydown="if(event.key==='Enter')_elChatSend()">
|
||||||
|
<button class="voice-btn-sm" onclick="toggleVoice('el-chat-inp')" title="Голосовой ввод">🎙</button>
|
||||||
|
<button class="elena-go-btn" onclick="_elChatSend()">→</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ═ 3. ОПЛАТА ═ -->
|
<!-- ═ 3. ОПЛАТА ═ -->
|
||||||
@ -5891,59 +5902,63 @@ function _rcTransferToElena(intent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Показывает поле ввода в chatwrap без picker'а (для продолжения разговора после deadline-перехода)
|
// Показывает постоянный чат-бар внизу экрана Елены
|
||||||
function _elenaShowInput() {
|
function _elenaShowInput() {
|
||||||
var wrap = document.querySelector('.chatwrap') || document.getElementById('el-step1');
|
var bar = document.getElementById('el-chat-bar');
|
||||||
if (!wrap) return;
|
if (bar) {
|
||||||
var old = document.getElementById('el-continue-input');
|
bar.style.display = '';
|
||||||
if (old) { var oi = old.querySelector('input'); if (oi) { oi.focus(); } return; }
|
setTimeout(function(){
|
||||||
var div = document.createElement('div');
|
var inp = document.getElementById('el-chat-inp');
|
||||||
div.id = 'el-continue-input';
|
if (inp) inp.focus();
|
||||||
div.className = 'elena-dialog-wrap';
|
}, 200);
|
||||||
div.style.cssText = 'margin-top:12px;margin-bottom:80px';
|
}
|
||||||
div.innerHTML = '<div class="elena-dialog-row">'
|
|
||||||
+ '<input class="elena-main-inp" id="intake-custom-cont" placeholder="Уточните детали..." '
|
|
||||||
+ 'onkeydown="if(event.key===\'Enter\')_elenaContinueSend()">'
|
|
||||||
+ '<button class="voice-btn-sm" onclick="toggleVoice(\'intake-custom-cont\')" title="Голосовой ввод">🎙</button>'
|
|
||||||
+ '<button class="elena-go-btn" onclick="_elenaContinueSend()">→</button>'
|
|
||||||
+ '</div>';
|
|
||||||
wrap.appendChild(div);
|
|
||||||
div.scrollIntoView({behavior:'smooth'});
|
|
||||||
setTimeout(function(){ var i = document.getElementById('intake-custom-cont'); if (i) i.focus(); }, 300);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _elenaContinueSend() {
|
// Отправка из чат-бара
|
||||||
var inp = document.getElementById('intake-custom-cont');
|
function _elChatSend() {
|
||||||
|
var inp = document.getElementById('el-chat-inp');
|
||||||
if (!inp) return;
|
if (!inp) return;
|
||||||
var txt = inp.value.trim(); if (!txt) return;
|
var txt = inp.value.trim(); if (!txt) return;
|
||||||
inp.value = '';
|
inp.value = '';
|
||||||
var wrap = document.querySelector('.chatwrap') || document.getElementById('el-step1');
|
|
||||||
|
var wrap = document.querySelector('.chatwrap');
|
||||||
if (!wrap) return;
|
if (!wrap) return;
|
||||||
|
|
||||||
// Пузырь пользователя
|
// Пузырь пользователя
|
||||||
var uDiv = document.createElement('div');
|
var uDiv = document.createElement('div');
|
||||||
uDiv.className = 'msg msg-user';
|
uDiv.className = 'msg msg-user';
|
||||||
uDiv.innerHTML = '<div class="bubble user">' + txt.replace(/</g,'<') + '</div>';
|
uDiv.innerHTML = '<div class="bubble user">' + txt.replace(/</g, '<') + '</div>';
|
||||||
var cont = document.getElementById('el-continue-input');
|
wrap.appendChild(uDiv);
|
||||||
if (cont) wrap.insertBefore(uDiv, cont); else wrap.appendChild(uDiv);
|
wrap.scrollTop = wrap.scrollHeight;
|
||||||
if (cont) cont.remove();
|
|
||||||
// Елена отвечает
|
// Елена отвечает
|
||||||
_hcAddTyping();
|
var tDiv = document.createElement('div');
|
||||||
_elenaApi(txt, 'create', function(apiReply, apiActions) {
|
tDiv.className = 'msg'; tDiv.id = 'el-chat-typing';
|
||||||
_hcRemoveTyping();
|
tDiv.innerHTML = '<div class="av"><img src="logos/elena-photo.jpg"></div>' +
|
||||||
var reply = apiReply || 'Уточните, пожалуйста, детали документа.';
|
'<div class="bubble"><div class="nm">Елена</div>' +
|
||||||
|
'<div class="hc-typing-dots"><span></span><span></span><span></span></div></div>';
|
||||||
|
wrap.appendChild(tDiv);
|
||||||
|
wrap.scrollTop = wrap.scrollHeight;
|
||||||
|
|
||||||
|
_elenaApi(txt, 'question', function(apiReply, apiActions) {
|
||||||
|
var t = document.getElementById('el-chat-typing'); if (t) t.remove();
|
||||||
|
var reply = apiReply || 'Уточните, пожалуйста.';
|
||||||
_chatHistory.push({role:'user', content: txt});
|
_chatHistory.push({role:'user', content: txt});
|
||||||
_chatHistory.push({role:'assistant', content: reply});
|
_chatHistory.push({role:'assistant', content: reply});
|
||||||
|
_saveHistory();
|
||||||
|
|
||||||
var eDiv = document.createElement('div');
|
var eDiv = document.createElement('div');
|
||||||
eDiv.className = 'msg';
|
eDiv.className = 'msg';
|
||||||
eDiv.innerHTML = '<div class="av"><img src="logos/elena-photo.jpg"></div>'
|
eDiv.innerHTML = '<div class="av"><img src="logos/elena-photo.jpg"></div>' +
|
||||||
+ '<div class="bubble"><div class="nm">Елена</div>' + _rcEscape(reply) + '</div>';
|
'<div class="bubble"><div class="nm">Елена</div>' + _rcEscape(reply) + '</div>';
|
||||||
wrap.appendChild(eDiv);
|
wrap.appendChild(eDiv);
|
||||||
if (apiActions && apiActions.length) _renderElenaActions(apiActions, wrap);
|
if (apiActions && apiActions.length) _renderElenaActions(apiActions, wrap);
|
||||||
wrap.scrollTop = wrap.scrollHeight;
|
wrap.scrollTop = wrap.scrollHeight;
|
||||||
_elenaShowInput();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// _elenaContinueSend → заменён на _elChatSend через постоянный чат-бар
|
||||||
|
|
||||||
function _getElenaCtxReply(intent, dl) {
|
function _getElenaCtxReply(intent, dl) {
|
||||||
var name = dl.title || 'срок';
|
var name = dl.title || 'срок';
|
||||||
if (intent === 'create') {
|
if (intent === 'create') {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user