首页 > 编程语言 >阅读txt程序

阅读txt程序

时间:2023-04-28 22:33:44浏览次数:30  
标签:function obj 程序 else Bindex 阅读 var txt fn


<html>
<head>
<HTA:APPLICATION ID="oHTA"
    APPLICATIONNAME="myApp"
    WINDOWSTATE = ""
    MAXIMIZEBUTTON="no"
    border="thin"
    borderStyle="static"
   >
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>读书程序</title> 
<style>
a {
      text-decoration : none;
      color: white;
  }
table
{
  border-collapse:collapse;
  border-spacing:0px;
}td
{
   color:white;
   border: 0px solid red;
   width:20px;
   height:20px;
   text-align:center;
}body
{
   cursor:default;
}
</style>
</head>
<body scroll=no topmargin=0 leftmargin=20 rightmargin=0 bottommargin=0 οnkeypress="checkkey()" bgcolor="black"><a href=# οnclick="clearscroll();" title="停止滚屏" style="position:absolute; left:-5px; top:-4px; font-family:'Webdings';font-size:30px;">v</a>
<a href=# οnclick="setscroll(1);" title="增加滚屏速度" style="position:absolute; left:-5px; top:30px;font-family:'Webdings';font-size:29px;">f</a>
<span id=scrolltime style="position:absolute; left:352px; top:0px; layout-flow: vertical-ideographic; color:red; text-align:left;word-break :keep-all; word-wrap : normal;" title="离换页的秒数"></span>
<a href=# οnclick="scrollpage(0);" title="上页" style="position:absolute; left:-5px; top:87px;font-family:'Webdings';font-size:30px;">5</a>
<a href=# οnclick="scrollpage(1)" title="下页" style="position:absolute; left:-5px; top:110px;font-family:'Webdings'; font-size:30px;">6</a>
<input id=filepath type=file style="display:none;" οnchange="if(this.value != ''){openfile(this.value,0); this.outerHTML = newinput;}">
<a href=# οnclick="filepath.click();" title="打开新的小说" style="position:absolute; left:-1px;top:145px; font-size:17px; font-family:'Wingdings';">&</a><a href=# οnclick="delfile()" title="删除当前文件" style="position:absolute; left:-2px; top:170px; font-family:'Wingdings'; font-size:33px;">N</a>
<a href=# οnclick="showconfig()" title="隐/显文字观看区设置" style="position:absolute; left:-1px;top:210px; font-family:'Webdings'; font-size:21px;">@</a>
<a href=# οnclick="showbookmark()" title="书签" style="position:absolute; left:-1px;top:240px; font-family:'Webdings'; font-size:21px;">N</a>
<div id=config style="position:absolute; left:22px; top:25px; display:none; background:black; color:white; border:1px solid red; width:323px; height:420px; overflow-y:auto;" οnclick="fix(event.srcElement)">
<input type=checkbox value1="fontWeight" value="bold">粗体<br>
<input type=checkbox value1="fontStyle" value="italic">斜体<br>
--------------------------------------<BR>
<input name="family" type=radio value1="fontFamily" value="宋体">宋体<br>
<input name="family" type=radio value1="fontFamily" value="华文仿宋">华文仿宋<br>
<input name="family" type=radio value1="fontFamily" value="华文彩云">华文彩云<br>
<input name="family" type=radio value1="fontFamily" value="黑体">黑体</option><br>
<input name="family" type=radio value1="fontFamily" value="仿宋_GB2312">仿宋_GB2312<br>
<input name="family" type=radio value1="fontFamily" value="方正姚体">方正姚体<br>
<input name="family" type=radio value1="fontFamily" value="方正舒体">方正舒体<br>
<input name="family" type=radio value1="fontFamily" value="华文琥珀">华文琥珀<br>
<input name="family" type=radio value1="fontFamily" value="华文楷体">华文楷体<br>
<input name="family" type=radio value1="fontFamily" value="华文隶书">华文隶书<br>
<input name="family" type=radio value1="fontFamily" value="华文宋体">华文宋体<br>
<input name="family" type=radio value1="fontFamily" value="华文细黑" checked>华文细黑<br>
<input name="family" type=radio value1="fontFamily" value="华文新魏">华文新魏<br>
<input name="family" type=radio value1="fontFamily" value="华文行楷">华文行楷<br>
<input name="family" type=radio value1="fontFamily" value="华文中宋">华文中宋<br>
<input name="family" type=radio value1="fontFamily" value="楷体_GB2312">楷体_GB2312<br>
<input name="family" type=radio value1="fontFamily" value="隶书">隶书<br>
<input name="family" type=radio value1="fontFamily" value="微软雅黑">微软雅黑<br>
<input name="family" type=radio value1="fontFamily" value="新宋体">新宋体<br>
<input name="family" type=radio value1="fontFamily" value="幼圆">幼圆<BR>
--------------------------------------<BR>
</div>
<div id=bookmarkdiv style="position:absolute; left:22px; top:25px; display:none; background:black; color:white; border:1px solid red; width:323px; height:420px; overflow-y:auto;" οnclick="openbookmark(event.srcElement)" οncοntextmenu="delbookmark(event.srcElement);return false;" title="左键点击打开
右键点击删除"></div>

<div id=txt title="按钮说明:
没光汽车->停止自动换页;
发光汽车->设置自动换页秒数;
空白->提示离换页秒数;
正三角->上一页;
倒三角->下一页;
打开的书->打开新的小说;
死人头->删除现在打开的文件;
铁钳和铁锤->文字观看区设置;
眼睛->书签(保存了观看某小说的进度);

style="width:100%; height:100%; overflow-y:hidden; overflow-x:visible; word-wrap:break-word; line-height:16px; font-size:16px; fontFamily:华文细黑; border:1px solid orange; color:white;" chlen="500">
</div></body>
</html><script>
var htaPath = document.URL.replace("file://","").replace(/[][^]+$/g,"") + "/";//程序路径
var bookmark = "bookmark.txt";//书签文件名
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fn = null; //打开的文章的句柄
var Bindex = 0; //可见的字节定位
var scrollV = 40; //滚屏速度
var scrollv = 0; //滚屏速度复制
var scrollT = 0 ; //滚动定时句柄
var scrollS = null ; //自动滚屏倒计时句柄
var nowfile = ""; //使用中的路径
var newinput = "<input id=filepath type=file style=/"display:none;/" οnchange=/"if(this.value != ''){openfile(this.value,0); this.outerHTML = newinput;}/">"; //file input html码
var cols = 17;
var rows = 22;function setscroll(how)
{
         if(fn == null)
         {
             return alert("未载入文件");
         }         var newV = parseInt( prompt("一页为500个全角字节,默认60秒换一页(输入[正整数]之外的值无效,到尾页会自动停止).",scrollV) ); 
         
         if( isNaN(newV) || (newV < 1) ) 
         {
             return false;
         }
        
        scrollV = newV;
        clearscroll();
        
        scrollv = scrollV;
        var time = 1000;
        scrollT = setInterval("autoscroll()",time ); 
         
}function autoscroll()
{
    scrolltime.innerText = --scrollv + "秒";
    if(scrollv < 1)
    {
        scrollv = scrollV;
        scrollpage(1,1);
    }
}function clearscroll()
{
      clearInterval(scrollT);
      scrolltime.innerText = "";
}function scrollpage(how,auto)
{
    if(fn == null)
    {
        return alert("未载入任何文件");
    }    if(how == 0)
    {
      if( Bindex > 500 )
      {
             fn = fso.openTextFile(nowfile,1,false);
             
             var LN = Bindex % 500;             if( LN > 0 )
             {
               Bindex = Bindex - LN;
               fn.skip(Bindex - 500);
             }else
              {
               Bindex = Bindex - 500;
               fn.skip(Bindex - 500);
              }
       }else
        {    
           return alert("已是首页");
        }
    }else if(how == 1)
     {
        if(fn.atendofstream)
        {
            if(auto)
           {
               clearscroll();
           }           return alert("已是最后一页");
        }
     }
     
        txt2div();
        scrollv = scrollV;
}function openfile(path,index)
{
       if(!fso.fileExists(path))
       {
           return alert("无法载入,文件不存在");
       }       clearscroll();
       fn = fso.openTextFile(path, 1, false);
       txt.value = "";       if(index > 0)
       {
          fn.skip(Bindex = index * 1);
       }else
        {
           Bindex = 0;
        }       nowfile = path;
       document.title = fso.getFileName(path);
}function addbookmark(auto)
{   if (nowfile == "")
   {    if(!auto)
    {
         return alert("未打开任何文章!");
    }
     
      return false;
    }   
   var found = -1;
   var bookmarks = bookmarkdiv.children;   for(var index = 0; bookmarks.length > index; index++)
   {
     if( (bookmarks[index].tagName == "A") && (bookmarks[index].path.indexOf(document.title) > 0) )
     { 
         found = index;
         break;
     }
   }   if( found == -1 )
   {
     bookmarkdiv.insertAdjacentHTML("beforeEnd", '<a href="#" path="' + nowfile + '" findex="' + Bindex + '"><font style="font-size:17px; font-family:/'Wingdings/';">&</font>' + document.title + '<br></a>');
   }else if(confirm("此文章的进度已存在,是否要替换?"))
   {
     bookmarks[found].outerHTML = '<a href="#" path="' + nowfile + '" findex="' + Bindex + '"><font style="font-size:17px; font-family:/'Wingdings/';">&</font>' + document.title + '<br></a>';
   }
  
}function openbookmark(obj)
{
   if( (obj.tagName == "A") && confirm("确定要打开/n/n " + obj.path))
   {
         openfile(obj.path, obj.findex);
   }    
}function delbookmark(obj)
{
     if((obj.tagName == "A") && confirm("删除下面的标签?/n/n" + obj.innerText))
     {
      obj.outerHTML = "";
     }
}function loadbookmark()
{
  bookmarkdiv.innerHTML =  '<input type=button title="保存观看进度" οnclick="addbookmark()" value="点此保存当前观看的小说进度" style="width:100%;">';
}function window.onload()
{
  window.resizeTo(354,478);
  document.title = (location.href);  txt.value = "";
  var text = "";  try{
      if (fso.fileExists(htaPath + bookmark))
     {
         var bm = fso.opentextfile(htaPath + bookmark,1,false,true);    
         text = bm.readall();
     }
    }catch(e){}   try{
      bm.close();
    }catch(e){}    if( text.indexOf("<A") > -1 )
    {
        bookmarkdiv.innerHTML = text;
    }else
     {
       loadbookmark(); 
     }
} 
function window.onbeforeunload()
{
  addbookmark(1);
  var bm = fso.OpenTextFile(htaPath + bookmark, 2, true,true);
  bm.write(bookmarkdiv.innerHTML);
  bm.close();
}function checkkey()
{
  var E = event;
  var keycode = E.keyCode;  switch(keycode)
  {
      case 32:
            scrollpage(1);
            break;
      default:
            //alert(keycode);
  }
} 
function delfile()
{
     if((nowfile != "") && confirm("删除当前观看中的文件?"))
     {
      try
      {
         Bindex = 0; //可见的字节定位
         clearscroll();
         fn.close();
         fn = null;
         fso.deleteFile(nowfile,true);
         nowfile = "";
         txt.value = "";
         document.title = "读书程序";
         alert("文件已删除");
      }catch(e){alert(e.descripton);}
     }
}function showconfig(n)
{
    if(config.style.display == "none")
    {
       config.style.display = "";
       bookmarkdiv.style.display = "none";
    }else
     {
       config.style.display = "none";
    }     
}function fix(obj)
{
    if(obj.tagName == "INPUT")
    {
      if(obj.checked)
      {
        eval("txt.style." + obj.value1 + " = '" + obj.value + "'");
      }else
       {
         eval("txt.style." + obj.value1 + " = ''; ");
       }
    }
}function showbookmark()
{
    if(bookmarkdiv.style.display == "none")
    {
      bookmarkdiv.style.display = "";
      config.style.display = "none";
    }else
     {
       bookmarkdiv.style.display = "none";
    }  
}function txt2div()
{
     var tableH = "<table>";
     for (var readt,forI = 0; forI < rows; forI++)
     {
        tableH += "<tr>";
        for (var forII = 0; forII < cols; forII ++)
        {
           //document.title = forII + " " + forI
           if (fn.AtEndOfStream)
           {
             readt = " ";
           }else 
            {
              readt = fn.read(1);
            }
           Bindex++;
           if (readt == "/n")
           {
              while (forII < cols)
              {
                tableH += "<TD> </td>";
                forII++;
              }
           }else if(readt.toString().replace(//s/g,"") != "")
            {              
              tableH += "<TD>" + readt + "</td>"
            }else
             {
               tableH += "<TD> </td>";
             }
        }
      
        tableH += "</tr>";
     }
     
     txt.innerHTML = tableH + "</table>";
}
</script>

标签:function,obj,程序,else,Bindex,阅读,var,txt,fn
From: https://blog.51cto.com/u_252283/6235721

相关文章

  • 百炼成仙阅读笔记
    第二章字符串只要不为空,就代表真,否则代表假。数字只要不为0,就代表真,否则就是假split("")把字符串分开为数组toString().lengthstr.indexOf("")搜索返回位置replace("a","A")第三章jQuery基础css选择器5种:标签(div)、ID(#a)、类class(.a)、群组(.a,.b,.c)、后代(.a.b)<in......
  • 构建之法 阅读笔记04
    第十一章软件设计与实现11.2图形建模和分析方法思维导图、实体关系图、UseCaseDiagram11.3其他设计方法形式化的方法、文学化编程11.5开发阶段的日常管理第十二章用户体验12.1用户体验的要素用户的第一印象从用户的角度考虑问题软件服务始终都要记住用户的选择(......
  • 《代码大全2》阅读笔记01
    在我的软件开发经历中,我曾经遇到过编写代码时犯的一些错误,而这些错误在《代码大全2》这本书中都有提到。其中一个问题是过度地注释代码。我过去常常使用很多注释,认为它们可以帮助我自己和其他人更好地理解代码。但是,在阅读这本书之后,我了解到这种做法可能会带来一些负面影响,并会......
  • VC下Base64编码及解码程序源代码
    //Base64.h:interfacefortheCBase64class.////#if!defined(AFX_BASE64_H__8D85F486_CD10_4A0A_A689_2299C9DE52CB__INCLUDED_)#defineAFX_BASE64_H__8D85F486_CD10_4A0A_A689_2299C9DE52CB__INCLUDED_#if_MSC_VER>1000#pragmaonce#endif//_MSC_V......
  • VS2010创建Webservice程序
    VisualStudio2010中已经找不到直接创建WebService的模板方式了,但下面的方法可心实现:  在VisualStudio2010的新建Web应用程序或者Web网站窗口中,如果你选择.NET4.0,会发现缺少了ASP.NETWebServices模板。你可能会怀疑VS2010是不是不支持ASP.NETWebServices......
  • 阅读文献《DCRNet:Dilated Convolution based CSI Feedback Compression for Massive M
    这篇文章的作者是广州大学的范立生老师和他的学生汤舜璞,于2022年10月发表在IEEETRANSACTIONSONVEHICULARTECHNOLOGY。文献提出了一种基于空洞卷积(DilatedConvolution)的CSI反馈网络,即空洞信道重建网络(DilatedChannelReconstructionNetwork,DCRNet)。还设计了编码器和解......
  • 程序员跳槽动机被误读,薪资只是表象
    每每看科技或者财经类的新闻访谈节目,就会发现,无论那些来自IT的高管们如何侃侃而谈,他们的共同话题只有一个,那就是人才。当他们中的许多在千方百计招人、留人同时又小心提防竞争对手挖角的时候,却非常可悲地发现他们手中的人才越来越少,因为他们并不了解程序员的性格、想法和需求,不能......
  • Java程序性能优化
    一、避免在循环条件中使用复杂表达式在不做编译优化的情况下,在循环中,循环条件会被反复计算,如果不使用复杂表达式,而使循环条件值不变的话,程序将会运行的更快。例子:importjava.util.Vector;classCEL{voidmethod(Vectorvector){for(inti=0;i<vector.si......
  • access 查询报“提供程序无法确定 Object 值.例如,该行刚刚创建,未提供 Object 列的默
    access查询报“提供程序无法确定Object值.例如,该行刚刚创建,未提供Object列的默认值,并且”System.InvalidOperationException:TheprovidercouldnotdeterminetheObjectvalue.Forexample,therowwasjustcreated,thedefaultfortheObjectcolumnwasnota......
  • 《程序员修炼之道:从小工到专家》阅读笔记十
    二十九它只是个视图不要将程序写成一个大块,而应该“分而治之”,把程序划分成模块。模块或类的一个好的定义:具有单一的,定义良好的责任。发布和订阅当我们对某个publisher生成的特定事件感兴趣,我们能做的是登记自己。publisher追踪Subscriber对象,publisher生成事......