You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
klintersrv/editor/dialog/findreplace.htm

119 lines
3.8 KiB

3 months ago
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript src="dialog.js"></script>
<link href='dialog.css' type='text/css' rel='stylesheet'>
<TITLE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> / <EFBFBD></TITLE>
<script language="JavaScript">
var oSelection;
oSelection = dialogArguments.document.selection.createRange();
function searchtype(){
var retval = 0;
var matchcase = 0;
var matchword = 0;
if (document.frmSearch.blnMatchCase.checked) matchcase = 4;
if (document.frmSearch.blnMatchWord.checked) matchword = 2;
retval = matchcase + matchword;
return(retval);
}
function checkInput(){
if (document.frmSearch.strSearch.value.length < 1) {
alert("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return false;
} else {
return true;
}
}
function findtext(){
if (checkInput()) {
var searchval = document.frmSearch.strSearch.value;
oSelection.collapse(false);
if (oSelection.findText(searchval, 1000000000, searchtype())) {
oSelection.select();
} else {
var startfromtop = confirm("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD>Ƿ<EFBFBD>Ҫ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
if (startfromtop) {
oSelection.expand("textedit");
oSelection.collapse();
oSelection.select();
findtext();
}
}
}
}
function replacetext(){
if (checkInput()) {
if (document.frmSearch.blnMatchCase.checked){
if (oSelection.text == document.frmSearch.strSearch.value) oSelection.text = document.frmSearch.strReplace.value
} else {
if (oSelection.text.toLowerCase() == document.frmSearch.strSearch.value.toLowerCase()) oSelection.text = document.frmSearch.strReplace.value
}
findtext();
}
}
function replacealltext(){
if (checkInput()) {
var searchval = document.frmSearch.strSearch.value;
var wordcount = 0;
var msg = "";
oSelection.expand("textedit");
oSelection.collapse();
oSelection.select();
while (oSelection.findText(searchval, 1000000000, searchtype())){
oSelection.select();
oSelection.text = document.frmSearch.strReplace.value;
wordcount++;
}
if (wordcount == 0) msg = "Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>"
else msg = wordcount + " " + "<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>";
alert(msg);
}
}
function InitDocument(){
adjustDialog();
}
</script>
</HEAD>
<BODY onload="InitDocument()">
<table border=0 cellpadding=0 cellspacing=5 id=tabDialogSize><tr><td>
<TABLE CELLSPACING="0" cellpadding="0" border="0" align=center>
<FORM NAME="frmSearch" method="post" action="">
<TR>
<TD VALIGN="top" align="left" nowrap width="60%">
<label for="strSearch"><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD></label><br>
<INPUT TYPE=TEXT SIZE=25 NAME=strSearch id="strSearch"><br>
<label for="strReplace"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></label><br>
<INPUT TYPE=TEXT SIZE=25 NAME=strReplace id="strReplace"><br>
<INPUT TYPE=Checkbox NAME=blnMatchCase ID="blnMatchCase"><label for="blnMatchCase"><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>Сд</label><br>
<INPUT TYPE=Checkbox NAME=blnMatchWord ID="blnMatchWord"><label for="blnMatchWord">ȫ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD></label>
</td>
<td width="5%">
<td rowspan="2" valign="bottom" width="35%">
<table border=0 cellpadding=0 cellspacing=5 width="100%" align=center>
<tr><td><input type=button style="width:100%" name="btnFind" onClick="findtext();" value="<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>"></td></tr>
<tr><td><input type=button style="width:100%" name="btnCancel" onClick="window.close();" value="<EFBFBD>ر<EFBFBD>"></td></tr>
<tr><td><input type=button style="width:100%" name="btnReplace" onClick="replacetext();" value="<EFBFBD>滻"></td></tr>
<tr><td><input type=button style="width:100%" name="btnReplaceall" onClick="replacealltext();" value=<EFBFBD><EFBFBD><EFBFBD>滻"></td></tr>
</table>
</td>
</tr>
</FORM>
</table>
</td></tr></table>
</BODY>
</HTML>