2007-04-14 14:21:09 +02:00
|
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
2006-11-07 19:18:22 +01:00
|
|
|
|
<!--
|
2007-04-14 14:21:09 +02:00
|
|
|
|
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
|
|
|
|
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
|
|
|
|
|
*
|
|
|
|
|
* == BEGIN LICENSE ==
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the terms of any of the following licenses at your
|
|
|
|
|
* choice:
|
|
|
|
|
*
|
|
|
|
|
* - GNU General Public License Version 2 or later (the "GPL")
|
|
|
|
|
* http://www.gnu.org/licenses/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
|
|
|
|
|
* http://www.gnu.org/licenses/lgpl.html
|
|
|
|
|
*
|
|
|
|
|
* - Mozilla Public License Version 1.1 or later (the "MPL")
|
|
|
|
|
* http://www.mozilla.org/MPL/MPL-1.1.html
|
|
|
|
|
*
|
|
|
|
|
* == END LICENSE ==
|
|
|
|
|
*
|
|
|
|
|
* "Replace" dialog box window.
|
2006-11-07 19:18:22 +01:00
|
|
|
|
-->
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
|
<head>
|
|
|
|
|
<title></title>
|
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
|
<meta content="noindex, nofollow" name="robots" />
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
|
|
var oEditor = window.parent.InnerDialogLoaded() ;
|
|
|
|
|
|
|
|
|
|
function OnLoad()
|
|
|
|
|
{
|
|
|
|
|
// First of all, translate the dialog box texts
|
|
|
|
|
oEditor.FCKLanguageManager.TranslatePage( document ) ;
|
|
|
|
|
|
|
|
|
|
window.parent.SetAutoSize( true ) ;
|
|
|
|
|
|
|
|
|
|
oEditor.FCKUndo.SaveUndoStep() ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function btnStat(frm)
|
|
|
|
|
{
|
2007-04-14 14:21:09 +02:00
|
|
|
|
document.getElementById('btnReplace').disabled =
|
|
|
|
|
document.getElementById('btnReplaceAll').disabled =
|
2006-11-07 19:18:22 +01:00
|
|
|
|
( document.getElementById('txtFind').value.length == 0 ) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ReplaceTextNodes( parentNode, regex, replaceValue, replaceAll, hasFound )
|
|
|
|
|
{
|
|
|
|
|
for ( var i = 0 ; i < parentNode.childNodes.length ; i++ )
|
|
|
|
|
{
|
|
|
|
|
var oNode = parentNode.childNodes[i] ;
|
|
|
|
|
if ( oNode.nodeType == 3 )
|
|
|
|
|
{
|
|
|
|
|
var sReplaced = oNode.nodeValue.replace( regex, replaceValue ) ;
|
|
|
|
|
if ( oNode.nodeValue != sReplaced )
|
|
|
|
|
{
|
|
|
|
|
oNode.nodeValue = sReplaced ;
|
|
|
|
|
if ( ! replaceAll )
|
|
|
|
|
return true ;
|
|
|
|
|
hasFound = true ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hasFound = ReplaceTextNodes( oNode, regex, replaceValue, replaceAll, hasFound ) ;
|
|
|
|
|
if ( ! replaceAll && hasFound )
|
|
|
|
|
return true ;
|
|
|
|
|
}
|
2007-04-14 14:21:09 +02:00
|
|
|
|
|
2006-11-07 19:18:22 +01:00
|
|
|
|
return hasFound ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetRegexExpr()
|
|
|
|
|
{
|
|
|
|
|
var sExpr = EscapeRegexString( document.getElementById('txtFind').value ) ;
|
|
|
|
|
|
|
|
|
|
if ( document.getElementById('chkWord').checked )
|
|
|
|
|
sExpr = '\\b' + sExpr + '\\b' ;
|
|
|
|
|
|
|
|
|
|
return sExpr ;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-14 14:21:09 +02:00
|
|
|
|
function GetCase()
|
2006-11-07 19:18:22 +01:00
|
|
|
|
{
|
|
|
|
|
return ( document.getElementById('chkCase').checked ? '' : 'i' ) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetReplacement()
|
|
|
|
|
{
|
|
|
|
|
return document.getElementById('txtReplace').value.replace( /\$/g, '$$$$' ) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function EscapeRegexString( str )
|
|
|
|
|
{
|
|
|
|
|
return str.replace( /[\\\^\$\*\+\?\{\}\.\(\)\!\|\[\]\-]/g, '\\$&' ) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Replace()
|
|
|
|
|
{
|
|
|
|
|
var oRegex = new RegExp( GetRegexExpr(), GetCase() ) ;
|
|
|
|
|
if ( !ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, GetReplacement(), false, false ) )
|
|
|
|
|
alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ReplaceAll()
|
|
|
|
|
{
|
|
|
|
|
var oRegex = new RegExp( GetRegexExpr(), GetCase() + 'g' ) ;
|
|
|
|
|
if ( !ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, GetReplacement(), true, false ) )
|
|
|
|
|
alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
|
|
|
|
|
window.parent.Cancel() ;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</head>
|
|
|
|
|
<body onload="OnLoad()" style="overflow: hidden">
|
|
|
|
|
<table cellspacing="3" cellpadding="2" width="100%" border="0">
|
|
|
|
|
<tr>
|
|
|
|
|
<td nowrap="nowrap">
|
|
|
|
|
<label for="txtFind" fcklang="DlgReplaceFindLbl">
|
|
|
|
|
Find what:</label>
|
|
|
|
|
</td>
|
|
|
|
|
<td width="100%">
|
|
|
|
|
<input id="txtFind" onkeyup="btnStat(this.form)" style="width: 100%" tabindex="1"
|
|
|
|
|
type="text" />
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
<input id="btnReplace" style="width: 100%" disabled="disabled" onclick="Replace();"
|
|
|
|
|
type="button" value="Replace" fcklang="DlgReplaceReplaceBtn" />
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td valign="top" nowrap="nowrap">
|
|
|
|
|
<label for="txtReplace" fcklang="DlgReplaceReplaceLbl">
|
|
|
|
|
Replace with:</label>
|
|
|
|
|
</td>
|
|
|
|
|
<td valign="top">
|
|
|
|
|
<input id="txtReplace" style="width: 100%" tabindex="2" type="text" />
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
<input id="btnReplaceAll" disabled="disabled" onclick="ReplaceAll()" type="button"
|
|
|
|
|
value="Replace All" fcklang="DlgReplaceReplAllBtn" />
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td valign="bottom" colspan="3">
|
|
|
|
|
<input id="chkCase" tabindex="3" type="checkbox" /><label for="chkCase" fcklang="DlgReplaceCaseChk">Match
|
|
|
|
|
case</label>
|
|
|
|
|
<br />
|
|
|
|
|
<input id="chkWord" tabindex="4" type="checkbox" /><label for="chkWord" fcklang="DlgReplaceWordChk">Match
|
|
|
|
|
whole word</label>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|