Subversion Repositories Applications.papyrus

Rev

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