fix: resolve bugs 01 through 08 and set Ollama TTL to 1h
This commit is contained in:
1 parent
a01bf64445
commit
9bbc9473de
14 files changed
+366
-108
No files matched your search
@@ -27,12 +27,26 @@ export function slugify(text) {
|
||||
|
||||
export function shuffleArray(array) {
|
||||
if (!array || !Array.isArray(array)) return [];
|
||||
const arr = [...array];
|
||||
for (let i = arr.length - 1; i > 0; i--) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[arr[i], arr[j]] = [arr[j], arr[i]];
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
return arr;
|
||||
return array;
|
||||
}
|
||||
|
||||
export function cleanPromptTranslation(text) {
|
||||
if (!text || typeof text !== 'string') return '';
|
||||
// Strip grammatical inflection notes that contain Latin words to prevent spoilers in tests
|
||||
return text.replace(/\s*\([а-яА-ЯёЁ0-9\s.,-]*\bот\s+[a-zA-Z\x27-]+\)/gi, '').trim();
|
||||
}
|
||||
|
||||
export function formatTranslationWithSpoiler(text) {
|
||||
if (!text || typeof text !== 'string') return '';
|
||||
const noteMatch = text.match(/\s*\(([а-яА-ЯёЁ0-9\s.,-]*\bот\s+[a-zA-Z\x27-]+)\)/i);
|
||||
if (!noteMatch) return escapeHtml(text);
|
||||
const cleanText = text.replace(noteMatch[0], '').trim();
|
||||
const noteText = noteMatch[1];
|
||||
return `${escapeHtml(cleanText)} <span class="grammar-hint-badge" title="Нажмите, чтобы показать форму" onclick="this.classList.toggle('active')"><span class="badge-label">ℹ️ форма</span><span class="badge-body">${escapeHtml(noteText)}</span></span>`;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -270,6 +284,8 @@ export const ui = {
|
||||
updateHeaderStats,
|
||||
playAudio,
|
||||
playTextSpeech,
|
||||
cleanPromptTranslation,
|
||||
formatTranslationWithSpoiler,
|
||||
};
|
||||
|
||||
export default ui;
|
||||
Reference in new issue
Block a user