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