~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/_samples/_plugins/findreplace/replace.html

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

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