FCKeditor 2.6.6
[freeside.git] / httemplate / elements / fckeditor / editor / wsc / w.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
2 <!--\r
3  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
4  * Copyright (C) 2003-2010 Frederico Caldeira Knabben\r
5  *\r
6  * == BEGIN LICENSE ==\r
7  *\r
8  * Licensed under the terms of any of the following licenses at your\r
9  * choice:\r
10  *\r
11  *  - GNU General Public License Version 2 or later (the "GPL")\r
12  *    http://www.gnu.org/licenses/gpl.html\r
13  *\r
14  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
15  *    http://www.gnu.org/licenses/lgpl.html\r
16  *\r
17  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
18  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
19  *\r
20  * == END LICENSE ==\r
21 -->\r
22 <html>\r
23 <head>\r
24         <title></title>\r
25         <style>\r
26                 #wsc_frames , #errorMessage{\r
27                         position:absolute;\r
28                         top:0px;\r
29                         left:0px;\r
30                         width:500px;\r
31                         height:395px;\r
32                         margin:0px;\r
33                         padding:0px;\r
34                         border:0px;\r
35                         display:block;\r
36                         overflow: hidden;\r
37                 }\r
38                 #wsc_frames   { z-index:10;}\r
39                 #errorMessage {\r
40                         color:red;\r
41                         display:none;\r
42                         font-size:16px;\r
43                         font-weight:bold;\r
44                         padding-top:160px;\r
45                         text-align:center;\r
46                         z-index:11;\r
47                 }\r
48                 #errorMessage p {\r
49                         color:#000;\r
50                         font-size:11px;\r
51                         text-align:left;\r
52                         font-weight: normal;\r
53                         padding-left:80px;\r
54                 }\r
55 \r
56         </style>\r
57         <script type="text/javascript">\r
58 \r
59 var oEditor = window.parent.InnerDialogLoaded() ;\r
60 var FCKConfig = oEditor.FCKConfig;\r
61 \r
62 function doLoadScript(url)\r
63 {\r
64         if (!url)\r
65                 return false ;\r
66 \r
67         var s = document.createElement('script') ;\r
68         s.type = 'text/javascript' ;\r
69         s.src = url ;\r
70 \r
71         document.getElementsByTagName('head')[0].appendChild(s) ;\r
72 \r
73         return true ;\r
74 }\r
75 \r
76 function Ok()\r
77 {\r
78         return window.parent.Cancel() ;\r
79 }\r
80 \r
81 function _callOnCancel( dT )\r
82 {\r
83         window.parent.Cancel() ;\r
84 }\r
85 \r
86 function _callOnFinish( dT )\r
87 {\r
88         oEditor.FCK.SetData( dT.value ) ;\r
89         window.parent.CloseDialog( true ) ;\r
90 }\r
91 \r
92 function _cancelOnError(m)\r
93 {\r
94         var _conId = 'errorMessage' ;\r
95         var message = m || 'Sorry, but service is unavailable now.' ;\r
96 \r
97         if ( typeof( WSC_Error ) == 'undefined' )\r
98         {\r
99                 var _con = document.createElement( 'div' ) ;\r
100                 _con.setAttribute( 'id', _conId ) ;\r
101                 document.body.appendChild( _con ) ;\r
102                 dom_con = document.getElementById( _conId ) ;\r
103                 dom_con.innerHTML = message ;\r
104                 dom_con.style.display = 'block' ;\r
105         }\r
106         //return Ok() ;\r
107 }\r
108 \r
109 function URL_abs2full( uri )\r
110 {\r
111         return uri.match( 'http' )\r
112                 ? uri\r
113                 : document.location.protocol + '//' + document.location.host + uri ;\r
114 }\r
115 \r
116 function clearErrorUsermessage()\r
117 {\r
118         // empty error container\r
119         var _con = document.getElementById( 'errorMessage' ) ;\r
120 \r
121         if ( !_con )\r
122                 return ;\r
123 \r
124         _con.innerHTML = '' ;\r
125         _con.style.display = 'none' ;\r
126 }\r
127 \r
128 var gInterval ;\r
129 \r
130 function onLoad()\r
131 {\r
132         clearErrorUsermessage() ;\r
133         var _errorMessage = 'The SpellChecker Service is currently unavailable.' ;\r
134         if ( 'undefined' != typeof( oEditor.FCK.Config.WSChLoaderScript ) )\r
135             _errorMessage = '<div>The SpellChecker Service is currently unavailable.</div><p>Error loading application<br>service host: ' + oEditor.FCK.Config.WSChLoaderScript + '</p>';\r
136 \r
137         var burnSpelling = function( oName, _eMessage )\r
138         {\r
139                 var i = 0 ;\r
140 \r
141                 return function ()\r
142                 {\r
143                         if ( typeof( window[oName] ) == 'function' )\r
144                                 initAndSpell() ;\r
145                         else if ( i++ == 180 )\r
146                                 _cancelOnError( _eMessage ) ;\r
147                 }\r
148         }\r
149 \r
150         gInterval = window.setInterval( burnSpelling( 'doSpell', _errorMessage ), 250 ) ;\r
151 \r
152         // WSC CORE init section\r
153         var protocol = document.location.protocol || 'http:' ;\r
154         var baseUrl = protocol + '//loader.spellchecker.net/sproxy_fck/sproxy.php' ;\r
155         var plugin = "fck2" ;\r
156         var customerid = oEditor.FCK.Config.WSCnCustomerId\r
157                 || "1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk" ;\r
158         var wscCoreUrl = oEditor.FCK.Config.WSChLoaderScript\r
159                 || ( baseUrl + '?'\r
160                         + 'plugin='    + plugin + '&'\r
161                         + 'customerid='+ customerid + '&'\r
162                         + 'cmd=script&doc=wsc&schema=22' ) ;\r
163 \r
164         // load WSC core\r
165         doLoadScript( wscCoreUrl ) ;\r
166 }\r
167 \r
168 function initAndSpell()\r
169 {\r
170         //xall from window.setInteval expected at once\r
171         if ( typeof( gInterval ) == 'undefined' )\r
172                 return null ;\r
173         window.clearInterval( gInterval ) ;\r
174 \r
175         // global var is used in FCK specific core\r
176         // change on equal var used in fckplugin.js\r
177         gFCKPluginName = 'wsc' ;\r
178 \r
179         // get the data to be checked\r
180         var sData = oEditor.FCK.GetData() ;\r
181 \r
182         // prepare content\r
183         var ctrlId =  'myEditor' ;\r
184         var dCurT = document.getElementById( ctrlId ) ;\r
185         dCurT.value = sData ;\r
186 \r
187         // service paths corecting/preparing\r
188         var sPath2Scin = URL_abs2full( oEditor.FCK.Config.SkinDialogCSS ) ;\r
189         var sPathCiframe = FCKConfig.BasePath + 'wsc/ciframe.html' ;\r
190         var sPathFrameset = FCKConfig.BasePath + 'wsc/tmpFrameset.html' ;\r
191 \r
192         // language abbr standarts comparer\r
193         var LangComparer = new _SP_FCK_LangCompare() ;\r
194         LangComparer.setDefaulLangCode( oEditor.FCK.Language.DefaultLanguage ) ;\r
195 \r
196         // clear user message console (if application was loaded more then after 2 seconds)\r
197         clearErrorUsermessage() ;\r
198 \r
199         doSpell( {\r
200                 ctrl : ctrlId,\r
201                 lang : LangComparer.getSPLangCode( oEditor.FCK.Language.GetActiveLanguage() ),\r
202                 winType : 'wsc_frames',// if not defined app will run on winpopup\r
203 \r
204                 // callback binding section\r
205                 onCancel :window._callOnCancel,\r
206                 onFinish :window._callOnFinish,\r
207 \r
208                 // @TODO: basePath assingning\r
209 \r
210                 // some manipulations with client static pages\r
211                 framesetPath : sPathFrameset,\r
212                 iframePath : sPathCiframe,\r
213 \r
214                 // styles defining\r
215                 schemaURI : sPath2Scin\r
216         } ) ;\r
217 \r
218         return true ;\r
219 }\r
220 \r
221         </script>\r
222 </head>\r
223 <body onload="onLoad()" style="padding: 0px; overflow: hidden;">\r
224         <textarea style="display: none;" id="myEditor" rows="10" cols="40"></textarea>\r
225         <iframe src="" name="wsc_frames" id="wsc_frames"></iframe>\r
226 </body>\r
227 </html>\r