mirror of
https://github.com/elder-plinius/P4RS3LT0NGV3.git
synced 2026-06-07 23:43:58 +02:00
dc10a90851
- 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)
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
window.HistoryUtils = {
|
|
addToHistory(historyArray, maxItems, source, content) {
|
|
if (!historyArray || !Array.isArray(historyArray)) {
|
|
console.warn('HistoryUtils.addToHistory: historyArray is not an array');
|
|
return;
|
|
}
|
|
|
|
if (!content) {
|
|
return;
|
|
}
|
|
|
|
const entry = {
|
|
source: source || 'Unknown',
|
|
content: content,
|
|
timestamp: new Date().toISOString(),
|
|
id: Date.now() + Math.random()
|
|
};
|
|
|
|
historyArray.unshift(entry);
|
|
|
|
if (historyArray.length > maxItems) {
|
|
historyArray.splice(maxItems);
|
|
}
|
|
},
|
|
|
|
clearHistory(historyArray) {
|
|
if (historyArray && Array.isArray(historyArray)) {
|
|
// Use splice to remove all items (same approach as removeFromHistory)
|
|
historyArray.splice(0, historyArray.length);
|
|
}
|
|
},
|
|
|
|
removeFromHistory(historyArray, id) {
|
|
if (!historyArray || !Array.isArray(historyArray)) {
|
|
return;
|
|
}
|
|
|
|
const index = historyArray.findIndex(item => item.id === id);
|
|
if (index !== -1) {
|
|
historyArray.splice(index, 1);
|
|
}
|
|
},
|
|
|
|
getHistorySource(activeTab, context = {}) {
|
|
if (activeTab === 'transforms' && context.activeTransform) {
|
|
return `Transform: ${context.activeTransform.name}`;
|
|
} else if (activeTab === 'steganography') {
|
|
if (context.activeSteg === 'invisible') {
|
|
return 'Invisible Text';
|
|
} else if (context.selectedEmoji) {
|
|
return `Emoji: ${context.selectedEmoji}`;
|
|
}
|
|
return 'Steganography';
|
|
} else if (activeTab === 'transforms') {
|
|
return 'Transform';
|
|
}
|
|
return 'Unknown';
|
|
}
|
|
};
|
|
|