📄 news.htc
字号:
<!--///////////////////////////////////////////////////////////////////////
// Module Name: news ///////////////////////////////////////////////////
// Author: hzh ///////////////////////////////////////////////////
// Date: 2005-07-07 ///////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////-->
<public:component name="news" urn="news" lightweight="true">
<public:property name="xmlSource" get="getDataXML" put="putDataXML" />
<public:property name="left" put="putLeft" />
<public:property name="top" put="putTop" />
<public:property name="width" put="putWidth" />
<public:property name="height" put="putHeight" />
<public:property name="newStyle" put="putNewsStyle" />
<public:property name="init" put="initialize"/>
<script language="JavaScript">
var objXMLDoc = null;
var objContainersDiv = null;
var objTempDiv = null;
var objNewsItemList = null;
var strMultiNews = "";
var vLeft = 0;
var vTop = 0;
var vWidth = 180;
var vHeight = 20;
var vStyle = 1;// 1 - 横向滚动 2 - 纵向滚动
/////////单行新闻显示//////////////
var delay = 3000;
var fcontent = new Array()
var begintag = '<font>';
var closetag = '</font>';
var faderdelay = 0;
var index = 0;
var frame = 20;
var hex = 255;
var faderdelay = 2000;
function colorfade(){
if(frame > 0) {
hex-= 12;
objContainersDiv.style.color = "rgb(" + hex + "," + hex + "," + hex + ")";
frame--;
setTimeout(colorfade,20);
}else{
objContainersDiv.style.color = "rgb(0,0,0)";
frame = 20;
hex = 255
}
}
function changecontent(){
if(!objNewsItemList) return;
if (index >= objNewsItemList.length) index = 0;
objContainersDiv.style.color = "rgb(255,255,255)";
objContainersDiv.innerHTML = begintag + objNewsItemList[index].getAttribute("caption") + closetag;
colorfade();
index ++;
setTimeout(changecontent, delay + faderdelay);
}
///////单行滚动新闻结束///////////////////////////////////////////
////垂直滚动新闻//////////////////////////////////////////////////////
var stopscroll = false; //这个变量控制是否停止滚动
function scrollUp(){
preTop = 0;
if(stopscroll == true) return;
preTop = objContainersDiv.scrollTop;
objContainersDiv.scrollTop += 1;
if(preTop == objContainersDiv.scrollTop){
objContainersDiv.scrollTop = objTempDiv.offsetHeight - vHeight + 1;
}
}
////////////////////////////////////////////////////////////////////////////
function initialize(){
objContainersDiv = element.document.createElement("<div class='__hzh_news_containers'>");
objContainersDiv = element.appendChild(objContainersDiv);
objTempDiv = element.document.createElement("<div class='__hzh_news_tempDiv'>");
objTempDiv = element.appendChild(objTempDiv);
objTempDiv.style.visibility = "hidden";
refresh();
var vXSLT = '<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/><xsl:template match="/"><table border="0" cellpadding="2" cellspacing="1" bgcolor="#ffffff"><xsl:apply-templates select="root"/></table></xsl:template><xsl:template match="root"> <xsl:for-each select="r"><tr bgcolor="#ffffff"><td><xsl:value-of select="@caption"/></td></tr></xsl:for-each></xsl:template></xsl:stylesheet>';
if( vStyle == 1 ){
objNewsItemList = objXMLDoc.selectNodes("//r");
}else{
strMultiNews = window.parent.__objGlobalCommonInst.transformXML(objXMLDoc,vXSLT);
}
if(vStyle == 1){//水平滚动
changecontent();
}else if(vStyle == 2){//垂直滚动
if(strMultiNews==""){
objContainersDiv.innerText = "新闻读取失败";
return;
}
objContainersDiv.innerHTML = strMultiNews;
with(objContainersDiv){
noWrap = true;
style.width = 0;
style.height = vHeight;
style.overflowY = "hidden";
style.cursor = "hand";
onmouseover = new Function("stopscroll=true");
onmouseout = new Function("stopscroll=false");
}
while(objTempDiv.offsetHeight< vHeight){
objTempDiv.innerHTML += objContainersDiv.innerHTML;
}
objContainersDiv.innerHTML = objTempDiv.innerHTML + objTempDiv.innerHTML;
setInterval(scrollUp,50);
}
}
function refresh(){
with(element.style){
left = vLeft;
top = vTop;
width = vWidth;
height = vHeight;
}
with(objContainersDiv.style){
left = vLeft;
top = vTop;
width = vWidth;
height = vHeight;
paddingLeft = 3;
paddingTop = 3;
}
}
/////////////////////////////////////////
function putDataXML(argXMLSource){
objXMLDoc = window.parent.__objGlobalCommonInst.inputXML(argXMLSource);
if(!objXMLDoc) return;
}
function putLeft(argLeft){// news Left
vLeft = isNaN(parseInt(argLeft)) ? vLeft : parseInt(argLeft);
}
function putTop(argTop){// news Top
vTop = isNaN(parseInt(argTop)) ? vTop : parseInt(argTop);
}
function putWidth(argWidth){// news Width
vWidth = isNaN(parseInt(argWidth)) ? vWidth : parseInt(argWidth);
}
function putNewsStyle(argStyle){//
vStyle = isNaN(parseInt(argStyle)) ? 1 : parseInt(argStyle);;
}
function putHeight(argHeight){// news Height
vHeight = isNaN(parseInt(argHeight)) ? 20 : parseInt(argHeight);
}
</script>
</public:component>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -