LABEQ / coach.js
leeennn009's picture
Deploy LABEQ source 7f17d316abef on ZeroGPU
43309f8 verified
Raw History Blame Contribute Delete
2.83 kB
/* LABEQ V16 - context-grounded coaching only.
* No hard-coded situation quotes. The coaching text is generated by Qwen base,
* never represented as Faisal's own rationale or as external validation. */
(()=>{
'use strict';
const id=(key)=>document.getElementById(key);
const clean=(s)=>typeof s==='string'?s.trim():'';
const styles={polite:'لبق',firm:'حازم',diplomatic:'دبلوماسي',apology:'اعتذار',clarify:'طلب توضيح'};
function compareCard(item,label){
const card=document.createElement('div');
card.className='coach-comparison-card';
const title=document.createElement('strong');
title.textContent=label+' · '+(styles[item.style]||'أسلوب الرد');
const reply=document.createElement('p');
reply.textContent=item.reply;
card.append(title,reply);
return card;
}
function syncResult({coaching,isDemo,comparison}){
const box=id('coachLearning');if(!box)return;
const c=coaching||{};
const strategy=clean(c.strategy), core=clean(c.core), risk=clean(c.risk);
if(isDemo||(!strategy&&!core&&!risk)) {box.hidden=true;return;}
box.hidden=false;
id('coachGlimpse').textContent=strategy||core;
id('coachWhy').textContent=core||clean(c.objective)||'لم يكتمل تحليل الموقف.';
id('coachWatch').textContent=risk||'راجعي المعنى قبل الإرسال، خاصة أي تفاصيل لم تذكريها.';
const compare=id('coachCompareCards');compare.replaceChildren();
if(comparison){
compare.append(compareCard(comparison.before,'الرد الأول'),compareCard(comparison.after,'الرد الثاني'));
}
const p=document.createElement('p');p.className='contextual-comparison-help';
p.textContent='الاختلاف الحقيقي بين الأسلوبين يبان في ردّين مولّدين لنفس الموقف؛ جرّبي أسلوبًا ثانيًا للمقارنة بدل أمثلة عامة.';
if(!comparison)compare.append(p);
const b=document.createElement('button');b.type='button';b.className='action-button';b.textContent='جرّبي أسلوبًا ثانيًا';
b.addEventListener('click',()=>{
const opts=id('replyOptions');if(opts)opts.open=true;
const btn=id('changeStyleBtn');if(btn)btn.click();
opts?.scrollIntoView?.({behavior:'smooth',block:'center'});
});compare.append(b);
const note=box.querySelector('.coach-disclaimer');
if(note)note.textContent='الشرح ناتج عن خطوة تخطيط آلية باستخدام Qwen الأساسي، وليس تفسيرًا داخليًا لقرار فيصل أو تقييمًا بشريًا.';
}
function clearResult(){const box=id('coachLearning');if(box)box.hidden=true;for(const key of ['coachInsight','coachCompare']){const el=id(key);if(el)el.open=false;}}
window.labeqCoach={syncResult,clearResult,reset:clearResult};
})();