EmbyCrackedClient/web/modules/emby-elements/guide/guide-settings.js
2025-06-25 11:46:04 +08:00

1 line
No EOL
3.8 KiB
JavaScript

import globalize from"./../../common/globalize.js";import layoutManager from"./../../layoutmanager.js";import userSettings from"./../../common/usersettings/usersettings.js";import dialogHelper from"./../../dialoghelper/dialoghelper.js";import"./../emby-scroller/emby-scroller.js";import"./../emby-checkbox/emby-checkbox.js";import"./../emby-select/emby-select.js";import"./../emby-dialogclosebutton/emby-dialogclosebutton.js";function save(context){let i,length;var chkIndicators=context.querySelectorAll(".chkIndicator");for(i=0,length=chkIndicators.length;i<length;i++){var type=chkIndicators[i].getAttribute("data-type");userSettings.set("guide-indicator-"+type,chkIndicators[i].checked)}userSettings.showChannelNumberInGuide(context.querySelector(".chkChannelNumber").checked),userSettings.guideChannelStyle(context.querySelector(".selectChannelDisplay").value),userSettings.set("guide-colorcodedbackgrounds",context.querySelector(".chkColorCodedBackgrounds").checked),userSettings.set(userSettings.getLiveTvChannelSortSettingsKey(),context.querySelector(".selectChannelSort").value),userSettings.set("guide-tagids",context.querySelector(".selectTags").getValues().join(","))}function fillChannelSortOrder(context){var items=userSettings.getLiveTvChannelSortOrders(globalize);let value,html="";for(let i=0,length=items.length;i<length;i++){var item=items[i];html+='<option value="'+item.value+'">'+item.name+"</option>",item.selected&&(value=item.value)}context=context.querySelector(".selectChannelSort");context.innerHTML=html,context.value=value}function load(context){let i,length;var chkIndicators=context.querySelectorAll(".chkIndicator");for(i=0,length=chkIndicators.length;i<length;i++){var type=chkIndicators[i].getAttribute("data-type");"true"===chkIndicators[i].getAttribute("data-default")?chkIndicators[i].checked="false"!==userSettings.get("guide-indicator-"+type):chkIndicators[i].checked="true"===userSettings.get("guide-indicator-"+type)}context.querySelector(".chkColorCodedBackgrounds").checked="true"===userSettings.get("guide-colorcodedbackgrounds"),context.querySelector(".chkChannelNumber").checked=userSettings.showChannelNumberInGuide(),context.querySelector(".selectChannelDisplay").value=userSettings.guideChannelStyle(),fillChannelSortOrder(context)}function getLiveTvChannelTags(query){var outerItemIds=query.Ids;return query.Ids=null,this.getLiveTvChannelTags(Object.assign({SortBy:"SortName",SortOrder:"Ascending",EnableImages:!1,EnableUserData:!1,OuterIds:outerItemIds},query))}function setSelectedChannelTags(context){context=context.querySelector(".selectTags");let channelTagIds=userSettings.get("guide-tagids");channelTagIds=channelTagIds?channelTagIds.split(","):[],context.values=channelTagIds}function loadChannelTags(context,apiClient){var selectTags=context.querySelector(".selectTags");selectTags.getItems=getLiveTvChannelTags.bind(apiClient),selectTags.parentContainer=context.querySelector(".fldTags"),setSelectedChannelTags(context)}function showEditor(options,apiClient){return new Promise(function(resolve,reject){let settingsChanged=!1;require(["text!modules/emby-elements/guide/guide-settings.template.html"],function(template){var dialogOptions={removeOnClose:!0,scrollY:!1,offsetTop:2,positionTo:options.positionTo,positionX:options.positionX,positionY:options.positionY};layoutManager.tv&&(dialogOptions.size="fullscreen");let dlg=dialogHelper.createDialog(dialogOptions);dlg.classList.add("formDialog");dialogOptions="";dialogOptions+=globalize.translateDocument(template,"sharedcomponents"),dlg.innerHTML=dialogOptions,dlg.addEventListener("change",function(){settingsChanged=!0}),dlg.addEventListener("close",function(){save(dlg),(settingsChanged?resolve:reject)()}),load(dlg),loadChannelTags(dlg,apiClient),dialogHelper.open(dlg)})})}require(["formDialogStyle","material-icons"]);export default{show:showEditor};