bep40 commited on
Commit
f2b0937
·
verified ·
1 Parent(s): 2333d28

CRITICAL FIX: remove chat intercept that hijacked 'báo giá' to main page AI search

Browse files
Files changed (1) hide show
  1. index.html +6 -44
index.html CHANGED
@@ -3080,51 +3080,13 @@ function _handleChatAI(msg){
3080
  }
3081
  </script>
3082
  <script>
3083
- // Intercept chat AI messages to use AI Search/Quote
3084
- document.addEventListener('DOMContentLoaded',function(){
3085
- // Find chat send button and input
3086
- const chatInput=document.querySelector('.chat-input');
3087
- const chatSend=document.querySelector('.chat-send');
3088
- if(chatInput&&chatSend){
3089
- const origClick=chatSend.onclick;
3090
- chatSend.addEventListener('click',function(e){
3091
- const msg=chatInput.value.trim();
3092
- if(msg&&_tryChatAI(msg)){chatInput.value='';e.stopPropagation();e.preventDefault();return false}
3093
- },true);
3094
- chatInput.addEventListener('keypress',function(e){
3095
- if(e.key==='Enter'){
3096
- const msg=chatInput.value.trim();
3097
- if(msg&&_tryChatAI(msg)){chatInput.value='';e.stopPropagation();e.preventDefault();return false}
3098
- }
3099
- },true);
3100
- }
3101
- });
3102
  function _tryChatAI(msg){
3103
- const lo=msg.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/đ/g,'d');
3104
- // Detect: search intent, quote intent, or product code
3105
- const isCode=/^[A-Z]{2,}[\-]?[A-Z0-9]{2,}/i.test(msg.trim());
3106
- const hasComma=/[,;]/.test(msg);
3107
- const isQuote=lo.includes('bao gia')||lo.includes('combo')||lo.includes('du toan');
3108
- const isSearch=lo.includes('tim')||lo.includes('kiem')||lo.includes('goi y')||isCode||hasComma;
3109
- if(isQuote||isSearch||isCode){
3110
- // Put query in AI search box
3111
- document.getElementById('aiSearch').value=msg;
3112
- // Trigger appropriate function
3113
- if(isQuote){doAISearch()}else{doAISearch()}
3114
- // Show chat response
3115
- const chatBody=document.querySelector('.chat-body');
3116
- if(chatBody){
3117
- const bubble=document.createElement('div');
3118
- bubble.className='chat-msg bot';
3119
- bubble.innerHTML=isQuote?'📋 Em đã lên báo giá bên dưới ↓':'🔍 Em đã tìm SP bên dưới ↓';
3120
- chatBody.appendChild(bubble);
3121
- chatBody.scrollTop=chatBody.scrollHeight;
3122
- }
3123
- // Scroll to results
3124
- setTimeout(()=>{document.getElementById('aiResults').scrollIntoView({behavior:'smooth',block:'center'})},300);
3125
- return true;
3126
- }
3127
- return false;
3128
  }
3129
  </script>
3130
  <script>
 
3080
  }
3081
  </script>
3082
  <script>
3083
+ // Chat AI: only redirect pure SEARCH queries to AI search on main page
3084
+ // "báo giá" handled by sendChat() inline (NOT redirected)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3085
  function _tryChatAI(msg){
3086
+ var lo=msg.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/\u0111/g,'d');
3087
+ // If it's a quote request → DO NOT intercept, let sendChat handle it
3088
+ if(lo.includes('bao gia')||lo.includes('combo')||lo.includes('du toan'))return false;
3089
+ return false; // Let all messages go through sendChat for AI response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3090
  }
3091
  </script>
3092
  <script>