Subversion Repositories Applications.papyrus

Rev

Rev 521 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<!--
3
 * FCKeditor - The text editor for internet
875 ddelon 4
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
431 ddelon 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
 *
521 ddelon 12
 * "Support Open Source software. What about a donation today?"
13
 *
431 ddelon 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>
22
	<head>
875 ddelon 23
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
24
		<meta content="noindex, nofollow" name="robots" />
431 ddelon 25
		<script type="text/javascript">
26
 
27
var oEditor = window.parent.InnerDialogLoaded() ;
28
 
29
function OnLoad()
30
{
31
	// First of all, translate the dialog box texts
32
	oEditor.FCKLanguageManager.TranslatePage( document ) ;
33
 
34
	window.parent.SetAutoSize( true ) ;
35
 
36
	oEditor.FCKUndo.SaveUndoStep() ;
37
}
38
 
39
function btnStat(frm)
40
{
41
	document.getElementById('btnReplace').disabled =
42
		document.getElementById('btnReplaceAll').disabled =
43
			( document.getElementById('txtFind').value.length == 0 ) ;
44
}
45
 
46
function ReplaceTextNodes( parentNode, regex, replaceValue, replaceAll, hasFound )
47
{
48
	for ( var i = 0 ; i < parentNode.childNodes.length ; i++ )
49
	{
50
		var oNode = parentNode.childNodes[i] ;
51
		if ( oNode.nodeType == 3 )
52
		{
53
			var sReplaced = oNode.nodeValue.replace( regex, replaceValue ) ;
54
			if ( oNode.nodeValue != sReplaced )
55
			{
56
				oNode.nodeValue = sReplaced ;
57
				if ( ! replaceAll )
58
					return true ;
59
				hasFound = true ;
60
			}
61
		}
62
 
63
		hasFound = ReplaceTextNodes( oNode, regex, replaceValue, replaceAll, hasFound ) ;
64
		if ( ! replaceAll && hasFound )
65
			return true ;
66
	}
67
 
68
	return hasFound ;
69
}
70
 
71
function GetRegexExpr()
72
{
73
	if ( document.getElementById('chkWord').checked )
74
		var sExpr = '\\b' + document.getElementById('txtFind').value + '\\b' ;
75
	else
76
		var sExpr = document.getElementById('txtFind').value ;
77
 
78
	return sExpr ;
79
}
80
 
81
function GetCase()
82
{
83
	return ( document.getElementById('chkCase').checked ? '' : 'i' ) ;
84
}
85
 
86
function Replace()
87
{
88
	var oRegex = new RegExp( GetRegexExpr(), GetCase() ) ;
875 ddelon 89
	if ( !ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, document.getElementById('txtReplace').value, false, false ) )
90
		alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
431 ddelon 91
}
92
 
93
function ReplaceAll()
94
{
95
	var oRegex = new RegExp( GetRegexExpr(), GetCase() + 'g' ) ;
875 ddelon 96
	if ( !ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, document.getElementById('txtReplace').value, true, false ) )
97
		alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
431 ddelon 98
	window.parent.Cancel() ;
99
}
100
		</script>
101
	</head>
102
	<body onload="OnLoad()" scroll="no" style="OVERFLOW: hidden">
103
		<table cellSpacing="3" cellPadding="2" width="100%" border="0">
104
			<tr>
105
				<td noWrap><label for="txtFind" fckLang="DlgReplaceFindLbl">Find what:</label>
106
				</td>
107
				<td width="100%"><input id="txtFind" onkeyup="btnStat(this.form)" style="WIDTH: 100%" tabIndex="1" type="text">
108
				</td>
109
				<td><input id="btnReplace" style="WIDTH: 100%" disabled onclick="Replace();" type="button"
110
						value="Replace" fckLang="DlgReplaceReplaceBtn">
111
				</td>
112
			</tr>
113
			<tr>
114
				<td vAlign="top" noWrap><label for="txtReplace" fckLang="DlgReplaceReplaceLbl">Replace
115
						with:</label>
116
				</td>
117
				<td vAlign="top"><input id="txtReplace" style="WIDTH: 100%" tabIndex="2" type="text">
118
				</td>
119
				<td><input id="btnReplaceAll" disabled onclick="ReplaceAll()" type="button" value="Replace All"
120
						fckLang="DlgReplaceReplAllBtn">
121
				</td>
122
			</tr>
123
			<tr>
124
				<td vAlign="bottom" colSpan="3">&nbsp;<input id="chkCase" tabIndex="3" type="checkbox"><label for="chkCase" fckLang="DlgReplaceCaseChk">Match
125
						case</label>
126
					<br>
127
					&nbsp;<input id="chkWord" tabIndex="4" type="checkbox"><label for="chkWord" fckLang="DlgReplaceWordChk">Match
128
						whole word</label>
129
				</td>
130
			</tr>
131
		</table>
132
	</body>
133
</html>