⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findreplace.vm

📁 一个webwork+spring+ibatis的小例子
💻 VM
字号:
<HTML>
<HEAD>
<TITLE>$action.getText('webeditor.dialog.findreplace.title'</TITLE>
<LINK type="text/css" rel="stylesheet" href="${action.getText('config.webeditor.path.css')}/dialog.css">
<script language="JavaScript">
	#parse("${action.getText('config.webeditor.path.js')}/dialog.js.vm")
</script>

<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("$action.getText('webeditor.dialog.findreplace.inputSearchContent')");
        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("$action.getText('webeditor.dialog.findreplace.reSearch')");
            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 = "$action.getText('webeditor.dialog.findreplace.notFoundInfo')
"
        else msg = wordcount + " $action.getText('webeditor.dialog.findreplace.replaceSuccess')
";
        alert(msg);
    }
}
</script>

</HEAD>
<BODY bgcolor="menu">
<FORM NAME="frmSearch" method="post" action="">
<TABLE CELLSPACING="0" cellpadding="5" border="0">
<TR><TD VALIGN="top" align="left" nowrap>
    <label for="strSearch">$action.getText('webeditor.dialog.findreplace.searchContent')</label><br>
    <INPUT TYPE=TEXT SIZE=40 NAME=strSearch id="strSearch" style="width : 200px;"><br>
    <label for="strReplace">$action.getText('webeditor.dialog.findreplace.replaceContent')</label><br>
    <INPUT TYPE=TEXT SIZE=40 NAME=strReplace id="strReplace" style="width : 200px;"><br>
    <INPUT TYPE=Checkbox SIZE=40 NAME=blnMatchCase ID="blnMatchCase"><label for="blnMatchCase">$action.getText('webeditor.dialog.findreplace.ireplace')</label><br>
    <INPUT TYPE=Checkbox SIZE=40 NAME=blnMatchWord ID="blnMatchWord"><label for="blnMatchWord">$action.getText('webeditor.dialog.findreplace.allMatch')</label>
</td>
<td rowspan="2" valign="top">
    <input type=button style="width:80px;margin-top:15px" name="btnFind" onClick="findtext();" value="$action.getText('webeditor.dialog.findreplace.searchNext')"><br>
    <input type=button style="width:80px;margin-top:5px" name="btnCancel" onClick="window.close();" value="$action.getText('webeditor.dialog.close')"><br>
    <input type=button style="width:80px;margin-top:5px" name="btnReplace" onClick="replacetext();" value="$action.getText('webeditor.dialog.findreplace.replace')"><br>
    <input type=button style="width:80px;margin-top:5px" name="btnReplaceall" onClick="replacealltext();" value="$action.getText('webeditor.dialog.findreplace.allReplace')"><br>
</td>
</tr>
</table>
</FORM>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -