Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 74fd3f5

Browse filesBrowse files
committed
completed playlist feature
1 parent 46e063d commit 74fd3f5
Copy full SHA for 74fd3f5

4 files changed

+50-9Lines changed: 50 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎dist/NuoFlix/EnhancedNuoFlix.js‎

Copy file name to clipboardExpand all lines: dist/NuoFlix/EnhancedNuoFlix.js
+19-4Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
const defaultPlaylists = [
3939
{ id: 1, is_custom: false, max_items: -1, name: 'Favoriten', item_cnt: 0, items: [], },
4040
{ id: 2, is_custom: false, max_items: -1, name: 'Für später gespeichert', item_cnt: 0, items: [], },
41-
{ id: 3, is_custom: false, max_items: 3, name: 'Zuletzt angesehene Videos', item_cnt: 0, items: [], },
41+
{ id: 3, is_custom: false, max_items: 10, name: 'Zuletzt angesehene Videos', item_cnt: 0, items: [], },
4242
];
4343
// IDs of Playlists with special functions
4444
const favoritesID = 1;
@@ -1903,6 +1903,9 @@ div:not(:last-child) > .playlistButton {
19031903
initializePlaylistButtons();
19041904
document.getElementById('pageLengthSelect').addEventListener('change', doChangeLength);
19051905
document.getElementById('pageLengthSelectBottom').addEventListener('change', doChangeLength);
1906+
document.addEventListener('visibilitychange', function() {
1907+
if (!document.hidden) updatePage();
1908+
});
19061909
}
19071910
function doUpdateDateFilter(fromInput, toInput) {
19081911
const revertDateRangeInputs = document.getElementById('revertDateRangeInputs');
@@ -2443,7 +2446,7 @@ function addEditPlaylistDialog() {
24432446
cursor: default;
24442447
}
24452448
.videoListEntry_id {
2446-
padding-right: 2rem;
2449+
width: 3.75rem;
24472450
}
24482451
.videoListEntry_name {
24492452
white-space: nowrap;
@@ -2557,15 +2560,15 @@ function addEditPlaylistDialog() {
25572560
const playlistId = parseInt(this.getAttribute('data-playlist-id'));
25582561
const playlist = getPlaylistObjectById(playlistId);
25592562
let newName;
2560-
if (!playlist.is_custom) {
2563+
if (playlist.is_custom) {
25612564
newName = document.getElementById('playlistName').value;
25622565
if (newName.length > 0) playlist.name = newName;
25632566
}
25642567
let newVideoItems = [];
25652568
for (const listedEntry of document.getElementById('videoList').children) {
25662569
const listedEntryId = parseInt(listedEntry.getAttribute('data-video-id'));
25672570
for (const storedEntry of playlist.items) {
2568-
if (storedEntry.id === listedEntryId) {
2571+
if (parseInt(storedEntry.id) === listedEntryId) {
25692572
newVideoItems.push(storedEntry);
25702573
break;
25712574
}
@@ -2576,6 +2579,7 @@ function addEditPlaylistDialog() {
25762579
set_value('playlistData', playlistData);
25772580
window.removeEventListener('resize', lazyResizer);
25782581
removeFromDOM(customElementsRegister.get('editPlaylistDialog'));
2582+
updatePage();
25792583
});
25802584
document.getElementById('playlistDialogCancelBtn').addEventListener('click', function() {
25812585
window.removeEventListener('resize', lazyResizer);
@@ -2882,7 +2886,16 @@ function doOrderCommentData(orderType = 'activity') {
28822886
}
28832887
}
28842888
function updatePage() {
2889+
playlistData = get_value('playlistData');
28852890
filteredCommentsCount = getFilteredCount();
2891+
if (filteredCommentsCount < totalComments) {
2892+
const totalPages = Math.ceil((totalComments - filteredCommentsCount) / currentLength);
2893+
const currentPage = Math.ceil(currentStart / currentLength);
2894+
if (currentPage > totalPages) {
2895+
currentStart = totalPages * currentLength - currentLength;
2896+
if (currentStart < 1) currentStart = 1;
2897+
}
2898+
}
28862899
updateComments();
28872900
updatePaginationUI();
28882901
updateStaticTranslations();
@@ -2967,6 +2980,7 @@ function execute_genericPage() {
29672980
}
29682981
});
29692982
const opener = function () {
2983+
playlistData = get_value('playlistData');
29702984
openAddToPlaylistMenu(document.getElementById('addToPlaylistWrapper'));
29712985
document.getElementById('addToPlaylistIcon').removeEventListener('click', opener);
29722986
}
@@ -3142,6 +3156,7 @@ function openAddToPlaylistMenu(refElement) {
31423156
addToDOM(entry, checkboxList, InsertionService.AsLastChild, false);
31433157
}
31443158
const opener = function () {
3159+
playlistData = get_value('playlistData');
31453160
openAddToPlaylistMenu(document.getElementById('addToPlaylistWrapper'));
31463161
document.getElementById('addToPlaylistIcon').removeEventListener('click', opener);
31473162
}
Collapse file

‎src/NuoFlix/EnhancedNuoFlix/ProfilePage/editPlaylistDialog.js‎

Copy file name to clipboardExpand all lines: src/NuoFlix/EnhancedNuoFlix/ProfilePage/editPlaylistDialog.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
}
8383
8484
.videoListEntry_id {
85-
padding-right: 2rem;
85+
width: 3.75rem;
8686
}
8787
8888
.videoListEntry_name {
Collapse file

‎src/NuoFlix/EnhancedNuoFlix/ProfilePage/functions_profilePage.js‎

Copy file name to clipboardExpand all lines: src/NuoFlix/EnhancedNuoFlix/ProfilePage/functions_profilePage.js
+26-4Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ function execute_profilePage() {
281281
// mount handler for selecting another length value
282282
document.getElementById('pageLengthSelect').addEventListener('change', doChangeLength);
283283
document.getElementById('pageLengthSelectBottom').addEventListener('change', doChangeLength);
284+
285+
// mount handler which update the page if we came from another tab (this will make playlistData and commentData "live")
286+
document.addEventListener('visibilitychange', function() {
287+
if (!document.hidden) updatePage();
288+
});
289+
284290
}
285291

286292

@@ -1101,18 +1107,18 @@ function addEditPlaylistDialog() {
11011107

11021108
// store new name (except its a default playlist)
11031109
let newName;
1104-
if (!playlist.is_custom) {
1110+
if (playlist.is_custom) {
11051111
newName = document.getElementById('playlistName').value;
11061112
if (newName.length > 0) playlist.name = newName;
11071113
}
11081114

1109-
// create new list with video items // FIXME deletes all elements!!
1115+
// create new list with video items
11101116
let newVideoItems = [];
11111117
for (const listedEntry of document.getElementById('videoList').children) {
11121118
const listedEntryId = parseInt(listedEntry.getAttribute('data-video-id'));
11131119
// transfer all storedEntries to the new item list, if they are still in the element list
11141120
for (const storedEntry of playlist.items) {
1115-
if (storedEntry.id === listedEntryId) {
1121+
if (parseInt(storedEntry.id) === listedEntryId) {
11161122
newVideoItems.push(storedEntry);
11171123
break;
11181124
}
@@ -1123,6 +1129,7 @@ function addEditPlaylistDialog() {
11231129
set_value('playlistData', playlistData);
11241130
window.removeEventListener('resize', lazyResizer);
11251131
removeFromDOM(customElementsRegister.get('editPlaylistDialog'));
1132+
updatePage();
11261133
});
11271134

11281135
// mount handler for the "cancel" button in the dialog
@@ -1612,12 +1619,27 @@ function doOrderCommentData(orderType = 'activity') {
16121619
* Wrapper which will update all custom stuff
16131620
*/
16141621
function updatePage() {
1622+
// update playlist data object to make the data "live"
1623+
playlistData = get_value('playlistData');
1624+
16151625
filteredCommentsCount = getFilteredCount();
1626+
1627+
// the following edge case is only relevant if there are at least one comment left after filtering
1628+
if (filteredCommentsCount < totalComments) {
1629+
// if we are on a page, which is now (after filtering) higher than the total page count, then switch to the last page
1630+
const totalPages = Math.ceil((totalComments - filteredCommentsCount) / currentLength);
1631+
const currentPage = Math.ceil(currentStart / currentLength);
1632+
if (currentPage > totalPages) {
1633+
currentStart = totalPages * currentLength - currentLength;
1634+
if (currentStart < 1) currentStart = 1;
1635+
}
1636+
}
1637+
16161638
updateComments();
16171639
updatePaginationUI();
16181640
updateStaticTranslations();
16191641
addPlaylistContainer();
1620-
1642+
16211643
// process translation edge cases (elements which are basically dynamic, but not reset on update)
16221644
for (const element of document.getElementsByClassName('selectedUserFilter')) {
16231645
element.lastElementChild.setAttribute('title', t('Entfernen'));
Collapse file

‎src/NuoFlix/EnhancedNuoFlix/VideoPage/functions_videoPage.js‎

Copy file name to clipboardExpand all lines: src/NuoFlix/EnhancedNuoFlix/VideoPage/functions_videoPage.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ function execute_genericPage() {
5252

5353
// mount handler for button "add to playlist"
5454
const opener = function () {
55+
// update the playlistData in case someone have multiple video pages open to add videos
56+
playlistData = get_value('playlistData');
5557
openAddToPlaylistMenu(document.getElementById('addToPlaylistWrapper'));
5658
document.getElementById('addToPlaylistIcon').removeEventListener('click', opener);
5759
}
@@ -338,6 +340,8 @@ function openAddToPlaylistMenu(refElement) {
338340
}
339341

340342
const opener = function () {
343+
// update the playlistData in case someone have multiple video pages open to add videos
344+
playlistData = get_value('playlistData');
341345
openAddToPlaylistMenu(document.getElementById('addToPlaylistWrapper'));
342346
document.getElementById('addToPlaylistIcon').removeEventListener('click', opener);
343347
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.