
@@ -2872,15 +2990,15 @@
let badgeHtml = '';
if (runner.passType === 'premium') {
- badgeHtml = `
Premium`;
+ badgeHtml = `
`;
} else if (runner.passType === 'pro') {
- badgeHtml = `
Pro`;
- } else if (runner.passType === 'medium') {
- badgeHtml = `
Medium`;
+ badgeHtml = `
`;
} else if (runner.passType === 'flash') {
- badgeHtml = `
Flash`;
+ badgeHtml = `
`;
+ } else if (runner.passType === 'lite') {
+ badgeHtml = `
`;
} else if (runner.isRecommended) {
- badgeHtml = `
Recommandé`;
+ badgeHtml = `
`;
}
reel.innerHTML = `
@@ -3308,11 +3426,14 @@
updateFilterChipsUI();
let filtered = runners.filter(r => {
- // Filtre texte
+ // Filtre texte (services, catégories, lieux, et personnes de manière transparente)
if (query) {
const matchText = r.title.toLowerCase().includes(query) ||
r.categoryName.toLowerCase().includes(query) ||
- r.name.toLowerCase().includes(query) ||
+ (r.name && r.name.toLowerCase().includes(query)) ||
+ (r.firstName && r.firstName.toLowerCase().includes(query)) ||
+ (r.lastName && r.lastName.toLowerCase().includes(query)) ||
+ (r.fullName && r.fullName.toLowerCase().includes(query)) ||
r.desc.toLowerCase().includes(query) ||
(r.city && r.city.toLowerCase().includes(query)) ||
(r.cluster && r.cluster.toLowerCase().includes(query)) ||
@@ -3366,7 +3487,7 @@
if (sortMode === 'distance') return (a.distanceKm || 0) - (b.distanceKm || 0);
// Pertinence par défaut
- const passRank = { premium: 5, pro: 4, medium: 3, flash: 2, free: 1 };
+ const passRank = { premium: 5, pro: 4, flash: 3, lite: 2, free: 2, none: 1 };
const scoreA = ((passRank[a.passType] || 1) * 12) + (a.isRecommended ? 8 : 0) + (parseFloat(a.rating) * 3) + (a.reviews / 10);
const scoreB = ((passRank[b.passType] || 1) * 12) + (b.isRecommended ? 8 : 0) + (parseFloat(b.rating) * 3) + (b.reviews / 10);
return scoreB - scoreA;
@@ -3689,7 +3810,65 @@
return scoreB - scoreA;
});
const featured = sortedByRelevance.slice(0, 6);
- homeRecs.innerHTML = featured.map(r => createRunnerCard(r)).join('');
+ if (homeRecs) homeRecs.innerHTML = featured.map(r => createRunnerCard(r)).join('');
+
+ updateHomeLikedAds();
+ updateHomeSearchBasedAds();
+ }
+
+ function updateHomeLikedAds() {
+ const container = document.getElementById('home-liked-container');
+ const section = document.getElementById('home-liked-section');
+ const countEl = document.getElementById('home-liked-count');
+ if (!container) return;
+
+ const likedRunners = runners.filter(r => favoriteIds.has(r.id));
+ if (countEl) countEl.textContent = likedRunners.length;
+
+ if (likedRunners.length === 0) {
+ container.innerHTML = `
+
+
+
Aucune annonce likée pour le moment.
+
Cliquez sur le cœur d'une annonce pour la retrouver ici.
+
`;
+ } else {
+ // Affiche les 3 premières annonces likées
+ container.innerHTML = likedRunners.slice(0, 3).map(r => createRunnerCard(r)).join('');
+ }
+ }
+
+ function updateHomeSearchBasedAds() {
+ const container = document.getElementById('home-history-container');
+ const section = document.getElementById('home-history-section');
+ if (!container) return;
+
+ // Déduire les annonces selon les mots-clés des dernières recherches
+ let matched = [];
+ if (recentSearches && recentSearches.length > 0) {
+ const keywords = recentSearches.map(s => s.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, ""));
+ matched = runners.filter(r => {
+ const titleNorm = (r.title || '').toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
+ const catNorm = (r.categoryName || '').toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
+ const descNorm = (r.desc || '').toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
+ return keywords.some(k => titleNorm.includes(k) || catNorm.includes(k) || descNorm.includes(k) || k.includes(catNorm));
+ });
+ }
+
+ // Si aucune correspondance exacte, proposer les prestataires les plus fiables
+ if (matched.length === 0) {
+ matched = runners.filter(r => r.rating >= 4.8).slice(0, 3);
+ }
+
+ const selection = matched.slice(0, 3);
+ if (selection.length === 0) {
+ container.innerHTML = `
+
+
Effectuez une recherche pour voir des suggestions personnalisées ici.
+
`;
+ } else {
+ container.innerHTML = selection.map(r => createRunnerCard(r)).join('');
+ }
}
function navigate(viewId, isBack = false) {
@@ -3816,29 +3995,29 @@
const badgeText = document.getElementById('detail-badge-text');
if (runner.passType === 'premium') {
- badgeContainer.innerHTML = `
`;
- badgeText.innerHTML = `
Top 1 Premium`;
- badgeText.className = "text-[10px] font-bold px-2.5 py-0.5 rounded-md bg-gradient-to-r from-gray-950 to-purple-950 text-purple-200 border border-purple-500/40 flex items-center gap-1";
+ badgeContainer.innerHTML = `
`;
+ badgeText.innerHTML = `
`;
+ badgeText.className = "p-1 rounded-full flex items-center justify-center";
} else if (runner.passType === 'pro') {
- badgeContainer.innerHTML = `
`;
- badgeText.innerHTML = `
Pass Pro`;
- badgeText.className = "text-[10px] font-bold px-2.5 py-0.5 rounded-md bg-rose-50 text-rose-700 border border-rose-200 flex items-center gap-1";
- } else if (runner.passType === 'medium') {
- badgeContainer.innerHTML = `
`;
- badgeText.innerHTML = `
Pass Medium`;
- badgeText.className = "text-[10px] font-bold px-2.5 py-0.5 rounded-md bg-emerald-50 text-emerald-700 border border-emerald-200 flex items-center gap-1";
+ badgeContainer.innerHTML = `
`;
+ badgeText.innerHTML = `
`;
+ badgeText.className = "p-1 rounded-full flex items-center justify-center";
} else if (runner.passType === 'flash') {
- badgeContainer.innerHTML = `
`;
- badgeText.innerHTML = `
Pass Flash`;
- badgeText.className = "text-[10px] font-bold px-2.5 py-0.5 rounded-md bg-blue-50 text-blue-700 border border-blue-200 flex items-center gap-1";
+ badgeContainer.innerHTML = `
`;
+ badgeText.innerHTML = `
`;
+ badgeText.className = "p-1 rounded-full flex items-center justify-center";
+ } else if (runner.passType === 'lite') {
+ badgeContainer.innerHTML = `
`;
+ badgeText.innerHTML = `
`;
+ badgeText.className = "p-1 rounded-full flex items-center justify-center";
} else if (runner.isRecommended) {
- badgeContainer.innerHTML = `
`;
- badgeText.innerHTML = `
Artisan Recommandé`;
- badgeText.className = "text-[10px] font-bold px-2 py-0.5 rounded-md bg-amber-100 text-amber-800 flex items-center gap-1";
+ badgeContainer.innerHTML = `
`;
+ badgeText.innerHTML = `
`;
+ badgeText.className = "p-1 rounded-full flex items-center justify-center";
} else {
badgeContainer.innerHTML = ``;
- badgeText.innerHTML = `Classique`;
- badgeText.className = "text-[10px] font-bold px-2 py-0.5 rounded-md bg-gray-100 text-gray-500";
+ badgeText.innerHTML = ``;
+ badgeText.className = "hidden";
}
updateDetailFavoriteIcon();
@@ -4307,7 +4486,16 @@
conv.lastMsg = reply;
renderMessagesList();
}
- }, 1000);
+
+ // Si l'utilisateur est actif sur le site, afficher le popup de notification
+ if (document.visibilityState === 'visible' && !document.hidden) {
+ triggerCustomModal(`Nouveau message de ${conv ? conv.name : 'votre contact'}`, "notification", true);
+ } else {
+ // S'il n'est pas sur le site, juste marquer non-lu et allumer le point rouge
+ if (conv) conv.unread = true;
+ updateMessagesNotification();
+ }
+ }, 1200);
}
function acceptContractAsClient(convId) {
@@ -5034,6 +5222,7 @@
localStorage.setItem('jr_recent_searches', JSON.stringify(recentSearches));
} catch(e) {}
renderRecentSearches();
+ if (typeof updateHomeSearchBasedAds === 'function') updateHomeSearchBasedAds();
}
function removeRecentSearch(idx) {
@@ -5043,6 +5232,7 @@
localStorage.setItem('jr_recent_searches', JSON.stringify(recentSearches));
} catch(e) {}
renderRecentSearches();
+ if (typeof updateHomeSearchBasedAds === 'function') updateHomeSearchBasedAds();
}
}
@@ -5149,39 +5339,120 @@
// Inscription libre sans blocage d'âge
}
- function simulateIdUpload() {
- document.getElementById('id-upload-placeholder').classList.add('hidden');
- document.getElementById('id-upload-success').classList.remove('hidden');
- triggerCustomModal("Pièce d'identité enregistrée avec succès.", "check");
-
- const codeStep = document.getElementById('kyc-code-step');
- if (codeStep) codeStep.classList.remove('hidden');
+ let pendingRegistration = null;
- const otpLabel = document.getElementById('kyc-otp-label');
- const otpInput = document.getElementById('kyc-code-input');
- const otpLoaderIcon = document.getElementById('kyc-otp-loader-icon');
-
- if (otpInput) {
- otpInput.value = '';
- otpInput.setAttribute('readonly', true);
- }
- if (otpLabel) otpLabel.textContent = 'Code envoyé… réception dans 2s';
-
- setTimeout(() => {
- if (otpInput) {
- otpInput.value = '4829';
- otpInput.removeAttribute('readonly');
- otpInput.classList.add('border-job-sage', 'bg-job-sage-light/30');
- }
- if (otpLoaderIcon) otpLoaderIcon.style.animation = 'none';
- if (otpLabel) {
- otpLabel.textContent = '✓ Code reçu par SMS — vérifiez et validez';
- otpLabel.className = 'text-xs font-bold text-job-sage';
- }
- triggerCustomModal("Code reçu et pré-rempli. Cliquez sur Créer mon compte.", "check");
- }, 1800);
+ function generateVerificationCode() {
+ return Math.floor(100000 + Math.random() * 900000).toString();
}
+ function openSimulatedEmailModal() {
+ const modal = document.getElementById('simulated-email-modal');
+ if (modal) {
+ modal.classList.remove('hidden');
+ modal.classList.add('flex');
+ }
+ }
+
+ function closeSimulatedEmailModal() {
+ const modal = document.getElementById('simulated-email-modal');
+ if (modal) {
+ modal.classList.add('hidden');
+ modal.classList.remove('flex');
+ }
+ }
+
+ function copyAndUseVerificationCode() {
+ if (pendingRegistration && pendingRegistration.code) {
+ const input = document.getElementById('reg-verify-code-input');
+ if (input) {
+ input.value = pendingRegistration.code;
+ input.classList.add('border-job-sage', 'bg-job-sage-light/30');
+ }
+ closeSimulatedEmailModal();
+ }
+ }
+
+ function resendVerificationEmail() {
+ if (!pendingRegistration) return;
+ pendingRegistration.code = generateVerificationCode();
+ document.getElementById('simulated-email-code-display').textContent = pendingRegistration.code;
+ document.getElementById('verify-email-target').textContent = pendingRegistration.email;
+ openSimulatedEmailModal();
+ }
+
+ function handleAccountRegisterSubmit(e) {
+ e.preventDefault();
+
+ const firstName = document.getElementById('reg-firstname').value.trim();
+ const lastName = document.getElementById('reg-lastname').value.trim();
+ const email = document.getElementById('reg-email').value.trim();
+ const phone = document.getElementById('reg-phone').value.trim();
+ const password = document.getElementById('reg-password').value;
+ const passwordConfirm = document.getElementById('reg-password-confirm').value;
+
+ if (password !== passwordConfirm) {
+ alert("Les deux mots de passe ne correspondent pas.");
+ return;
+ }
+
+ const verifyStep = document.getElementById('email-verify-step');
+ const codeInput = document.getElementById('reg-verify-code-input');
+
+ // Étape 1 : Si le code n'a pas encore été généré, envoyer le mail Jobrunner
+ if (!pendingRegistration || verifyStep.classList.contains('hidden')) {
+ const code = generateVerificationCode();
+ pendingRegistration = {
+ firstName,
+ lastName,
+ email,
+ phone,
+ password,
+ code
+ };
+
+ // Préparation de l'email officiel simulé
+ document.getElementById('verify-email-target').textContent = email;
+ document.getElementById('simulated-email-to').textContent = `${firstName} ${lastName} <${email}>`;
+ document.getElementById('simulated-email-recipient-name').textContent = firstName;
+ document.getElementById('simulated-email-code-display').textContent = code;
+
+ verifyStep.classList.remove('hidden');
+ document.getElementById('reg-submit-btn').textContent = "Confirmer et finaliser l'inscription";
+
+ // Ouvre l'email officiel reçu pour que l'utilisateur voie la simulation
+ openSimulatedEmailModal();
+ return;
+ }
+
+ // Étape 2 : Vérification du code saisi
+ const enteredCode = (codeInput.value || '').trim();
+ if (enteredCode !== pendingRegistration.code) {
+ codeInput.classList.add('border-rose-400');
+ codeInput.focus();
+ alert("Code de vérification incorrect. Veuillez renseigner le code à 6 chiffres reçu dans l'email Jobrunner.");
+ return;
+ }
+
+ // Inscription validée avec succès
+ currentUser.isLoggedIn = true;
+ currentUser.firstName = pendingRegistration.firstName;
+ currentUser.lastName = pendingRegistration.lastName;
+ currentUser.email = pendingRegistration.email;
+ currentUser.phone = pendingRegistration.phone;
+ currentUser.idVerified = true;
+ currentUser.passType = 'lite';
+
+ saveSession();
+ renderHeaderAuth();
+ updateProfilePassUI();
+ updateMessagesNotification();
+ closeAuthModal();
+ triggerCustomModal("Connecté", "check", true);
+ navigate('profile');
+ }
+
+ const handleKycRegister = handleAccountRegisterSubmit;
+
function loginAsChristophe() {
currentUser.isLoggedIn = true;
currentUser.firstName = "Christophe";
@@ -5193,7 +5464,7 @@
updateProfilePassUI();
updateMessagesNotification();
closeAuthModal();
- triggerCustomModal("Ravi de vous revoir, Christophe !", "check");
+ triggerCustomModal("Connecté", "check", true);
navigate('profile');
}
const loginAsNils = loginAsChristophe;
@@ -5229,52 +5500,16 @@
updateProfilePassUI();
updateMessagesNotification();
closeAuthModal();
- triggerCustomModal(`Connexion réussie ! Ravi de vous revoir, ${currentUser.firstName}.`, "check");
+ triggerCustomModal("Connecté", "check", true);
navigate('home');
}
- function handleKycRegister(e) {
- e.preventDefault();
-
- // Vérification du code OTP si l'étape est visible
- const codeStep = document.getElementById('kyc-code-step');
- if (codeStep && !codeStep.classList.contains('hidden')) {
- const otpCode = document.getElementById('kyc-code-input').value.trim();
- if (otpCode !== '4829') {
- triggerCustomModal("Code de vérification incorrect. Vérifiez le code reçu.", "info");
- const otpInput = document.getElementById('kyc-code-input');
- otpInput.value = '';
- otpInput.classList.add('border-rose-400');
- otpInput.focus();
- return;
- }
- }
-
- currentUser.isLoggedIn = true;
- currentUser.firstName = document.getElementById('kyc-firstname').value.trim();
- currentUser.lastName = document.getElementById('kyc-lastname').value.trim();
- currentUser.email = document.getElementById('kyc-email').value.trim();
- currentUser.phone = document.getElementById('kyc-phone').value.trim();
- currentUser.address = document.getElementById('kyc-address').value.trim();
- currentUser.iban = document.getElementById('kyc-iban').value.trim();
- currentUser.idVerified = true;
-
- saveSession();
- renderHeaderAuth();
- updateProfilePassUI();
- updateMessagesNotification();
- closeAuthModal();
- triggerCustomModal(`Félicitations ${currentUser.firstName} ! Votre compte est créé.`, "check");
- navigate('profile');
- }
-
function handleLogout() {
currentUser.isLoggedIn = false;
currentUser.idVerified = false;
clearSession();
renderHeaderAuth();
updateMessagesNotification();
- triggerCustomModal("Déconnexion réussie. Vous naviguez en mode invité.", "info");
navigate('home');
}
@@ -5416,30 +5651,29 @@
closePassStoreModal();
const names = {
- free: "Pass Gratuit (3 Shorts)",
+ lite: "Pass Lite (3 Shorts)",
+ free: "Pass Lite (3 Shorts)",
flash: "Pass Flash (4 Shorts)",
- medium: "Pass Medium (5 Shorts)",
pro: "Pass Pro (6 Shorts)",
- premium: "Pass Premium (8 Shorts max & Top 1)"
+ premium: "Pass Premium (8 Shorts & Top 1)"
};
- triggerCustomModal(`Abonnement validé : ${names[type]} actif !`, "check");
+ triggerCustomModal(`Merci pour votre achat : ${names[type] || 'Pass activé'} !`, "check", true);
}
function getMaxShorts() {
- const baseShorts = { free: 3, flash: 4, medium: 5, pro: 6, premium: 8 };
- let total = baseShorts[currentUser.passType] + currentUser.extraShorts;
+ const baseShorts = { lite: 3, free: 3, flash: 4, medium: 4, pro: 6, premium: 8 };
+ let total = (baseShorts[currentUser.passType] || 3) + currentUser.extraShorts;
return total > 8 ? 8 : total;
}
function buyExtraShort() {
if (getMaxShorts() >= 8) {
- triggerCustomModal("Limite absolue atteinte : 8 shorts maximum.", "info");
return;
}
currentUser.extraShorts++;
updateProfilePassUI();
- triggerCustomModal("+1 Short ajouté pour 0.50€/mois !", "check");
+ triggerCustomModal("Merci pour votre achat : +1 Short vidéo ajouté !", "check", true);
}
function updateProfilePassUI() {
@@ -5456,43 +5690,32 @@
if (shortsIndicator) shortsIndicator.textContent = `${currentUser.shortsUsed}/${max} Shorts`;
if (currentUser.passType === 'premium') {
- passPill.innerHTML = `
Pass Premium`;
- passPill.className = "flex items-center gap-1 bg-gradient-to-r from-gray-950 via-purple-950 to-indigo-950 text-purple-200 border border-purple-400/50 text-xs font-bold px-3 py-1 rounded-full shadow-sm";
+ passPill.innerHTML = `
Pass Premium`;
+ passPill.className = "flex items-center gap-1 bg-purple-950 text-purple-200 border border-purple-500/40 text-xs font-bold px-3 py-1 rounded-full shadow-xs";
passCardTitle.innerHTML = `Pass Premium
`;
- passCardDesc.textContent = "Top 1 Garanti, Badge diamant Noir / Violet sur votre profil et visibilité maximale.";
- if (publishBadge) publishBadge.textContent = "Pass Premium (Noir / Violet)";
+ passCardDesc.textContent = "Top 1 Garanti, visibilité maximale et badge Premium violet & noir sur votre profil.";
+ if (publishBadge) publishBadge.textContent = "Pass Premium (Violet/Noir)";
if (avatarBadge) {
- avatarBadge.className = "absolute bottom-0 right-0 w-6 h-6 bg-gradient-to-tr from-black via-purple-950 to-purple-800 border-2 border-purple-400 text-purple-200 rounded-full flex items-center justify-center text-xs shadow-sm";
+ avatarBadge.className = "absolute bottom-0 right-0 w-6 h-6 bg-purple-900 border-2 border-white text-purple-200 rounded-full flex items-center justify-center text-xs shadow-xs";
avatarBadge.innerHTML = `
`;
avatarBadge.title = "Pass Premium";
}
} else if (currentUser.passType === 'pro') {
- passPill.innerHTML = `
Pass Pro`;
- passPill.className = "flex items-center gap-1 bg-rose-600 text-white text-xs font-bold px-3 py-1 rounded-full shadow-sm";
+ passPill.innerHTML = `
Pass Pro`;
+ passPill.className = "flex items-center gap-1 bg-rose-600 text-white text-xs font-bold px-3 py-1 rounded-full shadow-xs";
passCardTitle.innerHTML = `Pass Pro Actif
`;
- passCardDesc.textContent = "Fort boost algorithmique de toutes vos annonces (Badge Rouge).";
+ passCardDesc.textContent = "Fort boost algorithmique de toutes vos annonces (Badge Pro Rouge).";
if (publishBadge) publishBadge.textContent = "Pass Pro (Rouge)";
if (avatarBadge) {
- avatarBadge.className = "absolute bottom-0 right-0 w-6 h-6 bg-rose-600 text-white rounded-full flex items-center justify-center border-2 border-white text-xs shadow-sm";
+ avatarBadge.className = "absolute bottom-0 right-0 w-6 h-6 bg-rose-600 text-white rounded-full flex items-center justify-center border-2 border-white text-xs shadow-xs";
avatarBadge.innerHTML = `
`;
avatarBadge.title = "Pass Pro";
}
- } else if (currentUser.passType === 'medium') {
- passPill.innerHTML = `
Pass Medium`;
- passPill.className = "flex items-center gap-1 bg-emerald-600 text-white text-xs font-bold px-3 py-1 rounded-full shadow-sm";
- passCardTitle.innerHTML = `Pass Medium Actif
`;
- passCardDesc.textContent = "Remontée moyenne dans la recherche assurée (Badge Vert).";
- if (publishBadge) publishBadge.textContent = "Pass Medium (Vert)";
- if (avatarBadge) {
- avatarBadge.className = "absolute bottom-0 right-0 w-6 h-6 bg-emerald-600 text-white rounded-full flex items-center justify-center border-2 border-white text-xs shadow-sm";
- avatarBadge.innerHTML = `
`;
- avatarBadge.title = "Pass Medium";
- }
} else if (currentUser.passType === 'flash') {
- passPill.innerHTML = `
Pass Flash`;
+ passPill.innerHTML = `
Pass Flash`;
passPill.className = "flex items-center gap-1 bg-blue-600 text-white text-xs font-bold px-3 py-1 rounded-full shadow-sm";
passCardTitle.innerHTML = `Pass Flash Actif
`;
- passCardDesc.textContent = "Léger boost par rapport aux annonces gratuites (Badge Bleu).";
+ passCardDesc.textContent = "Léger boost algorithmique de visibilité (Badge Flash Bleu).";
if (publishBadge) publishBadge.textContent = "Pass Flash (Bleu)";
if (avatarBadge) {
avatarBadge.className = "absolute bottom-0 right-0 w-6 h-6 bg-blue-600 text-white rounded-full flex items-center justify-center border-2 border-white text-xs shadow-sm";
@@ -5500,15 +5723,16 @@
avatarBadge.title = "Pass Flash";
}
} else {
- passPill.textContent = "Pass Gratuit";
- passPill.className = "bg-job-bg text-job-dark text-xs font-bold px-3 py-1 rounded-full border border-job-gray";
- passCardTitle.textContent = "Pass Runner Gratuit";
- passCardDesc.textContent = "Classement standard. Sécurisez vos paiements sereinement.";
- if (publishBadge) publishBadge.textContent = "Pass Gratuit";
+ // Pass Lite (défaut / gratuit)
+ passPill.innerHTML = `
Pass Lite`;
+ passPill.className = "flex items-center gap-1 bg-emerald-50 text-emerald-800 border border-emerald-300 text-xs font-bold px-3 py-1 rounded-full shadow-xs";
+ passCardTitle.textContent = "Pass Lite Actif";
+ passCardDesc.textContent = "Formule essentielle avec 3 Shorts inclus et référencement standard.";
+ if (publishBadge) publishBadge.textContent = "Pass Lite (Vert)";
if (avatarBadge) {
- avatarBadge.className = "absolute bottom-0 right-0 w-6 h-6 bg-emerald-500 text-white rounded-full flex items-center justify-center border-2 border-white text-xs";
+ avatarBadge.className = "absolute bottom-0 right-0 w-6 h-6 bg-emerald-600 text-white rounded-full flex items-center justify-center border-2 border-white text-xs shadow-xs";
avatarBadge.innerHTML = `
`;
- avatarBadge.title = "Compte vérifié";
+ avatarBadge.title = "Pass Lite";
}
}
@@ -5518,15 +5742,166 @@
}
let temporaryEditAvatar = null;
- function simulateProfileAvatarUpload() {
- const avatars = [
- 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&auto=format&fit=crop&q=80',
- 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=200&auto=format&fit=crop&q=80',
- 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=200&auto=format&fit=crop&q=80'
- ];
- temporaryEditAvatar = avatars[Math.floor(Math.random() * avatars.length)];
- document.getElementById('edit-avatar-preview').src = temporaryEditAvatar;
- triggerCustomModal("Nouvelle photo chargée !", "check");
+ let cropState = {
+ rawImage: null,
+ zoom: 1,
+ panX: 0,
+ panY: 0,
+ isDragging: false,
+ startX: 0,
+ startY: 0
+ };
+
+ function triggerProfilePhotoPicker() {
+ const input = document.getElementById('profile-photo-file-input');
+ if (input) {
+ input.value = ''; // Réinitialise pour permettre de re-sélectionner le même fichier si besoin
+ input.click();
+ }
+ }
+
+ function handleProfilePhotoSelected(event) {
+ const file = event.target.files && event.target.files[0];
+ if (!file) return;
+
+ if (!file.type.startsWith('image/')) {
+ triggerCustomModal("Veuillez sélectionner un fichier image valide.", "warning");
+ return;
+ }
+
+ const reader = new FileReader();
+ reader.onload = function(e) {
+ openPhotoCropModal(e.target.result);
+ };
+ reader.readAsDataURL(file);
+ }
+
+ function openPhotoCropModal(imageSrc) {
+ const modal = document.getElementById('photo-crop-modal');
+ const target = document.getElementById('crop-image-target');
+ const slider = document.getElementById('crop-zoom-slider');
+ const zoomVal = document.getElementById('crop-zoom-value');
+
+ cropState.zoom = 1;
+ cropState.panX = 0;
+ cropState.panY = 0;
+ cropState.isDragging = false;
+
+ if (slider) slider.value = "1";
+ if (zoomVal) zoomVal.textContent = "1.0x";
+
+ const img = new Image();
+ img.onload = function() {
+ cropState.rawImage = img;
+ target.src = imageSrc;
+ updateCropTransform();
+ initCropInteractions();
+
+ modal.classList.remove('hidden');
+ modal.classList.add('flex');
+ };
+ img.src = imageSrc;
+ }
+
+ function updateCropTransform() {
+ const target = document.getElementById('crop-image-target');
+ if (!target) return;
+ target.style.transform = `translate(calc(-50% + ${cropState.panX}px), calc(-50% + ${cropState.panY}px)) scale(${cropState.zoom})`;
+ }
+
+ function handleCropZoomChange(val) {
+ cropState.zoom = parseFloat(val);
+ const zoomVal = document.getElementById('crop-zoom-value');
+ if (zoomVal) zoomVal.textContent = `${cropState.zoom.toFixed(1)}x`;
+ updateCropTransform();
+ }
+
+ function initCropInteractions() {
+ const viewport = document.getElementById('crop-viewport');
+ if (!viewport || viewport.dataset.initialized) return;
+ viewport.dataset.initialized = 'true';
+
+ function onPointerDown(e) {
+ cropState.isDragging = true;
+ const pageX = e.touches ? e.touches[0].pageX : e.pageX;
+ const pageY = e.touches ? e.touches[0].pageY : e.pageY;
+ cropState.startX = pageX - cropState.panX;
+ cropState.startY = pageY - cropState.panY;
+ }
+
+ function onPointerMove(e) {
+ if (!cropState.isDragging) return;
+ const pageX = e.touches ? e.touches[0].pageX : e.pageX;
+ const pageY = e.touches ? e.touches[0].pageY : e.pageY;
+ cropState.panX = pageX - cropState.startX;
+ cropState.panY = pageY - cropState.startY;
+ updateCropTransform();
+ }
+
+ function onPointerUp() {
+ cropState.isDragging = false;
+ }
+
+ viewport.addEventListener('mousedown', onPointerDown);
+ window.addEventListener('mousemove', onPointerMove);
+ window.addEventListener('mouseup', onPointerUp);
+
+ viewport.addEventListener('touchstart', onPointerDown, { passive: true });
+ window.addEventListener('touchmove', onPointerMove, { passive: true });
+ window.addEventListener('touchend', onPointerUp);
+ }
+
+ function cancelPhotoCrop() {
+ const modal = document.getElementById('photo-crop-modal');
+ modal.classList.add('hidden');
+ modal.classList.remove('flex');
+ const fileInput = document.getElementById('profile-photo-file-input');
+ if (fileInput) fileInput.value = '';
+ }
+
+ function confirmPhotoCrop() {
+ if (!cropState.rawImage) return;
+
+ const viewport = document.getElementById('crop-viewport');
+ const vpRect = viewport.getBoundingClientRect();
+ const size = 300; // résolution carrée finale pour l'avatar
+
+ const canvas = document.createElement('canvas');
+ canvas.width = size;
+ canvas.height = size;
+ const ctx = canvas.getContext('2d');
+
+ // Ratio d'affichage de l'image originale dans le viewport
+ const img = cropState.rawImage;
+ const aspect = img.width / img.height;
+ let drawW, drawH;
+ if (aspect > 1) {
+ drawH = vpRect.height;
+ drawW = drawH * aspect;
+ } else {
+ drawW = vpRect.width;
+ drawH = drawW / aspect;
+ }
+
+ const scaleRatio = size / vpRect.width;
+
+ ctx.clearRect(0, 0, size, size);
+ ctx.save();
+ ctx.translate(size / 2, size / 2);
+ ctx.translate(cropState.panX * scaleRatio, cropState.panY * scaleRatio);
+ ctx.scale(cropState.zoom, cropState.zoom);
+ ctx.drawImage(img, (-drawW * scaleRatio) / 2, (-drawH * scaleRatio) / 2, drawW * scaleRatio, drawH * scaleRatio);
+ ctx.restore();
+
+ const croppedDataUrl = canvas.toDataURL('image/jpeg', 0.92);
+ temporaryEditAvatar = croppedDataUrl;
+
+ // Mise à jour de la prévisualisation dans la modale d'infos personnelles
+ const preview = document.getElementById('edit-avatar-preview');
+ if (preview) preview.src = croppedDataUrl;
+
+ cancelPhotoCrop();
+ triggerCustomModal("Photo recadrée et sélectionnée avec succès !", "check");
}
function openPersonalInfoModal() {
@@ -6052,11 +6427,24 @@
}
}
- function triggerCustomModal(message, type = 'check') {
+ function triggerCustomModal(message, type = 'check', force = false) {
+ // Filtrage strict : seuls les popups autorisés s'affichent
+ // 1. "Merci pour votre achat" (Pass)
+ // 2. "Connecté" (Connexion)
+ // 3. Notification de message / alerte quand l'utilisateur est actif sur le site
+ const isPurchase = message.includes("Merci pour votre achat") || message.includes("Pass activé") || message.includes("Short vidéo ajouté");
+ const isLogin = message === "Connecté" || message.startsWith("Connecté");
+ const isMessageNotification = type === 'notification' || message.includes("Nouveau message");
+
+ if (!force && !isPurchase && !isLogin && !isMessageNotification) {
+ return; // Bloque tous les autres petits popups intempestifs du site
+ }
+
const modal = document.getElementById('custom-modal');
const text = document.getElementById('modal-text');
const icon = document.getElementById('modal-icon');
const container = document.getElementById('modal-icon-container');
+ if (!modal || !text || !icon || !container) return;
text.textContent = message;
@@ -6066,6 +6454,9 @@
} else if (type === 'info') {
icon.className = 'ph-bold ph-info text-sky-400 text-lg';
container.className = 'w-6 h-6 rounded-full bg-sky-500/20 text-sky-400 flex items-center justify-center shrink-0';
+ } else if (type === 'notification') {
+ icon.className = 'ph-fill ph-chat-teardrop-dots text-job-sage text-lg';
+ container.className = 'w-6 h-6 rounded-full bg-job-sage/30 text-job-sage flex items-center justify-center shrink-0';
} else {
icon.className = 'ph-fill ph-check-circle text-job-sage text-lg';
container.className = 'w-6 h-6 rounded-full bg-job-sage/30 text-job-sage flex items-center justify-center shrink-0';
@@ -6078,7 +6469,7 @@
window.toastTimeout = setTimeout(() => {
modal.classList.add('hidden');
modal.classList.remove('flex');
- }, 3200);
+ }, 3000);
}
function initSwipeButton() {
@@ -6259,7 +6650,58 @@
}
}
- // ====== MODALE INFORMATIONS LEGALES & SECURITE ======
+ function handleInstagramClick(e) {
+ e.preventDefault();
+ const webUrl = SOCIAL_LINKS.instagram || 'https://www.instagram.com/jobrunnerr/';
+ const appUrl = 'instagram://user?username=jobrunnerr';
+
+ // Tente d'ouvrir directement l'application Instagram native (iOS/Android)
+ // Si pas installée ou sur PC, bascule naturellement sur l'URL web dans un nouvel onglet
+ const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
+ if (isMobile) {
+ window.location.href = appUrl;
+ setTimeout(() => {
+ window.open(webUrl, '_blank');
+ }, 1000);
+ } else {
+ window.open(webUrl, '_blank');
+ }
+ }
+
+ // ====== GESTION DES NOTIFICATIONS DE MESSAGES EN ARRIÈRE-PLAN OU SUR LE SITE ======
+ function receiveSimulatedMessage(runnerName, text) {
+ if (!currentUser.isLoggedIn) return;
+
+ // Trouve ou prépare une conversation
+ let conv = conversations.find(c => c.name.toLowerCase().includes(runnerName.toLowerCase())) || conversations[0];
+ if (conv) {
+ conv.messages.push({ sender: 'them', text: text });
+ conv.lastMsg = text;
+ conv.time = "À l'instant";
+ }
+
+ // Règle demandée :
+ // "qd tu recoit une notif (que qd tu recoit la notif et que t sur le site, si t pas dessus, qd touvre ta juste le petit point dans le truc msg"
+ const isUserOnSite = document.visibilityState === 'visible' && !document.hidden;
+
+ if (isUserOnSite) {
+ triggerCustomModal(`Nouveau message de ${runnerName}`, "notification", true);
+ if (conv) conv.unread = true;
+ updateMessagesNotification();
+ renderMessagesList();
+ if (typeof renderDesktopMessenger === 'function') renderDesktopMessenger();
+ } else {
+ if (conv) conv.unread = true;
+ updateMessagesNotification();
+ }
+ }
+
+ // Ecouteur de reprise de focus : quand l'utilisateur rouvre l'onglet, met à jour le petit point rouge
+ document.addEventListener('visibilitychange', () => {
+ if (document.visibilityState === 'visible') {
+ updateMessagesNotification();
+ }
+ });
function openLegalModal(type) {
const modal = document.getElementById('legal-modal');
const titleEl = document.getElementById('legal-modal-title');
@@ -6544,13 +6986,13 @@
-
+
Instagram
- @jobrunner.fr
+ @jobrunnerr
@@ -6659,7 +7101,7 @@
if (sessionRestored) {
setTimeout(() => {
- triggerCustomModal(`Bon retour, ${currentUser.firstName} ! Session restaurée.`, "check");
+ triggerCustomModal("Connecté", "check", true);
}, 600);
}
});