1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
3
* FCKeditor - The text editor for internet
4
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
6
* Licensed under the terms of the GNU Lesser General Public License:
7
* http://www.opensource.org/licenses/lgpl-license.php
9
* For further information visit:
10
* http://www.fckeditor.net/
12
* "Support Open Source software. What about a donation today?"
14
* File Name: replace.html
15
* This is the sample "Replace" plugin window.
18
* Frederico Caldeira Knabben (fredck@fckeditor.net)
22
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
23
<meta content="noindex, nofollow" name="robots">
24
<script type="text/javascript">
26
var oEditor = window.parent.InnerDialogLoaded() ;
30
// First of all, translate the dialog box texts
31
oEditor.FCKLanguageManager.TranslatePage( document ) ;
33
window.parent.SetAutoSize( true ) ;
38
document.getElementById('btnReplace').disabled =
39
document.getElementById('btnReplaceAll').disabled =
40
( document.getElementById('txtFind').value.length == 0 ) ;
43
function ReplaceTextNodes( parentNode, regex, replaceValue, replaceAll, hasFound )
45
for ( var i = 0 ; i < parentNode.childNodes.length ; i++ )
47
var oNode = parentNode.childNodes[i] ;
48
if ( oNode.nodeType == 3 )
50
var sReplaced = oNode.nodeValue.replace( regex, replaceValue ) ;
51
if ( oNode.nodeValue != sReplaced )
53
oNode.nodeValue = sReplaced ;
60
hasFound = ReplaceTextNodes( oNode, regex, replaceValue, replaceAll, hasFound ) ;
61
if ( ! replaceAll && hasFound )
68
function GetRegexExpr()
70
if ( document.getElementById('chkWord').checked )
71
var sExpr = '\\b' + document.getElementById('txtFind').value + '\\b' ;
73
var sExpr = document.getElementById('txtFind').value ;
80
return ( document.getElementById('chkCase').checked ? '' : 'i' ) ;
85
var oRegex = new RegExp( GetRegexExpr(), GetCase() ) ;
86
ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, document.getElementById('txtReplace').value, false ) ;
91
var oRegex = new RegExp( GetRegexExpr(), GetCase() + 'g' ) ;
92
ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, document.getElementById('txtReplace').value, true ) ;
93
window.parent.Cancel() ;
97
<body onload="OnLoad()" scroll="no" style="OVERFLOW: hidden">
101
<table cellSpacing="3" cellPadding="2" width="100%" border="0">
103
<td noWrap><label for="txtFind" fckLang="DlgMyReplaceFindLbl">Find what:</label>
105
<td width="100%"><input id="txtFind" onkeyup="btnStat(this.form)" style="WIDTH: 100%" tabIndex="1" type="text">
107
<td><input id="btnReplace" style="WIDTH: 100%" disabled onclick="Replace();" type="button"
108
value="Replace" fckLang="DlgMyReplaceReplaceBtn">
112
<td vAlign="top" nowrap><label for="txtReplace" fckLang="DlgMyReplaceReplaceLbl">Replace
115
<td vAlign="top"><input id="txtReplace" style="WIDTH: 100%" tabIndex="2" type="text">
117
<td><input id="btnReplaceAll" disabled onclick="ReplaceAll()" type="button" value="Replace All"
118
fckLang="DlgMyReplaceReplAllBtn">
122
<td vAlign="bottom" colSpan="3"> <input id="chkCase" tabIndex="3" type="checkbox"><label for="chkCase" fckLang="DlgMyReplaceCaseChk">Match
125
<input id="chkWord" tabIndex="4" type="checkbox"><label for="chkWord" fckLang="DlgMyReplaceWordChk">Match