MCPcopy Create free account
hub / github.com/TheJoWo/Clean-Clode / saveToHistory

Function saveToHistory

script.js:181–216  ·  view source on GitHub ↗
(cleanedText, originalText)

Source from the content-addressed store, hash-verified

179 }
180
181 function saveToHistory(cleanedText, originalText) {
182 if (!isHistoryEnabled() || !cleanedText.trim()) {
183 return;
184 }
185
186 // Prevent duplicate history items when the same input/output is processed again
187 if (originalText === lastCleanedInput && cleanedText === lastCleanedOutput) {
188 return;
189 }
190
191 try {
192 const history = getHistory();
193 const newItem = {
194 id: Date.now(),
195 timestamp: new Date().toISOString(),
196 cleaned: cleanedText,
197 original: originalText || '',
198 preview: cleanedText.substring(0, 100) + (cleanedText.length > 100 ? '...' : '')
199 };
200
201 history.unshift(newItem);
202
203 const trimmedHistory = history.slice(0, 50);
204
205 localStorage.setItem(HISTORY_KEY, JSON.stringify(trimmedHistory));
206
207 // Update tracking variables
208 lastCleanedInput = originalText;
209 lastCleanedOutput = cleanedText;
210
211 showHistorySection();
212
213 updateHistoryDisplay();
214 } catch (error) {
215 }
216 }
217
218 function updateHistoryVisibility() {
219 const history = getHistory();

Callers 1

performCleanupFunction · 0.85

Calls 4

isHistoryEnabledFunction · 0.85
getHistoryFunction · 0.85
showHistorySectionFunction · 0.85
updateHistoryDisplayFunction · 0.85

Tested by

no test coverage detected