Files
ploxion-contacts/app.blade.php

35 lines
6.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{-- PL0XI0N contacts 📇 — LES CONTACTS UTILES de la zone (module civ, vague 2 appart) : régie, concierge, voisins,
urgences, fournisseurs (électricité, internet), médecin, assurance. Par zone (jOSStore zone:<id>:contacts), pack
suisse (urgences 112/117/118/144/145 Tox/143), appel/mail/plan en un tap (tel:/mailto:/maps), notes, tags.
describe() = nombre + urgences en liste (act = appeler via ploxion.contacts.cmd). --}}
<script>
(function () {
var ID = 'contacts';
var PACK = [['Urgences (Europe)', '112', 'urgence', '🚨'], ['Police', '117', 'urgence', '👮'], ['Pompiers', '118', 'urgence', '🚒'], ['Ambulance', '144', 'urgence', '🚑'], ['Tox Info Suisse', '145', 'urgence', '☠️'], ['La Main Tendue', '143', 'urgence', '🤝'], ['Régie / gérance', '', 'logement', '🏢'], ['Concierge', '', 'logement', '🧹'], ['Voisin·e', '', 'voisinage', '🏘️'], ['Électricité (fournisseur)', '', 'fournisseur', '⚡'], ['Internet', '', 'fournisseur', '📶'], ['Assurance ménage / RC', '', 'assurance', '🛡️'], ['Médecin', '', 'sante', '🩺'], ['Pharmacie de garde', '', 'sante', '💊']];
function mount(container, ctx) {
var C = window.jOSCiv, U = C && C.ui; if (!C) { container.innerHTML = '<div style="padding:20px">cœur civ absent</div>'; return { unmount: function () { container.innerHTML = ''; } }; }
U.style(); container.classList.add('cv'); container.style.position = 'relative';
var Z = (ctx && ctx.zone && jOSZone.get(ctx.zone.id)) || jOSZone.current(); if (!Z) { container.innerHTML = '<div class="cv__empty">aucune zone — ouvre 🫧 zone</div>'; return { unmount: function () { container.innerHTML = ''; } }; }
var S = jOSStore('zone:' + Z.id + ':contacts'), q = '', offS = null;
function all() { return S.all().filter(function (c) { return c && c.id; }); }
function row(c) { var tel = (c.tel || '').replace(/\s+/g, ''); return '<div class="cv__row" data-id="' + c.id + '"><span class="ic">' + U.esc(c.icon || '📇') + '</span><div class="tx"><b>' + U.esc(c.nom) + '</b><small>' + U.esc([c.tag, c.tel, c.mail, c.notes].filter(Boolean).join(' · ')) + '</small></div>' + (tel ? '<a class="cv__btn ok" href="tel:' + U.esc(tel) + '" data-call title="appeler">📞</a>' : '') + (c.mail ? '<a class="cv__btn" href="mailto:' + U.esc(c.mail) + '" data-call title="écrire">✉️</a>' : '') + (c.adresse ? '<a class="cv__btn" href="https://maps.apple.com/?q=' + encodeURIComponent(c.adresse) + '" target="_blank" rel="noopener" data-call title="plan">📍</a>' : '') + '</div>'; }
function render() {
var list = all().filter(function (c) { return !q || (c.nom + ' ' + (c.tag || '') + ' ' + (c.notes || '')).toLowerCase().indexOf(q) >= 0; });
var by = {}; list.forEach(function (c) { (by[c.tag || 'autre'] = by[c.tag || 'autre'] || []).push(c); });
var order = ['urgence', 'logement', 'voisinage', 'fournisseur', 'assurance', 'sante', 'autre'];
var h = U.zoneHd(Z, 'Contacts utiles', '📇') + '<div class="cv__bd"><input type="search" placeholder="chercher…" data-q value="' + U.esc(q) + '" style="width:100%;padding:9px 11px;border-radius:10px;border:1px solid var(--xr-border,#22324f);background:var(--xr-surface,#0c1320);color:inherit;font:14px system-ui;margin-bottom:8px">';
h += order.filter(function (t) { return by[t]; }).map(function (t) { return '<div class="cv__sec"><span>' + t + '</span><span>' + by[t].length + '</span></div>' + by[t].map(row).join(''); }).join('') || '<div class="cv__empty">Aucun contact.</div>';
if (all().length < 3) h += '<div style="text-align:center;margin-top:10px"><button class="cv__btn" data-pack>🇨🇭 pack de départ (urgences + régie, voisins, fournisseurs à compléter)</button></div>';
h += '</div><button class="cv__fab" data-add>+</button>'; container.innerHTML = h;
}
function form(c) { U.form(container, c ? 'Contact' : 'Nouveau contact', [{ k: 'nom', label: 'nom', val: c ? c.nom : '' }, { k: 'tag', label: 'type', type: 'chips', opts: [{ v: 'urgence', l: '🚨 urgence' }, { v: 'logement', l: '🏢 logement' }, { v: 'voisinage', l: '🏘️ voisinage' }, { v: 'fournisseur', l: '⚡ fournisseur' }, { v: 'assurance', l: '🛡️ assurance' }, { v: 'sante', l: '🩺 santé' }, { v: 'autre', l: 'autre' }], val: c ? c.tag : 'logement' }, { k: 'tel', label: 'téléphone', type: 'tel', val: c ? c.tel : '' }, { k: 'mail', label: 'e-mail', type: 'email', val: c ? c.mail : '' }, { k: 'adresse', label: 'adresse', val: c ? c.adresse : '' }, { k: 'icon', label: 'icône', val: c ? c.icon : '📇' }, { k: 'notes', label: 'notes (n° de client, horaires…)', type: 'textarea', val: c ? c.notes : '' }], function (v) { var it = Object.assign({ id: c ? c.id : 'c' + Date.now().toString(36), m: Date.now() }, v); if (c) S.set(c.id, it); else S.upsert(function (x) { return x.id === it.id; }, it); render(); }, c ? '<div style="margin-top:8px"><button type="button" class="cv__btn" data-del>🗑 supprimer</button></div>' : ''); var d = container.querySelector('[data-del]'); if (d && c) d.addEventListener('click', function () { S.remove(c.id); container.querySelector('.cv__form').remove(); render(); }); }
container.addEventListener('click', function (e) { if (e.target.closest('[data-call]')) return; if (e.target.closest('[data-add]')) { form(null); return; } if (e.target.closest('[data-pack]')) { PACK.forEach(function (p) { S.upsert(function (x) { return x.nom === p[0]; }, { id: 'c' + Math.random().toString(36).slice(2, 8), nom: p[0], tel: p[1], tag: p[2], icon: p[3], m: Date.now() }); }); render(); return; } var r = e.target.closest('[data-id]'); if (r) form(S.get(r.getAttribute('data-id'))); });
container.addEventListener('input', function (e) { if (e.target.matches('[data-q]')) { q = e.target.value.toLowerCase(); var v = e.target.value; render(); var i = container.querySelector('[data-q]'); if (i) { i.focus(); i.value = v; } } });
render(); offS = S.on(function () { render(); });
return { unmount: function () { try { offS(); } catch (e) {} container.classList.remove('cv'); container.innerHTML = ''; } };
}
function describe() { var Z = window.jOSZone && jOSZone.current(); if (!Z || !window.jOSStore) return null; var S = jOSStore('zone:' + Z.id + ':contacts'), all = S.all(); return { v: 1, id: ID, title: 'Contacts', icon: '📇', items: [{ p: 1, kind: 'stat', label: 'contacts', value: all.length }, { p: 2, kind: 'list', label: 'urgences', items: all.filter(function (c) { return c.tag === 'urgence' && c.tel; }).slice(0, 7).map(function (c) { return { label: (c.icon || '') + ' ' + c.nom, value: c.tel }; }) }] }; }
window.jOSApps = window.jOSApps || {}; window.jOSApps[ID] = { manifest: { id: ID, name: 'Contacts utiles', icon: '📇' }, mount: mount, describe: describe };
})();
</script>