function ControllerDownload(){throw{msg:"Don't NEW a singleton."}}ControllerDownload.show=function(e){this.init&&this.init(),ControllerDownload.refresh(e),$("#download-dialog").show(),this.resize()},ControllerDownload.hide=function(){$("#download-dialog").hide()},ControllerDownload.resize=function(){$("#download-dialog").css({height:window.innerHeight,width:window.innerWidth}),$("#download-dialog .bc-dialog").css({top:(window.innerHeight-$("#download-dialog .bc-dialog").innerHeight())/2,left:(window.innerWidth-$("#download-dialog .bc-dialog").innerWidth())/2})},ControllerDownload.refresh=function(e){var i=ControllerMain.isNvr?g_device.channels[e].videoFiles:g_device.channels[e].playbackFiles,o=ControllerLogin.channelState[e]?ControllerLogin.channelState[e].name:"";if(o=o||oneToZeroOne(e+1),$("#download-channel-id").text("CH "+o),$("#download-file-list").html(""),$("#download-date").text(PlayerPlayback.bcDatePicker.getSearchDate().getUnixDateOnly()),i&&i.length>0)for(var n=0;n div").outerWidth()})}),0)},ControllerDownload.addFile=function(e){var i,o,n=$("#download-file-list");if(ControllerMain.isNvr)i=String.formatSize(e.fileSize,1),o='
',o+='
'+e.fileName+"
";else{i=String.formatSize(e.size,1);var t=e.fileName.replace(/_\d{8}_\d{6}_/,"_"+e.startTime.getUnixDateOnly().replace(/\-/g,"")+"_"+e.startTime.getUnixTimeOnly().replace(/\:/g,"")+"_");o='
',o+='
'+t+"
",o+='
'+e.startTime.getUnixTimeOnly()+"
",o+='
'+e.endTime.getUnixTimeOnly()+"
"}o+='
'+i.num+" "+i.unit+"
",n.append(o)},ControllerDownload.init=function(){$("#download-dialog").on("click",(function(e){"download-dialog"==e.target.id&&ControllerDownload.hide()})),this.status="idle",$("#download-dialog").find(".bc-dialog-close").on("click",(function(){ControllerDownload.hide()})),this.inputType="radio",$("#download-file-list").on("click","input",(function(){setTimeout((function(){0!=$("#download-file-list input:checked").length||ControllerLogin.isIE?$("#download-do").removeAttr("disabled"):$("#download-do").attr("disabled",!0)}),0)})),$("#download-file-list").on("click",">div>div:nth-child(n+2)",(function(){$(this).parent().find("input").trigger("click")})),$("#download-do").on("click",(function(){$(this).attr("disabled",!0),$("#download-file-list input:checked").each((function(){var e=document.createElement("iframe"),i=$(this).parent().parent().find(".dl-row-name");e.id=String.random(32);var o=ControllerLogin.getQueryDataByCount([],"Download"),n="";-1!==o&&(n=o.query,o.count.free=!1),e.src=window.location.protocol+"//"+window.location.host+"/cgi-bin/api.cgi?token="+infoHandler.recover2Str(ControllerLogin.token)+"&cmd=Download&source="+i.attr("real-name")+"&output="+i.text().replace(/\//g,"_")+"&"+n,e.style.display="none",document.body.appendChild(e),setTimeout((function(){-1!==o&&(o.count.free=!0),document.body.removeChild(e)}),3e3)})),$(this).removeAttr("disabled")})),delete this.init};