text: myApp.controller("postlist",["$scope","$http","NgTableParams","$timeout",function(n,t,i,r){var u,f;window.hub.stop();n.loading();u=this;u.stats=[];u.data={};n.kw="";n.orderby=1;n.paginationConf={currentPage:1,itemsPerPage:10,pagesLength:25,perPageOptions:[1,5,10,15,20,30,40,50,100,200],rememberPerPage:"perPageItems",onChange:function(){u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage)}};$(".orderby").dropdown("set value",n.orderby);$(".orderby").dropdown({allowAdditions:!1,onChange:function(t){n.orderby=t;u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage)}});$(".field").dropdown({allowAdditions:!1,onChange:function(t){["Author","Email","Status","VoteUpCount","VoteDownCount"].map(function(t){n[t]=!1});t.split(",").map(function(t){n[t]=!0});u.tableParams.reload()}});n.request("/post/viewtoken",null,function(t){n.ViewToken=t.Data});this.GetPageData=function(r,f){n.loading();t.post("/post/getpagedata",{page:r,size:f,kw:n.kw,orderby:n.orderby}).then(function(t){n.paginationConf.totalItems=t.data.TotalCount;$("div[ng-table-pagination]").remove();u.tableParams=new i({count:5e4},{filterDelay:0,dataset:t.data.Data});u.data=t.data.Data;Enumerable.From(t.data.Data).Select(n=>n.Status).Distinct().ToArray().map(function(n){u.stats.push({id:n,title:n})});u.stats=Enumerable.From(u.stats).Distinct().ToArray();n.loadingDone()})};u.del=function(t){swal({title:"确认删除这篇文章吗？",text:t.Title,showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"确定",cancelButtonText:"取消",showLoaderOnConfirm:!0,animation:!0,allowOutsideClick:!1}).then(function(){n.request("/post/delete",{id:t.Id},function(n){window.notie.alert({type:1,text:n.Message,time:4})});u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage)},function(){}).catch(swal.noop)};u.truncate=function(t){swal({title:"确认要彻底删除这篇文章吗？",text:t.Title,showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"确定",cancelButtonText:"取消",showLoaderOnConfirm:!0,animation:!0,allowOutsideClick:!1}).then(function(){n.request("/post/truncate",{id:t.Id},function(n){window.notie.alert({type:1,text:n.Message,time:4})});_.remove(u.tableParams.settings().dataset,function(n){return t===n});u.tableParams.reload().then(function(n){n.length===0&&u.tableParams.total()>0&&(u.tableParams.page(u.tableParams.page()-1),u.tableParams.reload())})},function(){}).catch(swal.noop)};u.pass=function(t){n.request("/post/pass",t,function(t){window.notie.alert({type:1,text:t.Message,time:4});u.stats=[];u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage)})};u.restore=function(t){n.request("/post/restore",{id:t.Id},function(t){window.notie.alert({type:1,text:t.Message,time:4});u.stats=[];u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage)})};u.fixtop=function(t){n.request("/post/Fixtop",{id:t},function(t){window.notie.alert({type:1,text:t.Message,time:4});u.stats=[];u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage)})};n.search=function(t){f&&r.cancel(f);f=r(function(){n.kw=t;u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage);f=null},500)};n.loadingDone();u.analyse=function(i){t.post("/post/analyse",{id:i.Id}).then(function(t){var r=t.data.Data;if(!t.data.Success){window.notie.alert({type:3,text:t.data.Message,time:4});return}n.postAnalyse=r;layer.open({type:1,zIndex:20,title:"文章《"+i.Title+"》访客数据可视化",offset:window.screen.height*.1+"px",area:document.body.clientWidth*.7+"px",content:$("#modal"),success:function(){$("#chart").highcharts({chart:{zoomType:"x"},credits:{enabled:!1},boost:{useGPUTranslations:!0},tooltip:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%Y-%m-%d",week:"%m-%d",month:"%Y-%m",year:"%Y"},formatter:function(){return"时间点：<b>"+Highcharts.dateFormat("%Y-%m-%d",this.points[0].x)+'<\/b><br/><span style="color:'+Highcharts.getOptions().colors[0]+'">访问量：<b>'+this.points[0].y+"次<\/b><\/span><br/>"},crosshairs:!0,shared:!0},scrollbar:{enabled:!1},title:{text:""},legend:{enabled:!1},xAxis:{type:"datetime",dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%m-%d",week:"%Y-%m-%d",month:"%Y-%m",year:"%Y"}},yAxis:[{title:{text:"访问量"},min:0,opposite:!1}],plotOptions:{series:{showInNavigator:!0,marker:{enabled:!1}}},series:[{name:"访问量",data:r.list,type:"areaspline",fillColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,Highcharts.getOptions().colors[0]],[1,Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get("rgba")]]}}]})},end:function(){$("#modal").css("display","none")}})})}}]);myApp.controller("writeblog",["$scope","$http","$timeout",function(n,t,i){window.hub.stop();n.post={Title:"",schedule:!1,Content:"",CategoryId:1,Label:"",Seminars:""};n.loading();n.post.Author=n.user.NickName||n.user.Username;n.post.Email=n.user.Email;n.getCategory=function(){n.loading();t.post("/category/getcategories",null).then(function(t){n.loadingDone();var i=t.data;i.Success?(n.cat=i.Data,$(".ui.dropdown.category").dropdown({onChange:function(t){n.post.CategoryId=t},message:{maxSelections:"最多选择 {maxCount} 项",noResults:"无搜索结果！"}})):window.notie.alert({type:3,text:"获取文章分类失败！",time:4})})};n.getCategory();n.request("/post/gettag",null,function(t){n.Tags=t.Data;$(".ui.dropdown.tags").dropdown({allowAdditions:!0,maxSelections:5,message:{maxSelections:"最多选择 {maxCount} 项"},onChange:function(t){n.post.Label=t}})});n.request("/seminar/getall",null,function(t){n.Seminars=t.Data;$(".ui.dropdown.seminar").dropdown({allowAdditions:!1,onChange:function(t){n.post.Seminars=t}});i(function(){$(".ui.dropdown.category").dropdown("set selected",[1])},100)});$(".ui.dropdown.keyword").dropdown({allowAdditions:!0,onChange:function(t){n.post.Keyword=t}});n.upload=function(){n.loading();$("#fileform").ajaxSubmit({url:"/Upload/UploadWord",type:"post",success:function(t){n.loadingDone();console.log(t);t.Success?(window.notie.alert({type:1,text:"文档上传成功!",time:2}),n.$apply(function(){n.post.Content=t.Data.Content;n.post.IsWordDocument=!0;n.post.ResourceName=t.Data.ResourceName;n.post.Title=t.Data.Title}),layer.closeAll()):window.notie.alert({type:3,text:t.Message,time:4})}});n.selectFile=!1};n.showupload=function(){layui.use("layer",function(){var n=layui.layer;n.open({type:1,title:"上传Word文档",area:["420px","150px"],content:$("#upfile")})})};n.submit=function(i){if(n.loading(),i.Label||(i.Label=null),i.Title.trim().length<=2||i.Title.trim().length>64){window.notie.alert({type:3,text:"文章标题必须在2到64个字符以内！",time:4});n.loadingDone();return}t.post("/Post/write",i).then(function(t){var i=t.data;n.loadingDone();i.Success?(window.notie.alert({type:1,text:i.Message,time:4}),n.post.Content="",n.post.Title="",n.post.IsWordDocument=!1,n.post.ResourceName=""):window.notie.alert({type:3,text:i.Message,time:4})})};n.Scheduled=function(){n.post.schedule=!n.post.schedule;i(function(){$("#timespan").jeDate({isinitVal:!0,festival:!0,isTime:!0,ishmsVal:!0,format:"YYYY-MM-DD hh:mm:ss",minDate:(new Date).Format("yyyy-MM-dd 00:00:00"),maxDate:"2099-06-16 23:59:59",okfun:function(t){$(t.elem).val(t.val);n.post.timespan=t.val}})},0)}}]);myApp.controller("postedit",["$scope","$http","$location","$timeout",function(n,t,i,r){window.hub.stop();n.id=i.search().id;n.loading();n.notify=!0;n.reserve=!0;n.request("/post/get",{id:n.id},function(t){n.post=t.Data;n.request("/post/gettag",null,function(t){n.Tags=t.Data;$(".ui.dropdown.tags").dropdown({allowAdditions:!0,maxSelections:5,message:{maxSelections:"最多选择 {maxCount} 项"},onChange:function(t){n.post.Label=t}})});$(".ui.dropdown.tags").dropdown("set value",n.post.Label);n.request("/seminar/getall",null,function(t){n.Seminars=t.Data;$(".ui.dropdown.seminar").dropdown({allowAdditions:!0,maxSelections:5,message:{maxSelections:"最多选择 {maxCount} 项"},onChange:function(t){n.post.Seminars=t}});n.post.Seminars&&r(function(){$(".ui.dropdown.seminar").dropdown("set selected",n.post.Seminars.split(","))},10)});n.getCategory();$(".ui.dropdown.keyword").dropdown({allowAdditions:!0,onChange:function(t){n.post.Keyword=t}});$(".ui.dropdown.keyword").dropdown("set selected",n.post.Keyword.split(","))});n.getCategory=function(){n.loading();t.post("/category/getcategories",null).then(function(t){n.loadingDone();var i=t.data;i.Success?(n.cat=i.Data,$(".ui.dropdown.category").dropdown({onChange:function(t){n.post.CategoryId=t},message:{maxSelections:"最多选择 {maxCount} 项",noResults:"无搜索结果！"}}),r(function(){$(".ui.dropdown.category").dropdown("set selected",[n.post.CategoryId])},10)):window.notie.alert({type:3,text:"获取文章分类失败！",time:4})})};n.upload=function(){n.loading();$("#fileform").ajaxSubmit({url:"/Upload/UploadWord",type:"post",success:function(t){n.loadingDone();console.log(t);t.Success?(window.notie.alert({type:1,text:"文档上传成功!",time:2}),n.$apply(function(){n.post.Content=t.Data.Content;n.post.IsWordDocument=!0;n.post.ResourceName=t.Data.ResourceName;n.post.Title=t.Data.Title}),layer.closeAll()):window.notie.alert({type:3,text:t.Message,time:4})}});n.selectFile=!1};n.showupload=function(){layui.use("layer",function(){var n=layui.layer;n.open({type:1,title:"上传Word文档",area:["420px","150px"],content:$("#upfile")})})};n.submit=function(i){if(n.loading(),i.Label||(i.Label=null),i.Title.trim().length<=2||i.Title.trim().length>64){window.notie.alert({type:3,text:"文章标题必须在2到64个字符以内！",time:4});n.loadingDone();return}if(i.Author.trim().length<=0||i.Author.trim().length>20){window.notie.alert({type:3,text:"再怎么你也应该留个合理的名字吧，非主流的我可不喜欢！",time:4});n.loadingDone();return}if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(i.Email.trim())){window.notie.alert({type:3,text:"请输入正确的邮箱格式！",time:4});n.loadingDone();return}if(i.Content.length<200||i.Content.length>1e6){window.notie.alert({type:3,text:"文章内容过短或者超长的，我都认为你是在制造垃圾！",time:4});n.loadingDone();return}i.notify=n.notify;i.reserve=n.reserve;t.post("/Post/edit",i).then(function(t){var i=t.data;n.loadingDone();i.Success?(window.notie.alert({type:1,text:i.Message,time:4}),n.post=i.Data):window.notie.alert({type:3,text:i.Message,time:4})})}}]);myApp.controller("toppost",["$scope","$http","$location","$timeout",function(n,t){window.hub.stop();n.isAdd=!0;n.loading();n.post={};n.getdata=function(){n.request("/post/gettops",null,function(t){n.tops=t.Data});n.request("/post/getnottops",null,function(n){$("#post").select3({allowClear:!0,items:n.Data,placeholder:"请选择一篇文章"})})};n.getdata();n.remove=function(t){swal({title:"确定取消头图页吗？",text:t.Title,type:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"确定",cancelButtonText:"取消"}).then(function(i){i&&(n.loading(),n.request("/post/RemoveTop",{id:t.Id},function(t){swal(t.Message,null,"success");n.getdata()}))}).catch(swal.noop)};n.add=function(){n.post={};n.isAdd=!0;layer.open({type:1,zIndex:20,title:"设置头图页文章",area:(window.screen.width>650?650:window.screen.width)+"px",content:$("#modal"),cancel:function(){return setTimeout(function(){$("#modal").css("display","none")},500),!0}})};n.edit=function(t){n.post=t;n.isAdd=!1;layer.open({type:1,zIndex:20,title:"设置头图页文章",area:(window.screen.width>650?650:window.screen.width)+"px",content:$("#modal"),cancel:function(){return setTimeout(function(){$("#modal").css("display","none")},500),!0}})};n.closeAll=function(){layer.closeAll();setTimeout(function(){$("#modal").css("display","none")},500)};n.submit=function(t){n.isAdd&&(t.Id=$("#post").select3("val"));n.request("/post/AddTop",t,function(t){n.closeAll();window.notie.alert({type:1,text:t.Message,time:4});n.getdata();n.post.ImageUrl="";n.post.Description=""})};n.upload=function(){swal({title:"请选择一张图片",input:"file",inputAttributes:{accept:"image/*"}}).then(function(i){if(i){var r=new FileReader;r.onload=function(i){swal({title:"上传预览",text:"确认后将开始上传并应用设置！",imageUrl:i.target.result,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"开始上传",cancelButtonText:"取消",showLoaderOnConfirm:!0,preConfirm:function(){return new Promise(function(n,r){t.post("/upload/DecodeDataUri",{data:i.target.result}).then(function(t){var i=t.data;i.Success?n(i.Data):r(i.Message)},function(n){r("请求失败，错误码："+n.status)})})}}).then(function(t){n.post.ImageUrl=t}).catch(swal.noop)};r.readAsDataURL(i)}}).catch(swal.noop)}}]);myApp.controller("category",["$scope","$http","NgTableParams",function(n,t,i){window.hub.stop();var r=this,u=[];r.data={};this.load=function(){n.request("/category/GetCategories",null,function(n){r.tableParams=new i({},{filterDelay:0,dataset:n.Data});u=n.Data})};r.load();r.del=function(t){var i={};Enumerable.From(u).Where(n=>n.Name!=t.Name).Select(n=>({id:n.Id,name:n.Name})).Distinct().ToArray().map(function(n){i[n.id]=n.name});swal({title:"确定删除这个分类吗？",text:"删除后将该分类下的所有文章移动到：",input:"select",inputOptions:i,inputPlaceholder:"请选择分类",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"确定",cancelButtonText:"取消",inputValidator:function(n){return new Promise(function(t,i){n==""?i("请选择一个分类"):t()})}}).then(function(i){i&&(t.Id==1?swal({type:"error",html:"默认分类不能被删除！"}):(n.request("/category/delete",{id:t.Id},function(n){swal({type:"success",html:n.Message})}),_.remove(r.tableParams.settings().dataset,function(n){return t===n}),r.tableParams.reload().then(function(n){n.length===0&&r.tableParams.total()>0&&(r.tableParams.page(r.tableParams.page()-1),r.tableParams.reload())})))}).catch(swal.noop)};r.edit=function(n){swal({title:"修改分类",html:'<div class="input-group"><span class="input-group-addon">分类名称： <\/span><input id="name" type="text" class="form-control input-lg" autofocus placeholder="请输入新的分类名" value="'+n.Name+'"><\/div><div class="input-group"><span class="input-group-addon">分类描述： <\/span><input id="desc" type="text" class="form-control input-lg" placeholder="请输入分类描述" value="'+n.Description+'"><\/div>',showCloseButton:!0,showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"确定",cancelButtonText:"取消",showLoaderOnConfirm:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(i,r){n.Name=$("#name").val();n.Description=$("#desc").val();t.post("/category/edit",n).then(function(n){n.data.Success?i(n.data.Message):r(n.data.Message)},function(){r("操作失败")})})}}).then(function(n){n&&(swal({type:"success",html:n}),r.load())}).catch(swal.noop)};r.add=function(){swal({title:"请输入分类名",input:"text",inputPlaceholder:"请输入分类",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"确定",cancelButtonText:"取消",inputValidator:function(n){return new Promise(function(t,i){n?t():i("分类名不能为空")})}}).then(function(t){t&&n.request("/category/add",{Name:t},function(n){swal({type:"success",html:n.Message});r.load()})}).catch(swal.noop)}}]);myApp.controller("postpending",["$scope","$http","NgTableParams","$timeout",function(n,t,i,r){var u,f;window.hub.stop();u=this;n.loading();n.kw="";n.orderby=1;n.paginationConf={currentPage:n.currentPage?n.currentPage:1,itemsPerPage:10,pagesLength:25,perPageOptions:[1,5,10,15,20,30,40,50,100,200],rememberPerPage:"perPageItems",onChange:function(){u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage)}};this.GetPageData=function(r,f){n.loading();t.post("/post/GetPending",{page:r,size:f,search:n.kw}).then(function(t){n.paginationConf.currentPage=r;n.paginationConf.totalItems=t.data.TotalCount;$("div[ng-table-pagination]").remove();u.tableParams=new i({count:5e4},{filterDelay:0,dataset:t.data.Data});n.loadingDone()})};u.del=function(t){swal({title:"确认删除这篇文章吗？",text:t.Title,showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"确定",cancelButtonText:"取消",showLoaderOnConfirm:!0,animation:!0,allowOutsideClick:!1}).then(function(){n.request("/post/delete",{id:t.Id},function(n){window.notie.alert({type:1,text:n.Message,time:4})});_.remove(u.tableParams.settings().dataset,function(n){return t===n});u.tableParams.reload().then(function(n){n.length===0&&u.tableParams.total()>0&&(u.tableParams.page(u.tableParams.page()-1),u.tableParams.reload())})},function(){}).catch(swal.noop)};u.pass=function(t){n.request("/post/pass",t,function(t){window.notie.alert({type:1,text:t.Message,time:4});u.stats=[];u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage)})};n.search=function(t){f&&r.cancel(f);f=r(function(){n.kw=t;u.GetPageData(n.paginationConf.currentPage,n.paginationConf.itemsPerPage,n.kw);f=null},500)};n.loadingDone()}]);myApp.controller("share",["$scope","$http","NgTableParams",function(n,t,i){window.hub.stop();var r=this,u=[];r.data={};this.load=function(){n.request("/share",null,function(n){r.tableParams=new i({},{filterDelay:0,dataset:n.Data});u=n.Data})};r.load();n.closeAll=function(){layer.closeAll();setTimeout(function(){$("#modal").css("display","none")},500)};n.submit=function(t){t.Id?n.request("/share/update",t,function(t){swal(t.Message,null,"info");n.share={};n.closeAll();r.load()}):n.request("/share/add",t,function(t){window.notie.alert({type:1,text:t.Message,time:3});n.share={};n.closeAll();r.load()})};r.del=function(t){swal({title:"确认删除这个分享吗？",text:t.Title,showCancelButton:!0,showCloseButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"确定",cancelButtonText:"取消",showLoaderOnConfirm:!0,animation:!0,allowOutsideClick:!1}).then(function(){n.request("/share/remove",{id:t.Id},function(n){window.notie.alert({type:1,text:n.Message,time:4});r.load()})},function(){}).catch(swal.noop)};r.edit=function(t){layer.open({type:1,zIndex:20,title:"修改快速分享",area:(window.screen.width>600?600:window.screen.width)+"px",content:$("#modal"),success:function(){n.share=t},end:function(){$("#modal").css("display","none")}})};r.add=function(){layer.open({type:1,zIndex:20,title:"添加快速分享",area:(window.screen.width>600?600:window.screen.width)+"px",content:$("#modal"),success:function(){n.share={}},end:function(){$("#modal").css("display","none")}})}}]);