JSON import pagination
This commit is contained in:
1 parent
13b2eb5fe3
commit
70d385133d
1 file changed
+47
-23
@@ -1506,35 +1506,59 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importFromJSON() {
|
function importFromJSON() {
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.type = 'file';
|
input.type = 'file';
|
||||||
input.accept = '.json';
|
input.accept = '.json';
|
||||||
|
|
||||||
input.onchange = (e) => {
|
input.onchange = async (e) => {
|
||||||
const file = e.target.files[0];
|
const file = e.target.files[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
try {
|
try {
|
||||||
const jsonData = JSON.parse(e.target.result);
|
const jsonData = JSON.parse(e.target.result);
|
||||||
console.log('JSON data imported:', jsonData);
|
|
||||||
|
|
||||||
// Update the ttsList with the imported data
|
ttsList = jsonData;
|
||||||
ttsList = jsonData;
|
currentPage = 1; // Reset to the first page
|
||||||
|
updateUIList();
|
||||||
|
updatePaginationControls(); // Update pagination controls
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error parsing JSON:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Refresh the on-screen list
|
input.click();
|
||||||
updateUIList(); // This function updates the UI with the contents of ttsList
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error('Error parsing JSON:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
input.click();
|
function updatePaginationControls() {
|
||||||
|
const lastPage = Math.ceil(ttsList.length / itemsPerPage);
|
||||||
|
const pageIndicator = document.getElementById('pageIndicator');
|
||||||
|
if (pageIndicator) {
|
||||||
|
pageIndicator.textContent = `Page ${currentPage} of ${lastPage}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prevPageButton = document.getElementById('prevPage');
|
||||||
|
if (prevPageButton) {
|
||||||
|
prevPageButton.disabled = (currentPage === 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextPageButton = document.getElementById('nextPage');
|
||||||
|
if (nextPageButton) {
|
||||||
|
nextPageButton.disabled = (currentPage === lastPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Similar updates for any additional pagination controls if you have them
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//////// Other Things ////////
|
//////// Other Things ////////
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|||||||
Reference in new issue
Block a user