mirror of
https://git.j0bot.ch/admin_j0bot/ploxion-morse.git
synced 2026-11-29 06:55:07 +00:00
synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
commit
d353274047
21
README.md
Normal file
21
README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# ··− Morse
|
||||
|
||||
Texte ↔ code morse, avec écoute audio (dit/dah) et copie. Les signaux du xerboxion.
|
||||
|
||||
| | |
|
||||
| --- | --- |
|
||||
| id | `morse` |
|
||||
| fournit | `morse` `encode` `signal` |
|
||||
| bions qu'il nomme | `jOSApps` |
|
||||
| fichiers | `app.blade.php` |
|
||||
| dans le labo | `resources/views/ploxions/morse/` (dépôt `my_website2`) |
|
||||
|
||||
## Contribuer
|
||||
|
||||
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=morse — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||
- **Dans VS Code** : `xb prendre morse` (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
|
||||
89
app.blade.php
Normal file
89
app.blade.php
Normal file
@ -0,0 +1,89 @@
|
||||
{{-- PL0XION morse — texte ↔ morse + écoute (von Neumann, forge PAR BIONS). On-theme
|
||||
XERB0XI0N (les signaux : ON/I/ION). Encode/décode, joue le morse en audio (bion
|
||||
♪ beep : dit court / dah long), copie (bion copy). Composé sur window.jOSb.
|
||||
window.jOSApps['morse']. mount(c,ctx)->{unmount}. 100% client-side. --}}
|
||||
@include('ploxions._bions')
|
||||
<style>
|
||||
.ms { display:flex; flex-direction:column; height:100%; background:#0a0e0c; color:#e6f2ea; font-family:ui-sans-serif,system-ui,sans-serif; font-size:.84rem; }
|
||||
.ms__bar { flex:0 0 auto; display:flex; align-items:center; gap:8px; padding:8px 11px; border-bottom:1px solid rgba(80,200,140,.2); }
|
||||
.ms__t { font-weight:800; color:#34d399; }
|
||||
.ms__io { flex:1; min-height:0; display:flex; flex-direction:column; gap:8px; padding:11px; }
|
||||
.ms textarea { flex:1; min-height:54px; box-sizing:border-box; resize:none; background:rgba(0,0,0,.3); border:1px solid rgba(80,200,140,.25);
|
||||
border-radius:10px; color:#dafce8; padding:10px; font:0.84rem ui-monospace,monospace; outline:none; letter-spacing:.04em; }
|
||||
.ms textarea:focus { border-color:rgba(52,211,153,.6); }
|
||||
.ms__row { flex:0 0 auto; display:flex; gap:7px; align-items:center; flex-wrap:wrap; padding:0 11px 11px; }
|
||||
.ms__b { cursor:pointer; border-radius:9px; border:1px solid rgba(52,211,153,.4); background:rgba(16,54,40,.5); color:#bff5dd; font-size:.8rem; padding:8px 13px; font-weight:600; }
|
||||
.ms__b:hover { background:rgba(24,80,58,.6); }
|
||||
.ms__b.main { background:#34d399; color:#04241a; border:0; font-weight:800; }
|
||||
.ms__lab { font-size:.62rem; color:rgba(180,220,200,.55); }
|
||||
.ms__viz { font-family:ui-monospace,monospace; font-size:1.1rem; color:#34d399; min-height:1.2em; letter-spacing:2px; }
|
||||
</style>
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
var M = { A:'.-',B:'-...',C:'-.-.',D:'-..',E:'.',F:'..-.',G:'--.',H:'....',I:'..',J:'.---',K:'-.-',L:'.-..',M:'--',N:'-.',O:'---',P:'.--.',Q:'--.-',R:'.-.',S:'...',T:'-',U:'..-',V:'...-',W:'.--',X:'-..-',Y:'-.--',Z:'--..',
|
||||
'0':'-----','1':'.----','2':'..---','3':'...--','4':'....-','5':'.....','6':'-....','7':'--...','8':'---..','9':'----.',
|
||||
'.':'.-.-.-',',':'--..--','?':'..--..',"'":'.----.','!':'-.-.--','/':'-..-.','(':'-.--.',')':'-.--.-','&':'.-...',':':'---...',';':'-.-.-.','=':'-...-','+':'.-.-.','-':'-....-','_':'..--.-','"':'.-..-.','@':'.--.-.' };
|
||||
var R = {}; for (var k in M) R[M[k]] = k;
|
||||
|
||||
function toMorse(s) { return s.toUpperCase().split('').map(function (c) { if (c === ' ') return '/'; return M[c] || ''; }).filter(function (x) { return x !== ''; }).join(' '); }
|
||||
function fromMorse(s) { return s.trim().split(/\s+/).map(function (t) { return t === '/' ? ' ' : (R[t] || ''); }).join('').replace(/\s+/g, ' '); }
|
||||
|
||||
var LIVE = null; // posé au mount : { text, playing }
|
||||
function describe() {
|
||||
var text = LIVE ? LIVE.text() : '';
|
||||
var playing = LIVE ? LIVE.playing() : false;
|
||||
return { v: 1, id: 'morse', title: 'Morse', icon: '··−', items: [
|
||||
{ p: 1, kind: 'stat', label: playing ? '▶ écoute' : 'texte ↔ morse', value: text ? text.slice(0, 40) : 'rien encore' }
|
||||
] };
|
||||
}
|
||||
function mount(container, ctx) {
|
||||
var ac = null, playing = false, playTimer = 0;
|
||||
container.innerHTML =
|
||||
'<div class="ms">'
|
||||
+ ' <div class="ms__bar"><span class="ms__t">· − Morse</span><span class="ms__lab">texte ↔ morse · écoute</span></div>'
|
||||
+ ' <div class="ms__io">'
|
||||
+ ' <textarea data-text placeholder="ton texte…"></textarea>'
|
||||
+ ' <div class="ms__row" style="padding:0"><button class="ms__b main" data-enc>↓ en morse</button><button class="ms__b" data-dec>↑ en texte</button></div>'
|
||||
+ ' <textarea data-morse placeholder=".... . .-.. .-.. ---"></textarea>'
|
||||
+ ' <div class="ms__viz" data-viz></div>'
|
||||
+ ' </div>'
|
||||
+ ' <div class="ms__row"><button class="ms__b" data-play>▶ écouter</button><button class="ms__b" data-copy>copier le morse</button>'
|
||||
+ ' <span class="ms__lab">vitesse</span><input type="range" min="8" max="30" value="18" data-wpm style="accent-color:#34d399"></div>'
|
||||
+ '</div>';
|
||||
var elText = container.querySelector('[data-text]'), elMorse = container.querySelector('[data-morse]'), elViz = container.querySelector('[data-viz]'), elWpm = container.querySelector('[data-wpm]');
|
||||
|
||||
container.querySelector('[data-enc]').addEventListener('click', function () { elMorse.value = toMorse(elText.value); });
|
||||
container.querySelector('[data-dec]').addEventListener('click', function () { elText.value = fromMorse(elMorse.value); });
|
||||
elText.addEventListener('input', function () { elMorse.value = toMorse(elText.value); });
|
||||
container.querySelector('[data-copy]').addEventListener('click', function () { if (window.jOSb && elMorse.value) { jOSb.copy(elMorse.value); jOSb.toast(container, '✓ morse copié'); } });
|
||||
|
||||
function stop() { playing = false; if (playTimer) { clearTimeout(playTimer); playTimer = 0; } elViz.textContent = ''; var b = container.querySelector('[data-play]'); b.textContent = '▶ écouter'; }
|
||||
function play() {
|
||||
var code = (elMorse.value || toMorse(elText.value)).trim(); if (!code) return;
|
||||
if (playing) { stop(); return; }
|
||||
try { ac = ac || new (window.AudioContext || window.webkitAudioContext)(); if (ac.state === 'suspended') ac.resume(); } catch (e) { return; }
|
||||
playing = true; container.querySelector('[data-play]').textContent = '■ stop';
|
||||
var unit = 1.2 / (+elWpm.value || 18); // durée d'un « dit » en secondes (PARIS)
|
||||
var seq = [], t = 0;
|
||||
code.split('').forEach(function (ch) {
|
||||
if (ch === '.') { seq.push([t, unit]); t += unit + unit; }
|
||||
else if (ch === '-') { seq.push([t, unit * 3]); t += unit * 3 + unit; }
|
||||
else if (ch === ' ') { t += unit * 2; } // entre lettres (déjà +unit) -> ~3
|
||||
else if (ch === '/') { t += unit * 4; } // entre mots -> ~7
|
||||
});
|
||||
seq.forEach(function (s) { if (window.jOSb) jOSb.beep(ac, { freq: 620, vol: 0.35, when: ac.currentTime + s[0], dur: s[1], type: 'sine' }); });
|
||||
// viz : déroule le code
|
||||
var i = 0; (function step() { if (!playing) return; elViz.textContent = code.slice(0, i).replace(/\//g, ' / '); i++;
|
||||
if (i <= code.length) playTimer = setTimeout(step, unit * 1000 * 1.5); else stop(); })();
|
||||
}
|
||||
container.querySelector('[data-play]').addEventListener('click', play);
|
||||
|
||||
setTimeout(function () { elText.focus(); }, 30);
|
||||
LIVE = { text: function () { return elText.value; }, playing: function () { return playing; } };
|
||||
return { unmount: function () { LIVE = null; stop(); if (ac) try { ac.close(); } catch (e) {} container.innerHTML = ''; } };
|
||||
}
|
||||
window.jOSApps = window.jOSApps || {};
|
||||
window.jOSApps['morse'] = { manifest: { id: 'morse', name: 'Morse', icon: '··−' }, mount: mount, describe: describe };
|
||||
})();
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user