mirror of
https://github.com/elder-plinius/P4RS3LT0NGV3.git
synced 2026-06-06 06:53:56 +02:00
Fix: implement real Semaphore Flags (arrow-pair mapping with decode); reviewed cipher implementations for consistency
This commit is contained in:
+35
-6
@@ -1148,16 +1148,45 @@ const transforms = {
|
||||
|
||||
semaphore: {
|
||||
name: 'Semaphore Flags',
|
||||
map: {
|
||||
'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': '🔄'
|
||||
// Positions 1..8 around the clock: 1=⬆️ 2=↗️ 3=➡️ 4=↘️ 5=⬇️ 6=↙️ 7=⬅️ 8=↖️
|
||||
arrows: ['','⬆️','↗️','➡️','↘️','⬇️','↙️','⬅️','↖️'],
|
||||
// Standard semaphore mapping (J is special: 2-1)
|
||||
table: {
|
||||
'A':[1,2],'B':[1,3],'C':[1,4],'D':[1,5],'E':[1,6],'F':[1,7],'G':[1,8],
|
||||
'H':[2,3],'I':[2,4],'J':[2,1],
|
||||
'K':[2,5],'L':[2,6],'M':[2,7],'N':[2,8],
|
||||
'O':[3,4],'P':[3,5],'Q':[3,6],'R':[3,7],'S':[3,8],
|
||||
'T':[4,5],'U':[4,6],'V':[4,7],'W':[4,8],
|
||||
'X':[5,6],'Y':[5,7],'Z':[5,8]
|
||||
},
|
||||
encodePair: function(pair) { return this.arrows[pair[0]] + this.arrows[pair[1]]; },
|
||||
buildReverse: function() {
|
||||
if (this._rev) return this._rev;
|
||||
const rev = {};
|
||||
for (const [k,v] of Object.entries(this.table)) {
|
||||
rev[this.encodePair(v)] = k;
|
||||
}
|
||||
this._rev = rev; return rev;
|
||||
},
|
||||
func: function(text) {
|
||||
return [...text.toLowerCase()].map(c => this.map[c] || c).join(' ');
|
||||
return [...text].map(ch => {
|
||||
if (/\s/.test(ch)) return '/';
|
||||
const up = ch.toUpperCase();
|
||||
const pair = this.table[up];
|
||||
return pair ? this.encodePair(pair) : ch;
|
||||
}).join(' ');
|
||||
},
|
||||
preview: function(text) {
|
||||
return this.func(text);
|
||||
return this.func((text || 'flag').slice(0, 4));
|
||||
},
|
||||
reverse: function(text) {
|
||||
const rev = this.buildReverse();
|
||||
const tokens = text.trim().split(/\s+/);
|
||||
return tokens.map(tok => {
|
||||
if (tok === '/') return ' ';
|
||||
// Some platforms add variation selectors; normalize by direct match first
|
||||
return rev[tok] || tok;
|
||||
}).join('');
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user