Files
P4RS3LT0NGV3/src/transformers/format/qwerty-shift.js
T
Dustin Farley dc10a90851 refactor: migrate to modular tool-based architecture
- Implement tool registry system with individual tool modules
- Reorganize transformers into categorized source modules
- Remove emojiLibrary.js, consolidate into EmojiUtils and emojiData
- Fix mobile close button and tooltip functionality
- Add build system for transforms and emoji data
- Migrate from Python backend to pure JavaScript
- Add comprehensive documentation and testing
- Improve code organization and maintainability
- Ignore generated files (transforms-bundle.js, emojiData.js)
2025-12-02 20:26:32 -08:00

40 lines
1.2 KiB
JavaScript

// qwerty-shift transform
import BaseTransformer from '../BaseTransformer.js';
export default new BaseTransformer({
name: 'QWERTY Right Shift',
priority: 40,
rows: [
'qwertyuiop',
'asdfghjkl',
'zxcvbnm'
],
buildMap: function() {
if (this._map) return this._map;
const map = {};
for (const row of this.rows) {
for (let i=0;i<row.length;i++) {
const from = row[i], to = row[(i+1)%row.length];
map[from] = to;
map[from.toUpperCase()] = to.toUpperCase();
}
}
this._map = map; return map;
},
func: function(text) {
const m = this.buildMap();
return [...text].map(c => m[c] || c).join('');
},
preview: function(text) {
if (!text) return '[qwerty]';
return this.func(text.slice(0,8)) + (text.length>8?'...':'');
},
reverse: function(text) {
const m = this.buildMap();
const inv = {};
Object.keys(m).forEach(k => inv[m[k]] = k);
return [...text].map(c => inv[c] || c).join('');
}
});