Spaces:
Running
Running
File size: 1,400 Bytes
a9bc9c2 6497e67 d789176 a9bc9c2 d789176 a9bc9c2 a06b8f9 a9bc9c2 d789176 a9bc9c2 801ff92 a06b8f9 a9bc9c2 a06b8f9 a9bc9c2 a06b8f9 a9bc9c2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
validateAndLoadJson(data, sourceName) {
if (!Array.isArray(data)) {
throw new Error('Invalid JSON format: Expected array');
}
const isValid = data.every(item =>
item.text !== undefined &&
typeof item.start_time === 'number' &&
typeof item.end_time === 'number'
);
if (!isValid) {
throw new Error('Each item must have: text (string), start_time (number), end_time (number)');
}
this.jsonTimestamps = data;
this.updateJsonUI(sourceName, data.length);
}
updateJsonUI(filename, wordCount) {
const jsonStatus = document.getElementById('json-status');
const jsonFilename = document.getElementById('json-filename');
const jsonWordsCount = document.getElementById('json-words-count');
if (jsonStatus && jsonFilename && jsonWordsCount) {
jsonStatus.classList.remove('hidden');
jsonFilename.textContent = filename;
jsonWordsCount.textContent = `${wordCount} palavras`;
// Visual feedback
const zone = document.getElementById('json-upload-zone');
zone.classList.add('border-green-500', 'bg-green-100');
setTimeout(() => {
zone.classList.remove('border-green-500', 'bg-green-100');
}, 1000);
}
} |