<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>搜索关键字管理</title>
<link href="css_body.css" rel="stylesheet" type="text/css" />
<link href="div.css" rel="stylesheet" type="text/css">
<style>
	.nnpp{
	border-bottom:1px solid #98CAEF;
	border-top:1px solid #FFFFFF;
	border-left:1px solid #FFFFFF;
	border-right:1px solid #FFFFFF;
	filter:alpha(opacity=50);
 }
</style>
<script language="javascript" src="../include/dedeajax2.js"></script>
<script language='javascript' src='main.js'></script>
<script language="JavaScript">
var pageno = 1;
var totalrow = <?php echo $totalRow?>;
var pagesize = <?php echo $pagesize?>;
var orderby = '<?php echo $orderby?>';
var addget = '<?php echo $addget?>';
var showtag = '<?php echo $showtag; ?>';
var showkw = '<?php echo $showkw; ?>';
var keyword = '<?php echo $keyword; ?>';
//加载列表
function ReloadPage(ordertype){
	orderby = ordertype;
	var listArea = $Obj('rslist');
	var errMsg = "网络通信出错！<br>[<a href=\"javascript:ReloadPage('"+ordertype+"')\"><u>点击此重新加载列表</u></a>]";
  var myajax = new DedeAjax(listArea,true,true,"",errMsg,"正在加载...");
  myajax.SendGet("search_keywords_main.php?dopost=getlist&pageno="+pageno+"&orderby="+ordertype+addget);
}
//载入指定页的列表
function LoadPage(npage){
	pageno = npage;
	ReloadPage(orderby);
	ReloadPageNum(pageno);
}
//更新一个关键词
function UpdateNote(nid){
	var listArea = $Obj('rslist');
	var kw = $Obj('keyword'+nid).value;
	var kws = $Obj('spwords'+nid).value;
	var ct = $Obj('count'+nid).value;

	var errMsg = "网络通信出错！<br>[<a href=\"javascript:LoadPage('"+pageno+"')\"><u>点击此重新加载列表</u></a>]";
	var myajax = new DedeAjax(listArea,true,true,"",errMsg,"正在处理...");
  	myajax.SendGet("search_keywords_main.php?dopost=update&aid="+nid+"&keyword="+kw+"&spwords="+kws+"&count="+ct+"&pageno="+pageno);
}

function AddNewNote(){
	var listArea = $Obj('rslist');
	var kw = $Obj('keywords').value;
	var kws = $Obj('spwords').value;
	var ct = $Obj('count').value;

	var errMsg = "网络通信出错！<br>[<a href=\"javascript:LoadPage('"+pageno+"')\"><u>点击此重新加载列表</u></a>]";
	var myajax = new DedeAjax(listArea,true,true,"",errMsg,"正在处理...");
  	myajax.SendGet("search_keywords_main.php?dopost=add&keyword="+kw+"&spwords="+kws+"&count="+ct+"&pageno="+pageno);
}



//删除关键词
function DelNote(nid){
	var listArea = $Obj('rslist');
	totalrow = totalrow - 1;
  var pagenum = Math.ceil(totalrow/pagesize);
  if(pagenum<=pageno) pageno = pagenum;
  var errMsg = "网络通信出错！<br>[<a href=\"javascript:LoadPage('"+pageno+"')\"><u>点击此重新加载列表</u></a>]";
	var myajax = new DedeAjax(listArea,true,true,"",errMsg,"正在处理...");
  myajax.SendGet("search_keywords_main.php?dopost=del&aid="+nid+"&pageno="+pageno);
  ReloadPageNum(pageno);
}
//重新加载分页列表
function ReloadPageNum(startnum){
  var ListArea = $Obj('pagelist');
  var pagenum = Math.ceil(totalrow/pagesize);
  var listsize = 3;
  var ahtml = "";
  var startloop = 1;
  var endnum = 0;
  ahtml += "共："+totalrow+" 条记录/"+pagenum+"页";
  if(pageno>1 && pageno!=1) ahtml += " <a href='#' onclick='LoadPage(1)'>首页</a> ";
  if(pageno>1) ahtml += "<a href='#' onclick='LoadPage("+(pageno-1)+")'>↑上页</a> ";
  if(startnum >= pagenum-listsize){
  	startloop = pagenum-(listsize*2);
  	if(startloop<1) startloop = 1;
  	for(i=startloop;i<=pagenum;i++){
  		if(i==pageno) ahtml += i+" ";
  		else ahtml += "<a href='#' onclick='LoadPage("+i+")'>["+i+"]</a> ";
  	}
  }
  else if(pagenum < listsize){
  	for(i=1;i<=pagenum;i++){
  		if(i==pageno) ahtml += i+" ";
  		else ahtml += "<a href='#' onclick='LoadPage("+i+")'>["+i+"]</a> ";
  	}
  }
  else{
  	startloop = startnum-listsize;
  	if(startloop<1){ startloop=1; endnum = startloop + (listsize*2); }
  	else{ endnum = startnum+listsize; }
  	if(endnum >= pagenum) endnum = pagenum;
  	for(i=startloop;i<=endnum;i++){
  		if(i==pageno) ahtml += i+" ";
  		else ahtml += "<a href='#' onclick='LoadPage("+i+")'>["+i+"]</a> ";
  	}
  }
  if(pageno<pagenum) ahtml += "<a href='#' onclick='LoadPage("+(pageno+1)+")'>下页↓</a> ";
  if(pageno!=pagenum && pagenum>1) ahtml += " <a href='#' onclick='LoadPage("+pagenum+")'>末页</a>";
  ListArea.innerHTML = ahtml;
}
</script>
</head>
<body>
<div class="bodytitle">
	<div class="bodytitleleft"></div>
	<div class="bodytitletxt">批量管理</div>
</div>
<div class="main">
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="background:#E2F5BC;">
    <tr>
      <td height="35" colspan="8" valign="bottom" bgcolor="#EDF9D5">
        <table width="96%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="20%" style="padding-top:6px"><strong>&nbsp;搜索关键词维护</strong></td>
            <td width="60%" style="padding-top:6px">
			<table width="400" border="0" cellspacing="0" cellpadding="0">
                <form action="search_keywords_main.php" name="form1">
                	<input type="hidden" name="type" value="search" />
                  <tr>
                    <td align="center" width="61%">
                   	关键字：<input name="keyword" type="text" id="keywordse" style="width:150px" value="<?php echo $keyword; ?>"></td>
                    <td width="39%"> <input type="submit" name="Submit" value="搜索" class="inputbut" />                    </td>
                  </tr>
                </form>
            </table>			</td>
            <td width="20%" align="right" style="padding-top:6px">
			<input name="n1" type="button" id="n1" value="文档关键字维护" onClick="location='article_keywords_main.php';" class="inputbut" />
			</td>
          </tr>
        </table>
		</td>
    </tr>
	<tr>
      <td height="36" colspan="8" align="right" bgcolor="#F7FAEB" style="padding-right:3px">
	    <table border='0' cellpadding='1' cellspacing='1'>
        <tr align='center' bgcolor='#ffffff'>
          <td width="66" height='28' bgcolor="#EFFAC9">关键词：</td>
          <td width="180" bgcolor="#EFFAC9"><input name='keywords' style="width:160px" type='text' id='keywords' value='' class='ininput' /></td>
          <td width="72" bgcolor="#EFFAC9">分词结果：</td>
          <td width="180" bgcolor="#EFFAC9"><input name='spwords' style="width:160px" type='text' id='spwords' value='' class='ininput' /></td>
          <td width="72" bgcolor="#EFFAC9">搜索频率：</td>
          <td width="80" bgcolor="#EFFAC9"><input name='count' style="width:60px" type='text' id='count' value='10' class='ininput' /></td>
          <td bgcolor="#EFFAC9"><a href='###' onclick='AddNewNote()'>〖新增一条〗</a></td>
        </tr>
      </table></td>
    </tr>
	</table>
<form action="?action=delete" method="post">
	<span id='rslist'>
    <?php
		GetKeywordList($dsql,$pageno,$pagesize,$orderby);
	?>
    </span>
  <center>
  <input type="submit" name="submit" value="删除选中的关键词" />
</center>    
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="background:#E2F5BC;">
    <tr align="center">
      <td height="35" colspan="8" bgcolor="#F9FCF1">
      <span id='pagelist'></span>
      <script language='javascript'>ReloadPageNum(1);</script>
      </td>
    </tr>
  </table>

</form>
</div>
</body>
</html>