source: trunk/admin/inc/FCKeditor/editor/dialog/fck_replace.html@ 161

Last change on this file since 161 was 2, checked in by root, 15 years ago

importo il progetto

File size: 4.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!--
3 * FCKeditor - The text editor for internet
4 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
5 *
6 * Licensed under the terms of the GNU Lesser General Public License:
7 * http://www.opensource.org/licenses/lgpl-license.php
8 *
9 * For further information visit:
10 * http://www.fckeditor.net/
11 *
12 * "Support Open Source software. What about a donation today?"
13 *
14 * File Name: fck_replace.html
15 * "Replace" dialog box window.
16 *
17 * File Authors:
18 * Frederico Caldeira Knabben (fredck@fckeditor.net)
19 * Abdul-Aziz A. Al-Oraij (aziz.oraij.com)
20-->
21<html xmlns="http://www.w3.org/1999/xhtml">
22<head>
23 <title></title>
24 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
25 <meta content="noindex, nofollow" name="robots" />
26 <script type="text/javascript">
27
28var oEditor = window.parent.InnerDialogLoaded() ;
29
30function OnLoad()
31{
32 // First of all, translate the dialog box texts
33 oEditor.FCKLanguageManager.TranslatePage( document ) ;
34
35 window.parent.SetAutoSize( true ) ;
36
37 oEditor.FCKUndo.SaveUndoStep() ;
38}
39
40function btnStat(frm)
41{
42 document.getElementById('btnReplace').disabled =
43 document.getElementById('btnReplaceAll').disabled =
44 ( document.getElementById('txtFind').value.length == 0 ) ;
45}
46
47function ReplaceTextNodes( parentNode, regex, replaceValue, replaceAll, hasFound )
48{
49 for ( var i = 0 ; i < parentNode.childNodes.length ; i++ )
50 {
51 var oNode = parentNode.childNodes[i] ;
52 if ( oNode.nodeType == 3 )
53 {
54 var sReplaced = oNode.nodeValue.replace( regex, replaceValue ) ;
55 if ( oNode.nodeValue != sReplaced )
56 {
57 oNode.nodeValue = sReplaced ;
58 if ( ! replaceAll )
59 return true ;
60 hasFound = true ;
61 }
62 }
63
64 hasFound = ReplaceTextNodes( oNode, regex, replaceValue, replaceAll, hasFound ) ;
65 if ( ! replaceAll && hasFound )
66 return true ;
67 }
68
69 return hasFound ;
70}
71
72function GetRegexExpr()
73{
74 var sExpr = EscapeRegexString( document.getElementById('txtFind').value ) ;
75
76 if ( document.getElementById('chkWord').checked )
77 sExpr = '\\b' + sExpr + '\\b' ;
78
79 return sExpr ;
80}
81
82function GetCase()
83{
84 return ( document.getElementById('chkCase').checked ? '' : 'i' ) ;
85}
86
87function GetReplacement()
88{
89 return document.getElementById('txtReplace').value.replace( /\$/g, '$$$$' ) ;
90}
91
92function EscapeRegexString( str )
93{
94 return str.replace( /[\\\^\$\*\+\?\{\}\.\(\)\!\|\[\]\-]/g, '\\$&' ) ;
95}
96
97function Replace()
98{
99 var oRegex = new RegExp( GetRegexExpr(), GetCase() ) ;
100 if ( !ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, GetReplacement(), false, false ) )
101 alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
102}
103
104function ReplaceAll()
105{
106 var oRegex = new RegExp( GetRegexExpr(), GetCase() + 'g' ) ;
107 if ( !ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, GetReplacement(), true, false ) )
108 alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
109 window.parent.Cancel() ;
110}
111 </script>
112</head>
113<body onload="OnLoad()" style="overflow: hidden">
114 <table cellspacing="3" cellpadding="2" width="100%" border="0">
115 <tr>
116 <td nowrap="nowrap">
117 <label for="txtFind" fcklang="DlgReplaceFindLbl">
118 Find what:</label>
119 </td>
120 <td width="100%">
121 <input id="txtFind" onkeyup="btnStat(this.form)" style="width: 100%" tabindex="1"
122 type="text" />
123 </td>
124 <td>
125 <input id="btnReplace" style="width: 100%" disabled="disabled" onclick="Replace();"
126 type="button" value="Replace" fcklang="DlgReplaceReplaceBtn" />
127 </td>
128 </tr>
129 <tr>
130 <td valign="top" nowrap="nowrap">
131 <label for="txtReplace" fcklang="DlgReplaceReplaceLbl">
132 Replace with:</label>
133 </td>
134 <td valign="top">
135 <input id="txtReplace" style="width: 100%" tabindex="2" type="text" />
136 </td>
137 <td>
138 <input id="btnReplaceAll" disabled="disabled" onclick="ReplaceAll()" type="button"
139 value="Replace All" fcklang="DlgReplaceReplAllBtn" />
140 </td>
141 </tr>
142 <tr>
143 <td valign="bottom" colspan="3">
144 &nbsp;<input id="chkCase" tabindex="3" type="checkbox" /><label for="chkCase" fcklang="DlgReplaceCaseChk">Match
145 case</label>
146 <br />
147 &nbsp;<input id="chkWord" tabindex="4" type="checkbox" /><label for="chkWord" fcklang="DlgReplaceWordChk">Match
148 whole word</label>
149 </td>
150 </tr>
151 </table>
152</body>
153</html>
Note: See TracBrowser for help on using the repository browser.