teletype.wsc
来自「Windows Web脚本开发指南/(美) Dan Heflin, Todd N」· WSC 代码 · 共 185 行
WSC
185 行
<?XML version="1.0"?>
<?component error="true" debug="true"?>
<component >
<public>
<property name="Text">
<get/>
<put/>
</property>
<property name="Visible">
<get/>
<put/>
</property>
<property name="Rows">
<get/>
<put/>
</property>
<property name="FontSize">
<get/>
<put/>
</property>
<property name="IsRunning">
<get/>
</property>
<method name="StartTeletype">
</method>
<method name="StopTeletype">
</method>
<method name="FireTimer">
</method>
<event name="EndOfMessage"/>
</public>
<implements type="Behavior" id="Behavior">
<layout>
<![CDATA[
<div id="divTeletype"></div>
]]>
</layout>
<attach event="onmouseover" handler="MouseOver"/>
<attach event="onmouseout" handler="MouseOut"/>
</implements>
<script language="JavaScript">
<![CDATA[
var Text;
var Visible = true;
var Rows = 2;
var FontSize = 2;
var Timer = 0;
var LineLocation = 1;
var ArrayLocation = 0;
var TextLines;
var IsRunning = false;
var InHref = false;
var LastHTML
var WasRunning;
function get_Text(){
return Text;
}
function put_Text(newValue){
Text = newValue;
TextLines = Text.split("<BR>");
ArrayLocation = 0;
LineLocation = 1;
}
function get_Visible(){
return Visible;
}
function put_Visible(newValue){
if (newValue == true)
document.all.divTeletype.innerHTML = LastHTML;
else
document.all.divTeletype.innerHTML = "";
Visible = newValue;
}
function get_Rows(){
return Rows;
}
function put_Rows(newValue){
if (newValue < 1)
newValue = 1;
Rows = newValue;
}
function get_FontSize(){
return FontSize;
}
function put_FontSize(newValue){
if (FontSize == 4 && newValue == 3)
newValue = 2;
if (FontSize == 3 && newValue == 4)
newValue = 5;
if (newValue > 7)
newValue = 7;
else{
if (newValue < 2){
newValue = 2;
alert("Font size can not be decreased.");
}
}
FontSize = newValue;
}
function get_IsRunning(){
return IsRunning;
}
function StopTeletype(){
window.clearInterval(Timer);
IsRunning = false;
Timer = 0;
}
function StartTeletype(){
if (Timer == 0)
Timer = window.setInterval(this.id + ".FireTimer()", 250, "javascript");
IsRunning = true;
}
function FireTimer(){
var sTemp = "";
var iStart;
var iCount;
var sCurrentLine;
var iEndOfTag;
var sTemp;
sCurrentLine = TextLines[ArrayLocation];
LineLocation++;
if (LineLocation > sCurrentLine.length){
LineLocation = 1;
ArrayLocation++;
if (ArrayLocation > TextLines.length - 1 ){
ArrayLocation = 0;
fireEvent("EndOfMessage");
if (IsRunning == false)
return;
}
sCurrentLine = TextLines[ArrayLocation];
}
if (sCurrentLine.substr(LineLocation, 1) == "<"){
iEndOfTag = sCurrentLine.indexOf(">", LineLocation);
if (iEndOfTag == -1){
return;
// end;
// Err.Raise 10001, "Missing > in current line:" + sCurrentLine;
}
sTemp = sCurrentLine.toUpperCase();
if (sTemp.indexOf("A HREF=", LineLocation) != -1)
InHref = true;
else{
if (sTemp.indexOf("/A", LineLocation) != -1)
InHref = false;
}
LineLocation = iEndOfTag;
sTemp = "";
}
if (Visible == true){
iStart = ArrayLocation - Rows + 1;
if (iStart < 0){
for (iCount = 1; iCount <= Math.abs(iStart); iCount++){
sTemp = sTemp + "<FONT face=Courier size=" + FontSize + "><BR></FONT>";
}
iStart = 0;
}
for (iCount = iStart; iCount <= ArrayLocation - 1; iCount++){
sTemp = sTemp + "<FONT face=Courier size=" + FontSize + ">" + TextLines[iCount] + "</FONT><BR>";
}
if (InHref == true)
sTemp = sTemp + "<FONT face=Courier New size=" + FontSize + ">" + sCurrentLine.substr(0, LineLocation) + "</A></FONT><BR>";
else{
sTemp = sTemp + "<FONT face=Courier New size=" + FontSize + ">" + sCurrentLine.substr(0, LineLocation) + "</FONT><BR>";
}
}
else
sTemp = "";
document.all.divTeletype.innerHTML = sTemp;
LastHTML = sTemp;
}
function MouseOver(){
WasRunning = this.IsRunning;
this.StopTeletype();
}
function MouseOut(){
if (WasRunning == true){
this.StartTeletype();
}
}
]]>
</script>
</component>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?