Spaces:
Running
Running
Download app.js from Hugdrigo/careermatch-ai: direct link, hf CLI and curl.
- Browser
- Download file 5.5 kB
-
https://huggingface.co/spaces/Hugdrigo/careermatch-ai/resolve/main/app.js
- Command line
-
hf download hf://spaces/Hugdrigo/careermatch-ai/app.js
-
curl -L -o app.js https://huggingface.co/spaces/Hugdrigo/careermatch-ai/resolve/main/app.js
5.5 kB
| (function(){ | |
| ; | |
| const $=id=>document.getElementById(id); | |
| const SAMPLE_CV=`Operations and project management professional with experience coordinating international teams, improving processes and supporting business operations. Managed cross-functional projects, stakeholder communication and KPI reporting. Advanced Excel, Power BI, data analysis and CRM experience. Built automation workflows and dashboards to reduce manual reporting. Research background in international business and economic development. Languages: Spanish, English, Italian and Portuguese.`; | |
| const SAMPLE_JOB=`We are hiring a Program Operations Manager. Required: 4+ years of experience in operations or project management, strong stakeholder management, KPI reporting, Excel and data analysis. The candidate must be comfortable coordinating cross-functional teams and documenting processes. Preferred: experience with Power BI, CRM systems, automation and international teams. English and Spanish are required. Experience with SQL is a plus.`; | |
| let result=null; | |
| const addText=(parent,tag,text,cls)=>{const el=document.createElement(tag);el.textContent=text;if(cls)el.className=cls;parent.appendChild(el);return el;}; | |
| function pillList(id,items,kind,empty){const el=$(id);el.replaceChildren();if(items.length===0){addText(el,'span',empty,'small');return;}items.forEach(t=>addText(el,'span',t,'tag '+kind));} | |
| function render(r){ | |
| $('score').textContent=r.score+'%';$('band').textContent=r.band; | |
| $('language').textContent=r.jobLang.length?'Job language mentions: '+r.jobLang.join(', ')+(r.missingLang.length?' · not stated in CV: '+r.missingLang.join(', '):' · all stated in CV'):'No explicit language requirement detected.'; | |
| const bars=$('bars');bars.replaceChildren();r.components.forEach(c=>{const line=addText(bars,'div','','meter-line');const head=addText(line,'div','','meter-top');addText(head,'span',c.name);addText(head,'strong',c.value+'%');const track=addText(line,'div','','track');const fill=addText(track,'div','','fill');fill.style.width=c.value+'%';addText(line,'div','Weight in composite: '+c.weight+'%','small');}); | |
| pillList('matched',r.matchedSkills,'match','No explicit matching taxonomy skills were found.'); | |
| pillList('missing',r.missingSkills,'miss','No unmentioned taxonomy skills detected.'); | |
| pillList('keywords',r.keywordsMatched,'match','No shared high-frequency job keywords detected.'); | |
| const req=$('requirements');req.replaceChildren();if(!r.reqs.length)addText(req,'p','No requirement sentences detected.','small'); | |
| r.reqs.forEach(row=>{const div=addText(req,'div','','result-req');const head=addText(div,'div','','req-head');addText(head,'span',row.importance,'req-kind');addText(head,'span',Math.round(row.evidence*100)+'% lexical evidence','req-evidence');addText(div,'div',row.text,'req-text');if(row.signals.length)addText(div,'div','Shared words: '+row.signals.join(', '),'req-evidence');}); | |
| const rec=$('recommendations');rec.replaceChildren();r.recommendations.forEach(s=>addText(rec,'li',s));$('method').textContent=r.method; | |
| $('results').hidden=false;$('export').hidden=false; | |
| } | |
| function showError(s){$('error').textContent=s;$('error').hidden=false;$('status').textContent='Please correct the input and try again.';} | |
| $('sample').addEventListener('click',()=>{$('cv').value=SAMPLE_CV;$('job').value=SAMPLE_JOB;$('cv-file').value='';$('job-file').value='';$('status').textContent='Example loaded. Click Analyze alignment.';}); | |
| $('clear').addEventListener('click',()=>{['cv','job'].forEach(id=>$(id).value='');['cv-file','job-file'].forEach(id=>$(id).value='');$('results').hidden=true;$('error').hidden=true;$('export').hidden=true;$('status').textContent='Ready.';result=null;}); | |
| async function fileText(id){const f=$(id).files[0];if(!f)return '';if(!/\.(txt|md)$/i.test(f.name))throw new Error('Only .txt and .md uploads are supported in this browser-only version. Paste PDF/DOCX text instead.');if(f.size>250000)throw new Error('File is too large (250 KB max).');return await f.text();} | |
| $('analyze').addEventListener('click',async()=>{try{$('error').hidden=true;$('status').textContent='Analyzing text locally…';const cv=[$('cv').value,await fileText('cv-file')].filter(Boolean).join('\n\n');const job=[$('job').value,await fileText('job-file')].filter(Boolean).join('\n\n');result=CareerMatchEngine.compare(cv,job);render(result);$('status').textContent='Analysis complete. All scoring ran locally in your browser.';$('results').scrollIntoView({behavior:'smooth',block:'start'});}catch(err){showError(err.message);}}); | |
| $('export').addEventListener('click',()=>{if(!result)return;const rows=['CareerMatch AI - Browser-only evidence alignment report','Rodrigo Pantoja','',`Composite text alignment: ${result.score}% (${result.band})`,'Method: '+result.method,'',...result.components.map(c=>`${c.name}: ${c.value}% (weight ${c.weight}%)`),'','Matched skills: '+result.matchedSkills.join(', '),'Unmentioned job skills: '+result.missingSkills.join(', '),'','Requirement evidence:',...result.reqs.map(r=>`${r.importance} (${Math.round(r.evidence*100)}%): ${r.text}`),'','Recommendations:',...result.recommendations.map(s=>'- '+s),'','NOT a hiring probability or actual qualification assessment.'];const blob=new Blob([rows.join('\n')],{type:'text/plain;charset=utf-8'});const url=URL.createObjectURL(blob);const link=document.createElement('a');link.href=url;link.download='careermatch-ai-report.txt';link.click();setTimeout(()=>URL.revokeObjectURL(url),2000);}); | |
| })(); | |