javascript 模拟Dreamweaver开发的纯文本查询器

来源:互联网 发布:windows安全中心闪退 编辑:程序博客网 时间:2024/05/17 13:10

模拟Dreamweaver开发的纯文本查询器,

结合:  javascript,Dom,正则表达式,层等研制开发

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"
>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>QUERY INFO</title>

<script language="javascript">
 

 
function  GetAimInfo(a,b,c,d,selAnd,chkSub)     
 
{  
  
var temp = "";
  
//--------------
  if(d == ""){
   alert(
"please put in the routine of the file");
   
return false;
  }

  
  
if(a == "" && b== "" && c == ""){
   alert(
"please put the finding  character in");
   
return false;
  }

  
if(a == ""){
   a 
= "###";
  }

  
if(b == ""){
   b 
= "###";
  }

  
if(c == ""){
   c 
= "###";
  }

  
//-------------------------
  var query;
  
var strProcss=a;
  
var strEmail=b;
  
var strOther =c; 
  
var theCount= 0;
  
var theOldNumb = 0;
  
var sLine="";
  
var fso,f,r   
  
var ForReading = 1,ForWriting = 2;  
  
//-------------------------
  try
  

   fso   
=   new   ActiveXObject("Scripting.FileSystemObject"
   f   
=   fso.OpenTextFile(d,   ForReading);  
  }

  
catch(e)
  
{
   alert(
"the file of the  routine is not exist,please put in once more!");
   
return false;
  }

  
//----------------------------------------------
      temp = "<html><title>Find the data</title><body>";
   temp 
+= "<table width='100%' border='1'  cellpadding='0' cellspacing='0' bordercolorlight='#6699ff' bordercolordark='#6699ff' >";
   temp 
+= "<tr class='th' ><td >Number</td><td align = 'center'>  ----------- The content of the finding ----------- </td><td>oldNum</td></tr>"
  
while (sLine != null)
  

    
   
try
   
{
    sLine 
= f.ReadLine();    

    
if (sLine != null)
    

     theOldNumb 
= theOldNumb + 1;     
     
//无论大小写,只要有,就为 true
     var boolProcess = (sLine.indexOf(strProcss)>0 || sLine.indexOf(strProcss.toLowerCase())>0  || sLine.indexOf(strProcss.toUpperCase())>0);
     
var boolEmail   = (sLine.indexOf(strEmail) >0 || sLine.indexOf(strEmail.toLowerCase()) > 0 || sLine.indexOf(strEmail.toUpperCase())>0);
     
var boolOther = (sLine.indexOf(strOther) >0 || sLine.indexOf(strOther.toLowerCase()) >0  ||sLine.indexOf(strOther.toUpperCase()) >0);
     
     
if(selAnd == "And")
     
{
      
if(strProcss == "###")
       query 
= boolEmail && boolOther;
      
else if(strEmail == "###")
       query 
= boolProcess && boolOther;
      
else if(strOther == "###")
       query 
= boolProcess && boolEmail;
      
else
       query 
= boolProcess && boolEmail && boolOther; 
     }

     
else
     
{ query = boolProcess || boolEmail || boolOther; }
     
     
     
if(sLine.indexOf(strProcss.toLowerCase())>0)
     
{//在一定的条件下 把[子进程号]包含当作条件
      var theLeft = sLine.indexOf("("+ 1;
      
var theRirgh = sLine.indexOf(")");
      
var subString = sLine.substring(theLeft,theRirgh);
      
      
if(subString.toLowerCase() == strProcss.toLowerCase() || subString == "00000000")
      
{ }
      
else
      
{ subString = sLine.substring(theLeft,theRirgh); }
     }

     
     
if(chkSub.checked) //如果子进程复选框选中的话,条件中加入。。。
     {
      query 
= query || sLine.indexOf(subString)>0;    
     }

     
if(query)
     
{//查看有没有要查找信息
      theCount = theCount + 1;
      temp 
+= "<tr onmouseover="this.bgColor='#C4DFF7'" onmouseout="this.bgColor='#ffffff'">" ;
      temp 
+= "<td>" + theCount + "</td>";      
      temp 
+= "<td>" +  sLine + "</td>";
      temp 
+= "<td>" + theOldNumb + "</td>"
      temp 
+= "</tr>";
     }

    }

   }

   
catch(e)
   
{
    
break;
   }

  }

  
  temp 
+="<tr><td colspan='3'>总计: " + theCount + " 条</td></tr>";
  temp 
+= "</table>"
  temp 
+= "</body></html>";
  
if(theCount == 1 || theCount == 0)
  
{
   alert(
"no record");
   
return;
  }

  temp 
= ReplaceStr2(temp,"TO: <","TO: ");  
  temp 
= ReplaceStr2(temp,"TO:<","TO: ");
  temp 
= ReplaceStr2(temp,"to: <","TO: ");
  temp 
= ReplaceStr2(temp,"to:<","TO: ");
  temp 
= ReplaceStr2(temp,"To:<","TO: ");
  
  temp 
= ReplaceStr2(temp,"FROM: <","FROM: ");
  temp 
= ReplaceStr2(temp,"FROM:<","FROM: ");
  temp 
= ReplaceStr2(temp,"from:<","from: ");
  temp 
= ReplaceStr2(temp,"from: <","from: ");

  temp 
= ReplaceStr(temp,strProcss,"#ff0000");
  temp 
= ReplaceStr(temp,strProcss.toLowerCase(),"#ff0000");
  temp 
= ReplaceStr(temp,strProcss.toUpperCase(),"#ff0000");
  
//email
  temp = ReplaceStr(temp,strEmail,"#0000ff");
  temp 
= ReplaceStr(temp,strEmail.toLowerCase(),"#0000ff");
  temp 
= ReplaceStr(temp,strEmail.toUpperCase(),"#0000ff");
  
//other
  temp = ReplaceStr(temp,strOther,"#007744");
  temp 
= ReplaceStr(temp,strOther.toLowerCase(),"#007744");
  temp 
= ReplaceStr(temp,strOther.toUpperCase(),"#007744");
  

 
//---------------------------------------------
  document.all.show.innerHTML = temp;
   
//---------------------------------------------
 }
  
 
 
/*
 输入的原来字符串
 要替换的
 目标字符
 
*/

 
function ReplaceStr(inputStr,oldStr,colorStr)
 
{
  
var strReturn;
  
if(oldStr == "")
   
return;
  re 
= new RegExp(oldStr,"g");
  
var newStr = "<strong><font color = '" + colorStr + "'><u>" + oldStr +"</u></font></strong>";
  strReturn 
= inputStr.replace(re,newStr);
  
return strReturn;
 }

 
 
function ReplaceStr2(inputStr,oldStr,newStr)
 
{
  
var strReturn;
  
if(oldStr == "")
   
return;
  re 
= new RegExp(oldStr,"g");
  strReturn 
= inputStr.replace(re,newStr);
  
return strReturn;
 }

 
 
function chkAddFun(a,b)
 
{
  
if(a.checked)
  
{
   b.style.background 
= "#CCCCCC";
   b.disabled 
= 1;
  }

  
else
  
{
   b.style.background 
= "#FFFFFF";
   b.disabled 
= 0;
  }

 }

 
 
function selAddFun(a,b)
 
{
 
/*
  if(a == "#FFFFFF")
  {
   b.disabled = 0;
   b.style.background = a;
  }
  else
  {
   b.disabled = 1;
   b.style.background = a;
  }
 
*/

 }

</script>
<link href="CSS/styles.css" rel="stylesheet" type="text/css">
<link href="CSS/color.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 
{color: #C3CDDE}
-->
</style>
</head>
<body id="bodyNode" class="bodyTop">

<form name="form1" method="post" action="showInfo.asp">
<table width="100%" border="1" bordercolorlight="#6699ff" bordercolordark="#6699ff"  cellpadding="0" cellspacing="0" class="BlueBoldfont" >
 
<tr>
  
<td>
   
<div align="center">[QUERY INFO]</div>
  
</td>
 
</tr>
 
<tr>
  
<td>
   
<div align="center">File path:<input  type="file" name="txtPath" ></div>
  
</td>
 
</tr>
 
<tr>
  
<td>   
   
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    
<tr>
     
<td width="8%"><div align="right">Course:</div></td>
     
<td width="21%">
      
<input name="txtProcess" type="text" id="txtProcess" size="18">
      
<input name="chkSub" id="chkSub" type="checkbox" value="">sub
     
</td>
     
<td width="8%"><div align="right">Email: </div></td>
     
<td width="21%"><input name="txtEmail" type="text" id="txtEmail2" size="18"></td>
     
<td width="6%"><div align="right">Other:</div></td>
     
<td><input name="txtOther"  type="text" id="txtOther2" size="18"></td>
     
<td>
      
<div align="left">
      Mode:
      
<select name="selAnd" onChange="selAddFun(this.form.selAnd.value,this.form.txtOther)">
       
<option value="#FFFFFF" selected>Or</option>
       
<option value="#CCCCCC">And</option>      
      
</select>
      
</div>
     
</td>
     
<td>&nbsp;</td>
     
<td width="8%"><input type="button" name="Submit"   class="btn_mouseout" value="Query" onClick = "GetAimInfo(this.form.txtProcess.value,this.form.txtEmail.value,this.form.txtOther.value,this.form.txtPath.value,this.form.selAnd.options[selAnd.selectedIndex].text,this.form.chkSub)"></td>
    
</tr>
   
</table>
  
</td>
 
</tr>
 
</tr>
</table>
<br>
 
<div class="BlueBoldfont">
   
<div align="left">『EXPLAINS』: When data quantity big,Possibly must wait a bit about for 30 seconds. Best uses the IE browser.</div>
 
</div>
 
<div id="show" style="display:block;"></div>
</form>
</body>
</html>


Css样式表

body {
    background-image
: url("IMAGES/images_content/01.gif");
    background-repeat
:no-repeat;
    FONT-FAMILY
: Arial, Helvetica, sans-serif;
    FONT-SIZE
: 12px;
    text-decoration
: none;
    color
:#000000;
    BACKGROUND-COLOR
:#FFFFFF;
    line-height
: 20px;
    SCROLLBAR-ARROW-COLOR
: black;
    SCROLLBAR-FACE-COLOR
: #ffffff;
    SCROLLBAR-HIGHLIGHT-COLOR
: #acacac;
    SCROLLBAR-SHADOW-COLOR
: #acacac;
    SCROLLBAR-3DLIGHT-COLOR
: #ffffff;
    SCROLLBAR-TRACK-COLOR
: #f8f8f8;
    SCROLLBAR-DARKSHADOW-COLOR
: #ffffff;
    border-top-style
: none;
    border-bottom-style
: none;
    background-attachment
: fixed;
    border-right-style
: none;
    border-left-style
: none;
    margin-right
: 5px;
    margin-left
: 5px;
    margin-bottom
: 5px;
    margin-top
: 5px;
    overflow
:auto;
    
    
}

input
{
    height
:18px
}

.imageBack
{
    background-image
: url("../IMAGES/images_content/01.gif");
    line-height
: 150%;
}


.BlueBoldfont
{
    font-size
: 12px;
    color
: #003366;
    font-weight
:bold;
}

.BrownBoldfont
{
    font-size
: 12px;
    color
:#993300;
    font-weight
:bold;
}

.BlackBoldfont
{
    font-size
: 12px;
    color
:#000000;
    font-weight
:bold;
}


.bodyTop
{
    overflow
: visible;
}

{
    font-size
: 12px;
    text-align
: left;
}

table
{
    border-collapse
: collapse;
    margin
: 0px;
    padding
: 0px;
    border
: 0;
}

.tbShow
{
    border-collapse
: collapse;
    padding
: 0px;
    cellpadding
:0px;
    cellspacing
:1px;
    border-collapse
:collapse;
    border
: #6699ff;
    width
: 100%;
}

.th 
{
 FILTER
:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#FFFFFF, EndColorStr=#4898DB); 
    font-size
: 12px;
    text-align
: center;
    white-space
: pre;
    font-weight
: normal;
    color
:  
    line-height: 200%
;
}

.thCalender 
{
    background-color
:#007db5;
    font-size
: 16px;
    text-align
: center;
    white-space
: pre;
    font-weight
: normal;
    color
: #FFFFFF;
    line-height
: 200%;
}

.tdCalender 
{
    border-color
:#6699ff;
    white-space
: pre;
    font-size
: 16px;
    text-align
: center;
    white-space
: pre;
    font-weight
: normal;
    line-height
: 200%;
}

.td 
{
    border-color
:#6699ff;
    white-space
: pre;
}

.total 
{
    white-space
: pre;
    background-color
: bccbe0;
}

.tdHigh 
{
    border-color
:#6699ff;
    white-space
: pre;
    padding-top
: 5px;
    padding-bottom
: 5px;
}

td 
{
    font-size
: 12px;
    padding-left
: 2px;
}

.tbTitle 
{
    text-align
: right;
}

.number 
{
    text-align
: right;
}

form
{
    text-align
: center;
}

textarea 
{
    BACKGROUND-COLOR
: #ffffff;
    color
:#000000;
    background-image
: none;
    BORDER-BOTTOM
: #006cb5 1px solid;
    BORDER-LEFT
: #006cb5 1px solid;
    BORDER-RIGHT
: #006cb5 1px solid;
    BORDER-TOP
:#006cb5 1px solid;
    cursor
: hand;
    font-size
: 12px;
}

.myInput
{
    BACKGROUND-COLOR
: #fffff1;
    color
:#000000;
    background-image
: 01.gif;
    BORDER-BOTTOM
: #006cb5 1px solid;
    BORDER-LEFT
: #006cb5 1px solid;
    BORDER-RIGHT
: #006cb5 1px solid;
    BORDER-TOP
:#006cb5 1px solid;
    HEIGHT
: 18px;
    font-size
: 12px;
    cursor
: hand;
}


.textField
{
    HEIGHT
: 18px;
}

.textTop
{
    HEIGHT
: 18px;
}

.textFieldB
{
    HEIGHT
: 14px;
    text-align
: right;
    position
: relative;
    top
: -1px; 
    clip
: rect()
}

.textFieldR
{
    HEIGHT
: 18px;
    text-align
: right;
}

select
{
    BACKGROUND-COLOR
: #ffffff;
    color
:#000000;
    background-image
: none;
    BORDER-BOTTOM
: #006cb5 1px solid;
    BORDER-LEFT
: #006cb5 1px solid;
    BORDER-RIGHT
: #006cb5 1px solid;
    BORDER-TOP
:#006cb5 1px solid;
    HEIGHT
: 18px;
    font-size
: 12px;
    cursor
: hand;
}

A
{COLOR: #007db5;}
A:hover
{
    COLOR
: #FF7E00;
    TEXT-DECORATION
:none;
    position
: relative;
    left
: 1px; 
    top
: 1px; 
    clip
: rect()
}


a:link 
{
    font-size
: 12px;
    color
: #003366;
    font-weight
:bold;
}

a:active 
{
    font-size
: 12px;
    color
: #FF7E00;
}


a:visited 
{
    font-size
: 12px;
    color
: #003366;
    font-weight
:bold;
    
}


.list 
{
    text-align
: center;
    font-size
: 12px;
}


.over 
{
    filter
: BlendTrans(Duration=5);
    position
: relative;
    left
: 1px; 
    top
: 1px; 
    clip
: rect()
}

.out 
{
    filter
: alpha(opacity=70);
}

.important 
{
    color
: #FF0000;
    font-weight
: bold;
    font-size
: 12px;
}

Input
{
    BACKGROUND-COLOR
: #ffffff;
    color
:#000000;
    background-image
: none;
    BORDER-BOTTOM
: #006cb5 1px solid;
    BORDER-LEFT
: #006cb5 1px solid;
    BORDER-RIGHT
: #006cb5 1px solid;
    BORDER-TOP
:#006cb5 1px solid;
    HEIGHT
: 18px;
    font-size
: 12px;
    cursor
: hand;
}

.tbInput 
{
    white-space
: pre;
    border-collapse
: collapse;
    padding
: 0px;
    cellpadding
:0px;
    cellspacing
:1px;
}

hr 
{
    height
: 1px;
    width
: 98%;
    color
:#FF0000;
}

.TitleTb 
{
    background-color
: #eeeeee;
    font-size
: 14px;
}

table 
{
    text-align
: left;
}

.Title 
{
    font-size
: 18px;
    text-align
: center;
}

.tbSalary 
{
    font-size
: 10px;
    text-align
: center;
}

.btn 
{
 BORDER-RIGHT
: #7b9ebd 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7b9ebd 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 12px; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#cecfde); BORDER-LEFT: #7b9ebd 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #7b9ebd 1px solid;
}

.btn_mouseout 
{
 BORDER-RIGHT
: #3399FF 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #3399FF 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 12px; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#9EBFEA); BORDER-LEFT: #3399FF 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #3399FF 1px solid
}

.btn_mouseover 
{
 BORDER-RIGHT
: #000000 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #000000 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 12px; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#CCDDF4); BORDER-LEFT: #000000 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #000000 1px solid
}

原创粉丝点击