MCPcopy Create free account
hub / github.com/MALSync/MALSync / handleList

Method handleList

src/pages-sync/syncPage.ts:824–883  ·  view source on GitHub ↗
(searchCurrent = false, reTry = 0)

Source from the content-addressed store, hash-verified

822 }
823
824 handleList(searchCurrent = false, reTry = 0) {
825 if (!this.singleObj) return; // Object not ready yet
826 j.$('.mal-sync-active').removeClass('mal-sync-active');
827 j.$('[data-mal-sync-episode]').removeAttr('data-mal-sync-episode');
828 j.$('[data-mal-sync-episode-detected]').removeAttr('data-mal-sync-episode-detected');
829 j.$('[data-mal-sync-entry]').removeAttr('data-mal-sync-entry');
830 if (
831 typeof this.page.overview !== 'undefined' &&
832 typeof this.page.overview.list !== 'undefined'
833 ) {
834 const epList = this.getEpList();
835 if (typeof epList !== 'undefined' && epList.length > 0) {
836 this.offsetHandler(epList);
837 if (this.page.overview.list.elementUrl) {
838 const { elementUrl } = this.page.overview.list;
839 logger.log(
840 'Episode List',
841 j.$.map(epList, function (val, i) {
842 if (typeof val !== 'undefined') {
843 return elementUrl(val);
844 }
845 return '-';
846 }),
847 );
848 if (typeof this.page.overview.list.handleListHook !== 'undefined')
849 this.page.overview.list.handleListHook(this.singleObj.getEpisode(), epList);
850 const curEp = epList[parseInt(this.singleObj.getEpisode() || 1)];
851 if (
852 typeof curEp === 'undefined' &&
853 !curEp &&
854 searchCurrent &&
855 reTry < 10 &&
856 typeof this.page.overview.list.paginationNext !== 'undefined'
857 ) {
858 logger.log('Pagination next');
859 const This = this;
860 if (this.page.overview.list.paginationNext(false)) {
861 setTimeout(function () {
862 reTry++;
863 This.handleList(true, reTry);
864 }, 500);
865 }
866 }
867
868 const nextEp = epList[this.singleObj.getEpisode() + 1];
869 if (typeof nextEp !== 'undefined' && nextEp && !this.page.isSyncPage(this.url)) {
870 const message = `<a href="${elementUrl(nextEp)}">${api.storage.lang(
871 `syncPage_malObj_nextEp_${this.page.type}`,
872 [this.singleObj.getEpisode() + 1],
873 )}</a>`;
874 utils.flashm(message, {
875 hoverInfo: true,
876 type: 'nextEp',
877 minimized: true,
878 });
879 }
880 }
881 }

Callers 15

fillUIMethod · 0.95
initFunction · 0.80
initFunction · 0.80
checkFunction · 0.80
initFunction · 0.80
initFunction · 0.80
startFunction · 0.80
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80

Calls 4

getEpListMethod · 0.95
offsetHandlerMethod · 0.95
langMethod · 0.80
elementUrlFunction · 0.50

Tested by

no test coverage detected