-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileHandler.js
More file actions
25 lines (23 loc) · 899 Bytes
/
fileHandler.js
File metadata and controls
25 lines (23 loc) · 899 Bytes
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
function loadFile(file) {
var reader = new FileReader();
reader.onload = function (e) {
try {
chatData = JSON.parse(e.target.result);
if (chatData.length > 0) {
fileStatus.textContent = 'Loaded';
fileStatus.style.color = '#00e0ff';
msgCount.textContent = chatData.length;
playBtn.disabled = false;
restartBtn.disabled = false;
slider.disabled = false;
slider.max = chatData.length - 1;
totalTime.textContent = formatTime(chatData.length);
chatWindow.innerHTML = '';
showNotification('File loaded successfully!', 'success');
}
} catch (err) {
showNotification('Error: ' + err.message, 'error');
}
};
reader.readAsText(file);
}