+470
-214
@@ -1,243 +1,499 @@
|
||||
(function ($) {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
var reCaptchaSiteKey = null;
|
||||
var gTagManagerId = null;
|
||||
var CONSENT_KEY = "myai_cookie_consent";
|
||||
var reCaptchaSiteKey = null;
|
||||
var gTagManagerId = null;
|
||||
var CONSENT_KEY = "myai_cookie_consent";
|
||||
var LANG_KEY = "myai_lang";
|
||||
|
||||
$('#year').text(new Date().getFullYear());
|
||||
var i18n = {
|
||||
en: {
|
||||
"brand.subtitle": "AI engineering showcase",
|
||||
"nav.demos": "Demos",
|
||||
"nav.contact": "Contact",
|
||||
"nav.navigator": "Navigator",
|
||||
"nav.matcher": "Matcher",
|
||||
"home.eyebrow": "Applied AI lab",
|
||||
"home.title": "Production-minded AI demos, not generic chatbot wrappers.",
|
||||
"home.text": "MyAi.ro is a technical showcase for practical AI systems: document understanding, retrieval, matching, automation and decision support.",
|
||||
"home.openCv": "Open CV Matcher",
|
||||
"home.step1": "CV.pdf",
|
||||
"home.step2": "skills, projects, experience",
|
||||
"home.step3": "relevant CV context",
|
||||
"home.step4": "job match + gaps",
|
||||
"home.navigator": "Navigator",
|
||||
"home.selectDemo": "Select an AI demo",
|
||||
"home.selectText": "Our first steps in AI integrations.",
|
||||
"tag.available": "Available",
|
||||
"tag.next": "Next",
|
||||
"demo.cv.title": "CV Matcher",
|
||||
"demo.cv.text": "Upload a CV PDF, provide a job link or description, extract RAG context and generate a match score with strengths and gaps.",
|
||||
"demo.open": "Open demo →",
|
||||
"demo.rag.title": "RAG Playground",
|
||||
"demo.rag.text": "Experiment with chunk size, retrieval count and source context transparency.",
|
||||
"demo.agent.title": "Agent Automation",
|
||||
"demo.agent.text": "Job discovery, filtering, ranking and notification workflows.",
|
||||
"contact.title": "Discuss an AI integration or custom software project",
|
||||
"contact.text": "Fill in the form fields and will contact you.",
|
||||
"contact.person": "Contact person",
|
||||
"contact.phone": "Phone",
|
||||
"form.name": "Name",
|
||||
"form.namePlaceholder": "Your name",
|
||||
"form.email": "Email",
|
||||
"form.emailPlaceholder": "name@company.com",
|
||||
"form.message": "Message",
|
||||
"form.messagePlaceholder": "Tell me what you want to build.",
|
||||
"form.send": "Send message",
|
||||
"form.thanks": "Thank you for your message.",
|
||||
"form.captchaFailed": "Captcha verification failed.",
|
||||
"form.failed": "Failed to send the message.",
|
||||
"footer.rights": "All rights reserved",
|
||||
"footer.top": "Back to top",
|
||||
"legal.terms": "Terms",
|
||||
"legal.privacy": "Privacy",
|
||||
"legal.cookies": "Cookies",
|
||||
"status.sending": "Sending...",
|
||||
"cookies.title": "Cookies",
|
||||
"cookies.text": "We use necessary cookies and, with your consent, analytics through Google Tag Manager.",
|
||||
"cookies.policy": "Privacy policy",
|
||||
"cookies.reject": "Reject",
|
||||
"cookies.necessary": "Necessary only",
|
||||
"cookies.accept": "Accept analytics",
|
||||
"cookies.settings": "Cookie settings",
|
||||
"cv.brand": "CV Matcher",
|
||||
"cv.eyebrow": "AI CV Matcher",
|
||||
"cv.title": "Upload your CV, add a job link, and see how well they match.",
|
||||
"cv.text": "The backend should extract text from the PDF, create RAG context from your CV, retrieve relevant experience for the job, then score strengths, gaps and next actions.",
|
||||
"cv.try": "Try matcher",
|
||||
"cv.back": "Back to navigator",
|
||||
"cv.step1": "PDF text extraction",
|
||||
"cv.step2": "CV chunking + embeddings",
|
||||
"cv.step3": "Job URL/description parsing",
|
||||
"cv.step4": "Match score + evidence",
|
||||
"cv.input": "Input",
|
||||
"cv.details": "CV and job details",
|
||||
"cv.upload": "Upload CV PDF",
|
||||
"cv.fileHint": "PDF only, max size handled by backend",
|
||||
"cv.jobLink": "Job link",
|
||||
"cv.jobDescription": "Or paste job description",
|
||||
"cv.jobPlaceholder": "Paste the job description if the page cannot be crawled.",
|
||||
"cv.gdpr": "I agree that my CV is processed for this matching demo. Do not upload sensitive documents unless you trust the deployment.",
|
||||
"cv.submit": "Extract CV and match job",
|
||||
"cv.result": "Result",
|
||||
"cv.analysis": "Match analysis",
|
||||
"cv.empty": "Upload a CV and provide a job link or description to generate a result.",
|
||||
"cv.contactTitle": "Want this adapted for your workflow?",
|
||||
"cv.contactText": "This form uses the existing template contact API endpoint.",
|
||||
"cv.noFile": "Please upload a CV PDF.",
|
||||
"cv.noJob": "Add a job link or paste a job description.",
|
||||
"cv.noConsent": "GDPR consent is required.",
|
||||
"cv.processing": "Processing...",
|
||||
"cv.extracting": "Extracting CV and matching job...",
|
||||
"cv.processingLong": "Processing CV PDF and job input. Backend endpoints must be available.",
|
||||
"cv.cvFailed": "CV extraction failed",
|
||||
"cv.matchFailed": "Job matching failed",
|
||||
"cv.completed": "Match completed.",
|
||||
"cv.backendMissing": "The frontend is ready, but the backend endpoints /api/rag/cv and /api/rag/match-job must be implemented.",
|
||||
"cv.noSummary": "No summary returned.",
|
||||
"cv.noItems": "No items returned.",
|
||||
"cv.strengths": "Strengths",
|
||||
"cv.gaps": "Gaps",
|
||||
"cv.evidence": "Retrieved CV evidence"
|
||||
},
|
||||
ro: {
|
||||
"brand.subtitle": "prezentare inginerie AI",
|
||||
"nav.demos": "Demo-uri",
|
||||
"nav.contact": "Contact",
|
||||
"nav.navigator": "Navigator",
|
||||
"nav.matcher": "Matcher",
|
||||
"home.eyebrow": "Laborator AI aplicat",
|
||||
"home.title": "Demo-uri AI orientate spre producție, nu simple wrapper-e de chatbot.",
|
||||
"home.text": "MyAi.ro este o prezentare tehnică pentru sisteme AI practice: înțelegere documente, retrieval, potrivire, automatizare și suport decizional.",
|
||||
"home.openCv": "Deschide CV Matcher",
|
||||
"home.step1": "CV.pdf",
|
||||
"home.step2": "competențe, proiecte, experiență",
|
||||
"home.step3": "context relevant din CV",
|
||||
"home.step4": "potrivire job + lipsuri",
|
||||
"home.navigator": "Navigator",
|
||||
"home.selectDemo": "Alege un demo AI",
|
||||
"home.selectText": "Primele noastre projecte",
|
||||
"tag.available": "Disponibil",
|
||||
"tag.next": "Urmează",
|
||||
"demo.cv.title": "CV Matcher",
|
||||
"demo.cv.text": "Încarcă un CV PDF, adaugă un link sau o descriere de job, extrage context RAG și generează un scor de potrivire cu puncte forte și lipsuri.",
|
||||
"demo.open": "Deschide demo →",
|
||||
"demo.rag.title": "RAG Playground",
|
||||
"demo.rag.text": "Experimentează cu dimensiunea chunk-urilor, numărul de rezultate și transparența surselor.",
|
||||
"demo.agent.title": "Automatizare cu agenți",
|
||||
"demo.agent.text": "Fluxuri pentru descoperire joburi, filtrare, ranking și notificări.",
|
||||
"contact.title": "Discută o integrare AI sau un proiect software custom",
|
||||
"contact.text": "Complecteaza formularul si te vom contacta.",
|
||||
"contact.person": "Persoană de contact",
|
||||
"contact.phone": "Telefon",
|
||||
"form.name": "Nume",
|
||||
"form.namePlaceholder": "Numele tău",
|
||||
"form.email": "Email",
|
||||
"form.emailPlaceholder": "nume@companie.ro",
|
||||
"form.message": "Mesaj",
|
||||
"form.messagePlaceholder": "Spune-mi ce vrei să construiești.",
|
||||
"form.send": "Trimite mesajul",
|
||||
"form.thanks": "Mulțumesc pentru mesaj.",
|
||||
"form.captchaFailed": "Verificarea Captcha a eșuat.",
|
||||
"form.failed": "Mesajul nu a putut fi trimis.",
|
||||
"footer.rights": "Toate drepturile rezervate",
|
||||
"footer.top": "Înapoi sus",
|
||||
"legal.terms": "Termeni",
|
||||
"legal.privacy": "Confidențialitate",
|
||||
"legal.cookies": "Cookies",
|
||||
"status.sending": "Se trimite...",
|
||||
"cookies.title": "Cookies",
|
||||
"cookies.text": "Folosim cookies necesare și, cu acordul tău, analytics prin Google Tag Manager.",
|
||||
"cookies.policy": "Politica de confidențialitate",
|
||||
"cookies.reject": "Respinge",
|
||||
"cookies.necessary": "Doar necesare",
|
||||
"cookies.accept": "Accept analytics",
|
||||
"cookies.settings": "Setări cookies",
|
||||
"cv.brand": "CV Matcher",
|
||||
"cv.eyebrow": "AI CV Matcher",
|
||||
"cv.title": "Încarcă CV-ul, adaugă un link de job și vezi cât de bine se potrivesc.",
|
||||
"cv.text": "Backend-ul ar trebui să extragă textul din PDF, să creeze context RAG din CV, să recupereze experiența relevantă pentru job, apoi să calculeze punctele forte, lipsurile și pașii următori.",
|
||||
"cv.try": "Încearcă matcherul",
|
||||
"cv.back": "Înapoi la navigator",
|
||||
"cv.step1": "Extragere text PDF",
|
||||
"cv.step2": "Chunking CV + embeddings",
|
||||
"cv.step3": "Parsare URL/descriere job",
|
||||
"cv.step4": "Scor potrivire + dovezi",
|
||||
"cv.input": "Date de intrare",
|
||||
"cv.details": "CV și detalii job",
|
||||
"cv.upload": "Încarcă CV PDF",
|
||||
"cv.fileHint": "Doar PDF, limita de mărime este gestionată de backend",
|
||||
"cv.jobLink": "Link job",
|
||||
"cv.jobDescription": "Sau lipește descrierea jobului",
|
||||
"cv.jobPlaceholder": "Lipește descrierea jobului dacă pagina nu poate fi citită automat.",
|
||||
"cv.gdpr": "Sunt de acord ca CV-ul meu să fie procesat pentru acest demo de matching. Nu încărca documente sensibile dacă nu ai încredere în deployment.",
|
||||
"cv.submit": "Extrage CV și compară jobul",
|
||||
"cv.result": "Rezultat",
|
||||
"cv.analysis": "Analiză potrivire",
|
||||
"cv.empty": "Încarcă un CV și adaugă un link sau o descriere de job pentru a genera rezultatul.",
|
||||
"cv.contactTitle": "Vrei să adaptezi asta pentru workflow-ul tău?",
|
||||
"cv.contactText": "Formularul folosește endpoint-ul existent de contact din template.",
|
||||
"cv.noFile": "Te rog încarcă un CV PDF.",
|
||||
"cv.noJob": "Adaugă un link de job sau lipește descrierea jobului.",
|
||||
"cv.noConsent": "Consimțământul GDPR este obligatoriu.",
|
||||
"cv.processing": "Se procesează...",
|
||||
"cv.extracting": "Se extrage CV-ul și se compară jobul...",
|
||||
"cv.processingLong": "Se procesează PDF-ul și informațiile despre job. Endpoint-urile backend trebuie să fie disponibile.",
|
||||
"cv.cvFailed": "Extragerea CV-ului a eșuat",
|
||||
"cv.matchFailed": "Matching-ul jobului a eșuat",
|
||||
"cv.completed": "Matching finalizat.",
|
||||
"cv.backendMissing": "Frontend-ul este pregătit, dar endpoint-urile backend /api/rag/cv și /api/rag/match-job trebuie implementate.",
|
||||
"cv.noSummary": "Nu a fost returnat niciun sumar.",
|
||||
"cv.noItems": "Nu au fost returnate elemente.",
|
||||
"cv.strengths": "Puncte forte",
|
||||
"cv.gaps": "Lipsuri",
|
||||
"cv.evidence": "Dovezi recuperate din CV"
|
||||
}
|
||||
};
|
||||
|
||||
$('#menuToggle').on('click', function () {
|
||||
var $nav = $('#mainNav');
|
||||
var open = !$nav.hasClass('is-open');
|
||||
$nav.toggleClass('is-open', open);
|
||||
$(this).attr('aria-expanded', open ? 'true' : 'false');
|
||||
});
|
||||
function browserLang() {
|
||||
return ((navigator.language || navigator.userLanguage || 'en').toLowerCase().indexOf('ro') === 0) ? 'ro' : 'en';
|
||||
}
|
||||
|
||||
$('.nav a').on('click', function () {
|
||||
$('#mainNav').removeClass('is-open');
|
||||
$('#menuToggle').attr('aria-expanded', 'false');
|
||||
});
|
||||
function currentLang() {
|
||||
return localStorage.getItem(LANG_KEY) || browserLang();
|
||||
}
|
||||
|
||||
function getRecaptchaWebKey() {
|
||||
return $.get('/api/contact').done(function (res) {
|
||||
reCaptchaSiteKey = res;
|
||||
if (reCaptchaSiteKey && !window.__recaptcha_loaded) {
|
||||
window.__recaptcha_loaded = true;
|
||||
var script = document.createElement('script');
|
||||
script.setAttribute('src', 'https://www.google.com/recaptcha/api.js?render=' + reCaptchaSiteKey);
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
}).fail(function () {
|
||||
console.warn('Could not load reCaptcha site key from /api/contact');
|
||||
});
|
||||
}
|
||||
function t(key) {
|
||||
var lang = currentLang();
|
||||
return (i18n[lang] && i18n[lang][key]) || i18n.en[key] || key;
|
||||
}
|
||||
|
||||
function getGoogleTagManagerId() {
|
||||
return $.get('/api/google/tagmanager').done(function (res) {
|
||||
gTagManagerId = res;
|
||||
}).fail(function () {
|
||||
console.warn('Could not load Google Tag Manager id from /api/google/tagmanager');
|
||||
});
|
||||
}
|
||||
function updateLegalLinks(lang) {
|
||||
$('[data-legal]').each(function () {
|
||||
var page = $(this).data('legal');
|
||||
$(this).attr('href', '/legal/' + page + '-' + lang + '.html');
|
||||
});
|
||||
}
|
||||
|
||||
function loadGoogleTagManager() {
|
||||
if (window.__gtm_loaded || !gTagManagerId) return;
|
||||
window.__gtm_loaded = true;
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
|
||||
var script = document.createElement('script');
|
||||
script.async = true;
|
||||
script.src = 'https://www.googletagmanager.com/gtm/js?id=' + gTagManagerId;
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
function applyLanguage(lang) {
|
||||
localStorage.setItem(LANG_KEY, lang);
|
||||
document.documentElement.lang = lang;
|
||||
updateLegalLinks(lang);
|
||||
$('[data-i18n]').each(function () {
|
||||
$(this).text(t($(this).data('i18n')));
|
||||
});
|
||||
$('[data-i18n-placeholder]').each(function () {
|
||||
$(this).attr('placeholder', t($(this).data('i18n-placeholder')));
|
||||
});
|
||||
$('.lang-flag').attr('aria-pressed', 'false');
|
||||
$('.lang-flag[data-lang="' + lang + '"]').attr('aria-pressed', 'true');
|
||||
}
|
||||
|
||||
function getConsent() {
|
||||
try { return JSON.parse(localStorage.getItem(CONSENT_KEY)); } catch { return null; }
|
||||
}
|
||||
$('#year').text(new Date().getFullYear());
|
||||
applyLanguage(currentLang());
|
||||
$('.lang-flag').on('click', function () {
|
||||
applyLanguage($(this).data('lang'));
|
||||
});
|
||||
|
||||
function setConsent(consent) {
|
||||
localStorage.setItem(CONSENT_KEY, JSON.stringify(consent));
|
||||
}
|
||||
$('#menuToggle').on('click', function () {
|
||||
var $nav = $('#mainNav');
|
||||
var open = !$nav.hasClass('is-open');
|
||||
$nav.toggleClass('is-open', open);
|
||||
$(this).attr('aria-expanded', open ? 'true' : 'false');
|
||||
});
|
||||
$('.nav a').on('click', function () {
|
||||
$('#mainNav').removeClass('is-open');
|
||||
$('#menuToggle').attr('aria-expanded', 'false');
|
||||
});
|
||||
|
||||
function applyConsent(consent) {
|
||||
if (consent && consent.analytics === true) loadGoogleTagManager();
|
||||
}
|
||||
function getRecaptchaWebKey() {
|
||||
return $.get('/api/contact').done(function (res) {
|
||||
reCaptchaSiteKey = res;
|
||||
if (reCaptchaSiteKey && !window.__recaptcha_loaded) {
|
||||
window.__recaptcha_loaded = true;
|
||||
var script = document.createElement('script');
|
||||
script.setAttribute('src', 'https://www.google.com/recaptcha/api.js?render=' + reCaptchaSiteKey);
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
}).fail(function () {
|
||||
console.warn('Could not load reCaptcha site key from /api/contact');
|
||||
});
|
||||
}
|
||||
|
||||
function showBanner() { $('#cookieBanner').fadeIn(200); }
|
||||
function hideBanner() { $('#cookieBanner').fadeOut(200); }
|
||||
function showManage() { $('#cookieManage').show(); }
|
||||
function getGoogleTagManagerId() {
|
||||
return $.get('/api/google/tagmanager').done(function (res) {
|
||||
gTagManagerId = res;
|
||||
}).fail(function () {
|
||||
console.warn('Could not load Google Tag Manager id from /api/google/tagmanager');
|
||||
});
|
||||
}
|
||||
|
||||
$('#cookieReject, #cookieNecessary').on('click', function () {
|
||||
setConsent({ necessary: true, analytics: false, ts: new Date().toISOString() });
|
||||
hideBanner();
|
||||
showManage();
|
||||
});
|
||||
function loadGoogleTagManager() {
|
||||
if (window.__gtm_loaded || !gTagManagerId) return;
|
||||
window.__gtm_loaded = true;
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
window.dataLayer.push({
|
||||
'gtm.start': new Date().getTime(),
|
||||
event: 'gtm.js'
|
||||
});
|
||||
var script = document.createElement('script');
|
||||
script.async = true;
|
||||
script.src = 'https://www.googletagmanager.com/gtm/js?id=' + gTagManagerId;
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
$('#cookieAccept').on('click', function () {
|
||||
var consent = { necessary: true, analytics: true, ts: new Date().toISOString() };
|
||||
setConsent(consent);
|
||||
applyConsent(consent);
|
||||
hideBanner();
|
||||
showManage();
|
||||
});
|
||||
function getConsent() {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(CONSENT_KEY));
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$('#cookieManage').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
showBanner();
|
||||
});
|
||||
function setConsent(consent) {
|
||||
localStorage.setItem(CONSENT_KEY, JSON.stringify(consent));
|
||||
}
|
||||
|
||||
function initConsent() {
|
||||
var consent = getConsent();
|
||||
if (!consent) showBanner();
|
||||
else { applyConsent(consent); showManage(); }
|
||||
}
|
||||
function applyConsent(consent) {
|
||||
if (consent && consent.analytics === true) loadGoogleTagManager();
|
||||
}
|
||||
|
||||
function submitMSG(valid, msg) {
|
||||
var msgClasses = valid ? 'form-message text-success' : 'form-message text-danger';
|
||||
$('#msgSubmit').removeClass().addClass(msgClasses).text(msg);
|
||||
}
|
||||
function showBanner() {
|
||||
$('#cookieBanner').fadeIn(200);
|
||||
}
|
||||
|
||||
function formSuccess() {
|
||||
$('#contactForm')[0].reset();
|
||||
submitMSG(true, 'Thank you for your message.');
|
||||
}
|
||||
function hideBanner() {
|
||||
$('#cookieBanner').fadeOut(200);
|
||||
}
|
||||
|
||||
function formError() {
|
||||
$('#contactForm').removeClass().addClass('contact-form shake').one('animationend', function () {
|
||||
$(this).removeClass('shake');
|
||||
});
|
||||
}
|
||||
function showManage() {
|
||||
$('#cookieManage').show();
|
||||
}
|
||||
$('#cookieReject, #cookieNecessary').on('click', function () {
|
||||
setConsent({
|
||||
necessary: true,
|
||||
analytics: false,
|
||||
ts: new Date().toISOString()
|
||||
});
|
||||
hideBanner();
|
||||
showManage();
|
||||
});
|
||||
$('#cookieAccept').on('click', function () {
|
||||
var consent = {
|
||||
necessary: true,
|
||||
analytics: true,
|
||||
ts: new Date().toISOString()
|
||||
};
|
||||
setConsent(consent);
|
||||
applyConsent(consent);
|
||||
hideBanner();
|
||||
showManage();
|
||||
});
|
||||
$('#cookieManage').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
showBanner();
|
||||
});
|
||||
|
||||
$('#contactForm').on('submit', function (event) {
|
||||
event.preventDefault();
|
||||
var loader = $('#contactLoader');
|
||||
var button = $('#submit');
|
||||
loader.css('display', 'flex');
|
||||
button.prop('disabled', true);
|
||||
$('#msgSubmit').text('');
|
||||
function initConsent() {
|
||||
var consent = getConsent();
|
||||
if (!consent) showBanner();
|
||||
else {
|
||||
applyConsent(consent);
|
||||
showManage();
|
||||
}
|
||||
}
|
||||
|
||||
function postContact(token) {
|
||||
var message = {
|
||||
Name: $('#name').val(),
|
||||
Email: $('#email').val(),
|
||||
Subject: '[MyAi.ro contact request]',
|
||||
Message: $('#message').val(),
|
||||
CaptchaToken: token || ''
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/contact',
|
||||
data: JSON.stringify(message),
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
dataType: 'json'
|
||||
}).done(function (resp) {
|
||||
if (resp && resp.ok === true) formSuccess();
|
||||
else submitMSG(false, 'Captcha verification failed.');
|
||||
}).fail(function () {
|
||||
submitMSG(false, 'Failed to send the message.');
|
||||
formError();
|
||||
}).always(function () {
|
||||
loader.hide();
|
||||
button.prop('disabled', false);
|
||||
});
|
||||
}
|
||||
function submitMSG(valid, msg) {
|
||||
$('#msgSubmit').removeClass().addClass(valid ? 'form-message text-success' : 'form-message text-danger').text(msg);
|
||||
}
|
||||
|
||||
if (window.grecaptcha && reCaptchaSiteKey) {
|
||||
grecaptcha.ready(function () {
|
||||
grecaptcha.execute(reCaptchaSiteKey, { action: 'contact' }).then(postContact);
|
||||
});
|
||||
} else {
|
||||
postContact('');
|
||||
}
|
||||
});
|
||||
function formSuccess() {
|
||||
$('#contactForm')[0].reset();
|
||||
submitMSG(true, t('form.thanks'));
|
||||
}
|
||||
|
||||
$('#cvFile').on('change', function () {
|
||||
var file = this.files && this.files[0];
|
||||
$('#cvFileName').text(file ? file.name : 'PDF only, max size handled by backend');
|
||||
});
|
||||
function formError() {
|
||||
$('#contactForm').removeClass().addClass('contact-form shake').one('animationend', function () {
|
||||
$(this).removeClass('shake');
|
||||
});
|
||||
}
|
||||
|
||||
$('#cvMatcherForm').on('submit', async function (event) {
|
||||
event.preventDefault();
|
||||
var file = $('#cvFile')[0] && $('#cvFile')[0].files[0];
|
||||
var jobUrl = $('#jobUrl').val();
|
||||
var jobDescription = $('#jobDescription').val();
|
||||
var consent = $('#gdprConsent').is(':checked');
|
||||
var $msg = $('#matcherMsg');
|
||||
var $button = $('#matchSubmit');
|
||||
var $result = $('#matchResult');
|
||||
$('#contactForm').on('submit', function (event) {
|
||||
event.preventDefault();
|
||||
var loader = $('#contactLoader'),
|
||||
button = $('#submit');
|
||||
loader.css('display', 'flex');
|
||||
button.prop('disabled', true);
|
||||
$('#msgSubmit').text('');
|
||||
|
||||
if (!file) { $msg.removeClass().addClass('form-message text-danger').text('Please upload a CV PDF.'); return; }
|
||||
if (!jobUrl && !jobDescription) { $msg.removeClass().addClass('form-message text-danger').text('Add a job link or paste a job description.'); return; }
|
||||
if (!consent) { $msg.removeClass().addClass('form-message text-danger').text('GDPR consent is required.'); return; }
|
||||
function postContact(token) {
|
||||
var message = {
|
||||
Name: $('#name').val(),
|
||||
Email: $('#email').val(),
|
||||
Subject: '[MyAi.ro contact request]',
|
||||
Message: $('#message').val(),
|
||||
CaptchaToken: token || ''
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/contact',
|
||||
data: JSON.stringify(message),
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
dataType: 'json'
|
||||
}).done(function (resp) {
|
||||
if (resp && resp.ok === true) formSuccess();
|
||||
else submitMSG(false, t('form.captchaFailed'));
|
||||
}).fail(function () {
|
||||
submitMSG(false, t('form.failed'));
|
||||
formError();
|
||||
}).always(function () {
|
||||
loader.hide();
|
||||
button.prop('disabled', false);
|
||||
});
|
||||
}
|
||||
if (window.grecaptcha && reCaptchaSiteKey) {
|
||||
grecaptcha.ready(function () {
|
||||
grecaptcha.execute(reCaptchaSiteKey, {
|
||||
action: 'contact'
|
||||
}).then(postContact);
|
||||
});
|
||||
} else {
|
||||
postContact('');
|
||||
}
|
||||
});
|
||||
|
||||
$button.prop('disabled', true).text('Processing...');
|
||||
$msg.removeClass().addClass('form-message').text('Extracting CV and matching job...');
|
||||
$result.html('<div class="empty-result">Processing CV PDF and job input. Backend endpoints must be available.</div>');
|
||||
$('#cvFile').on('change', function () {
|
||||
var file = this.files && this.files[0];
|
||||
$('#cvFileName').text(file ? file.name : t('cv.fileHint'));
|
||||
});
|
||||
$('#cvMatcherForm').on('submit', async function (event) {
|
||||
event.preventDefault();
|
||||
var file = $('#cvFile')[0] && $('#cvFile')[0].files[0];
|
||||
var jobUrl = $('#jobUrl').val();
|
||||
var jobDescription = $('#jobDescription').val();
|
||||
var consent = $('#gdprConsent').is(':checked');
|
||||
var $msg = $('#matcherMsg'),
|
||||
$button = $('#matchSubmit'),
|
||||
$result = $('#matchResult');
|
||||
if (!file) {
|
||||
$msg.removeClass().addClass('form-message text-danger').text(t('cv.noFile'));
|
||||
return;
|
||||
}
|
||||
if (!jobUrl && !jobDescription) {
|
||||
$msg.removeClass().addClass('form-message text-danger').text(t('cv.noJob'));
|
||||
return;
|
||||
}
|
||||
if (!consent) {
|
||||
$msg.removeClass().addClass('form-message text-danger').text(t('cv.noConsent'));
|
||||
return;
|
||||
}
|
||||
$button.prop('disabled', true).text(t('cv.processing'));
|
||||
$msg.removeClass().addClass('form-message').text(t('cv.extracting'));
|
||||
$result.html('<div class="empty-result">' + escapeHtml(t('cv.processingLong')) + '</div>');
|
||||
try {
|
||||
var formData = new FormData();
|
||||
formData.append('cv', file);
|
||||
formData.append('gdprConsent', String(consent));
|
||||
var cvResponse = await fetch('/api/rag/cv', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
if (!cvResponse.ok) throw new Error(t('cv.cvFailed'));
|
||||
var cvData = await cvResponse.json();
|
||||
var matchResponse = await fetch('/api/rag/match-job', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
cvDocumentId: cvData.documentId || cvData.cvDocumentId,
|
||||
jobUrl: jobUrl,
|
||||
jobDescription: jobDescription,
|
||||
gdprConsent: consent
|
||||
})
|
||||
});
|
||||
if (!matchResponse.ok) throw new Error(t('cv.matchFailed'));
|
||||
var match = await matchResponse.json();
|
||||
renderMatchResult(match);
|
||||
$msg.removeClass().addClass('form-message text-success').text(t('cv.completed'));
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
$msg.removeClass().addClass('form-message text-danger').text(err.message || t('cv.matchFailed'));
|
||||
$result.html('<div class="empty-result">' + escapeHtml(t('cv.backendMissing')) + '</div>');
|
||||
} finally {
|
||||
$button.prop('disabled', false).text(t('cv.submit'));
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
var formData = new FormData();
|
||||
formData.append('cv', file);
|
||||
formData.append('gdprConsent', String(consent));
|
||||
function renderMatchResult(match) {
|
||||
var score = match.score || match.matchScore || 0;
|
||||
var summary = match.summary || t('cv.noSummary');
|
||||
var strengths = match.strengths || [];
|
||||
var gaps = match.gaps || match.missingSkills || [];
|
||||
var evidence = match.evidence || match.retrievedChunks || [];
|
||||
|
||||
var cvResponse = await fetch('/api/rag/cv', { method: 'POST', body: formData });
|
||||
if (!cvResponse.ok) throw new Error('CV extraction failed');
|
||||
var cvData = await cvResponse.json();
|
||||
function list(items) {
|
||||
if (!items || !items.length) return '<p class="empty-result">' + escapeHtml(t('cv.noItems')) + '</p>';
|
||||
return '<ul class="result-list">' + items.map(function (x) {
|
||||
var text = typeof x === 'string' ? x : (x.text || x.title || JSON.stringify(x));
|
||||
return '<li>' + escapeHtml(text) + '</li>';
|
||||
}).join('') + '</ul>';
|
||||
}
|
||||
$('#matchResult').html('<div class="score-badge">' + Number(score).toFixed(0) + '%</div><p>' + escapeHtml(summary) + '</p><h3>' + t('cv.strengths') + '</h3>' + list(strengths) + '<h3>' + t('cv.gaps') + '</h3>' + list(gaps) + '<h3>' + t('cv.evidence') + '</h3>' + list(evidence));
|
||||
}
|
||||
|
||||
var matchResponse = await fetch('/api/rag/match-job', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
cvDocumentId: cvData.documentId || cvData.cvDocumentId,
|
||||
jobUrl: jobUrl,
|
||||
jobDescription: jobDescription,
|
||||
gdprConsent: consent
|
||||
})
|
||||
});
|
||||
if (!matchResponse.ok) throw new Error('Job matching failed');
|
||||
var match = await matchResponse.json();
|
||||
renderMatchResult(match);
|
||||
$msg.removeClass().addClass('form-message text-success').text('Match completed.');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
$msg.removeClass().addClass('form-message text-danger').text(err.message || 'Failed to run the matcher.');
|
||||
$result.html('<div class="empty-result">The frontend is ready, but the backend endpoints /api/rag/cv and /api/rag/match-job must be implemented.</div>');
|
||||
} finally {
|
||||
$button.prop('disabled', false).text('Extract CV and match job');
|
||||
}
|
||||
});
|
||||
|
||||
function renderMatchResult(match) {
|
||||
var score = match.score || match.matchScore || 0;
|
||||
var summary = match.summary || 'No summary returned.';
|
||||
var strengths = match.strengths || [];
|
||||
var gaps = match.gaps || match.missingSkills || [];
|
||||
var evidence = match.evidence || match.retrievedChunks || [];
|
||||
|
||||
function list(items) {
|
||||
if (!items || !items.length) return '<p class="empty-result">No items returned.</p>';
|
||||
return '<ul class="result-list">' + items.map(function (x) {
|
||||
var text = typeof x === 'string' ? x : (x.text || x.title || JSON.stringify(x));
|
||||
return '<li>' + escapeHtml(text) + '</li>';
|
||||
}).join('') + '</ul>';
|
||||
}
|
||||
|
||||
$('#matchResult').html(
|
||||
'<div class="score-badge">' + Number(score).toFixed(0) + '%</div>' +
|
||||
'<p>' + escapeHtml(summary) + '</p>' +
|
||||
'<h3>Strengths</h3>' + list(strengths) +
|
||||
'<h3>Gaps</h3>' + list(gaps) +
|
||||
'<h3>Retrieved CV evidence</h3>' + list(evidence)
|
||||
);
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value).replace(/[&<>'"]/g, function (char) {
|
||||
return ({ '&': '&', '<': '<', '>': '>', "'": ''', '"': '"' })[char];
|
||||
});
|
||||
}
|
||||
|
||||
$(window).on('load', function () {
|
||||
$.when(getRecaptchaWebKey(), getGoogleTagManagerId()).always(initConsent);
|
||||
});
|
||||
})(jQuery);
|
||||
function escapeHtml(value) {
|
||||
return String(value).replace(/[&<>'"]/g, function (char) {
|
||||
return ({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
"'": ''',
|
||||
'"': '"'
|
||||
})[char];
|
||||
});
|
||||
}
|
||||
$(window).on('load', function () {
|
||||
$.when(getRecaptchaWebKey(), getGoogleTagManagerId()).always(initConsent);
|
||||
});
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user