{header:author/inc_header.html}
{header:author/inc_toper.html}
{header:author/inc_nav.html}
<script>
$(document).ready(function(){
	$("#main-bar").find("li").eq("1").addClass("act");
});
</script>
<link rel="stylesheet" type="text/css" href="{templates}/static/css/author/novellist.css">
<style>
.select{border: 1px solid #DDDDDD;height: 30px;outline: none !important;cursor: pointer;visibility: inherit;}
</style>

<div class="mainRight fl">
    <div class="crumbsWrap">
    	<i class="before"><a href="{小说作品列表}"><span>小说管理</span></a></i><em class="same"></em>
		<i class="current"><span>{名字}</span></i>
    </div>
    <div class="msgBoxTitle">
	    {cur:did>0}
    	<a class="create button" href="{小说新建草稿}"><em class="icon"></em>新建章节</a>
    	{/cur}
        <div class="tabSwitch cf">
            <span><a href="{编辑小说}">编辑作品信息</a></span>
            <span class="act"><a href="{小说草稿箱列表}">草稿箱</a></span>
            <span><a href="{小说分卷列表}">分卷管理</a></span>
            <span><a href="{小说章节列表}">章节管理</a></span>
        </div>
    </div>
    
    <div class="managerWrap cf">
        <div class="mRightContent fl" style="width: 1040px;">
            <div class="midWrap editWrap">
                <form id="form" name="form" method="post">
				{隐藏表单}
                    <div class="sectionViewWrap">
                        <div>
                        	<div class="sectionBtnBox cf" style="width: 96%;">
	                            <div class="titleBtn fr">
	                            	{cur:did>0}
	                                <a id="delete" class="button white" href="{删除草稿}">删除</a>
	                                {/cur}
	                                <a id="tongji" class="button white font" href="javascript:">字数统计</a>
	                                <a id="save" class="button white" href="javascript:">保存</a>
	                                <a id="sub" class="button green" href="javascript:"><span class="icon "></span>发布</a>
	                            </div>
	                            <em class="c999">发布至：</em>
	                            <div class="select-wrap mid">
		                            <select id="vid" name="vid" class="select">
		                            	<option value="">请选择分卷</option>
		                            	{小说分卷列表:}<option value="{小说分卷id}" {eq:{分卷id}:{小说分卷id}}selected="selected"{/eq}>{小说分卷名字}</option>{/小说分卷列表}
		                            </select>
	                            </div>

	                            <em class="c999">章节类型：</em>
	                            <div class="select-wrap min">
		                            <select id="pay" name="pay" class="select">
		                            	{小说章节类型列表:}<option value="{小说章节类型id}" {eq:{是否上架}:{小说章节类型id}}selected="selected"{/eq}>{小说章节类型名字}</option>{/小说章节类型列表}
		                            </select>
	                            </div>
	                        </div>
						</div>
                        <div class="zwText">
                            <input style="width: 100%;" autocomplete="off" id="title" name="title" type="text" maxlength="30" value="{标题}" placeholder="此处输入章节号与章节名。示例：“第十章 天降奇缘”">
                            <textarea style="width: 100%;" autocomplete="off" id="content" name="content" placeholder="请输入正文">{内容}</textarea>
                        </div>
                    </div>
 				</form>
            </div>
        </div>
    </div>
 </div>
{header:author/inc_footer.html}
<script>
//字数统计
$("#tongji").click(function(){
	var str = $("[name=content]").val();
	easydialog_alert('当前共有'+wordsNumber(str)+'个中文！','','','');
});
//保存草稿
$("#save").click(function(){
	var vid = $("#vid").val();
	var pay = $("#pay").val();
	var title = $("#title").val();
	var content = $("#content").val();
	
	if( !isPositiveNum(pay) ){
		easydialog_alert('对不起，章节类型错误！','','','');
	}else if( !isPositiveNum(vid) ){
		easydialog_alert('对不起，请先添加分卷！','','','');
		setTimeout(function(){window.parent.location = '{小说新建分卷}';},1000);
	}else if( title == '' || content == '' ){
		easydialog_alert('对不起，所有项都不能为空！','','','');
	}else{
		$.ajax({
			type:"POST",
			url:"{url:action;author.draftedit&ajax=yes}",
			data:$("#form").serializeArray(),
			dataType:"json",
			success:function(data){
				easydialog_alert(data.msg,'','','');
			},
			async:true,
		});
	}
});


//发布章节草稿
$("#sub").click(function(){
	var vid = $("#vid").val();
	var pay = $("#pay").val();
	var title = $("#title").val();
	var content = $("#content").val();
	var did = $("#did").val();
	var contentid = $("#contentid").val();
	var module = $("#module").val();
	
	if( !isPositiveNum(pay)){
		easydialog_alert('对不起，章节类型错误！','','','');
	}else if( !isPositiveNum(vid) ){
		easydialog_alert('对不起，请先添加分卷！','','','');
		setTimeout(function(){window.parent.location = '{小说新建分卷}';},1000);
	}else if( !isPositiveNum(did) || !isPositiveNum(contentid) ){
		easydialog_alert('对不起，草稿id和书籍id错误！','','','');
	}else if( module == '' ){
		easydialog_alert('对不起，草稿发布模块错误！','','','');
	}else if( title == '' || content == '' ){
		easydialog_alert('对不起，所有项都不能为空！','','','');
	}else{
		$.ajax({
			type:"POST",
			url:"{url:action;author.novel_chapteredit&ajax=yes}",
			data:$("#form").serializeArray(),
			dataType:"json",
			success:function(data){
				easydialog_alert(data.msg,'','','');
				if( data.code == 200){
					setTimeout(function(){window.parent.location = '{小说草稿箱列表}';},1000);
				}
			},
			async:true,
		});
	}
});
</script>