PageRenderTime 64ms CodeModel.GetById 18ms app.highlight 40ms RepoModel.GetById 1ms app.codeStats 0ms

/pigeoncms/Plugins/fckeditor/editor/_source/internals/fckxhtmlentities.js

http://pigeoncms.googlecode.com/
JavaScript | 357 lines | 324 code | 8 blank | 25 comment | 2 complexity | 77694778789404319a6292ed3043f329 MD5 | raw file
  1/*
  2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
  4 *
  5 * == BEGIN LICENSE ==
  6 *
  7 * Licensed under the terms of any of the following licenses at your
  8 * choice:
  9 *
 10 *  - GNU General Public License Version 2 or later (the "GPL")
 11 *    http://www.gnu.org/licenses/gpl.html
 12 *
 13 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 14 *    http://www.gnu.org/licenses/lgpl.html
 15 *
 16 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 17 *    http://www.mozilla.org/MPL/MPL-1.1.html
 18 *
 19 * == END LICENSE ==
 20 *
 21 * This file define the HTML entities handled by the editor.
 22 */
 23
 24var FCKXHtmlEntities = new Object() ;
 25
 26FCKXHtmlEntities.Initialize = function()
 27{
 28	if ( FCKXHtmlEntities.Entities )
 29		return ;
 30
 31	var sChars = '' ;
 32	var oEntities, e ;
 33
 34	if ( FCKConfig.ProcessHTMLEntities )
 35	{
 36		FCKXHtmlEntities.Entities = {
 37			// Latin-1 Entities
 38			' ':'nbsp',
 39			'Ą':'iexcl',
 40			'˘':'cent',
 41			'Ł':'pound',
 42			'¤':'curren',
 43			'Ľ':'yen',
 44			'Ś':'brvbar',
 45			'§':'sect',
 46			'¨':'uml',
 47			'Š':'copy',
 48			'Ş':'ordf',
 49			'Ť':'laquo',
 50			'Ź':'not',
 51			'­':'shy',
 52			'Ž':'reg',
 53			'Ż':'macr',
 54			'°':'deg',
 55			'ą':'plusmn',
 56			'˛':'sup2',
 57			'ł':'sup3',
 58			'´':'acute',
 59			'ľ':'micro',
 60			'ś':'para',
 61			'ˇ':'middot',
 62			'¸':'cedil',
 63			'š':'sup1',
 64			'ş':'ordm',
 65			'ť':'raquo',
 66			'ź':'frac14',
 67			'˝':'frac12',
 68			'ž':'frac34',
 69			'ż':'iquest',
 70			'×':'times',
 71			'÷':'divide',
 72
 73			// Symbols
 74
 75			'ƒ':'fnof',
 76			'•':'bull',
 77			'…':'hellip',
 78			'?':'prime',
 79			'?':'Prime',
 80			'?':'oline',
 81			'?':'frasl',
 82			'?':'weierp',
 83			'?':'image',
 84			'?':'real',
 85			'™':'trade',
 86			'?':'alefsym',
 87			'?':'larr',
 88			'?':'uarr',
 89			'?':'rarr',
 90			'?':'darr',
 91			'?':'harr',
 92			'?':'crarr',
 93			'?':'lArr',
 94			'?':'uArr',
 95			'?':'rArr',
 96			'?':'dArr',
 97			'?':'hArr',
 98			'?':'forall',
 99			'?':'part',
100			'?':'exist',
101			'?':'empty',
102			'?':'nabla',
103			'?':'isin',
104			'?':'notin',
105			'?':'ni',
106			'?':'prod',
107			'?':'sum',
108			'?':'minus',
109			'?':'lowast',
110			'?':'radic',
111			'?':'prop',
112			'?':'infin',
113			'?':'ang',
114			'?':'and',
115			'?':'or',
116			'?':'cap',
117			'?':'cup',
118			'?':'int',
119			'?':'there4',
120			'?':'sim',
121			'?':'cong',
122			'?':'asymp',
123			'?':'ne',
124			'?':'equiv',
125			'?':'le',
126			'?':'ge',
127			'?':'sub',
128			'?':'sup',
129			'?':'nsub',
130			'?':'sube',
131			'?':'supe',
132			'?':'oplus',
133			'?':'otimes',
134			'?':'perp',
135			'?':'sdot',
136			'\u2308':'lceil',
137			'\u2309':'rceil',
138			'\u230a':'lfloor',
139			'\u230b':'rfloor',
140			'\u2329':'lang',
141			'\u232a':'rang',
142			'?':'loz',
143			'?':'spades',
144			'?':'clubs',
145			'?':'hearts',
146			'?':'diams',
147
148			// Other Special Characters
149
150			'"':'quot',
151		//	'&':'amp',		// This entity is automatically handled by the XHTML parser.
152		//	'<':'lt',		// This entity is automatically handled by the XHTML parser.
153			'>':'gt',			// Opera and Safari don't encode it in their implementation
154			'ˆ':'circ',
155			'˜':'tilde',
156			'?':'ensp',
157			'?':'emsp',
158			'?':'thinsp',
159			'?':'zwnj',
160			'?':'zwj',
161			'?':'lrm',
162			'?':'rlm',
163			'–':'ndash',
164			'—':'mdash',
165			'‘':'lsquo',
166			'’':'rsquo',
167			'‚':'sbquo',
168			'“':'ldquo',
169			'”':'rdquo',
170			'„':'bdquo',
171			'†':'dagger',
172			'‡':'Dagger',
173			'‰':'permil',
174			'‹':'lsaquo',
175			'›':'rsaquo',
176			'€':'euro'
177		} ;
178
179		// Process Base Entities.
180		for ( e in FCKXHtmlEntities.Entities )
181			sChars += e ;
182
183		// Include Latin Letters Entities.
184		if ( FCKConfig.IncludeLatinEntities )
185		{
186			oEntities = {
187				'Ŕ':'Agrave',
188				'Á':'Aacute',
189				'Â':'Acirc',
190				'Ă':'Atilde',
191				'Ä':'Auml',
192				'Ĺ':'Aring',
193				'Ć':'AElig',
194				'Ç':'Ccedil',
195				'Č':'Egrave',
196				'É':'Eacute',
197				'Ę':'Ecirc',
198				'Ë':'Euml',
199				'Ě':'Igrave',
200				'Í':'Iacute',
201				'Î':'Icirc',
202				'Ď':'Iuml',
203				'Đ':'ETH',
204				'Ń':'Ntilde',
205				'Ň':'Ograve',
206				'Ó':'Oacute',
207				'Ô':'Ocirc',
208				'Ő':'Otilde',
209				'Ö':'Ouml',
210				'Ř':'Oslash',
211				'Ů':'Ugrave',
212				'Ú':'Uacute',
213				'Ű':'Ucirc',
214				'Ü':'Uuml',
215				'Ý':'Yacute',
216				'Ţ':'THORN',
217				'ß':'szlig',
218				'ŕ':'agrave',
219				'á':'aacute',
220				'â':'acirc',
221				'ă':'atilde',
222				'ä':'auml',
223				'ĺ':'aring',
224				'ć':'aelig',
225				'ç':'ccedil',
226				'č':'egrave',
227				'é':'eacute',
228				'ę':'ecirc',
229				'ë':'euml',
230				'ě':'igrave',
231				'í':'iacute',
232				'î':'icirc',
233				'ď':'iuml',
234				'đ':'eth',
235				'ń':'ntilde',
236				'ň':'ograve',
237				'ó':'oacute',
238				'ô':'ocirc',
239				'ő':'otilde',
240				'ö':'ouml',
241				'ř':'oslash',
242				'ů':'ugrave',
243				'ú':'uacute',
244				'ű':'ucirc',
245				'ü':'uuml',
246				'ý':'yacute',
247				'ţ':'thorn',
248				'˙':'yuml',
249				'Œ':'OElig',
250				'œ':'oelig',
251				'Š':'Scaron',
252				'š':'scaron',
253				'Ÿ':'Yuml'
254			} ;
255
256			for ( e in oEntities )
257			{
258				FCKXHtmlEntities.Entities[ e ] = oEntities[ e ] ;
259				sChars += e ;
260			}
261
262			oEntities = null ;
263		}
264
265		// Include Greek Letters Entities.
266		if ( FCKConfig.IncludeGreekEntities )
267		{
268			oEntities = {
269				'?':'Alpha',
270				'?':'Beta',
271				'?':'Gamma',
272				'?':'Delta',
273				'?':'Epsilon',
274				'?':'Zeta',
275				'?':'Eta',
276				'?':'Theta',
277				'?':'Iota',
278				'?':'Kappa',
279				'?':'Lambda',
280				'?':'Mu',
281				'?':'Nu',
282				'?':'Xi',
283				'?':'Omicron',
284				'?':'Pi',
285				'?':'Rho',
286				'?':'Sigma',
287				'?':'Tau',
288				'?':'Upsilon',
289				'?':'Phi',
290				'?':'Chi',
291				'?':'Psi',
292				'?':'Omega',
293				'?':'alpha',
294				'?':'beta',
295				'?':'gamma',
296				'?':'delta',
297				'?':'epsilon',
298				'?':'zeta',
299				'?':'eta',
300				'?':'theta',
301				'?':'iota',
302				'?':'kappa',
303				'?':'lambda',
304				'?':'mu',
305				'?':'nu',
306				'?':'xi',
307				'?':'omicron',
308				'?':'pi',
309				'?':'rho',
310				'?':'sigmaf',
311				'?':'sigma',
312				'?':'tau',
313				'?':'upsilon',
314				'?':'phi',
315				'?':'chi',
316				'?':'psi',
317				'?':'omega',
318				'\u03d1':'thetasym',
319				'\u03d2':'upsih',
320				'\u03d6':'piv'
321			} ;
322
323			for ( e in oEntities )
324			{
325				FCKXHtmlEntities.Entities[ e ] = oEntities[ e ] ;
326				sChars += e ;
327			}
328
329			oEntities = null ;
330		}
331	}
332	else
333	{
334		FCKXHtmlEntities.Entities = {
335			'>':'gt' // Opera and Safari don't encode it in their implementation
336		} ;
337		sChars = '>';
338
339		// Even if we are not processing the entities, we must render the &nbsp;
340		// correctly. As we don't want HTML entities, let's use its numeric
341		// representation (&#160).
342		sChars += ' ' ;
343	}
344
345	// Create the Regex used to find entities in the text.
346	var sRegexPattern = '[' + sChars + ']' ;
347
348	if ( FCKConfig.ProcessNumericEntities )
349		sRegexPattern = '[^ -~]|' + sRegexPattern ;
350
351	var sAdditional = FCKConfig.AdditionalNumericEntities ;
352
353	if ( sAdditional && sAdditional.length > 0 )
354		sRegexPattern += '|' + FCKConfig.AdditionalNumericEntities ;
355
356	FCKXHtmlEntities.EntitiesRegex = new RegExp( sRegexPattern, 'g' ) ;
357}