Home directory for Malawi's wwwroot
Duncan Ewan
2021-02-19 3e758c29e0fde36fc088efcfc88f9a3014432b64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2009 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 ==
 *
 * Create the FCKeditorAPI object that is available as a global object in
 * the page where the editor is placed in.
 */
 
var FCKeditorAPI ;
 
function InitializeAPI()
{
    var oParentWindow = window.parent ;
 
    if ( !( FCKeditorAPI = oParentWindow.FCKeditorAPI ) )
    {
        // Make the FCKeditorAPI object available in the parent window. Use
        // eval so this core runs in the parent's scope and so it will still be
        // available if the editor instance is removed ("Can't execute code
        // from a freed script" error).
 
        // Note: we check the existence of oEditor.GetParentForm because some external
        // code (like JSON) can extend the Object prototype and we get then extra oEditor
        // objects that aren't really FCKeditor instances.
        var sScript =
            'window.FCKeditorAPI = {' +
                'Version : "2.6.4.1",' +
                'VersionBuild : "23187",' +
                'Instances : window.FCKeditorAPI && window.FCKeditorAPI.Instances || {},' +
 
                'GetInstance : function( name )' +
                '{' +
                    'return this.Instances[ name ];' +
                '},' +
 
                '_FormSubmit : function()' +
                '{' +
                    'for ( var name in FCKeditorAPI.Instances )' +
                    '{' +
                        'var oEditor = FCKeditorAPI.Instances[ name ] ;' +
                        'if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )' +
                            'oEditor.UpdateLinkedField() ;' +
                    '}' +
                    'this._FCKOriginalSubmit() ;' +
                '},' +
 
                '_FunctionQueue    : window.FCKeditorAPI && window.FCKeditorAPI._FunctionQueue || {' +
                    'Functions : new Array(),' +
                    'IsRunning : false,' +
 
                    'Add : function( f )' +
                    '{' +
                        'this.Functions.push( f );' +
                        'if ( !this.IsRunning )' +
                            'this.StartNext();' +
                    '},' +
 
                    'StartNext : function()' +
                    '{' +
                        'var aQueue = this.Functions ;' +
                        'if ( aQueue.length > 0 )' +
                        '{' +
                            'this.IsRunning = true;' +
                            'aQueue[0].call();' +
                        '}' +
                        'else ' +
                            'this.IsRunning = false;' +
                    '},' +
 
                    'Remove : function( f )' +
                    '{' +
                        'var aQueue = this.Functions;' +
                        'var i = 0, fFunc;' +
                        'while( (fFunc = aQueue[ i ]) )' +
                        '{' +
                            'if ( fFunc == f )' +
                                'aQueue.splice( i,1 );' +
                            'i++ ;' +
                        '}' +
                        'this.StartNext();' +
                    '}' +
                '}' +
            '}' ;
 
        // In IE, the "eval" function is not always available (it works with
        // the JavaScript samples, but not with the ASP ones, for example).
        // So, let's use the execScript instead.
        if ( oParentWindow.execScript )
            oParentWindow.execScript( sScript, 'JavaScript' ) ;
        else
        {
            if ( FCKBrowserInfo.IsGecko10 )
            {
                // FF 1.0.4 gives an error with the request bellow. The
                // following seams to work well.
                eval.call( oParentWindow, sScript ) ;
            }
            else if( FCKBrowserInfo.IsAIR )
            {
                FCKAdobeAIR.FCKeditorAPI_Evaluate( oParentWindow, sScript ) ;
            }
            else if ( FCKBrowserInfo.IsSafari )
            {
                // oParentWindow.eval in Safari executes in the calling window
                // environment, instead of the parent one. The following should
                // make it work.
                var oParentDocument = oParentWindow.document ;
                var eScript = oParentDocument.createElement('script') ;
                eScript.appendChild( oParentDocument.createTextNode( sScript ) ) ;
                oParentDocument.documentElement.appendChild( eScript ) ;
            }
            else
                oParentWindow.eval( sScript ) ;
        }
 
        FCKeditorAPI = oParentWindow.FCKeditorAPI ;
 
        // The __Instances properly has been changed to the public Instances,
        // but we should still have the "deprecated" version of it.
        FCKeditorAPI.__Instances = FCKeditorAPI.Instances ;
    }
 
    // Add the current instance to the FCKeditorAPI's instances collection.
    FCKeditorAPI.Instances[ FCK.Name ] = FCK ;
}
 
// Attach to the form onsubmit event and to the form.submit().
function _AttachFormSubmitToAPI()
{
    // Get the linked field form.
    var oForm = FCK.GetParentForm() ;
 
    if ( oForm )
    {
        // Attach to the onsubmit event.
        FCKTools.AddEventListener( oForm, 'submit', FCK.UpdateLinkedField ) ;
 
        // IE sees oForm.submit function as an 'object'.
        if ( !oForm._FCKOriginalSubmit && ( typeof( oForm.submit ) == 'function' || ( !oForm.submit.tagName && !oForm.submit.length ) ) )
        {
            // Save the original submit.
            oForm._FCKOriginalSubmit = oForm.submit ;
 
            // Create our replacement for the submit.
            oForm.submit = FCKeditorAPI._FormSubmit ;
        }
    }
}
 
function FCKeditorAPI_Cleanup()
{
    if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat
            && !window.FCKUnloadFlag )
        return ;
    delete FCKeditorAPI.Instances[ FCK.Name ] ;
}
function FCKeditorAPI_ConfirmCleanup()
{
    if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat )
        window.FCKUnloadFlag = true ;
}
FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ;
FCKTools.AddEventListener( window, 'beforeunload', FCKeditorAPI_ConfirmCleanup) ;