ploxion-glyphed/_boutons.blade.php

169 lines
19 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.

{{-- L'atelier des glyphes · ⌗ boutons (02.11, RS-7 : « il y en a plein c'est des glyphes et c'est incompréhensible, on est obligé de hover pour
savoir ce que c'est, il faudrait travailler ensemble sur des glyphes ui plus précis », puis « donne-moi une page avec tous les boutons qui
existent dans le xer entier pour les propositions »). Chaque bouton du xer, relevé dans un vrai Chromium par bin/inventaire-boutons.mjs
(resources/data/boutons-ui.json, servi par /data/boutons-ui.json) : tel qu'il s'affiche, son nom, sa zone, son action ; trois glyphes
proposés, « le mot » (son nom écrit au lieu d'un glyphe), « garder », ou le tien. Plus une question pour tout le bureau : écrire le nom à
côté du glyphe quand il y a la place. Les choix vont dans jOSStore('glyphes-ui') (ton boxion) : xerxion les lit et les applique.
window.jOSGlyphedBoutons.monter(hote) → {stop}. Les SVG relevés sont nettoyés (liste blanche d'éléments et d'attributs) avant affichage. --}}
<style>
.gab{ display:flex; flex-direction:column; gap:10px; padding-bottom:10px; }
.gab__tete{ display:flex; flex-wrap:wrap; align-items:baseline; gap:8px; font-size:13px; } .gab__tete b{ font-size:15px; } .gab__tete span{ color:var(--m,#7f7699); }
.gab__glob{ border:1.5px solid var(--bd2,#3a3050); border-radius:14px; padding:10px 12px; display:flex; flex-direction:column; gap:8px; font-size:13px; }
.gab__glob p{ margin:0; color:var(--t,#ddd6ea); }
.gab__ch{ display:flex; flex-wrap:wrap; gap:6px; }
.gab__c{ cursor:pointer; min-height:34px; padding:4px 11px; border-radius:999px; border:1.5px solid var(--bd2,#3a3050); background:transparent; color:var(--t,#ddd6ea); font:600 12px ui-sans-serif,system-ui; }
.gab__c.on{ border-color:var(--b,#79d9a2); color:#08110b; background:var(--b,#79d9a2); }
.gab__c i{ font-style:normal; opacity:.65; margin-left:5px; }
.gab__f{ display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.gab__f input{ flex:1 1 160px; min-height:36px; border-radius:10px; border:1.5px solid var(--bd2,#3a3050); background:#0a0712; color:var(--t,#ddd6ea); padding:6px 10px; font:14px ui-sans-serif,system-ui; }
.gab__b{ display:grid; grid-template-columns:52px minmax(0,1fr); gap:6px 12px; padding:10px 4px; border-bottom:1px solid var(--bd,#272036); }
.gab__now{ grid-row:span 2; width:52px; height:52px; border-radius:12px; border:1.5px solid var(--bd2,#3a3050); display:flex; align-items:center; justify-content:center; font:20px ui-sans-serif,system-ui; color:var(--t,#ddd6ea); overflow:hidden; background:#0a0712; }
.gab__now svg{ width:30px; height:30px; } .gab__now small{ font-size:10px; text-align:center; line-height:1.1; padding:2px; }
.gab__q b{ font-size:14px; display:block; overflow-wrap:anywhere; } .gab__q small{ color:var(--m,#7f7699); font-size:11px; }
.gab__q small.cache{ color:#c99; }
.gab__p{ display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.gab__g{ cursor:pointer; min-width:42px; min-height:40px; padding:2px 10px; border-radius:11px; border:1.5px solid var(--bd2,#3a3050); background:transparent; color:var(--t,#ddd6ea); font:20px ui-sans-serif,system-ui; }
.gab__g.mot{ font:600 12px ui-sans-serif,system-ui; } .gab__g.on{ border-color:var(--b,#79d9a2); box-shadow:inset 0 0 0 1.5px var(--b,#79d9a2); color:#fff; }
.gab__g input{ width:2.2em; border:0; background:transparent; color:inherit; font:inherit; text-align:center; outline:none; }
.gab__plus{ text-align:center; } .gab__vide{ padding:30px 10px; text-align:center; color:var(--m,#7f7699); }
</style>
<script>
(function () {
'use strict';
if (window.jOSGlyphedBoutons) return;
// l'état de l'onglet survit à un nouveau rendu de l'atelier (il redessine tout à chaque geste)
var ETAT = { zone: "la barre d'une fenêtre", visibles: true, restants: false, q: '', max: 80 }, DONNEES = null;
var ZONES_D_ABORD = ["la barre d'une fenêtre", 'le dock', 'le haut du bureau', 'les réglages', 'le HUD téléphone', 'les onglets d\'une fenêtre'];
function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]; }); }
function cle(b) { return b.zone + '|' + (b.nom || b.texte); }
// trois glyphes proposés selon ce que fait le bouton (des glyphes sans variante emoji : ils restent des glyphes sur iPhone aussi)
var PROPOS = [
[/fermer|close/, ['✕', '⊗', '⊠']], [/réduire|minimi/, ['–', '⌄', '▁']], [/plein écran|full/, ['⤢', '▣', '⊡']],
[/tiling plein|tilefull/, ['▦', '▩', '⊟']], [/tiling|grille|\btile\b/, ['⊞', '▤', '⊟']], [/gauche|\bleft\b/, ['◧', '⇤', '▌']], [/droite|\bright\b/, ['◨', '⇥', '▐']],
[/nouvelle instance|\bdup\b|dupliquer/, ['⧉', '⊕', '⊔']], [/picture|\bpip\b/, ['◳', '⧈', '▣']], [/recharger|reload|actualiser/, ['⟳', '↻', '↺']],
[/analyser|analyse/, ['⌕', '⊙', '∴']], [/forger|forge/, ['⟐', '◈', '✠']], [/son temps|\btemps\b|tsoin/, ['⧗', '◷', '⧖']], [/chat|envoyer|message/, ['⇢', '✎', '▷']],
[/knob|tourner/, ['◔', '⊚', '◑']], [/widget|xerbion/, ['⬢', '▣', '⬡']], [/backend|frontend|plugion/, ['⌗', '⟨⟩', '⇅']], [/upgrade|mettre à jour/, ['⇪', '↥', '⤊']],
[/braindump|extrapol/, ['✎', '⤳', '∿']], [/connexion/, ['⋈', '⟷', '∞']], [/tout voir/, ['⊹', '◎', '⊙']], [/organiser|région/, ['⊞', '▤', '⊟']],
[/lanceur|launchpad|carte \/ lanceur/, ['⁂', '▦', '⊞']], [/xerkion/, ['⬡', '⬢', '⏣']], [/bureau seul|masquer la carte/, ['▭', '◻', '▢']],
[/mode ui|iphone|android|finch/, ['◫', '▯', '⇋']], [/xerminal|terminal/, ['›_', '⟩', '▸']], [/curseur|manette/, ['⌖', '➚', '✥']], [/\bmenu\b/, ['☰', '≡', '⋯']],
[/^ploxions$|ploxions\b/, ['◇', '◈', '⬦']], [/thème|identité|palette/, ['◐', '◑', '◒']], [/journal|quêtes/, ['☷', '≣', '⚑']], [/réglages|paramètres/, ['⛭', '⊛', '≚']],
[/tes xers|changer de xer|\bxers\b/, ['⇄', '✥', '⟲']], [/apparence/, ['◐', '◍', '✧']], [/^xer$/, ['◇', '⬦', '◈']], [/chrome/, ['▭', '▔', '⎕']], [/^bureau$/, ['▢', '⌂', '▦']],
[/^dock$|dock,/, ['▁', '⎽', '▂']], [/^jeu$/, ['◆', '✦', '⬥']], [/compte|profil/, ['◯', '⍝', '◉']], [/install/, ['⤓', '⊕', '⇩']], [/données/, ['⛁', '▤', '≣']],
[/mobile|téléphone/, ['▯', '▮', '⎕']], [/^son$|sons|musique/, ['♪', '♫', '∿']], [/aide/, ['?', '⍰', '¿']], [/fond/, ['▨', '▧', '▩']], [/icônes|glyphe/, ['△', '◇', '⬦']],
[/peau/, ['◍', '◌', '○']], [/monde/, ['◎', '⊕', '○']], [/époque/, ['◧', '⧗', '◷']], [/défaire|annuler/, ['↶', '↺', '⟲']], [/dossier/, ['⌂', '▱', '⊟']],
[/densité/, ['≡', '☰', '⋮']], [/mouvement|animation/, ['∿', '≋', '⤳']], [/police|taille/, ['Aa', 'ᴀ', 'A⁺']], [/clair|sombre/, ['◐', '◑', '☾']],
[/export/, ['⤓', '⇩', '↧']], [/import/, ['⤒', '⇧', '↥']], [/purger|vider|supprimer/, ['⌫', '✕', '⊘']], [/connecter|connexion/, ['⇥', '→', '⊸']],
[/zoom/, ['⊕', '⤢', '⊖']], [/recherch|chercher|filtrer/, ['⌕', '⊙', '◎']], [/aperçu/, ['◎', '⊙', '◉']], [/secours/, ['✚', '⊕', '◬']], [/actions/, ['▸', '⇉', '↯']],
[/renommer/, ['✎', '✐', 'Aa']], [/garder|sauver|enregistrer/, ['✓', '⤓', '◉']], [/réinitialiser|défaut|revenir/, ['↺', '⟲', '◌']], [/partag/, ['↗', '⇪', '⤴']],
[/succès/, ['★', '✦', '◆']], [/règles|quand/, ['⌁', '⇒', '≔']], [/sélecteur/, ['⇄', '⧉', '⊟']], [/éléments/, ['▦', '⊞', '⁘']], [/hud/, ['⌗', '▤', '⊡']]
];
function propositions(b) {
var t = ((b.nom || '') + ' ' + (b.texte || '') + ' ' + (b.act || '')).toLowerCase(), out = [];
for (var i = 0; i < PROPOS.length && out.length < 3; i++) if (PROPOS[i][0].test(t)) PROPOS[i][1].forEach(function (g) { if (out.length < 3 && out.indexOf(g) < 0 && g !== b.glyphe) out.push(g); });
['◇', '○', '▸'].forEach(function (g) { if (out.length < 3 && out.indexOf(g) < 0 && g !== b.glyphe) out.push(g); });
return out;
}
// le SVG relevé, nettoyé : seulement des formes et leurs attributs de dessin (jamais de script, de lien, d'événement, de style)
var EL_OK = /^(svg|g|path|circle|ellipse|line|polyline|polygon|rect|text|tspan|title|defs|lineargradient|radialgradient|stop|clippath|mask)$/i;
var AT_OK = /^(viewbox|width|height|d|cx|cy|r|rx|ry|x|y|x1|y1|x2|y2|points|fill|stroke|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-miterlimit|opacity|fill-opacity|stroke-opacity|transform|font-size|font-weight|text-anchor|dominant-baseline|fill-rule|clip-rule|offset|stop-color|stop-opacity|gradientunits|x1|id|clip-path|mask|vector-effect|xmlns|preserveaspectratio)$/i;
function svgSur(src) {
try {
var doc = new DOMParser().parseFromString(src, 'image/svg+xml'), r = doc.documentElement;
if (!r || r.nodeName.toLowerCase() !== 'svg' || doc.getElementsByTagName('parsererror').length) return '';
(function net(n) {
Array.prototype.slice.call(n.children).forEach(function (k) { if (!EL_OK.test(k.nodeName)) { k.parentNode.removeChild(k); return; } net(k); });
Array.prototype.slice.call(n.attributes).forEach(function (a) { var v = String(a.value || ''); if (!AT_OK.test(a.name) || /javascript:|url\(\s*['"]?\s*[a-z]+:/i.test(v)) n.removeAttribute(a.name); });
})(r);
r.removeAttribute('width'); r.removeAttribute('height');
return new XMLSerializer().serializeToString(r);
} catch (e) { return ''; }
}
function store() { try { return window.jOSStore ? window.jOSStore('glyphes-ui') : null; } catch (e) { return null; } }
function choixDe(S, k) { var x = S && S.get(k); return x ? x.choix : null; }
function choisir(S, b, choix) {
if (!S) return; var k = cle(b), x = S.get(k);
var v = { id: k, choix: choix, nom: b.nom || b.texte, zone: b.zone, avant: b.glyphe || (b.svg ? 'svg' : ''), act: b.act || '', m: Date.now() };
if (x && x.choix === choix) S.remove(k); else if (x) S.set(k, v); else S.add(v);
}
function monter(hote) {
if (!hote) return { stop: function () {} };
var vivant = true, S = store(), off = null;
hote.innerHTML = '<div class="gab__vide">◌ les boutons du xer se chargent…</div>';
var p = DONNEES ? Promise.resolve(DONNEES) : fetch('/data/boutons-ui.json', { credentials: 'same-origin', headers: { Accept: 'application/json' } }).then(function (r) { if (!r.ok) throw new Error(r.status); return r.json(); }).then(function (d) { DONNEES = d; return d; });
p.then(function () { if (vivant) rendre(); }, function () { if (vivant) hote.innerHTML = '<div class="gab__vide">△ le relevé des boutons ne répond pas</div>'; });
if (S && S.on) off = S.on(function () { if (vivant && DONNEES) majChoix(); });
function liste() {
var B = DONNEES.boutons || [], q = ETAT.q.trim().toLowerCase();
return B.filter(function (b) {
if (ETAT.zone !== '*' && (ETAT.zone === 'autres' ? ZONES_D_ABORD.indexOf(b.zone) >= 0 : b.zone !== ETAT.zone)) return false;
if (ETAT.visibles && !b.visible) return false;
if (ETAT.restants && choixDe(S, cle(b))) return false;
if (q && ((b.nom || '') + ' ' + (b.texte || '') + ' ' + b.zone + ' ' + (b.act || '')).toLowerCase().indexOf(q) < 0) return false;
return true;
});
}
function nbChoix() { return S ? S.all().filter(function (x) { return x && x.id !== '_bureau'; }).length : 0; }
function ligne(b) {
var k = cle(b), ch = choixDe(S, k), now = b.svg ? svgSur(b.svg) : '';
var PAST = { close: '#ff5f57', min: '#febc2e', full: '#28c840' }; // les trois pastilles de la barre : des ronds de couleur, sans glyphe
if (!now && PAST[b.act]) now = '<span style="width:16px;height:16px;border-radius:50%;background:' + PAST[b.act] + '"></span>';
if (!now) now = b.glyphe ? esc(b.glyphe) : '<small>' + esc((b.texte || '—').slice(0, 18)) + '</small>';
var props = propositions(b), perso = ch && ch.indexOf('g:') === 0 && props.indexOf(ch.slice(2)) < 0 ? ch.slice(2) : '';
return '<div class="gab__b" data-gk="' + esc(k) + '"><div class="gab__now" title="tel qu\'il s\'affiche aujourd\'hui">' + now + '</div>'
+ '<div class="gab__q"><b>' + esc(b.nom || b.texte || '(sans nom)') + '</b><small' + (b.visible ? '' : ' class="cache"') + '>' + esc(b.zone + (b.act ? ' · ' + b.act : '') + (b.n > 1 ? ' · ×' + b.n : '') + (b.visible ? '' : ' · caché au relevé')) + '</small></div>'
+ '<div class="gab__p" role="group" aria-label="choisir pour ' + esc(b.nom || b.texte) + '">'
+ props.map(function (g) { return '<button type="button" class="gab__g' + (ch === 'g:' + g ? ' on' : '') + '" data-gc="g:' + esc(g) + '" aria-pressed="' + (ch === 'g:' + g) + '" aria-label="glyphe ' + esc(g) + '">' + esc(g) + '</button>'; }).join('')
+ '<button type="button" class="gab__g mot' + (ch === 'mot' ? ' on' : '') + '" data-gc="mot" aria-pressed="' + (ch === 'mot') + '" title="écrire son nom au lieu d\'un glyphe">le mot</button>'
+ '<button type="button" class="gab__g mot' + (ch === 'garder' ? ' on' : '') + '" data-gc="garder" aria-pressed="' + (ch === 'garder') + '">garder</button>'
+ '<label class="gab__g' + (perso ? ' on' : '') + '" title="ton glyphe">✎<input data-gperso maxlength="3" value="' + esc(perso) + '" aria-label="ton glyphe pour ' + esc(b.nom || b.texte) + '"></label>'
+ '</div></div>';
}
function rendre() {
var B = DONNEES.boutons || [], zones = {}, l = liste();
B.forEach(function (b) { if (!ETAT.visibles || b.visible) zones[b.zone] = (zones[b.zone] || 0) + 1; });
var autres = Object.keys(zones).filter(function (z) { return ZONES_D_ABORD.indexOf(z) < 0; }).reduce(function (s, z) { return s + zones[z]; }, 0);
var glob = (S && S.get('_bureau')) || {};
hote.innerHTML = '<div class="gab"><div class="gab__tete"><b>⌗ ' + B.length + ' boutons dans le xer</b><span data-gnb>' + nbChoix() + ' choisis · relevé le ' + esc(String(DONNEES.releve || '').slice(0, 10)) + '</span></div>'
+ '<div class="gab__glob"><p>Sur le bureau, à côté de chaque glyphe :</p><div class="gab__ch">' + [['nom', 'son nom, quand il y a la place'], ['survol', 'rien, le nom au survol (comme maintenant)'], ['nom-barre', 'son nom seulement dans la barre des fenêtres']].map(function (x) { return '<button type="button" class="gab__c' + (glob.choix === x[0] ? ' on' : '') + '" data-gglob="' + x[0] + '" aria-pressed="' + (glob.choix === x[0]) + '">' + esc(x[1]) + '</button>'; }).join('') + '</div></div>'
+ '<div class="gab__ch" role="toolbar" aria-label="zones">' + ZONES_D_ABORD.filter(function (z) { return zones[z]; }).concat(autres ? ['autres'] : []).concat(['*']).map(function (z) { var n = z === '*' ? Object.keys(zones).reduce(function (s, k) { return s + zones[k]; }, 0) : z === 'autres' ? autres : zones[z]; return '<button type="button" class="gab__c' + (ETAT.zone === z ? ' on' : '') + '" data-gz="' + esc(z) + '">' + esc(z === '*' ? 'tout' : z) + '<i>' + n + '</i></button>'; }).join('') + '</div>'
+ '<div class="gab__f"><input data-gq type="search" placeholder="chercher un bouton (nom, zone, action)…" value="' + esc(ETAT.q) + '" aria-label="chercher un bouton">'
+ '<button type="button" class="gab__c' + (ETAT.visibles ? ' on' : '') + '" data-gvis aria-pressed="' + ETAT.visibles + '">visibles</button><button type="button" class="gab__c' + (ETAT.restants ? ' on' : '') + '" data-grest aria-pressed="' + ETAT.restants + '">pas encore choisis</button></div>'
+ '<div data-gl>' + (l.slice(0, ETAT.max).map(ligne).join('') || '<div class="gab__vide">rien ici</div>') + '</div>'
+ (l.length > ETAT.max ? '<div class="gab__plus"><button type="button" class="gab__c" data-gplus>+ ' + (l.length - ETAT.max) + ' de plus</button></div>' : '') + '</div>';
}
function majChoix() {
var nb = hote.querySelector('[data-gnb]'); if (nb) nb.textContent = nbChoix() + ' choisis · relevé le ' + String(DONNEES.releve || '').slice(0, 10);
hote.querySelectorAll('[data-gk]').forEach(function (el) {
var ch = choixDe(S, el.getAttribute('data-gk'));
el.querySelectorAll('[data-gc]').forEach(function (g) { var on = g.getAttribute('data-gc') === ch; g.classList.toggle('on', on); g.setAttribute('aria-pressed', on); });
var inp = el.querySelector('[data-gperso]'), perso = ch && ch.indexOf('g:') === 0 && !el.querySelector('[data-gc="' + ch.replace(/"/g, '') + '"]') ? ch.slice(2) : '';
if (inp && document.activeElement !== inp) inp.value = perso; if (inp) inp.parentNode.classList.toggle('on', !!perso);
});
var glob = (S && S.get('_bureau')) || {};
hote.querySelectorAll('[data-gglob]').forEach(function (g) { var on = g.getAttribute('data-gglob') === glob.choix; g.classList.toggle('on', on); g.setAttribute('aria-pressed', on); });
}
function bouton(k) { var B = DONNEES.boutons || []; for (var i = 0; i < B.length; i++) if (cle(B[i]) === k) return B[i]; return null; }
hote.addEventListener('click', function (e) {
var t = e.target.closest('button'); if (!t || !DONNEES) return;
if (t.hasAttribute('data-gz')) { ETAT.zone = t.getAttribute('data-gz'); ETAT.max = 80; return rendre(); }
if (t.hasAttribute('data-gvis')) { ETAT.visibles = !ETAT.visibles; return rendre(); }
if (t.hasAttribute('data-grest')) { ETAT.restants = !ETAT.restants; return rendre(); }
if (t.hasAttribute('data-gplus')) { ETAT.max += 120; return rendre(); }
if (t.hasAttribute('data-gglob') && S) { var g = t.getAttribute('data-gglob'), x = S.get('_bureau'); if (x && x.choix === g) S.remove('_bureau'); else if (x) S.set('_bureau', { choix: g, m: Date.now() }); else S.add({ id: '_bureau', choix: g, m: Date.now() }); return majChoix(); }
var r = t.closest('[data-gk]'); if (r && t.hasAttribute('data-gc')) { var b = bouton(r.getAttribute('data-gk')); if (b) { choisir(S, b, t.getAttribute('data-gc')); majChoix(); if (ETAT.restants) setTimeout(rendre, 400); } }
});
hote.addEventListener('change', function (e) {
var inp = e.target.closest('[data-gperso]'); if (!inp) return; var r = inp.closest('[data-gk]'), b = r && bouton(r.getAttribute('data-gk')), v = inp.value.trim();
if (!b || !S) return; var k = cle(b), x = S.get(k);
if (!v) { if (x && x.choix.indexOf('g:') === 0) S.remove(k); return majChoix(); }
choisir(S, b, 'g:' + v); if (S.get(k) == null) choisir(S, b, 'g:' + v); majChoix();
});
var qT = 0; hote.addEventListener('input', function (e) { if (!e.target.matches('[data-gq]')) return; ETAT.q = e.target.value; clearTimeout(qT); qT = setTimeout(function () { var pos = e.target.selectionStart; rendre(); var n = hote.querySelector('[data-gq]'); if (n) { n.focus(); try { n.setSelectionRange(pos, pos); } catch (x) {} } }, 200); });
return { stop: function () { vivant = false; try { if (off) off(); } catch (e) {} } };
}
window.jOSGlyphedBoutons = { monter: monter, propositions: propositions, svgSur: svgSur, cle: cle };
})();
</script>