mirror of
https://github.com/olegvodyanov/instalinks.git
synced 2025-12-20 12:37:05 +03:00
Compare commits
No commits in common. "fd5929f735e802f342c59fda650f199a2ee511e2" and "37ab5965ed3e43b5019e437ece505deab3b02ddd" have entirely different histories.
fd5929f735
...
37ab5965ed
@ -3,10 +3,9 @@ const addLinkBtn = document.getElementById('addLinkBtn');
|
|||||||
const newLinksContainer = document.getElementById('newLinksContainer');
|
const newLinksContainer = document.getElementById('newLinksContainer');
|
||||||
const watchedLinksContainer = document.getElementById('watchedLinksContainer');
|
const watchedLinksContainer = document.getElementById('watchedLinksContainer');
|
||||||
|
|
||||||
|
function loadLinks() {
|
||||||
const PER_PAGE = 8;
|
const PER_PAGE = 8;
|
||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
|
|
||||||
function loadLinks() {
|
|
||||||
fetch(`/api/links/?page=${currentPage}&per_page=${PER_PAGE}`)
|
fetch(`/api/links/?page=${currentPage}&per_page=${PER_PAGE}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@ -108,7 +107,7 @@ function deleteLink(linkId) {
|
|||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
linksData = linksData.filter(link => link.id !== linkId);
|
linksData = linksData.filter(link => link.id !== linkId);
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
loadLinks();
|
renderPaginatedList();
|
||||||
reinitializeInstagramEmbeds();
|
reinitializeInstagramEmbeds();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -134,7 +133,7 @@ function markLinkWatched(linkId) {
|
|||||||
if (idx !== -1) {
|
if (idx !== -1) {
|
||||||
linksData[idx] = updatedLink;
|
linksData[idx] = updatedLink;
|
||||||
}
|
}
|
||||||
loadLinks();
|
renderPaginatedList();
|
||||||
reinitializeInstagramEmbeds();
|
reinitializeInstagramEmbeds();
|
||||||
})
|
})
|
||||||
.catch(err => console.error(err));
|
.catch(err => console.error(err));
|
||||||
@ -156,7 +155,7 @@ addLinkBtn.addEventListener('click', () => {
|
|||||||
linksData.push(addedLink);
|
linksData.push(addedLink);
|
||||||
newLinkInput.value = '';
|
newLinkInput.value = '';
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
loadLinks();
|
renderPaginatedList();
|
||||||
reinitializeInstagramEmbeds();
|
reinitializeInstagramEmbeds();
|
||||||
})
|
})
|
||||||
.catch(err => console.error(err));
|
.catch(err => console.error(err));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user