168 lines
20 KiB
PHP
168 lines
20 KiB
PHP
{{-- PL0XI0N glyphed — L'ATELIER DES GLYPHES (19.10.2026, RS-7 : « un ploxion pour checker les glyphes de chacun et pouvoir les modifier, et
|
||
aussi pouvoir ajouter mes propres glyphes, donc un générateur de glyphes et un truc à la joswipe pour confirmer les glyphes et modifier ceux
|
||
que je trouve pas corrects »). Remplace l'éditeur pixel-art de l'ancien losange (même id : une seule porte vers les glyphes des ploxions).
|
||
Les icônes viennent de ploxi0n (window.jOSIcone : la forme = le type, la couleur = la catégorie, le glyphe = ce qu'il fait).
|
||
◇ revue : jOSSwipe — ← ✎ à corriger · → ♥ bon · ↑ ★ parfait (POST /px/icones/avis)
|
||
✎ corriger : le glyphe (la bibliothèque + les tiens), la couleur (6 palettes), le cœur, le style ; pour toi, ou pour tous (un admin :
|
||
ça part aussi dans le registre, que ploxi0n lit) — PUT /px/icones/{id}
|
||
✦ créer : le générateur (forme × marque) et le dessin au trait sur la grille → POST /px/glyphes (reconstruit côté serveur)
|
||
Chill-tekk : sombre, usé, sans dégradé, les onglets en bas, au pouce. Peu de texte : des glyphes. window.jOSApps['glyphed']. --}}
|
||
@include('ploxions.glyphed._boutons')
|
||
<style>
|
||
.gat{ --a:#a597cf; --b:#79d9a2; --t:#ddd6ea; --m:#7f7699; --bd:#272036; --bd2:#3a3050; --s:#0f0b18; display:flex; flex-direction:column; height:100%; min-height:0; background:#07050c; color:var(--t); font-family:-apple-system,system-ui,sans-serif; font-size:14px; }
|
||
.gat *{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
|
||
.gat__h{ flex:0 0 auto; display:flex; align-items:baseline; gap:10px; padding:12px 14px 6px; } .gat__h b{ font:800 15px ui-monospace,Menlo,monospace; letter-spacing:.08em; } .gat__h span{ font:600 11px ui-monospace,Menlo,monospace; color:var(--m); }
|
||
.gat__corps{ flex:1; min-height:0; overflow:auto; padding:6px 14px 10px; }
|
||
.gat__nav{ flex:0 0 auto; display:flex; gap:5px; margin:0 12px calc(env(safe-area-inset-bottom,0px) + 10px); padding:6px; border-radius:20px; border:2px solid var(--bd2); background:#0a0712; }
|
||
.gat__nav button{ flex:1; min-height:52px; border:0; border-radius:14px; background:none; color:var(--m); font:700 9px ui-monospace,Menlo,monospace; text-transform:uppercase; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; cursor:pointer; }
|
||
.gat__nav button i{ font-style:normal; font-size:18px; } .gat__nav button.on{ background:#151021; color:var(--t); box-shadow:inset 0 0 0 1.5px var(--b); }
|
||
.gat__carte{ display:flex; flex-direction:column; align-items:center; gap:8px; padding:18px 10px; } .gat__carte .ic{ width:min(52vw,190px); height:min(52vw,190px); } .gat__carte .ic svg{ width:100%; height:100%; }
|
||
.gat__carte b{ font-size:18px; } .gat__carte small{ font:600 11px ui-monospace,Menlo,monospace; color:var(--m); }
|
||
.gat__bt{ min-height:44px; padding:8px 14px; border-radius:14px; border:2px solid var(--bd2); background:#0f0b18; color:var(--t); font:700 12px ui-monospace,Menlo,monospace; cursor:pointer; }
|
||
.gat__bt.go{ border-color:var(--b); } .gat__bt.on{ border-color:var(--b); color:var(--b); } .gat__bt[disabled]{ opacity:.4; }
|
||
.gat__rang{ display:flex; flex-wrap:wrap; gap:6px; align-items:center; margin:8px 0; }
|
||
.gat__lab{ font:700 10px ui-monospace,Menlo,monospace; text-transform:uppercase; letter-spacing:.12em; color:var(--m); margin:12px 0 6px; }
|
||
.gat__q{ width:100%; min-height:42px; padding:8px 12px; border-radius:12px; border:2px solid var(--bd2); background:#0f0b18; color:var(--t); font:inherit; }
|
||
.gat__liste{ display:grid; grid-template-columns:repeat(auto-fill,minmax(78px,1fr)); gap:6px; }
|
||
.gat__px{ display:flex; flex-direction:column; align-items:center; gap:4px; padding:8px 4px; border-radius:14px; border:2px solid var(--bd); background:var(--s); color:var(--t); cursor:pointer; font:600 10px ui-monospace,Menlo,monospace; min-height:86px; }
|
||
.gat__px .ic{ width:46px; height:46px; } .gat__px .ic svg{ width:100%; height:100%; } .gat__px.on{ border-color:var(--b); } .gat__px.corr{ border-color:#ef6f8e; } .gat__px span{ max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
||
.gat__ed{ display:grid; grid-template-columns:minmax(0,180px) minmax(0,1fr); gap:14px; align-items:start; } @media (max-width:560px){ .gat__ed{ grid-template-columns:1fr; } }
|
||
.gat__apercu{ display:flex; gap:10px; justify-content:center; } .gat__apercu div{ width:84px; height:84px; } .gat__apercu svg{ width:100%; height:100%; }
|
||
.gat__gl{ display:grid; grid-template-columns:repeat(auto-fill,minmax(44px,1fr)); gap:5px; max-height:220px; overflow:auto; }
|
||
.gat__gl button{ aspect-ratio:1; border-radius:12px; border:2px solid var(--bd); background:#0f0b18; color:var(--t); padding:7px; cursor:pointer; } .gat__gl button.on{ border-color:var(--b); color:var(--b); }
|
||
.gat__gl button svg{ width:100%; height:100%; fill:none; stroke:currentColor; stroke-width:7; stroke-linecap:round; stroke-linejoin:round; } .gat__gl button.perso{ border-style:dashed; }
|
||
.gat__gl button svg .f{ fill:currentColor; stroke:none; } .gat__gl button svg .p{ stroke-dasharray:7 7; stroke-width:4.5; }
|
||
.gat__pal{ width:40px; height:40px; border-radius:12px; border:2px solid var(--bd); cursor:pointer; } .gat__pal.on{ border-color:var(--t); }
|
||
.gat__grille{ width:min(78vw,300px); aspect-ratio:1; touch-action:none; border-radius:16px; border:2px solid var(--bd2); background:#0f0b18; display:block; margin:0 auto; }
|
||
.gat__grille .pt{ fill:#3a3050; } .gat__grille .pt.on{ fill:var(--b); } .gat__grille .tr{ fill:none; stroke:var(--t); stroke-width:7; stroke-linecap:round; stroke-linejoin:round; }
|
||
.gat__msg{ font:600 11px ui-monospace,Menlo,monospace; color:var(--b); min-height:16px; margin-top:6px; }
|
||
.gat__vide{ padding:30px 10px; text-align:center; color:var(--m); font:600 12px ui-monospace,Menlo,monospace; }
|
||
</style>
|
||
<script>
|
||
(function () {
|
||
'use strict';
|
||
var ID = 'glyphed';
|
||
function esc(s) { return window.jOSb.esc(s); }
|
||
function csrf() { var m = document.querySelector('meta[name=csrf-token]'); return m ? m.content : ''; }
|
||
function api(url, methode, corps) {
|
||
return fetch(url, { method: methode || 'GET', credentials: 'same-origin', headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'X-CSRF-TOKEN': csrf(), 'X-Requested-With': 'XMLHttpRequest' }, body: corps ? JSON.stringify(corps) : undefined })
|
||
.then(function (r) { return r.json().catch(function () { return {}; }).then(function (d) { if (!r.ok) throw new Error(d.message || ('erreur ' + r.status)); return d; }); });
|
||
}
|
||
function I() { return window.jOSIcone && window.jOSIcone.px ? window.jOSIcone : null; } // nommé « jOSIcone.px » : la page /px inclut le partial des icônes
|
||
function pxs() { return (window.__PLOXIONS__ || []).filter(function (p) { return p && p.id && !p.admin; }); }
|
||
function inner(svg) { var m = /^<svg[^>]*>([\s\S]*)<\/svg>$/.exec(String(svg || '').trim()); return m ? m[1] : ''; }
|
||
function gly(nom) { var g = I() && I().GLYPHES[nom]; return '<svg viewBox="0 0 100 100" aria-hidden="true">' + (g || '') + '</svg>'; }
|
||
|
||
function mount(c, ctx) {
|
||
var gab = null, vivant = true, onglet = (ctx && ctx.params && ctx.params.onglet === 'boutons') || /[?&]onglet=boutons/.test(location.search) ? 'boutons' : 'revue', sel = null, q = '', brouillon = null, swipe = null, msg = '', gen = 0, trait = [], depart = null, outil = 'trait';
|
||
if (!I()) { c.innerHTML = '<div class="gat"><div class="gat__vide">◌ les icônes du xerboxion ne sont pas chargées</div></div>'; return { unmount: function () { c.innerHTML = ''; } }; }
|
||
function ico() { return I().icones(); }
|
||
function specDe(id) { var t = ico().tous[id] || {}, m = ico().mien[id] || {}; var o = {}; [t, m].forEach(function (x) { for (var k in x) o[k] = x[k]; }); return o; }
|
||
function rendu(id, sp, style, taille) { return I().px(id, { fond: true, perso: Object.assign({}, sp || {}, style ? { style: style } : {}), size: taille }); }
|
||
function aCorriger() { var a = ico().avis || {}; return Object.keys(a).filter(function (k) { return a[k] === 'corriger'; }); }
|
||
|
||
function dessiner() {
|
||
if (!vivant) return;
|
||
var tot = pxs().length, vus = Object.keys(ico().avis || {}).length;
|
||
c.innerHTML = '<div class="gat"><div class="gat__h"><b>◇ glyphes</b><span>' + vus + ' / ' + tot + ' revus · ✎ ' + aCorriger().length + '</span></div><div class="gat__corps" data-corps>'
|
||
+ (onglet === 'revue' ? '<div data-deck></div>' : onglet === 'corriger' ? vueCorriger() : onglet === 'boutons' ? '<div data-gab></div>' : vueCreer()) + '</div>'
|
||
+ '<nav class="gat__nav">' + [['revue', '◇', 'revue'], ['corriger', '✎', 'corriger'], ['creer', '✦', 'créer'], ['boutons', '⌗', 'boutons']].map(function (t) { return '<button data-onglet="' + t[0] + '"' + (onglet === t[0] ? ' class="on"' : '') + '><i>' + t[1] + '</i>' + t[2] + '</button>'; }).join('') + '</nav></div>';
|
||
try { if (gab) gab.stop(); } catch (e) {} gab = null;
|
||
if (onglet === 'boutons' && window.jOSGlyphedBoutons) gab = window.jOSGlyphedBoutons.monter(c.querySelector('[data-gab]')); // (02.11) ⌗ les boutons du xer
|
||
if (onglet === 'revue') monterRevue();
|
||
if (onglet === 'creer') majGrille();
|
||
}
|
||
|
||
/* ── ◇ revue : le deck (jOSSwipe), les ploxions pas encore revus ── */
|
||
function monterRevue() {
|
||
var hote = c.querySelector('[data-deck]'); if (!hote) return;
|
||
if (!window.jOSSwipe) { hote.innerHTML = '<div class="gat__vide">◌ jOSSwipe manquant</div>'; return; }
|
||
var a = ico().avis || {}, items = pxs().filter(function (p) { return !a[p.id]; }).slice(0, 80).map(function (p) {
|
||
return { id: p.id, render: function (el) { var s = I().spec ? I().spec({ id: p.id, nom: p.name }) : {}; el.innerHTML = '<div class="gat__carte"><div class="ic">' + rendu(p.id, specDe(p.id)) + '</div><b>' + esc(p.name) + '</b><small>' + esc((s && s.type) || '') + ' · ' + esc((specDe(p.id).glyphe) || (s && s.glyphe) || '') + '</small></div>'; } }; });
|
||
if (!items.length) { hote.innerHTML = '<div class="gat__vide">✓ tout est revu · ✎ ' + aCorriger().length + ' à corriger</div>'; return; }
|
||
try { if (swipe && swipe.destroy) swipe.destroy(); } catch (e) {}
|
||
swipe = window.jOSSwipe.mount(hote, {
|
||
items: items, persistNs: 'glyphes-revue', persistKeyOf: function (it) { return 'gr:' + it.id; },
|
||
verdicts: [{ key: 'corriger', label: '✎', dir: 'left', color: '#ef6f8e' }, { key: 'bon', label: '♥', dir: 'right', color: '#79d9a2' }, { key: 'parfait', label: '★', dir: 'up', color: '#f0d36c' }],
|
||
title: '◇', hint: '← ✎ · → ♥ · ↑ ★',
|
||
onVerdict: function (it, v) { ico().avis[it.id] = v; api('/px/icones/avis', 'POST', { ploxion: it.id, avis: v }).catch(function () {}); var h = c.querySelector('.gat__h span'); if (h) h.textContent = Object.keys(ico().avis).length + ' / ' + pxs().length + ' revus · ✎ ' + aCorriger().length; }
|
||
});
|
||
}
|
||
|
||
/* ── ✎ corriger ── */
|
||
function vueCorriger() {
|
||
var corr = aCorriger(), qq = q.trim().toLowerCase();
|
||
var liste = qq ? pxs().filter(function (p) { return (p.id + ' ' + p.name).toLowerCase().indexOf(qq) >= 0; }).slice(0, 40) : corr.map(function (id) { return pxs().filter(function (p) { return p.id === id; })[0]; }).filter(Boolean);
|
||
var h = '<input class="gat__q" data-q placeholder="⌕ un ploxion" value="' + esc(q) + '">'
|
||
+ '<div class="gat__lab">' + (qq ? '⌕ ' + liste.length : '✎ à corriger · ' + liste.length) + '</div>'
|
||
+ (liste.length ? '<div class="gat__liste">' + liste.map(function (p) { return '<button class="gat__px' + (sel === p.id ? ' on' : '') + (corr.indexOf(p.id) >= 0 ? ' corr' : '') + '" data-sel="' + esc(p.id) + '"><span class="ic">' + rendu(p.id, specDe(p.id)) + '</span><span>' + esc(p.name) + '</span></button>'; }).join('') + '</div>' : '<div class="gat__vide">' + (qq ? '∅' : '◇ revue : ← pour en mettre ici') + '</div>');
|
||
if (sel) h += editeur();
|
||
return h;
|
||
}
|
||
function editeur() {
|
||
var p = pxs().filter(function (x) { return x.id === sel; })[0] || { id: sel, name: sel }, b = brouillon || (brouillon = specDe(sel)), base = I().spec ? I().spec({ id: p.id, nom: p.name }) : {};
|
||
var noms = Object.keys(I().GLYPHES).filter(function (n) { return !/^(fermer|retour|minimiser|basculer|chercher|plus|moins|valider)$/.test(n); });
|
||
var perso = noms.filter(function (n) { return /^g-/.test(n); });
|
||
var ad = !!ico().admin;
|
||
return '<div class="gat__lab">✎ ' + esc(p.name) + '</div><div class="gat__ed"><div><div class="gat__apercu"><div>' + rendu(p.id, b, 'xerboxion') + '</div><div>' + rendu(p.id, b, 'glyphe') + '</div></div>'
|
||
+ '<div class="gat__rang" style="justify-content:center"><button class="gat__bt go" data-poser="moi">✓ moi</button>' + (ad ? '<button class="gat__bt go" data-poser="tous">✓ tous</button>' : '') + '<button class="gat__bt" data-defaut>↺</button></div><div class="gat__msg" data-msg>' + esc(msg) + '</div></div><div>'
|
||
+ '<div class="gat__lab" style="margin-top:0">glyphe · ' + esc(b.glyphe || base.glyphe || '') + '</div><div class="gat__gl">' + perso.concat(noms.filter(function (n) { return perso.indexOf(n) < 0; })).map(function (n) { return '<button data-gl="' + esc(n) + '" title="' + esc(n) + '" class="' + ((b.glyphe || base.glyphe) === n ? 'on ' : '') + (/^g-/.test(n) ? 'perso' : '') + '">' + gly(n) + '</button>'; }).join('') + '</div>'
|
||
+ '<div class="gat__lab">couleur</div><div class="gat__rang">' + I().GPAL.map(function (P, i) { var on = (b.pal != null ? +b.pal : base.pal) === i; return '<button class="gat__pal' + (on ? ' on' : '') + '" data-pal="' + i + '" title="' + P.n + '" style="background:' + P.bg + ';box-shadow:inset 0 0 0 8px ' + P.a + '"></button>'; }).join('') + '</div>'
|
||
+ '<div class="gat__lab">cœur</div><div class="gat__rang">' + [['wormion', '◎'], ['portion', '▣'], ['kion', '◇']].map(function (x) { return '<button class="gat__bt' + ((b.centre || base.centre) === x[0] ? ' on' : '') + '" data-centre="' + x[0] + '">' + x[1] + ' ' + x[0] + '</button>'; }).join('') + '</div>'
|
||
+ '</div></div>';
|
||
}
|
||
|
||
/* ── ✦ créer : le générateur et le trait ── */
|
||
function vueCreer() {
|
||
var cands = []; for (var i = 0; i < 12; i++) cands.push('gen-' + gen + '-' + i);
|
||
return '<div class="gat__lab">✦ le générateur · forme × marque</div><div class="gat__gl" style="max-height:none">' + cands.map(function (s) { return '<button data-cand="' + s + '">' + I().genere({ id: s }).replace(/class="[^"]*"/, '') + '</button>'; }).join('') + '</div>'
|
||
+ '<div class="gat__rang"><button class="gat__bt" data-gen>⟳ d\'autres</button></div>'
|
||
+ '<div class="gat__lab">✎ au trait · touche deux points</div><div class="gat__rang"><button class="gat__bt' + (outil === 'trait' ? ' on' : '') + '" data-outil="trait">╱ trait</button><button class="gat__bt' + (outil === 'rond' ? ' on' : '') + '" data-outil="rond">◯ rond</button><button class="gat__bt' + (outil === 'point' ? ' on' : '') + '" data-outil="point">● point</button><button class="gat__bt" data-annuler>↶</button><button class="gat__bt" data-vider>∅</button></div>'
|
||
+ '<svg class="gat__grille" data-grille viewBox="-5 -5 110 110"></svg>'
|
||
+ '<div class="gat__rang"><input class="gat__q" data-nom placeholder="nom du glyphe" maxlength="30" style="flex:1"><button class="gat__bt go" data-garder>+ garder</button></div><div class="gat__msg" data-msg>' + esc(msg) + '</div>'
|
||
+ mesGlyphes();
|
||
}
|
||
function mesGlyphes() { var l = (ico().glyphes || []).filter(function (g) { return g.mien; }); if (!l.length) return '';
|
||
return '<div class="gat__lab">tes glyphes · ' + l.length + '</div><div class="gat__gl">' + l.map(function (g) { return '<button class="perso" data-suppr-gl="' + g.id + '" title="' + esc(g.nom) + ' · ✕">' + gly(g.nom) + '</button>'; }).join('') + '</div>'; }
|
||
function corpsTrait() { return trait.map(function (t) { return t.k === 'trait' ? '<line x1="' + t.a[0] + '" y1="' + t.a[1] + '" x2="' + t.b[0] + '" y2="' + t.b[1] + '"/>' : t.k === 'rond' ? '<circle cx="' + t.a[0] + '" cy="' + t.a[1] + '" r="' + Math.round(Math.hypot(t.b[0] - t.a[0], t.b[1] - t.a[1])) + '"/>' : '<circle cx="' + t.a[0] + '" cy="' + t.a[1] + '" r="6" class="f"/>'; }).join(''); }
|
||
function majGrille() {
|
||
var g = c.querySelector('[data-grille]'); if (!g) return; var h = '';
|
||
for (var y = 0; y <= 100; y += 10) for (var x = 0; x <= 100; x += 10) h += '<circle class="pt' + (depart && depart[0] === x && depart[1] === y ? ' on' : '') + '" cx="' + x + '" cy="' + y + '" r="2.4" data-pt="' + x + ',' + y + '"/>';
|
||
g.innerHTML = h + '<g class="tr">' + corpsTrait().replace(/ class="f"/g, ' fill="#ddd6ea" stroke="none"') + '</g>';
|
||
}
|
||
function garder(corps, nom) {
|
||
if (!corps) { msg = '◇ vide'; return dessiner(); }
|
||
api('/px/glyphes', 'POST', { nom: nom || ('glyphe ' + Date.now().toString(36)), corps: corps }).then(function (d) { msg = '✓ ' + d.nom; trait = []; depart = null; return I().recharger(); }, function (e) { msg = '◇ ' + e.message; }).then(dessiner);
|
||
}
|
||
|
||
c.addEventListener('click', function (e) {
|
||
var b = e.target.closest('button,[data-pt]'); if (!b || !vivant) return; var d = b.dataset;
|
||
if (d.onglet) { onglet = d.onglet; msg = ''; return dessiner(); }
|
||
if (d.sel) { sel = d.sel; brouillon = null; msg = ''; return dessiner(); }
|
||
if (d.gl) { brouillon.glyphe = d.gl; return dessiner(); }
|
||
if (d.pal != null) { brouillon.pal = +d.pal; return dessiner(); }
|
||
if (d.centre) { brouillon.centre = d.centre; return dessiner(); }
|
||
if (d.poser) { var tous = d.poser === 'tous'; api('/px/icones/' + encodeURIComponent(sel), 'PUT', { spec: brouillon, tous: tous }).then(function () { if (!tous) ico().mien[sel] = Object.assign({}, brouillon); else ico().tous[sel] = Object.assign({}, brouillon); ico().avis[sel] = 'bon'; api('/px/icones/avis', 'POST', { ploxion: sel, avis: 'bon' }).catch(function () {}); msg = '✓ ' + (tous ? 'pour tous' : 'pour toi'); return I().recharger(); }, function (er) { msg = '◇ ' + er.message; }).then(dessiner); return; }
|
||
if (d.defaut != null) { api('/px/icones/' + encodeURIComponent(sel), 'DELETE').then(function () { delete ico().mien[sel]; brouillon = null; msg = '↺'; return I().recharger(); }).then(dessiner); return; }
|
||
if (d.gen != null) { gen++; return dessiner(); }
|
||
if (d.cand) { var nm = c.querySelector('[data-nom]'); garder(inner(I().genere({ id: d.cand })), nm && nm.value.trim()); return; }
|
||
if (d.outil) { outil = d.outil; depart = null; return dessiner(); }
|
||
if (d.annuler != null) { trait.pop(); return majGrille(); }
|
||
if (d.vider != null) { trait = []; depart = null; return majGrille(); }
|
||
if (d.garder != null) { var n2 = c.querySelector('[data-nom]'); garder(corpsTrait(), n2 && n2.value.trim()); return; }
|
||
if (d.supprGl) { api('/px/glyphes/' + d.supprGl, 'DELETE').then(function () { return I().recharger(); }).then(dessiner); return; }
|
||
if (d.pt) { var p = d.pt.split(',').map(Number);
|
||
if (outil === 'point') { trait.push({ k: 'point', a: p }); return majGrille(); }
|
||
if (!depart) { depart = p; return majGrille(); }
|
||
if (depart[0] !== p[0] || depart[1] !== p[1]) trait.push({ k: outil, a: depart, b: p }); depart = null; return majGrille(); }
|
||
});
|
||
c.addEventListener('input', function (e) { if (e.target.matches('[data-q]')) { q = e.target.value; var pos = e.target.selectionStart; dessiner(); var nq = c.querySelector('[data-q]'); if (nq) { nq.focus(); try { nq.setSelectionRange(pos, pos); } catch (er) {} } } });
|
||
I().recharger().then(function () { if (vivant) dessiner(); });
|
||
dessiner();
|
||
return { unmount: function () { vivant = false; try { if (swipe && swipe.destroy) swipe.destroy(); } catch (e) {} try { if (gab) gab.stop(); } catch (e) {} c.innerHTML = ''; } };
|
||
}
|
||
window.jOSApps = window.jOSApps || {};
|
||
window.jOSApps[ID] = { manifest: { id: ID, name: 'Atelier des glyphes', icon: '◇' }, mount: mount };
|
||
})();
|
||
</script>
|