EmbyCrackedClient/web/livetv/schedule.js

1 line
5.6 KiB
JavaScript
Raw Permalink Normal View History

2025-06-25 11:46:04 +08:00
import BaseTab from"./../modules/tabbedview/basetab.js";import"./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js";import"./../modules/emby-elements/emby-button/emby-button.js";import"./../modules/emby-elements/emby-scroller/emby-scroller.js";import datetime from"./../modules/common/datetime.js";import connectionManager from"./../modules/emby-apiclient/connectionmanager.js";import events from"./../modules/emby-apiclient/events.js";import imageLoader from"./../modules/common/imagehelper.js";import cardBuilder from"./../modules/cardbuilder/cardbuilder.js";import serverNotifications from"./../modules/common/input/api.js";function LiveTvScheduleTab(view,params){BaseTab.apply(this,arguments),this.view=view,this.params=params,this.apiClient=connectionManager.getApiClient(params.serverId),this.activeRecordingsItemsContainer=view.querySelector(".activeRecordings .itemsContainer"),this.activeRecordingsItemsContainer.fetchData=fetchActiveRecordings.bind(this),this.activeRecordingsItemsContainer.getListOptions=getActiveRecordingsListOptions.bind(this),this.activeRecordingsItemsContainer.parentContainer=this.activeRecordingsItemsContainer.closest(".verticalSection")}function renderTimers(view,timers){var items=timers.map(function(t){return t.Type="Timer",t}),groups=[];let currentGroupName="",currentGroup=[],i,length;timers=imageLoader.getPrimaryImageAspectRatio(items)||1;for(i=0,length=items.length;i<length;i++){var item=items[i];let dateText="";if(item.StartDate)try{var premiereDate=datetime.parseISO8601Date(item.StartDate,!0);dateText=datetime.toLocaleDateString(premiereDate,{weekday:"long",month:"short",day:"numeric"})}catch(err){}dateText!==currentGroupName?(currentGroup.length&&groups.push({name:currentGroupName,items:currentGroup}),currentGroupName=dateText,currentGroup=[item]):currentGroup.push(item)}currentGroup.length&&groups.push({name:currentGroupName,items:currentGroup});let html="";for(i=0,length=groups.length;i<length;i++){var group=groups[i];html=(html=(html=(html+='<div class="verticalSection verticalSection-cards">')+('<h2 class="sectionTitle sectionTitle-cards padded-left padded-left-page">'+group.name+"</h2>")+'<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-framesize="matchgrandparent" data-focusscroll="true" data-mousewheel="false">')+'<div is="emby-itemscontainer" data-focusabletype="nearest" class="itemsContainer scrollSlider focusable focuscontainer-x padded-left padded-left-page padded-right">'+"</div>")+"</div>"+"</div>"}var view=view.querySelector(".upcomingRecordings"),itemsContainers=(html?view.classList.remove("hide"):view.classList.add("hide"),view.innerHTML=html,view.querySelectorAll(".itemsContainer")),cardLayout=1.5<=timers;for(i=0,length=groups.length;i<length;i++)cardBuilder.buildCards(groups[i].items,{itemsContainer:itemsContainers[i],shape:"autooverflow",fields:["ParentNameOrName","ChannelName","AirTime"],showAirEndTime:!0,cardLayout:cardLayout,centerText:!cardLayout,action:"edit",cardFooterAside:!1,showChannelLogo:cardLayout,preferThumb:cardLayout||null,multiSelect:!1,horizontal:!0})}function fetchActiveRecordings(){var apiClient=this.apiClient;return apiClient.getLiveTvRecordings({UserId:apiClient.getCurrentUserId(),IsInProgress:!0,Fields:this.getRequestedItemFields()+",PrimaryImageAspectRatio",EnableTotalRecordCount:!1,EnableImageTypes:"Primary,Thumb,Backdrop"})}function getActiveRecordingsListOptions(){return{renderer:cardBuilder,options:{shape:"autooverflow",cardLayout:!1,fields:["ParentNameOrName","ChannelName","AirTime"],showAirEndTime:!0,preferThumb:"auto",centerText:!0,multiSelect:!1},virtualScrollLayout:"horizontal-grid"}}function onServerNotification(){this.paused?this.needsRefresh=!0:this.onResume({refresh:!0})}Object.assign(LiveTvScheduleTab.prototype,BaseTab.prototype),LiveTvScheduleTab.prototype.onResume=function(options){BaseTab.prototype.onResume.apply(this,arguments),this.serverNotificationHandler||(serverNotificationHandler=onServerNotification.bind(this),events.on(serverNotifications,"TimerCreated",serverNotificationHand