2017-05-17 20:18:08 -07:00
|
|
|
define(["jQuery","scripts/taskbutton","dom","libraryMenu","layoutManager","loading","listViewStyle","flexStyles","emby-itemscontainer","cardStyle","material-icons"],function($,taskButton,dom,libraryMenu,layoutManager,loading){"use strict";function resetTuner(page,id){var message=Globalize.translate("MessageConfirmResetTuner");require(["confirm"],function(confirm){confirm(message,Globalize.translate("HeaderResetTuner")).then(function(){loading.show(),ApiClient.resetLiveTvTuner(id).then(function(){loading.hide(),reload(page)})})})}function renderTuners(page,tuners){var html="";if(tuners.length){html+='<div class="paperList">';for(var i=0,length=tuners.length;i<length;i++){var tuner=tuners[i];html+='<div class="listItem">',html+='<i class="listItemIcon md-icon">live_tv</i>',html+='<div class="listItemBody two-line">',html+='<h3 class="listItemBodyText">',html+=tuner.Name,html+="</h3>",html+='<div class="listItemBodyText secondary">',html+=tuner.SourceType,html+="</div>",html+='<div class="listItemBodyText secondary">',"RecordingTv"==tuner.Status?tuner.ChannelName?(html+='<a href="itemdetails.html?id='+tuner.ChannelId+'">',html+=Globalize.translate("StatusRecordingProgram").replace("{0}",tuner.ChannelName),html+="</a>"):html+=Globalize.translate("StatusRecording"):"LiveTv"==tuner.Status?tuner.ChannelName?(html+='<a href="itemdetails.html?id='+tuner.ChannelId+'">',html+=Globalize.translate("StatusWatchingProgram").replace("{0}",tuner.ChannelName),html+="</a>"):html+=Globalize.translate("StatusWatching"):html+=tuner.Status,html+="</div>",html+="</div>",tuner.CanReset&&(html+='<button type="button" is="paper-icon-button-light" data-tunerid="'+tuner.Id+'" title="'+Globalize.translate("ButtonResetTuner")+'" class="btnResetTuner"><i class="md-icon">refresh</i></button>'),html+="</div>"}html+="</div>"}tuners.length?page.querySelector(".tunerSection").classList.remove("hide"):page.querySelector(".tunerSection").classList.add("hide");var elem=$(".tunerList",page).html(html);$(".btnResetTuner",elem).on("click",function(){var id=this.getAttribute("data-tunerid");resetTuner(page,id)})}function getServiceHtml(service){var html="";html+="<div>";var serviceUrl=service.HomePageUrl||"#";html+='<p><a href="'+serviceUrl+'" target="_blank">'+service.Name+"</a></p>";var versionHtml=service.Version||"Unknown";versionHtml+=service.HasUpdateAvailable?' <a style="margin-left: .25em;" href="'+serviceUrl+'" target="_blank">'+Globalize.translate("LiveTvUpdateAvailable")+"</a>":'<img src="css/images/checkmarkgreen.png" style="height: 17px; margin-left: 10px; margin-right: 0; position: relative; top: 5px; border-radius:3px;" /> '+Globalize.translate("LabelVersionUpToDate"),html+="<p>"+versionHtml+"</p>";var status=service.Status;return"Ok"==service.Status?status='<span style="color:green;">'+status+"</span>":(service.StatusMessage&&(status+=" ("+service.StatusMessage+")"),status='<span style="color:red;">'+status+"</span>"),html+="<p>"+Globalize.translate("ValueStatus",status)+"</p>",html+="</div>"}function loadPage(page,liveTvInfo){liveTvInfo.IsEnabled?$(".liveTvStatusContent",page).show():$(".liveTvStatusContent",page).hide();var servicesToDisplay=liveTvInfo.Services.filter(function(s){return s.IsVisible});servicesToDisplay.length?$(".servicesSection",page).show():$(".servicesSection",page).hide(),$(".servicesList",page).html(servicesToDisplay.map(getServiceHtml).join(""));for(var tuners=[],i=0,length=liveTvInfo.Services.length;i<length;i++)for(var j=0,numTuners=liveTvInfo.Services[i].Tuners.length;j<numTuners;j++)tuners.push(liveTvInfo.Services[i].Tuners[j]);renderTuners(page,tuners),ApiClient.getNamedConfiguration("livetv").then(function(config){renderDevices(page,config.TunerHosts),renderProviders(page,config.ListingProviders)}),loading.hide()}function getDeviceHtml(device){var padderClass,html="",cssClass="card scalableCard",cardBoxCssClass="cardBox visualCardBox";return cssClass+=" backdropCard backdropCard-scalable",padderClass="cardPadder-backdrop",layoutManager.tv&&(cssClass+=" card-focusscale",cardBoxCssClass+=" cardBox-focustransform"),cardB
|