jellyfin-web/dashboard-ui/scripts/indexpage.js

1 line
8.1 KiB
JavaScript
Raw Normal View History

2017-01-27 20:16:59 -07:00
define(["libraryBrowser","playbackManager","emby-tabs","emby-button"],function(libraryBrowser,playbackManager){"use strict";function getDefaultSection(index){switch(index){case 0:return defaultFirstSection;case 1:return"resume";case 2:return"nextup";case 3:return"latestmedia";case 4:return"latesttvrecordings";default:return""}}function loadSection(page,user,userSettings,index){var userId=user.Id,section=userSettings.get("homesection"+index)||getDefaultSection(index);"folders"==section&&(section=defaultFirstSection);var elem=page.querySelector(".section"+index);return"latestmedia"==section?Sections.loadRecentlyAdded(elem,user):"librarytiles"==section?Sections.loadLibraryTiles(elem,user,"backdrop",index):"smalllibrarytiles"==section?Sections.loadLibraryTiles(elem,user,"smallBackdrop",index):"smalllibrarytiles-automobile"==section?Sections.loadLibraryTiles(elem,user,"smallBackdrop",index):"librarytiles-automobile"==section?Sections.loadLibraryTiles(elem,user,"backdrop",index):"librarybuttons"==section?Sections.loadlibraryButtons(elem,userId,index):"resume"==section?Sections.loadResume(elem,userId):"nextup"==section?Sections.loadNextUp(elem,userId):"latesttvrecordings"==section?Sections.loadLatestLiveTvRecordings(elem,userId):"latestchannelmedia"==section?Sections.loadLatestChannelMedia(elem,userId):(elem.innerHTML="",Promise.resolve())}function loadSections(page,user,userSettings){var i,length,sectionCount=5,elem=page.querySelector(".sections"),html="";for(i=0,length=sectionCount;i<length;i++)html+='<div class="homePageSection section'+i+'"></div>';elem.innerHTML=html;var promises=[];for(i=0,length=sectionCount;i<length;i++)promises.push(loadSection(page,user,userSettings,i));return Promise.all(promises)}function displayPreferencesKey(){return AppInfo.isNativeApp?"Emby Mobile":"webclient"}function dismissWelcome(page,userId){getDisplayPreferences("home",userId).then(function(result){result.CustomPrefs[homePageTourKey]=homePageDismissValue,ApiClient.updateDisplayPreferences("home",result,userId,displayPreferencesKey())})}function showWelcomeIfNeeded(page,displayPreferences){if(displayPreferences.CustomPrefs[homePageTourKey]==homePageDismissValue)page.querySelector(".welcomeMessage").classList.add("hide");else{Dashboard.hideLoadingMsg();var elem=page.querySelector(".welcomeMessage");elem.classList.remove("hide"),displayPreferences.CustomPrefs[homePageTourKey]?(elem.querySelector(".tourHeader").innerHTML=Globalize.translate("HeaderWelcomeBack"),elem.querySelector(".tourButtonText").innerHTML=Globalize.translate("ButtonTakeTheTourToSeeWhatsNew")):(elem.querySelector(".tourHeader").innerHTML=Globalize.translate("HeaderWelcomeToProjectWebClient"),elem.querySelector(".tourButtonText").innerHTML=Globalize.translate("ButtonTakeTheTour"))}}function takeTour(page,userId){require(["slideshow"],function(){var slides=[{imageUrl:"css/images/tour/web/tourcontent.jpg",title:Globalize.translate("WebClientTourContent")},{imageUrl:"css/images/tour/web/tourmovies.jpg",title:Globalize.translate("WebClientTourMovies")},{imageUrl:"css/images/tour/web/tourmouseover.jpg",title:Globalize.translate("WebClientTourMouseOver")},{imageUrl:"css/images/tour/web/tourtaphold.jpg",title:Globalize.translate("WebClientTourTapHold")},{imageUrl:"css/images/tour/web/tourmysync.png",title:Globalize.translate("WebClientTourMySync")},{imageUrl:"css/images/tour/web/toureditor.png",title:Globalize.translate("WebClientTourMetadataManager")},{imageUrl:"css/images/tour/web/tourplaylist.png",title:Globalize.translate("WebClientTourPlaylists")},{imageUrl:"css/images/tour/web/tourcollections.jpg",title:Globalize.translate("WebClientTourCollections")},{imageUrl:"css/images/tour/web/tourusersettings1.png",title:Globalize.translate("WebClientTourUserPreferences1")},{imageUrl:"css/images/tour/web/tourusersettings2.png",title:Globalize.translate("WebClientTourUserPreferences2")},{imageUrl:"css/images/tour/web/tourusersettings3.png",title:Globalize.translate("WebClientTourUserPreferences3")},{imageUrl:"css/images/tour/web/tourusersettings4.png",title:Globalize.translate("WebClient