synchro du labo (0bf0da65) : app.blade.php, README.md

This commit is contained in:
cloudion 2026-11-03 22:40:37 +00:00
commit 8dca07e5e7
2 changed files with 429 additions and 0 deletions

21
README.md Normal file
View File

@ -0,0 +1,21 @@
# 🧠 Braindump
Capture-flux : tape une pensée + Entrée, elle se pose horodatée. Tu déverses, ça tient.
| | |
| --- | --- |
| id | `braindump` |
| fournit | `capture` `stream` |
| bions qu'il nomme | `jOSApps` `jOSBoxion` `jOSDecoupe` `jOSPorts` `jOSTsoin` `jOSWire` |
| fichiers | `app.blade.php` |
| dans le labo | `resources/views/ploxions/braindump/` (dépôt `my_website2`) |
## Contribuer
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=braindump — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
- **Dans VS Code** : `xb prendre braindump` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
© 2026 chill-tekk · ne pas nuire

408
app.blade.php Normal file
View File

@ -0,0 +1,408 @@
{{-- PL0XI0N braindump — LA MACHINE À BRAINDUMP (v2, 03.11.2026 ; braindump docs/braindumps/2026-11-03-escalion-machine-a-braindump.md §2.5).
Tu déverses (clavier ou dictée ◉), ça tient : chaque pensée se pose horodatée, puis jOSDecoupe la coupe sur tes marqueurs de parole et route
chaque morceau vers ploxion.<id>.inbox (≥ 0,7) ; le reste attend dans « à valider », où toucher un ploxion = l'envoyer + une règle apprise.
Les états personnels restent ici (◌ privé), jamais sur le bus. Onglets : flux · à valider · ploxions · mesure (§2.7 : fluence, flexibilité).
Stockage : localStorage xb:braindump (le même qu'en v1) + jOSBoxion (braindump/pensees) = PARTAGÉ entre tes appareils : chaque envoi tire,
fusionne (par id, la plus avancée gagne) puis renvoie ; reprise au retour sur l'onglet et toutes les 45 s ; les suppressions gardées
(braindump/suppr) pour qu'un appareil ne ressuscite pas une pensée effacée.
Ports : OUT posted {id,t,txt} (sans les morceaux privés) · OUT ploxion.<id>.inbox via jOSDecoupe · IN ploxion.braindump.inbox {txt} = une pensée.
S'enregistre dans window.jOSApps['braindump']. mount(c, ctx) → { unmount } ; ctx.onglet = flux | valider | ploxions | mesure (atlas-boxion le monte). Test : node bin/verify-decoupe.mjs --}}
<style>
.bdp { display:flex; flex-direction:column; height:100%; background:#06090d;
color:rgba(220,232,240,.92); font-family:ui-sans-serif,system-ui,sans-serif; }
.bdp__bar { flex:0 0 auto; display:flex; align-items:center; gap:8px; padding:7px 11px;
border-bottom:1px solid rgba(120,160,230,.18); }
.bdp__t { font-weight:700; letter-spacing:.04em; color:rgba(160,195,255,.95); font-size:.82rem; white-space:nowrap; }
.bdp__sp { flex:1; }
.bdp__cnt { font-size:.7rem; color:rgba(150,180,220,.6); font-family:ui-monospace,monospace; white-space:nowrap; }
.bdp__btn { cursor:pointer; padding:6px 11px; min-height:36px; border-radius:6px; border:1px solid rgba(120,160,230,.3);
background:none; color:rgba(160,195,255,.85); font-size:.72rem; }
.bdp__btn:hover, .bdp__btn[aria-pressed="true"] { background:rgba(120,160,230,.12); color:#fff; }
.bdp__btn[data-rec="1"] { border-color:rgba(255,120,120,.6); color:rgba(255,160,160,.95); }
.bdp__q { flex:0 1 160px; min-width:70px; min-height:32px; border-radius:6px; padding:5px 8px; border:1px solid rgba(120,160,230,.22);
background:rgba(18,26,42,.5); color:#fff; font-size:.74rem; outline:none; }
.bdp__tabs { flex:0 0 auto; display:flex; gap:4px; padding:5px 11px; border-bottom:1px solid rgba(120,160,230,.12); overflow-x:auto; }
.bdp__tab { cursor:pointer; border:0; background:none; color:rgba(150,180,220,.6); font-size:.72rem; padding:6px 10px; min-height:34px; border-radius:6px; white-space:nowrap; }
.bdp__tab[aria-selected="true"] { background:rgba(120,160,230,.14); color:#fff; }
.bdp__tab b { font-family:ui-monospace,monospace; font-weight:400; color:rgba(255,200,140,.85); margin-left:4px; }
.bdp__stream { flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:10px 12px; display:flex; flex-direction:column; gap:7px; }
.bdp__stream--flux { flex-direction:column-reverse; }
.bdp__e { border-left:2px solid rgba(120,160,230,.35); padding:3px 0 3px 10px; }
.bdp__e--prive { border-left-style:dashed; border-left-color:rgba(190,170,220,.45); }
.bdp__meta { font-size:.62rem; color:rgba(150,180,220,.5); font-family:ui-monospace,monospace; display:flex; align-items:center; gap:4px; }
.bdp__act { margin-left:auto; display:flex; gap:2px; opacity:0; }
.bdp__e:hover .bdp__act, .bdp__e:focus-within .bdp__act { opacity:1; }
.bdp__mini { cursor:pointer; border:0; background:none; color:rgba(160,195,255,.7); font-size:.7rem; padding:6px 8px; min-height:32px; border-radius:5px; }
.bdp__mini:hover { background:rgba(120,160,230,.12); color:#fff; }
.bdp__mini--del { color:rgba(255,140,140,.8); }
.bdp__mini--sur { background:rgba(255,120,120,.18); color:#fff; }
.bdp__txt { font-size:.84rem; line-height:1.4; white-space:pre-wrap; word-break:break-word; color:rgba(224,236,244,.95); }
.bdp__txt--voile { filter:blur(5px); user-select:none; }
.bdp__rt { display:flex; flex-wrap:wrap; gap:4px; margin-top:4px; align-items:center; }
.bdp__ch { font-size:.64rem; font-family:ui-monospace,monospace; padding:3px 7px; min-height:26px; border-radius:5px; border:1px solid rgba(120,160,230,.22);
background:none; color:rgba(160,195,255,.75); cursor:default; display:inline-flex; align-items:center; }
.bdp__ch--ok { border-color:rgba(120,210,160,.4); color:rgba(150,225,180,.9); }
.bdp__ch--prive { border-style:dashed; color:rgba(190,170,220,.7); }
.bdp__ch--rien { opacity:.45; }
button.bdp__ch { cursor:pointer; }
button.bdp__ch:hover { background:rgba(120,160,230,.12); color:#fff; }
.bdp__vers { width:110px; min-height:26px; font-size:.64rem; font-family:ui-monospace,monospace; border-radius:5px; padding:2px 6px;
border:1px dashed rgba(120,160,230,.3); background:none; color:#fff; outline:none; }
.bdp__frag { font-size:.8rem; line-height:1.35; color:rgba(224,236,244,.9); }
.bdp__type { font-size:.6rem; font-family:ui-monospace,monospace; color:rgba(255,200,140,.75); margin-right:6px; }
.bdp__grp { display:flex; align-items:baseline; gap:8px; padding:6px 0; border-bottom:1px solid rgba(120,160,230,.08); cursor:pointer; }
.bdp__grp b { font-family:ui-monospace,monospace; font-size:.78rem; color:rgba(150,225,180,.9); min-width:120px; }
.bdp__grp span { font-size:.7rem; color:rgba(150,180,220,.6); }
.bdp__num { display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:8px; }
.bdp__tuile { border:1px solid rgba(120,160,230,.16); border-radius:8px; padding:8px 10px; }
.bdp__tuile b { display:block; font-size:1.25rem; font-family:ui-monospace,monospace; font-weight:400; color:#fff; }
.bdp__tuile span { font-size:.66rem; color:rgba(150,180,220,.65); }
.bdp__jours { display:flex; align-items:flex-end; gap:3px; height:56px; margin-top:12px; }
.bdp__jours i { flex:1; background:rgba(120,160,230,.45); border-radius:3px 3px 0 0; min-height:2px; }
.bdp__note { font-size:.66rem; color:rgba(150,180,220,.5); margin-top:8px; line-height:1.4; }
.bdp__in { flex:0 0 auto; display:flex; flex-direction:column; gap:5px; padding:9px 11px; border-top:1px solid rgba(120,160,230,.18); }
.bdp__row { display:flex; gap:8px; }
.bdp__field { flex:1; resize:none; min-height:44px; max-height:180px; border-radius:8px; padding:9px 10px;
border:1px solid rgba(120,160,230,.25); background:rgba(18,26,42,.55); color:#fff; font-family:inherit; font-size:.84rem; outline:none; }
.bdp__field:focus { border-color:rgba(120,160,230,.55); }
.bdp__send { align-self:stretch; min-width:60px; }
.bdp__apercu { font-size:.64rem; font-family:ui-monospace,monospace; color:rgba(150,180,220,.6); min-height:1em; }
.bdp__empty { margin:auto; color:rgba(190,212,228,.4); font-size:.82rem; text-align:center; }
@media (hover:none){
.bdp__act { opacity:.7; }
.bdp__field, .bdp__q, .bdp__vers { font-size:16px; }
}
[data-size="xs"] .bdp__bar { padding:6px 9px; gap:6px; }
[data-size="xs"] .bdp__q, [data-size="xs"] .bdp__cnt { display:none; }
[data-size="xs"] .bdp__in { padding:7px 9px; }
</style>
@include('partials._structure_bion')
@include('partials._decoupe_bion')
<script>
(function () {
var KEY = 'xb:braindump', KEY_SUPPR = 'xb:braindump.suppr', KEY_VOILE = 'xb:braindump.voile';
function lsGet(k, d) { try { var v = localStorage.getItem(k); return v == null ? d : JSON.parse(v); } catch (e) { return d; } }
function lsSet(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch (e) {} }
function load() { var d = lsGet(KEY, []); return Array.isArray(d) ? d : []; }
function save(d) { lsSet(KEY, d); }
function p2(n) { return (n < 10 ? '0' : '') + n; }
function stamp(t) { var d = new Date(t); return p2(d.getDate()) + '/' + p2(d.getMonth() + 1) + ' ' + p2(d.getHours()) + ':' + p2(d.getMinutes()); }
function jour(t) { var d = new Date(t); return d.getFullYear() + '-' + p2(d.getMonth() + 1) + '-' + p2(d.getDate()); }
function el(tag, cls, txt) { var e = document.createElement(tag); if (cls) e.className = cls; if (txt != null) e.textContent = txt; return e; }
function dc() { return window.jOSDecoupe || null; }
// découpe + routage d'un texte → les routes gardées avec la pensée
function decoupe(v, emettre) {
var D = dc(); if (!D) return null;
try {
var fr = D.decouper(v), r = D.router(fr, { emettre: emettre !== false, sauf: ['braindump'] }), env = {}; // jamais vers soi-même (une boucle)
r.envoyes.forEach(function (f) { env[f.n] = f.cible; });
return fr.map(function (f) { return { n: f.n, texte: f.texte, type: f.type, prive: f.prive, envoye: env[f.n] || null, structures: f.structures || [],
choix: env[f.n] || f.prive || f.type === 'ack' ? [] : f.ploxions.filter(function (p) { return p.id !== 'braindump'; }).slice(0, 3).map(function (p) { return p.id; }) }; });
} catch (e) { return null; }
}
function aValider(it) { return (it.routes || []).filter(function (r) { return !r.prive && !r.envoye && r.type !== 'ack'; }); }
function prive(it) { return (it.routes || []).some(function (r) { return r.prive; }); }
function publie(it) {
return it.routes && prive(it) ? it.routes.filter(function (r) { return !r.prive; }).map(function (r) { return r.texte; }).join('\n') : it.txt;
}
function stats(items) {
var auj = jour(Date.now()), j7 = Date.now() - 7 * 864e5, s = { pensees: items.length, auj: 0, frag: 0, routes: 0, prives: 0, att: 0, st: {}, px: {}, j: {} };
items.forEach(function (it) {
if (jour(it.t) === auj) s.auj++;
if (it.t >= j7) s.j[jour(it.t)] = (s.j[jour(it.t)] || 0) + Math.max(1, (it.routes || []).length);
(it.routes || []).forEach(function (r) {
s.frag++;
if (r.prive) s.prives++; else if (r.envoye && r.envoye !== '—') { s.routes++; s.px[r.envoye] = (s.px[r.envoye] || 0) + 1; }
else if (!r.envoye && r.type !== 'ack') s.att++;
(r.structures || []).forEach(function (x) { s.st[x] = 1; });
});
});
return s;
}
function describe() {
var s = stats(load());
return { v: 1, id: 'braindump', title: 'Braindump', icon: '⁂', items: [
{ p: 1, kind: 'stat', label: 'pensées', value: s.pensees },
{ p: 2, kind: 'stat', label: 'aujourd\'hui', value: s.auj },
{ p: 2, kind: 'stat', label: 'à valider', value: s.att }
] };
}
function mount(container, ctx) {
var items = load(), suppr = lsGet(KEY_SUPPR, []), onglet = (ctx && ['flux', 'valider', 'ploxions', 'mesure'].indexOf(ctx.onglet) >= 0) ? ctx.onglet : 'flux', q = '', voile = !!lsGet(KEY_VOILE, false), offIn = null, rec = null, armee = null;
if (!Array.isArray(suppr)) suppr = [];
function filtrer() { var mort = {}; suppr.forEach(function (id) { mort[id] = 1; }); items = items.filter(function (it) { return it && it.id && !mort[it.id]; }); }
// PARTAGÉ ENTRE TES APPAREILS (RS-7 03.11) : le boxion garde la liste. Chaque envoi tire d'abord la version du boxion et FUSIONNE
// (jamais newest-wins : union par id, la version la plus avancée gagne, les effacées restent effacées), puis renvoie l'union —
// un téléphone en retard n'écrase plus les pensées posées sur le PC. On retire aussi au retour sur l'onglet et toutes les 45 s.
function poids(it) { return (it.routes || []).filter(function (x) { return x.envoye; }).length + (it.edit || 0) * 100; }
function fusionner(srv, sup) {
var avant = JSON.stringify([items.length, suppr.length, items.map(poids)]);
(sup || []).forEach(function (id) { if (suppr.indexOf(id) < 0) suppr.push(id); });
var byId = {};
items.concat(srv || []).forEach(function (it) { if (it && it.id && (!byId[it.id] || poids(it) > poids(byId[it.id]))) byId[it.id] = it; });
items = Object.keys(byId).map(function (k) { return byId[k]; }).sort(function (x, y) { return y.t - x.t; });
filtrer();
return JSON.stringify([items.length, suppr.length, items.map(poids)]) !== avant;
}
var enSync = false, encore = false, tSync = null, mort = false;
function boxion() { return window.jOSBoxion && jOSBoxion.get && jOSBoxion.save && (!jOSBoxion.authed || jOSBoxion.authed()); }
function synchro(pousser) {
if (!boxion() || mort) return Promise.resolve(false);
if (enSync) { encore = encore || !!pousser; return Promise.resolve(false); }
enSync = true;
return Promise.all([jOSBoxion.get('braindump', 'pensees'), jOSBoxion.get('braindump', 'suppr')]).then(function (r) {
var srv = Array.isArray(r[0]) ? r[0] : [], sup = Array.isArray(r[1]) ? r[1] : [];
var change = fusionner(srv, sup);
save(items); lsSet(KEY_SUPPR, suppr);
if (change && !mort) refresh();
// on renvoie si on a quelque chose que le boxion n'a pas (ou si on vient de changer ici)
var ids = {}; srv.forEach(function (x) { if (x && x.id) ids[x.id] = poids(x); });
var manque = pousser || sup.length !== suppr.length || items.length !== srv.length || items.some(function (it) { return ids[it.id] !== poids(it); });
if (!manque) return false;
return Promise.all([jOSBoxion.save('braindump', 'pensees', items, 'Braindump'), jOSBoxion.save('braindump', 'suppr', suppr, 'Braindump · effacées')]).then(function () { return true; });
}).catch(function () { return false; }).then(function (x) {
enSync = false;
if (encore) { encore = false; return synchro(true); }
return x;
});
}
function syncUp() { clearTimeout(tSync); tSync = setTimeout(function () { synchro(true); }, 800); }
function persist() { save(items); lsSet(KEY_SUPPR, suppr); syncUp(); }
function auRetour() { if (!document.hidden) synchro(false); }
document.addEventListener('visibilitychange', auRetour);
window.addEventListener('focus', auRetour);
var tTour = setInterval(function () { if (!document.hidden) synchro(false); }, 45000);
synchro(false);
filtrer();
var SR = window.SpeechRecognition || window.webkitSpeechRecognition;
container.innerHTML =
'<div class="bdp">'
+ ' <div class="bdp__bar"><span class="bdp__t">⁂ braindump</span><input class="bdp__q" type="search" placeholder="chercher" aria-label="chercher dans les pensées">'
+ ' <span class="bdp__sp"></span><span class="bdp__cnt"></span>'
+ ' <button class="bdp__btn" data-voile aria-pressed="false" title="voiler les morceaux privés (écran partagé)" aria-label="voiler le privé">◌</button>'
+ ' <button class="bdp__btn" data-export title="exporter (.md)" aria-label="exporter">⇩</button></div>'
+ ' <div class="bdp__tabs" role="tablist"></div>'
+ ' <div class="bdp__stream"></div>'
+ ' <div class="bdp__in"><div class="bdp__apercu" aria-live="polite"></div><div class="bdp__row">'
+ ' <textarea class="bdp__field" placeholder="déverse… (Entrée = poser · Maj+Entrée = saut de ligne)"></textarea>'
+ (SR ? ' <button class="bdp__btn" data-dicte aria-pressed="false" title="dicter" aria-label="dicter">◉</button>' : '')
+ ' <button class="bdp__btn bdp__send" data-send>poser</button></div></div>'
+ '</div>';
var stream = container.querySelector('.bdp__stream'), field = container.querySelector('.bdp__field'), cnt = container.querySelector('.bdp__cnt');
var tabs = container.querySelector('.bdp__tabs'), apercu = container.querySelector('.bdp__apercu'), qIn = container.querySelector('.bdp__q');
var bVoile = container.querySelector('[data-voile]'), bDicte = container.querySelector('[data-dicte]');
function cherche(t) { return !q || String(t || '').toLowerCase().indexOf(q) >= 0; }
function envoyer(it, r, id) {
try { if (id !== '—' && dc()) dc().corriger(r, id); } catch (e) {}
if (id !== '—') try { if (window.jOSPorts) window.jOSPorts.emit(id, 'inbox', { id: it.id + '-' + r.n, t: Date.now(), txt: r.texte, type: r.type, structures: r.structures || [], source: 'decoupe' }); } catch (e) {}
r.envoye = id; r.choix = []; persist(); refresh();
}
// les puces d'un morceau : ⇶ parti · ? proposé (toucher = envoyer + une règle) · → n'importe quel ploxion · ✓ rien · ◌ privé
function puces(it, r, box, plein) {
function ch(txt, cls, titre) { var c = el('span', 'bdp__ch' + (cls ? ' bdp__ch--' + cls : ''), txt); c.title = titre || ''; box.appendChild(c); return c; }
if (r.prive) { ch('◌ pourquoi · privé', 'prive'); return; }
if (r.envoye === '—') { ch('✓ gardé ici', 'rien'); return; }
if (r.envoye) { ch('⇶ ' + r.envoye, 'ok'); return; }
if (r.type === 'ack') { ch('· ack', 'rien'); return; }
r.choix.forEach(function (id) {
var b = el('button', 'bdp__ch', '? ' + id); b.title = 'envoyer à ' + id + ' (et retenir)';
b.addEventListener('click', function () { envoyer(it, r, id); }); box.appendChild(b);
});
if (!plein) { if (!r.choix.length) ch('· ' + r.type); return; }
var v = el('input', 'bdp__vers'); v.placeholder = '→ ploxion'; v.setAttribute('list', 'bdp-px'); v.setAttribute('aria-label', 'envoyer à un ploxion');
v.addEventListener('keydown', function (e) {
if (e.key !== 'Enter') return; var id = v.value.trim(); if (!id) return;
if (dc() && !dc().liste().some(function (p) { return p.id === id; })) { v.style.borderColor = 'rgba(255,120,120,.7)'; return; }
envoyer(it, r, id);
});
box.appendChild(v);
var rien = el('button', 'bdp__ch bdp__ch--rien', '✓ rien'); rien.title = 'le garder ici, ne pas router';
rien.addEventListener('click', function () { envoyer(it, r, '—'); }); box.appendChild(rien);
}
function action(txt, titre, fn, cls) { var b = el('button', 'bdp__mini' + (cls ? ' ' + cls : ''), txt); b.title = titre; b.setAttribute('aria-label', titre); b.addEventListener('click', fn); return b; }
function carte(it) {
var e = el('div', 'bdp__e' + (prive(it) ? ' bdp__e--prive' : ''));
var meta = el('div', 'bdp__meta'); meta.appendChild(el('span', '', stamp(it.t) + (it.edit ? ' · ✎' : '')));
var act = el('div', 'bdp__act');
act.appendChild(action('✎', 'reprendre (la remettre dans le champ)', function () {
field.value = it.txt; field.dataset.edit = it.id; grandir(); voir(); field.focus();
}));
act.appendChild(action('⧉', 'copier', function () { try { navigator.clipboard.writeText(it.txt); } catch (er) {} }));
var del = action('✕', 'effacer (toucher deux fois)', function () {
if (armee !== it.id) { armee = it.id; del.className = 'bdp__mini bdp__mini--del bdp__mini--sur'; del.textContent = '✕ sûr ?'; setTimeout(function () { if (armee === it.id) { armee = null; refresh(); } }, 3000); return; }
armee = null; suppr.push(it.id); items = items.filter(function (m) { return m.id !== it.id; }); persist(); refresh();
}, 'bdp__mini--del');
act.appendChild(del); meta.appendChild(act);
e.appendChild(meta);
var tx = el('div', 'bdp__txt', it.txt);
if (voile && prive(it)) tx.textContent = (it.routes || []).map(function (r) { return r.prive ? '◌ ◌ ◌' : r.texte; }).join('\n');
e.appendChild(tx);
if (it.routes && it.routes.length) {
var box = el('div', 'bdp__rt');
it.routes.forEach(function (r) { puces(it, r, box, false); });
e.appendChild(box);
}
return e;
}
function vide(txt) { stream.appendChild(el('div', 'bdp__empty', txt)); }
function vueFlux() {
var l = items.filter(function (it) { return cherche(it.txt); });
if (!l.length) return vide(items.length ? 'rien ne correspond' : 'le flux est vide — déverse en bas');
l.forEach(function (it) { stream.appendChild(carte(it)); });
}
function vueValider() {
var n = 0;
items.forEach(function (it) {
aValider(it).forEach(function (r) {
if (!cherche(r.texte)) return; n++;
var e = el('div', 'bdp__e'), f = el('div', 'bdp__frag');
f.appendChild(el('span', 'bdp__type', r.type)); f.appendChild(document.createTextNode(r.texte));
e.appendChild(el('div', 'bdp__meta', stamp(it.t))); e.appendChild(f);
var box = el('div', 'bdp__rt'); puces(it, r, box, true); e.appendChild(box);
stream.appendChild(e);
});
});
var vieilles = items.filter(function (it) { return !it.routes; });
if (vieilles.length && dc()) {
var b = el('button', 'bdp__btn', '⇶ découper les ' + vieilles.length + ' anciennes');
b.title = 'les découper sans rien envoyer : tout passe ici, à valider';
b.addEventListener('click', function () { vieilles.forEach(function (it) { var r = decoupe(it.txt, false); if (r) { r.forEach(function (x) { if (x.envoye) { x.choix = [x.envoye]; x.envoye = null; } }); it.routes = r; } }); persist(); refresh(); });
stream.appendChild(b);
}
if (!n && !vieilles.length) vide('tout est routé');
}
function vuePloxions() {
var g = {};
items.forEach(function (it) { (it.routes || []).forEach(function (r) { if (r.envoye && r.envoye !== '—' && cherche(r.texte)) (g[r.envoye] = g[r.envoye] || []).push({ it: it, r: r }); }); });
var ids = Object.keys(g).sort(function (a, b) { return g[b].length - g[a].length; });
if (!ids.length) return vide('rien n\'est encore parti');
ids.forEach(function (id) {
var ligne = el('div', 'bdp__grp'), ouvert = false, det = el('div');
ligne.appendChild(el('b', '', '⇶ ' + id)); ligne.appendChild(el('span', '', g[id].length + ' · dernier ' + stamp(g[id][0].it.t)));
ligne.addEventListener('click', function () {
ouvert = !ouvert; det.innerHTML = '';
if (ouvert) g[id].forEach(function (x) { var f = el('div', 'bdp__frag'); f.appendChild(el('span', 'bdp__type', x.r.type)); f.appendChild(document.createTextNode(x.r.texte)); det.appendChild(f); });
});
stream.appendChild(ligne); stream.appendChild(det);
});
}
function vueMesure() {
var s = stats(items), box = el('div', 'bdp__num');
function tuile(v, l) { var t = el('div', 'bdp__tuile'); t.appendChild(el('b', '', String(v))); t.appendChild(el('span', '', l)); box.appendChild(t); }
var j7 = 0; Object.keys(s.j).forEach(function (k) { j7 += s.j[k]; });
tuile(s.pensees, 'pensées'); tuile(s.auj, 'aujourd\'hui'); tuile(Math.round(j7 / 7 * 10) / 10, 'fluence · morceaux/jour (7 j)');
tuile(Object.keys(s.st).length + ' / 10', 'flexibilité · structures touchées');
tuile(Object.keys(s.px).length, 'ploxions nourris'); tuile(s.frag ? Math.round(s.routes / s.frag * 100) + ' %' : '—', 'routé');
tuile(s.att, 'à valider'); tuile(s.prives, 'privés');
stream.appendChild(box);
var barres = el('div', 'bdp__jours');
for (var i = 6; i >= 0; i--) { var k = jour(Date.now() - i * 864e5), v = s.j[k] || 0, max = 1; Object.keys(s.j).forEach(function (x) { if (s.j[x] > max) max = s.j[x]; });
var b = el('i'); b.style.height = Math.max(2, Math.round(v / max * 56)) + 'px'; b.title = k + ' · ' + v; barres.appendChild(b); }
stream.appendChild(barres);
stream.appendChild(el('div', 'bdp__note', 'te comparer à toi dans le temps, jamais aux autres. originalité (le résidu) et utilité (les paliers) viendront avec jOSResidu et chemin.'));
}
function voir() {
var s = stats(items);
tabs.innerHTML = '';
[['flux', '≋ flux', 0], ['valider', '? à valider', s.att], ['ploxions', '⇶ ploxions', Object.keys(s.px).length], ['mesure', '◔ mesure', 0]].forEach(function (o) {
var b = el('button', 'bdp__tab', o[1]); b.setAttribute('role', 'tab'); b.setAttribute('aria-selected', String(onglet === o[0]));
if (o[2]) b.appendChild(el('b', '', String(o[2])));
b.addEventListener('click', function () { onglet = o[0]; refresh(); }); tabs.appendChild(b);
});
}
function refresh() {
cnt.textContent = items.length + ' pensée' + (items.length > 1 ? 's' : '');
bVoile.setAttribute('aria-pressed', String(voile));
voir();
stream.innerHTML = ''; stream.className = 'bdp__stream' + (onglet === 'flux' ? ' bdp__stream--flux' : '');
({ flux: vueFlux, valider: vueValider, ploxions: vuePloxions, mesure: vueMesure })[onglet]();
}
// l'aperçu pendant que tu tapes : combien de morceaux, où ils iraient
var tAp = null;
function apercevoir() {
clearTimeout(tAp);
tAp = setTimeout(function () {
var v = field.value.trim(); if (!v || !dc()) { apercu.textContent = ''; return; }
var fr = dc().decouper(v), out = fr.map(function (f) { return f.prive ? '◌' : f.cible && f.confiance >= 0.7 ? '⇶ ' + f.cible : f.cible ? '? ' + f.cible : '·'; });
apercu.textContent = fr.length + ' morceau' + (fr.length > 1 ? 'x' : '') + ' · ' + out.join(' · ');
}, 250);
}
function grandir() { field.style.height = 'auto'; field.style.height = Math.min(180, field.scrollHeight) + 'px'; }
function poser(v, source) {
v = String(v || '').trim(); if (!v) return null;
var edit = source === 'champ' && field.dataset.edit, it;
if (edit) {
it = items.find(function (m) { return m.id === edit; });
delete field.dataset.edit;
if (it) { it.txt = v; it.edit = (it.edit || 0) + 1; it.routes = decoupe(v) || it.routes; persist(); refresh(); return it; }
}
it = { id: 'b' + Date.now().toString(36) + Math.floor(Math.random() * 1296).toString(36), t: Date.now(), txt: v };
var rt = decoupe(v); if (rt) it.routes = rt;
items.unshift(it); persist(); refresh();
var pub = publie(it);
// Port out « posted » : la pensée part sur le bus (murion.inbox, idee.seed via jOSWire) — sans les morceaux privés
try { if (window.jOSPorts && pub) window.jOSPorts.emit('braindump', 'posted', { id: it.id, t: it.t, txt: pub }); } catch (e) {}
// chaque pensée = un tsoin (la trace dans la machine)
try { if (window.jOSTsoin && jOSTsoin.mark && pub) jOSTsoin.mark('braindump', 'pensee', { txt: pub.slice(0, 120) }); } catch (e) {}
return it;
}
function add() { if (poser(field.value, 'champ')) { field.value = ''; grandir(); apercu.textContent = ''; } }
field.addEventListener('keydown', function (e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); add(); } });
field.addEventListener('input', function () { grandir(); apercevoir(); });
container.querySelector('[data-send]').addEventListener('click', add);
qIn.addEventListener('input', function () { q = qIn.value.trim().toLowerCase(); refresh(); });
bVoile.addEventListener('click', function () { voile = !voile; lsSet(KEY_VOILE, voile); refresh(); });
container.querySelector('[data-export]').addEventListener('click', function () {
var md = '# braindump\n\n' + items.slice().reverse().map(function (it) {
var l = '## ' + stamp(it.t) + '\n\n' + it.txt + '\n';
if (it.routes && it.routes.length) l += '\n' + it.routes.map(function (r) { return '- ' + (r.prive ? '◌ privé' : r.envoye && r.envoye !== '—' ? '⇶ ' + r.envoye : '· ' + r.type) + ' — ' + (r.prive ? '…' : r.texte); }).join('\n') + '\n';
return l;
}).join('\n');
var a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([md], { type: 'text/markdown' }));
a.download = 'braindump-' + jour(Date.now()) + '.md'; a.click(); setTimeout(function () { URL.revokeObjectURL(a.href); }, 1000);
});
// ◉ la dictée (Web Speech, fr) : le texte s'ajoute au champ, tu poses quand tu veux
if (bDicte && SR) bDicte.addEventListener('click', function () {
if (rec) { try { rec.stop(); } catch (e) {} return; }
rec = new SR(); rec.lang = 'fr-FR'; rec.continuous = true; rec.interimResults = true;
var base = field.value ? field.value.replace(/\s*$/, ' ') : '';
rec.onresult = function (ev) {
var fin = '', prov = '';
for (var i = 0; i < ev.results.length; i++) { if (ev.results[i].isFinal) fin += ev.results[i][0].transcript; else prov += ev.results[i][0].transcript; }
field.value = base + fin + prov; grandir(); apercevoir();
};
rec.onend = function () { rec = null; bDicte.dataset.rec = ''; bDicte.setAttribute('aria-pressed', 'false'); };
rec.onerror = rec.onend;
try { rec.start(); bDicte.dataset.rec = '1'; bDicte.setAttribute('aria-pressed', 'true'); } catch (e) { rec = null; }
});
// la liste des ploxions pour « → ploxion »
if (dc() && !document.getElementById('bdp-px')) {
var dl = el('datalist'); dl.id = 'bdp-px';
dc().liste().forEach(function (p) { var o = el('option'); o.value = p.id; o.label = p.nom; dl.appendChild(o); });
container.appendChild(dl);
}
// IN : une pensée envoyée par un autre ploxion (une dictée ailleurs, un post-it…)
try { if (window.jOSPorts && jOSPorts.on) offIn = jOSPorts.on('ploxion.braindump.inbox', function (p) { if (p && p.source !== 'decoupe' && (p.txt || p.text)) poser(p.txt || p.text, 'bus'); }); } catch (e) {}
refresh(); setTimeout(function () { field.focus(); }, 30);
return { unmount: function () { mort = true; clearInterval(tTour); clearTimeout(tSync); document.removeEventListener('visibilitychange', auRetour); window.removeEventListener('focus', auRetour); if (offIn) offIn(); if (rec) try { rec.stop(); } catch (e) {} clearTimeout(tAp); container.innerHTML = ''; } };
}
window.jOSApps = window.jOSApps || {};
window.jOSApps['braindump'] = { manifest: { id: 'braindump', name: 'Braindump', icon: '⁂' }, mount: mount, describe: describe };
})();
</script>