<% Option Explicit %>
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<!--#include file="../../Inc/Function.asp" -->
<%
'==============================================================================
'软件名称：风讯网站信息管理系统
'当前版本：Foosun Content Manager System 2.0 
'最新更新：2004.12
'==============================================================================
'商业注册联系：028-85098980-601,602 技术支持：028-85098980-606、607,客户支持：608
'产品咨询QQ：159410,655071,66252421
'技术支持:所有程序使用问题，请提问到bbs.foosun.net我们将及时回答您
'程序开发：风讯开发组 & 风讯插件开发组
'论坛支持：风讯在线论坛(http://bbs.foosun.net)
'官方网站：www.Foosun.net  演示站点：test.cooin.com    
'网站建设专区：www.cooin.com
'==============================================================================
'免费版本请在新闻首页保留版权信息，并做上本站LOGO友情连接
'==============================================================================
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0502") then Call ReturnError1()
		Dim JSID,TempJSObj,FileListObj,FileListSql,FileClassObj,MannerStr,ENameStr
       if Request("JsID")<>"" then
		   JSID = Clng(Request("JsID"))
	   else
		 Response.Write("<script>alert(""参数传递错误"");</script>")
		 response.end
	   end if
	   Set TempJSObj = Conn.Execute("select EName,Type,CName,Manner from FreeJS where ID="&JSID&"")
	   If TempJSObj.eof then
		 Response.Write("<script>alert(""未查询到相关记录"");</script>")
		 response.end
	   End If
	      MannerStr = TempJSObj("Manner")
		  ENameStr = TempJSObj("EName")
		  '--------删除 FreeJsFile 表的冗余数据 -----
		  Dim RikerLuObj,RikerNewsObj
		  Set RikerLuObj = Conn.Execute("Select FileName from FreeJsFile where JSName='"&TempJSObj("EName")&"'")
		  Do While Not RikerLuObj.eof
		  	Set RikerNewsObj = Conn.Execute("Select NewsID from News where FileName='"&RikerLuObj("FileName")&"' ")
		  	If RikerNewsObj.eof then
				Conn.Execute("Delete from FreeJsFile where FileName='"&RikerLuObj("FileName")&"'")
			End If
			RikerNewsObj.Close
			Set RikerNewsObj = Nothing
			RikerLuObj.MoveNext
		  Loop
		  RikerLuObj.Close
		  Set RikerLuObj = Nothing
		  Set FileListObj=server.createobject("adodb.recordset")
		  '---------------------------------------------
		  FileListSql="Select * from FreeJsFile where JSName='"&TempJSObj("EName")&"'"
		  FileListObj.open FileListSql,Conn,1,1
		%>
		<html>
		<head>
		<link href="../../CSS/css.css" rel="stylesheet" type="text/css">
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		<title>自由JS列表</title>
		</head>
		<script src="../JS/PublicJS.js" language="JavaScript"></script>
		<body topmargin="0" leftmargin="0" oncontextmenu="SelectJS(true);showMenu(MouseRightMenu);return false;"  ondragstart="return false;" onselectstart="return false;">
		
<table id="MainTable" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td valign="top"> <table width="100%" onclick="SelectJS(false);" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="41%" height="20" class="ButtonList"><div align="center">新闻名称</div></td>
          <td width="25%" class="ButtonList"><div align="center">所属栏目名称</div></td>
          <td width="11%" class="ButtonList"><div align="center">状态</div></td>
          <td width="23%" class="ButtonList"><div align="center">加入JS时间</div></td>
        </tr>
        <%if FileListObj.eof then %>
        <tr> 
          <td height="20" colspan="4" ><div align="center"><font color="#FF0000">暂时没有记录</font></div></td>
        </tr>
        <% end if
			do while Not FileListObj.Eof
			Dim FileClassName
			Set FileClassObj = Conn.Execute("Select ClassCName from NewsClass where ClassID='"&FileListObj("ClassID")&"'")
		    If FileClassObj.eof then
				FileClassName = "已删除"
			Else
				FileClassName = FileClassObj("ClassCName")
			End If
			Dim TempTypeFlag,RsTempObj,FlagTyype
			Set RsTempObj = Conn.Execute("Select HeadNewsTF,PicNewsTF from News where FileName='"&FileListObj("FileName")&"'")
		    If Not RsTempObj.eof then
			   If RsTempObj("HeadNewsTF")="1" then
				  TempTypeFlag = "<img src=""../Images/TitleNews.gif"" border=""0"">" '标题新闻标志
			   elseif RsTempObj("HeadNewsTF")="0" and RsTempObj("PicNewsTF")="0" then
				  TempTypeFlag = "<img src=""../Images/WordNews.gif"" border=""0"">" '文字新闻标志
			   else
				  TempTypeFlag = "<img src=""../Images/PicNews.gif"" border=""0"">" '图片新闻标志
			   end if
			Else
				TempTypeFlag = ""
			End  If
			If FileListObj("DelFlag")=1 then
				FlagTyype = "回收站"
			Else
				FlagTyype = "可用"
			End If
		%>
        <tr height="25"> 
          <td>
			<table border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td><% = TempTypeFlag %></td>
                <td><span NewsID="<%=FileListObj("ID")%>" JsType="<%=TempJSObj("Type")%>" class="TempletItem" align="center"><%=GotTopic(FileListObj("Title"),40)%></span></td>
              </tr>
            </table>
		  </td>
          <td><div align="center" class="TempletItem"><%=FileClassName%></div></td>
          <td><div align="center" class="TempletItem"><%=FlagTyype%></div></td>
          <td><div align="center" class="TempletItem"><%=FileListObj("ToJsTime")%></div></td>
        </tr>
        <%
		  		FileClassObj.Close
				FileListObj.MoveNext
			loop
			FileListObj.close
			set FileListObj=nothing
		%>
      </table></td>
  </tr>
</table>
<!-- 鼠标右键菜单 -->
<div id=MouseRightMenu onclick="ClickMenu(this);" onmouseover="MouseOverRightMenu();" onmouseout="MouseOverRightMenu();" class="menu"> 
  <div class="MouseRightItem" id="Add" ExeFunction="OpenWindow('JsTip.asp?FileName=JsAdd.asp&Title=新建自由JS',520,446,window);">新建样式</div>
  <div class="MouseRightItem" id="Edit" ExeFunction="OpenWindow('JsTip.asp?FileName=FileModify.asp&Types=Mod&Title=自由JS新闻图片修改&JsID='+NewsID,320,110,window);">修改</div>
  <div class="MouseRightItem" id="Del" ExeFunction="OpenWindow('JsTip.asp?FileName=FileModify.asp&Types=Del&Title=删除JS新闻&JsID='+NewsID,225,105,window);">删除</div>
  <hr id="HR1">
  <div class="MouseRightItem" id="Cut" ExeFunction="CutOperation();">剪切</div>
  <div class="MouseRightItem" id="Copy" ExeFunction="CopyOperation();">复制</div>
  <div class="MouseRightItem" id="Paste" ExeFunction="PasteOperation();">粘帖</div>
  <hr id="HR5">
  <div class="MouseRightItem" id="Refresh" ExeFunction="window.location.reload();">刷新</div>
   <hr id="HR6">
  <div class="MouseRightItem" id="Pros" ExeFunction="javascript:window.prompt('本页面路径属性' , '<%=Request.ServerVariables("SCRIPT_NAME")%>');">路径属性</div>
</div>
</body>
<%
Set Conn = Nothing
%>
<script>
var NewsID = '';
var JsType = '';
var TempENameStr='<%=ENameStr%>';
parent.MoveOrCopyObjectClass=TempENameStr;
Edit.className='MenuItemDisable';
Del.className='MenuItemDisable';
Cut.className='MenuItemDisable';
Copy.className='MenuItemDisable';
if (parent.MoveOrCopySourceNews!='')
{
	Paste.className='MouseRightItem';
}
else  Paste.className='MenuItemDisable';
var ListObjArray=new Array();
IntialListObjArray();
function IntialListObjArray()
{
	var CurrObj=null,j=1;
	for (var i=0;i<document.all.length;i++)
	{
		CurrObj=document.all(i);
		if (CurrObj.NewsID!=null)
		{
			ListObjArray[ListObjArray.length]=new ListObj(CurrObj,0,j,false);
			j++;
		}
	}
}
function ListObj(Obj,Type,Index,Selected)
{
	this.Obj=Obj;
	this.Index=Index;
	this.Type=Type;
	this.Selected=Selected;
}
function SelectJS(MouseRight)
{
	var el=event.srcElement;
	var i=0;
	if (!MouseRight)
	{
		if ((event.ctrlKey==true)||(event.shiftKey==true))
		{
			if (event.ctrlKey==true)
			{
				for (i=0;i<ListObjArray.length;i++)
				{
					if (el==ListObjArray[i].Obj)
					{
						if (ListObjArray[i].Selected==false)
						{
							ListObjArray[i].Obj.className='TempletSelectItem';
							ListObjArray[i].Selected=true;
						}
						else
						{
							ListObjArray[i].Obj.className='TempletItem';
							ListObjArray[i].Selected=false;
						}
					}
				}
			}
			if (event.shiftKey==true)
			{
				var MaxIndex=0,ObjInArray=false,EndIndex=0,ElIndex=-1;
				for (i=0;i<ListObjArray.length;i++)
				{
					if (ListObjArray[i].Selected==true)
					{
						if (ListObjArray[i].Index>=MaxIndex) MaxIndex=ListObjArray[i].Index;
					}
					if (el==ListObjArray[i].Obj)
					{
						ObjInArray=true;
						ElIndex=i;
						EndIndex=ListObjArray[i].Index;
					}
				}
				if (MaxIndex!=0)
				{
					for (i=MaxIndex-1;i<EndIndex;i++)
					{
						ListObjArray[i].Obj.className='TempletSelectItem';
						ListObjArray[i].Selected=true;
					}
				}
				else
				{
					if (ElIndex!=-1)
					{
						ListObjArray[ElIndex].Obj.className='TempletSelectItem';
						ListObjArray[ElIndex].Selected=true;
					}
				}
			}
		}
		else
		{
			for (i=0;i<ListObjArray.length;i++)
			{
				if (el==ListObjArray[i].Obj)
				{
					ListObjArray[i].Obj.className='TempletSelectItem';
					ListObjArray[i].Selected=true;
				}
				else
				{
					ListObjArray[i].Obj.className='TempletItem';
					ListObjArray[i].Selected=false;
				}
			}
		}
	}
	else
	{
		var elInSelectArray=false;
		for (i=0;i<ListObjArray.length;i++)
		{
			if (el==ListObjArray[i].Obj)
			{
				if (ListObjArray[i].Selected==true)
				{
					elInSelectArray=true;
				}
			}
		}
		if (!elInSelectArray)
		{
			for (i=0;i<ListObjArray.length;i++)
			{
				if (el==ListObjArray[i].Obj)
				{
					ListObjArray[i].Obj.className='TempletSelectItem';
					ListObjArray[i].Selected=true;
				}
				else
				{
					ListObjArray[i].Obj.className='TempletItem';
					ListObjArray[i].Selected=false;
				}
			}
		}
		GetID();
		var NewsFlag;
		NewsFlag=(NewsID!='')?1:0;   //选择了新闻----1  没有选择新闻----0
		if (NewsFlag==1) NewsFlag=(NewsID.indexOf(',')==-1)?2:NewsFlag;  //只选择了一个新闻----2
		switch (NewsFlag)
		{
			case 0:
				Edit.className='MenuItemDisable';
				Del.className='MenuItemDisable';
				Cut.className='MenuItemDisable';
				Copy.className='MenuItemDisable';
				if (parent.MoveOrCopySourceNews!='')
				{
					Paste.className='MouseRightItem';
				}
				else  Paste.className='MenuItemDisable';
				break;
			case 1:
				Edit.className='MenuItemDisable';
				Del.className='MouseRightItem';
				Cut.className='MouseRightItem';
				Copy.className='MouseRightItem';
				Paste.className='MenuItemDisable';
				break;
			case 2:
				if (JsType=='1') Edit.className='MouseRightItem';
				else Edit.className='MenuItemDisable';
				Del.className='MouseRightItem';
				Cut.className='MouseRightItem';
				Copy.className='MouseRightItem';
				Paste.className='MenuItemDisable';
				break;
			default:
			
		}
	}
}
function GetID()
{
	NewsID='';
	JsType='';
	for (i=0;i<ListObjArray.length;i++)
	{
		if (ListObjArray[i].Selected==true)
		{
			if (NewsID=='') NewsID=ListObjArray[i].Obj.NewsID;
			else NewsID=NewsID+','+ListObjArray[i].Obj.NewsID;
			if (JsType=='') JsType=ListObjArray[i].Obj.JsType;
			else JsType='2';
		}
	}
}
		
function CutOperation()
{
	parent.MoveTF=true;
	if (NewsID!='')
	{
		parent.MoveOrCopySourceClass=TempENameStr;
		parent.MoveOrCopySourceNews=NewsID;
	}
}

function CopyOperation()
{
	parent.MoveTF=false;
	if (NewsID!='')
	{
		parent.MoveOrCopySourceClass=TempENameStr;
		parent.MoveOrCopySourceNews=NewsID;
	}
}

function PasteOperation()
{
	var MoveOrCopyClassPara='MoveTF:'+parent.MoveTF+';SourceClass:'+parent.MoveOrCopySourceClass+';SourceNews:'+parent.MoveOrCopySourceNews+';ObjectClass:'+parent.MoveOrCopyObjectClass+';';
	OpenWindow('JsTip.asp?FileName=MoveOrCopyNews.asp&Title=移动或复制JS新闻&MoveOrCopyClassPara='+MoveOrCopyClassPara,300,105,window);
}
</script>
