ploxion-moment/app.blade.php

91 lines
7.1 KiB
PHP

{{-- PL0XION moment — capture l'INSTANT présent (von Neumann, forge PAR BIONS, pour
le tsoin engine). RS-7 : « la machine à tsoins ; chaque truc est un repo ».
Un tap capte le NOW : l'heure, ce qui joue (bus jOSSound), le thème, ta note —
et le scelle comme un tsoin addressable. Le flux de tes moments = ta timeline
d'instants. 100% local. Composé sur window.jOSb + window.jOSSound + jOSTsoin.
window.jOSApps['moment']. mount(c,ctx)->{unmount}. --}}
@include('ploxions._bions')
<style>
.mo { display:flex; flex-direction:column; height:100%; background:#0a0d10; color:#e9eef4; font-family:ui-sans-serif,system-ui,sans-serif; font-size:.84rem; }
.mo__top { flex:0 0 auto; display:flex; flex-direction:column; align-items:center; gap:12px; padding:18px 14px; border-bottom:1px solid rgba(110,200,180,.16); }
.mo__now { font-size:clamp(30px,9vmin,52px); font-weight:800; font-variant-numeric:tabular-nums; color:#5eead4; line-height:1; }
.mo__date { font-size:.74rem; color:rgba(180,220,210,.6); }
.mo__ctx { font-size:.72rem; color:rgba(180,215,205,.7); text-align:center; min-height:1.1em; }
.mo__note { width:100%; max-width:420px; box-sizing:border-box; background:rgba(0,0,0,.3); border:1px solid rgba(110,200,180,.25); border-radius:9px; color:#dffaf0; padding:8px 10px; font:0.84rem ui-sans-serif,system-ui; outline:none; }
.mo__cap { cursor:pointer; border:0; border-radius:24px; background:#5eead4; color:#06231c; font-weight:800; font-size:.95rem; padding:11px 28px; }
.mo__cap:hover { filter:brightness(1.08); }
.mo__list { flex:1; min-height:0; overflow-y:auto; padding:10px 11px; display:flex; flex-direction:column; gap:7px; }
.mo__m { border:1px solid rgba(110,200,180,.16); border-radius:11px; padding:9px 11px; background:rgba(255,255,255,.02); }
.mo__mh { display:flex; align-items:baseline; gap:8px; font-size:.7rem; color:rgba(180,215,205,.6); }
.mo__mt { color:#5eead4; font-weight:700; font-variant-numeric:tabular-nums; } .mo__sp { flex:1; }
.mo__del { cursor:pointer; border:0; background:none; color:rgba(255,150,150,.55); font-size:.7rem; }
.mo__mn { margin-top:5px; font-size:.9rem; line-height:1.4; white-space:pre-wrap; word-break:break-word; }
.mo__mc { margin-top:4px; font-size:.66rem; color:rgba(170,205,195,.6); }
.mo__empty { text-align:center; color:rgba(180,210,200,.5); padding:22px; font-size:.84rem; line-height:1.5; }
</style>
<script>
(function () {
'use strict';
function describe(){
var store = window.jOSb ? jOSb.store('xb:moments') : { get: function (d) { return d; } };
var moments = store.get([]) || [];
return { v:1, id:'moment', title:'Moment', icon:'⧗', items:[
{ p:1, kind:'stat', label:'instants captés', value:moments.length }
]};
}
function mount(container, ctx) {
var store = window.jOSb ? jOSb.store('xb:moments') : { get: function (d) { return d; }, set: function () {} };
var moments = store.get([]) || [], clk = 0;
container.innerHTML =
'<div class="mo">'
+ ' <div class="mo__top">'
+ ' <div><div class="mo__now" data-now>--:--</div><div class="mo__date" data-date></div></div>'
+ ' <div class="mo__ctx" data-ctx></div>'
+ ' <input class="mo__note" data-note placeholder="une note sur cet instant (optionnel)…">'
+ ' <button class="mo__cap" data-cap>⧗ capter l\'instant</button>'
+ ' </div>'
+ ' <div class="mo__list" data-list></div></div>';
var elNow = container.querySelector('[data-now]'), elDate = container.querySelector('[data-date]'), elCtx = container.querySelector('[data-ctx]'), elNote = container.querySelector('[data-note]'), list = container.querySelector('[data-list]');
function sound() { // ce qui joue, via le bus jOSSound
try { var live = (window.jOSSound && window.jOSSound.list() || []).filter(function (s) { return s.isPaused && !s.isPaused(); });
if (live.length) { var s = live[0]; return (s.icon || '🔊') + ' ' + ((s.label && s.label()) || s.kind || ''); } } catch (e) {}
return '';
}
function theme() { try { return document.documentElement.getAttribute('data-theme') || ''; } catch (e) { return ''; } }
function clock() {
var d = new Date();
elNow.textContent = ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2) + ':' + ('0' + d.getSeconds()).slice(-2);
elDate.textContent = d.toLocaleDateString('fr-FR', { weekday: 'long', day: 'numeric', month: 'long' });
var s = sound(); elCtx.textContent = s ? ('♪ ' + s) : 'silence';
}
function fmtT(ts) { var d = new Date(ts); return ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2); }
function fmtD(ts) { try { return new Date(ts).toLocaleDateString('fr-FR', { day: '2-digit', month: 'short' }); } catch (e) { return ''; } }
function render() {
if (!moments.length) { list.innerHTML = '<div class="mo__empty">aucun moment capté.<br>Tape « capter l\'instant » — chaque instant devient un tsoin, posé dans ta timeline.</div>'; return; }
list.innerHTML = moments.slice().reverse().map(function (m) {
return '<div class="mo__m" data-id="' + m.id + '"><div class="mo__mh"><span class="mo__mt">' + fmtT(m.at) + '</span><span>' + fmtD(m.at) + '</span><span class="mo__sp"></span><button class="mo__del" data-del="' + m.id + '">✕</button></div>'
+ (m.note ? '<div class="mo__mn">' + jOSb.esc(m.note) + '</div>' : '')
+ '<div class="mo__mc">' + jOSb.esc([m.sound ? '♪ ' + m.sound : '', m.theme ? '◐ ' + m.theme : ''].filter(Boolean).join(' · ') || '— instant nu') + '</div></div>';
}).join('');
list.querySelectorAll('[data-del]').forEach(function (b) { b.addEventListener('click', function () { moments = moments.filter(function (x) { return x.id !== b.getAttribute('data-del'); }); store.set(moments); render(); }); });
}
function capture() {
var m = { id: 'm' + Date.now().toString(36), at: Date.now(), note: elNote.value.trim(), sound: sound(), theme: theme() };
moments.push(m); store.set(moments.slice(-200)); moments = store.get([]); elNote.value = '';
try { if (window.jOSTsoin && window.jOSTsoin.isOn && window.jOSTsoin.isOn()) window.jOSTsoin.mark('moment', m.note || fmtT(m.at)); } catch (e) {}
if (window.jOSb) jOSb.toast(container, '⧗ instant capté');
render();
}
container.querySelector('[data-cap]').addEventListener('click', capture);
elNote.addEventListener('keydown', function (e) { if (e.key === 'Enter') capture(); });
clock(); render(); clk = setInterval(clock, 1000);
return { unmount: function () { if (clk) clearInterval(clk); container.innerHTML = ''; } };
}
window.jOSApps = window.jOSApps || {};
window.jOSApps['moment'] = { manifest: { id: 'moment', name: 'Moment', icon: '⧗' }, mount: mount, describe: describe };
})();
</script>