<%@ page language="C#" autoeventwireup="true" inherits="V5Shop.Admin.Html_Html_OneKeyPublic, V5Shop.Shop.Html" enableviewstatemac="false" enableEventValidation="false" viewStateEncryptionMode="Never" %>
<%@ Register Src="control/PageBottom.ascx" TagName="PageBottom" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>V5Shop</title>
    <link href="css/css.css" rel="stylesheet" type="text/css">
    <link href="css/control.css" rel="stylesheet" type="text/css">
    <link href="js/calendar-system.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" language="javascript" src="js/Common.js"></script>

    <script type="text/javascript" language="javascript" src="Js/Calendar.js"></script>

    <script type="text/javascript" language="javascript" src="Js/Calendar-zh.js"></script>

    <script type="text/javascript" language="javascript" src="Js/Calendar-Setup.js"></script>

    <script language="javascript" src="js/prototype.js" type="text/javascript"></script>

    <script type="text/javascript" src="editor/fckeditor.js"></script>

    <style>
.xingmu {
    line-height: 20px;
	font-family: "Verdana, ";
	color:#333333;
	font-size:12px;
	font-weight:bolder;
	background:#A8CFEB;
}
.processline,textarea{
    FONT-SIZE: 12px;
	COLOR:#333333;
    text-decoration: none;
    background:#F5FAFF;
	border:2px #9DB3C5 solid;
}
body{
    FONT-FAMILY: "";
    FONT-SIZE: 12px;
    text-decoration: none;
    line-height: 150%;
    /*background:#EBEBEB;*/
    SCROLLBAR-FACE-COLOR: #D5D5D5;
    SCROLLBAR-HIGHLIGHT-COLOR: #9A9A9A;
    SCROLLBAR-SHADOW-COLOR: #9A9A9A;
    SCROLLBAR-3DLIGHT-COLOR: #E0E0E0;
    SCROLLBAR-ARROW-COLOR: #333333;
    SCROLLBAR-TRACK-COLOR: #C5C5C5;
    SCROLLBAR-DARKSHADOW-COLOR: #E8E8E8;
    padding:0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
}

</style>
</head>
<body>
    <form id="form1" runat="server">
        <div class="OperateTitle">
            <div>
                <asp:Label ID="lblTitleAdd" runat="server" Text="【 站点发布 】"></asp:Label>
                <asp:Label ID="lblPublicNotice" runat="server">一键发布</asp:Label></div>
        </div>
        <div>
            <table id="OperateTable" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center" colspan="2" style="padding:30px 0 20px">
                        <div id="RefreshSchedule">
                            <div class="processline" align="left" style="width: 400px;">
                                <div id="RefreshLen" class="xingmu" style="width: 0px;">
                                    <span class="xingmu">0%</span>
                                </div>
                            </div>
                            <span id="CheckPublic" align="center" style="color:#009900">
                            正在检测当前是否有页面在发布</span>
                            <asp:Label ID="Status" runat="server" Text="系统检测上次的发布未结束，需要发布的页面数量为{$i}张，是否继续发布？" Visible="false"></asp:Label>
                            <span id="result_str" align="center" style="display: none">
                                正在准备数据</span>
                            <span id="wait1" style="display: none">.</span>
                            <span id="schedule" align="center" style="display: none">
                                共有{$totalcount}个页面需要发布.</span>
                             <span id="totalcount" align="center" style="display: none"></span>
                            <br />
                            <br />
                        </div>
                  </td>
                </tr>
                <tr>
                    <td height="30" align="center" colspan="2">
                    
                        <input type="hidden" id="StartID" value=''  runat="server"/>
                        <input type="hidden" id="EndID" value='' runat="server"/>
                        <input type="hidden" id="StartDate" value=''  runat="server"/>
                        <input type="hidden" id="EndDate" value='' runat="server"/>
                        <input type="hidden" id="CategoryID" value='' runat="server"/>
                        <input type="hidden" id="TopCount" value='' runat="server"/>
                        <input type="hidden" id="Action" value='' runat="server"/>
                        
                        <input type="button" id="btnCreate" value="一键发布" onclick="PrePublicData()"  runat="server"/>
                        <input type="button" id="btnGoOn" value="继续上一次发布" onclick="GoOnPublicData()"  runat="server" visible="false"/>
                    </td>
                </tr>
            </table>

            <script type="text/javascript">
            //加TABLE样式
            InitTrClass();
            
            </script>

        </div>
        <uc1:PageBottom ID="PageBottom1" runat="server" />
    </form>
<script language="javascript" type="text/javascript">
/*以下检测当前是否发布*/
var check=0,checkresult=0,check1=0,ispublic=true;
function CheckPublicData()
{
    $('wait1').style.display="";
    HiddenControl();
    var url = 'Html_Html_OneKeyPublic.aspx?StartCount=true&d='+Date();
    var Action = '';
    setTimeout('WaitPreData()',1000);
    var wAjax = new Ajax.Request(url,{method:'get',parameters:Action,onComplete:ShowCheckTimeOut});
}

function ShowCheckTimeOut(OriginalRequest)
{
     var originalrequest=OriginalRequest.responseText;
     setTimeout("ShowCheck("+originalrequest+")",1000);
}

function ShowCheck(originalrequest)
{
    if(check==0)
    {
        checkresult=originalrequest;
    }
    else
    {
        if(checkresult!=originalrequest)
        {
            check1=check1+1;
        }
    }
    check=check+1;
    if(check==4)
    {
        
        $("wait1").innerHTML="1";
        $("wait1").style.display="none";
        if(check1!=0)
        {
            $("CheckPublic").innerHTML="当前有页面正在发布，发布进度："
            ispublic=false;
            GoOnPublicData();
        }
        else
        {
            $("CheckPublic").innerHTML="检测完毕，当前没有发布"
            setTimeout("ShowControl()",1500);
        }
        return;
    }
    else
    {
        CheckPublicData();
    }
}
/*检测发布结束*/

/*控件状态改变*/
function ShowControl()
{
    $('result_str').style.display="none";
    $('btnCreate').disabled=false;
    try{
        $('btnGoOn').disabled=false;
    }catch(e){}
    
    try{
        $('Status').style.display="";
    }catch(e){}
    $("CheckPublic").style.display="none";
}

function HiddenControl()
{
    $('result_str').style.display="none";
    $('btnCreate').disabled=true;
    try{
        $('btnGoOn').disabled=true;
    }catch(e){}
    try{
        $('Status').style.display="none";
    }catch(e){}
}
/*控件状态改变*/

CheckPublicData();

/*以下是进度条脚本.*/
    function ShowWaitStatus(index){
    var id = "wait" + index;
    $(id).innerHTML = $(id).innerHTML + ".";
    if($(id).innerHTML == "............"){
        $(id).innerHTML = ".";
    }
}
function WaitPreData(){
    if($("wait1").innerHTML=="1")
    {
        return;
    }
    ShowWaitStatus(1);
    setTimeout('WaitPreData()', 1000);
}

/*一键盘发布：获取统计数据,并插入新数据*/
function PrePublicData()
{
    $('result_str').style.display="";
    $('wait1').style.display="";
    try{
        $('Status').style.display="none";
    }catch(e){}
    try{
        $('btnGoOn').disabled=true;
    }catch(e){}    
    $('wait1').innerHTML=".";
    $('btnCreate').disabled=true;
    var url = 'Html_Html_OneKeyPublic.aspx?Count=true&d='+Date();
    var Action = '';
    setTimeout('WaitPreData()',1000);
    var wAjax = new Ajax.Request(url,{method:'get',parameters:Action,onComplete:SetDisplayTimeOut});
}

/*获取统计数据，不改变当前数据*/
function GoOnPublicData()
{
    $('result_str').style.display="";
    $('wait1').style.display="";
    $('wait1').innerHTML=".";
    $('btnCreate').disabled=true;
    $('btnGoOn').disabled=true;
    $('Status').style.display="none";
    var url = 'Html_Html_OneKeyPublic.aspx?Count=true&goon=true&d='+Date();
    var Action = '';
    setTimeout('WaitPreData()',1000);
    var wAjax = new Ajax.Request(url,{method:'get',parameters:Action,onComplete:SetDisplayTimeOut});
}

/*延时*/
function SetDisplayTimeOut(OriginalRequest)
{
    $('schedule').innerHTML= $('schedule').innerHTML.replace('{$totalcount}',OriginalRequest.responseText);
    $('totalcount').value=OriginalRequest.responseText;
    setTimeout("ShowResult()",1500);
}

/*显示统计结果，开始发布页面*/
function ShowResult()
{
   $('result_str').style.display="none";
   $('wait1').style.display="none";
   $('schedule').style.display="";
   $("wait1").innerHTML="1";
   if(ispublic){
        StartPublic();
   }
   StartCount();
}

/*开始发布页面*/
function StartPublic()
{
    var url = 'Html_Html_OneKeyPublic.aspx?Start=true&d='+Date();
    var pars = '';
    new Ajax.Updater("", url, {method: 'get', parameters: pars});
}

/*开始统计进度*/
function StartCount()
{
    var url = 'Html_Html_OneKeyPublic.aspx?StartCount=true&d='+Date();
    var Action = '';
    var wAjax = new Ajax.Request(url,{method:'get',parameters:Action,onComplete:SetTimeOutIsOver});
}

/*延时*/
function SetTimeOutIsOver(OriginalRequest)
{
    var originalrequest=OriginalRequest.responseText;
    setTimeout("IsOver("+originalrequest+")",1000);
}

/*进度计算并显示*/
function IsOver(originalrequest)
{
    if(originalrequest==$('totalcount').value)
    {
		$("RefreshLen").style.width ="100%";
		$("RefreshLen").innerHTML="&nbsp;<span class=\"xingmu\">100%</span>";
        $('schedule').innerHTML= " 共有" + $('totalcount').value + "个页面需要发布.已经发布" + originalrequest + "个页面.发布完成";
        return;
    }
    else
    {
    	var percent=(originalrequest/$('totalcount').value)*100;
		percent=Math.round(percent);
		$("RefreshLen").style.width =percent+"%";
		$("RefreshLen").innerHTML="&nbsp;<span class=\"xingmu\">"+percent+"%</span>";
        $('schedule').innerHTML= " 共有" + $('totalcount').value + "个页面需要发布.已经发布" + originalrequest + "个页面";
        StartCount();
    }
}

/*模块发布：获取统计数据,并插入新数据*/
function ModulePublicData()
{
    $('result_str').style.display="";
    $('wait1').style.display="";
    $('wait1').innerHTML=".";
    try{
        $('Status').style.display="none";
    }catch(e){}  
    try{
        $('btnGoOn').disabled=true;
    }catch(e){}      
    $('btnCreate').disabled=true;
    var url = 'Html_Html_OneKeyPublic.aspx?module2=true&d='+Date();
    var forms={Action:$F("Action"),TopCount:$F("TopCount"),CategoryID:$F("CategoryID"),StartID:$F("StartID"),EndID:$F("EndID"),StartDate:$F("StartDate"),EndDate:$F("EndDate")};
 	var Action = $H(forms).toQueryString();
    setTimeout('WaitPreData()',1000);
    var wAjax = new Ajax.Request(url,{method:'post',parameters:Action,onComplete:SetDisplayTimeOut2});
}

/*延时*/
function SetDisplayTimeOut2(OriginalRequest)
{
    $('schedule').innerHTML= $('schedule').innerHTML.replace('{$totalcount}',OriginalRequest.responseText);
    $('totalcount').value=OriginalRequest.responseText;
    setTimeout("ShowResult2()",1500);
}

/*显示统计结果，开始发布页面*/
function ShowResult2()
{
   $('result_str').style.display="none";
   $('wait1').style.display="none";
   $('schedule').style.display="";
   $("wait1").innerHTML="1";
   if(ispublic){
        StartModulePublic();
   }
   StartCount();
}

/*开始发布页面*/
function StartModulePublic()
{
    var url = 'Html_Html_OneKeyPublic.aspx?StartModulePublic=true&d='+Date()+"&action="+$("Action").value;
 	var pars = "";
    new Ajax.Updater("", url, {method: 'get', parameters: pars});
}

</script>

</body>
</html>
