capcutsync-pro / script.js
eubottura's picture
🐳 07/02 - 05:00 - Role: Act as an expert Full-Stack Developer and Code Debugging Specialist.Goal: Diagnose the root causes of non-functional buttons and code errors within the provided context. Imple
a9bc9c2 verified
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);
}
}