/* Couche bêta JobRunner : bandeau, « Donner mon avis », données de démo (bots), libellés SIMULÉ. Injectée par beta/server.py : le site d'origine n'est pas modifié. */ (function () { 'use strict'; var H = { 'Content-Type': 'application/json', 'X-Beta': '1' }; function el(tag, attrs, html) { var e = document.createElement(tag); for (var k in attrs || {}) e.setAttribute(k, attrs[k]); if (html != null) e.textContent = html; return e; } // --- Bandeau Bêta --- var b = el('div', { id: 'jrb-bandeau', role: 'status' }); var badge = el('b', {}, 'BÊTA'); b.appendChild(badge); b.appendChild(document.createTextNode('Données fictives · paiement SIMULÉ')); var out = el('a', { href: '#' }, 'Quitter'); b.appendChild(out); out.addEventListener('click', function (ev) { ev.preventDefault(); fetch('/__beta/logout', { method: 'POST', headers: { 'X-Beta': '1' }, credentials: 'same-origin' }) .then(function () { location.href = '/__beta/gate'; }, function () { location.href = '/__beta/gate'; }); }); document.body.insertBefore(b, document.body.firstChild); // --- Garde-fou paiement : aucun appel vers un prestataire de paiement --- var BLOC = /stripe|stancer|paypal|adyen|checkout|didit/i; var f0 = window.fetch; if (f0) window.fetch = function (u) { if (BLOC.test(String(u && u.url || u))) return Promise.reject(new Error('Paiement désactivé en bêta')); return f0.apply(this, arguments); }; // --- Libellés SIMULÉ --- var tcm = window.triggerCustomModal; if (typeof tcm === 'function') window.triggerCustomModal = function (msg) { if (typeof msg === 'string' && /séquestre|débloqu|versé|virement|paiement|pass/i.test(msg) && !/SIMUL/.test(msg)) arguments[0] = msg + ' (SIMULÉ)'; return tcm.apply(this, arguments); }; function marquer(id, texte) { var m = document.getElementById(id); if (!m || m.querySelector('.jrb-simule')) return; var n = el('div', { 'class': 'jrb-simule' }, texte); var cible = m.firstElementChild || m; cible.insertBefore(n, cible.firstChild); } function simules() { marquer('escrow-confirm-modal', 'SIMULÉ · aucun argent réel · paiement Stancer non branché'); marquer('legal-sheet', 'SIMULÉ · aucun paiement réel ne sera effectué'); } // --- Données de démo (bots) --- var vus = {}; function categorie(id) { return ((typeof categoriesData !== "undefined" ? categoriesData : []) || []).filter(function (c) { return c.id === id; })[0] || { id: id, name: id, icon: 'ph-hammer' }; } function fusion(d) { var pro = {}; d.profiles.forEach(function (p) { pro[p.id] = p; }); var neuf = false; var modele = (runners || [])[0] || {}; d.ads.forEach(function (a) { var k = 'a' + a.id; if (vus[k]) return; var p = pro[a.profile_id]; if (!p) return; vus[k] = 1; neuf = true; var c = categorie(a.category), nom = p.first + ' ' + p.last_initial + '. (fictif)'; var ref = (runners || []).filter(function (r) { return r.categoryId === a.category; })[0] || modele; runners.push({ id: 900000 + a.id, name: nom, firstName: p.first, lastName: p.last_initial, fullName: nom, title: a.title, categoryId: c.id, categoryName: c.name, categoryIcon: c.icon, rating: '4.5', reviews: 0, reviewsList: [], price: a.price, time: a.unit, passType: 'lite', sellerType: 'particulier', isRecommended: false, city: p.city, cluster: p.city, department: p.dept, region: p.region, distanceKm: 3, location: p.city + ' (3 km)', avatar: '/__beta/avatar/' + p.seed + '.svg', jobImage: ref.jobImage, hasShort: false, shortVideo: null, likes: 0, desc: '[PROFIL FICTIF] ' + a.descr, isDemo: true }); }); d.convs.forEach(function (cv) { var p = pro[cv.profile_id]; if (!p) return; var id = 900000 + cv.id, existante = conversations.filter(function (x) { return x.id === id; })[0]; var nom = p.first + ' ' + p.last_initial + '. (fictif)'; if (!existante) { existante = { id: id, runnerId: 0, name: nom, avatar: '/__beta/avatar/' + p.seed + '.svg', lastMsg: '', time: "À l'instant", timestamp: Date.now(), unread: true, messages: [], demoCount: 0, isDemo: true }; if (cv.status === 'proposed') existante.contract = { status: 'proposed', title: cv.title, amount: cv.amount, runnerAccepted: true, clientAccepted: false, runnerDone: false, clientDone: false }; conversations.unshift(existante); neuf = true; } cv.messages.slice(existante.demoCount).forEach(function (m) { existante.messages.push({ sender: m.sender === 'me' ? 'me' : 'them', text: m.text }); existante.lastMsg = m.text; existante.unread = true; existante.timestamp = Date.now(); neuf = true; }); existante.demoCount = cv.messages.length; }); var a = document.getElementById('jrb-activite'); if (a && d.activity.length) { a.textContent = ''; a.appendChild(el('b', {}, 'Activité des bots')); d.activity.slice(0, 4).forEach(function (x) { a.appendChild(el('div', {}, '• ' + x.text)); }); a.className = 'on'; } if (neuf) rafraichir(); } function rafraichir() { try { if (typeof window.updateHomeRecs === 'function') window.updateHomeRecs(); if (typeof window.displaySearchResults === 'function') window.displaySearchResults(runners, 'Toutes les annonces'); if (typeof window.sortConversations === 'function') window.sortConversations(); if (typeof window.renderMessagesList === 'function') window.renderMessagesList(); if (typeof window.updateMessagesNotification === 'function') window.updateMessagesNotification(); } catch (e) { /* l'application reste utilisable sans la démo */ } } function charger() { if (typeof runners === "undefined" || typeof conversations === "undefined") return; fetch('/__beta/api/demo', { credentials: 'same-origin' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (d) { if (d) fusion(d); }).catch(function () {}); } // --- « Donner mon avis » --- var cap = null; var btn = el('button', { id: 'jrb-avis-btn', type: 'button' }, 'Donner mon avis'); var fond = el('div', { id: 'jrb-fond' }); var fen = el('div', { id: 'jrb-fen', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'jrb-t' }); fen.innerHTML = '
Dites-nous ce qu\'il faut garder ou changer sur cette page. Vos retours restent dans la bêta.
' + '' + '' + '