define(["jQuery","loading","events","globalize","humanedate","listViewStyle","emby-linkbutton"],function($,loading,events,globalize){"use strict";function reloadList(page){ApiClient.getScheduledTasks({isHidden:!1}).then(function(tasks){populateList(page,tasks),loading.hide()})}function populateList(page,tasks){tasks=tasks.sort(function(a,b){return a=a.Category+" "+a.Name,b=b.Category+" "+b.Name,a==b?0:a",html+=""),html+='
',html+="

",html+=currentCategory,html+="

",html+='
'),html+='
',html+="",html+='schedule',html+="",html+='",html+="Idle"==task.State?'':"Running"==task.State?'':'',html+="
"}tasks.length&&(html+="
",html+="
");var divScheduledTasks=page.querySelector(".divScheduledTasks");divScheduledTasks.innerHTML=html}function humane_elapsed(firstDateStr,secondDateStr){var dt1=new Date(firstDateStr),dt2=new Date(secondDateStr),seconds=(dt2.getTime()-dt1.getTime())/1e3,numdays=Math.floor(seconds%31536e3/86400),numhours=Math.floor(seconds%31536e3%86400/3600),numminutes=Math.floor(seconds%31536e3%86400%3600/60),numseconds=Math.round(seconds%31536e3%86400%3600%60),elapsedStr="";return elapsedStr+=1==numdays?numdays+" day ":"",elapsedStr+=numdays>1?numdays+" days ":"",elapsedStr+=1==numhours?numhours+" hour ":"",elapsedStr+=numhours>1?numhours+" hours ":"",elapsedStr+=1==numminutes?numminutes+" minute ":"",elapsedStr+=numminutes>1?numminutes+" minutes ":"",elapsedStr+=elapsedStr.length>0?"and ":"",elapsedStr+=1==numseconds?numseconds+" second":"",elapsedStr+=0==numseconds||numseconds>1?numseconds+" seconds":""}function getTaskProgressHtml(task){var html="";if("Idle"==task.State)task.LastExecutionResult&&(html+=globalize.translate("LabelScheduledTaskLastRan").replace("{0}",humane_date(task.LastExecutionResult.EndTimeUtc)).replace("{1}",humane_elapsed(task.LastExecutionResult.StartTimeUtc,task.LastExecutionResult.EndTimeUtc)),"Failed"==task.LastExecutionResult.Status?html+=" ("+globalize.translate("LabelFailed")+")":"Cancelled"==task.LastExecutionResult.Status?html+=" ("+globalize.translate("LabelCancelled")+")":"Aborted"==task.LastExecutionResult.Status&&(html+=" "+globalize.translate("LabelAbortedByServerShutdown")+""));else if("Running"==task.State){var progress=(task.CurrentProgressPercentage||0).toFixed(1);html+='
',html+='
',html+='
',html+="
",html+="
",html+=""+progress+"%",html+="
"}else html+=""+globalize.translate("LabelStopping")+"";return html}function updateTasks(page,tasks){for(var i=0,length=tasks.length;i