fckxhtmlentities.js
上传用户:dbstep
上传日期:2022-08-06
资源大小:2803k
文件大小:7k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

ASP/ASPX

  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. var FCKXHtmlEntities = new Object() ;
  24. FCKXHtmlEntities.Initialize = function()
  25. {
  26. if ( FCKXHtmlEntities.Entities )
  27. return ;
  28. var sChars = '' ;
  29. var oEntities, e ;
  30. if ( FCKConfig.ProcessHTMLEntities )
  31. {
  32. FCKXHtmlEntities.Entities = {
  33. // Latin-1 Entities
  34. ' ':'nbsp',
  35. '¡':'iexcl',
  36. '¢':'cent',
  37. '£':'pound',
  38. '¤':'curren',
  39. '¥':'yen',
  40. '¦':'brvbar',
  41. '§':'sect',
  42. '¨':'uml',
  43. '©':'copy',
  44. 'ª':'ordf',
  45. '«':'laquo',
  46. '¬':'not',
  47. '­':'shy',
  48. '®':'reg',
  49. '¯':'macr',
  50. '°':'deg',
  51. '±':'plusmn',
  52. '²':'sup2',
  53. '³':'sup3',
  54. '´':'acute',
  55. 'µ':'micro',
  56. '¶':'para',
  57. '·':'middot',
  58. '¸':'cedil',
  59. '¹':'sup1',
  60. 'º':'ordm',
  61. '»':'raquo',
  62. '¼':'frac14',
  63. '½':'frac12',
  64. '¾':'frac34',
  65. '¿':'iquest',
  66. '×':'times',
  67. '÷':'divide',
  68. // Symbols
  69. 'ƒ':'fnof',
  70. '•':'bull',
  71. '…':'hellip',
  72. '′':'prime',
  73. '″':'Prime',
  74. '‾':'oline',
  75. '⁄':'frasl',
  76. '℘':'weierp',
  77. 'ℑ':'image',
  78. 'ℜ':'real',
  79. '™':'trade',
  80. 'ℵ':'alefsym',
  81. '←':'larr',
  82. '↑':'uarr',
  83. '→':'rarr',
  84. '↓':'darr',
  85. '↔':'harr',
  86. '↵':'crarr',
  87. '⇐':'lArr',
  88. '⇑':'uArr',
  89. '⇒':'rArr',
  90. '⇓':'dArr',
  91. '⇔':'hArr',
  92. '∀':'forall',
  93. '∂':'part',
  94. '∃':'exist',
  95. '∅':'empty',
  96. '∇':'nabla',
  97. '∈':'isin',
  98. '∉':'notin',
  99. '∋':'ni',
  100. '∏':'prod',
  101. '∑':'sum',
  102. '−':'minus',
  103. '∗':'lowast',
  104. '√':'radic',
  105. '∝':'prop',
  106. '∞':'infin',
  107. '∠':'ang',
  108. '∧':'and',
  109. '∨':'or',
  110. '∩':'cap',
  111. '∪':'cup',
  112. '∫':'int',
  113. '∴':'there4',
  114. '∼':'sim',
  115. '≅':'cong',
  116. '≈':'asymp',
  117. '≠':'ne',
  118. '≡':'equiv',
  119. '≤':'le',
  120. '≥':'ge',
  121. '⊂':'sub',
  122. '⊃':'sup',
  123. '⊄':'nsub',
  124. '⊆':'sube',
  125. '⊇':'supe',
  126. '⊕':'oplus',
  127. '⊗':'otimes',
  128. '⊥':'perp',
  129. '⋅':'sdot',
  130. 'u2308':'lceil',
  131. 'u2309':'rceil',
  132. 'u230a':'lfloor',
  133. 'u230b':'rfloor',
  134. 'u2329':'lang',
  135. 'u232a':'rang',
  136. '◊':'loz',
  137. '♠':'spades',
  138. '♣':'clubs',
  139. '♥':'hearts',
  140. '♦':'diams',
  141. // Other Special Characters
  142. '"':'quot',
  143. // '&':'amp', // This entity is automatically handled by the XHTML parser.
  144. // '<':'lt', // This entity is automatically handled by the XHTML parser.
  145. '>':'gt', // Opera and Safari don't encode it in their implementation
  146. 'ˆ':'circ',
  147. '˜':'tilde',
  148. ' ':'ensp',
  149. ' ':'emsp',
  150. ' ':'thinsp',
  151. '‌':'zwnj',
  152. '‍':'zwj',
  153. '‎':'lrm',
  154. '‏':'rlm',
  155. '–':'ndash',
  156. '—':'mdash',
  157. '‘':'lsquo',
  158. '’':'rsquo',
  159. '‚':'sbquo',
  160. '“':'ldquo',
  161. '”':'rdquo',
  162. '„':'bdquo',
  163. '†':'dagger',
  164. '‡':'Dagger',
  165. '‰':'permil',
  166. '‹':'lsaquo',
  167. '›':'rsaquo',
  168. '€':'euro'
  169. } ;
  170. // Process Base Entities.
  171. for ( e in FCKXHtmlEntities.Entities )
  172. sChars += e ;
  173. // Include Latin Letters Entities.
  174. if ( FCKConfig.IncludeLatinEntities )
  175. {
  176. oEntities = {
  177. 'À':'Agrave',
  178. 'Á':'Aacute',
  179. 'Â':'Acirc',
  180. 'Ã':'Atilde',
  181. 'Ä':'Auml',
  182. 'Å':'Aring',
  183. 'Æ':'AElig',
  184. 'Ç':'Ccedil',
  185. 'È':'Egrave',
  186. 'É':'Eacute',
  187. 'Ê':'Ecirc',
  188. 'Ë':'Euml',
  189. 'Ì':'Igrave',
  190. 'Í':'Iacute',
  191. 'Î':'Icirc',
  192. 'Ï':'Iuml',
  193. 'Ð':'ETH',
  194. 'Ñ':'Ntilde',
  195. 'Ò':'Ograve',
  196. 'Ó':'Oacute',
  197. 'Ô':'Ocirc',
  198. 'Õ':'Otilde',
  199. 'Ö':'Ouml',
  200. 'Ø':'Oslash',
  201. 'Ù':'Ugrave',
  202. 'Ú':'Uacute',
  203. 'Û':'Ucirc',
  204. 'Ü':'Uuml',
  205. 'Ý':'Yacute',
  206. 'Þ':'THORN',
  207. 'ß':'szlig',
  208. 'à':'agrave',
  209. 'á':'aacute',
  210. 'â':'acirc',
  211. 'ã':'atilde',
  212. 'ä':'auml',
  213. 'å':'aring',
  214. 'æ':'aelig',
  215. 'ç':'ccedil',
  216. 'è':'egrave',
  217. 'é':'eacute',
  218. 'ê':'ecirc',
  219. 'ë':'euml',
  220. 'ì':'igrave',
  221. 'í':'iacute',
  222. 'î':'icirc',
  223. 'ï':'iuml',
  224. 'ð':'eth',
  225. 'ñ':'ntilde',
  226. 'ò':'ograve',
  227. 'ó':'oacute',
  228. 'ô':'ocirc',
  229. 'õ':'otilde',
  230. 'ö':'ouml',
  231. 'ø':'oslash',
  232. 'ù':'ugrave',
  233. 'ú':'uacute',
  234. 'û':'ucirc',
  235. 'ü':'uuml',
  236. 'ý':'yacute',
  237. 'þ':'thorn',
  238. 'ÿ':'yuml',
  239. 'Œ':'OElig',
  240. 'œ':'oelig',
  241. 'Š':'Scaron',
  242. 'š':'scaron',
  243. 'Ÿ':'Yuml'
  244. } ;
  245. for ( e in oEntities )
  246. {
  247. FCKXHtmlEntities.Entities[ e ] = oEntities[ e ] ;
  248. sChars += e ;
  249. }
  250. oEntities = null ;
  251. }
  252. // Include Greek Letters Entities.
  253. if ( FCKConfig.IncludeGreekEntities )
  254. {
  255. oEntities = {
  256. 'Α':'Alpha',
  257. 'Β':'Beta',
  258. 'Γ':'Gamma',
  259. 'Δ':'Delta',
  260. 'Ε':'Epsilon',
  261. 'Ζ':'Zeta',
  262. 'Η':'Eta',
  263. 'Θ':'Theta',
  264. 'Ι':'Iota',
  265. 'Κ':'Kappa',
  266. 'Λ':'Lambda',
  267. 'Μ':'Mu',
  268. 'Ν':'Nu',
  269. 'Ξ':'Xi',
  270. 'Ο':'Omicron',
  271. 'Π':'Pi',
  272. 'Ρ':'Rho',
  273. 'Σ':'Sigma',
  274. 'Τ':'Tau',
  275. 'Υ':'Upsilon',
  276. 'Φ':'Phi',
  277. 'Χ':'Chi',
  278. 'Ψ':'Psi',
  279. 'Ω':'Omega',
  280. 'α':'alpha',
  281. 'β':'beta',
  282. 'γ':'gamma',
  283. 'δ':'delta',
  284. 'ε':'epsilon',
  285. 'ζ':'zeta',
  286. 'η':'eta',
  287. 'θ':'theta',
  288. 'ι':'iota',
  289. 'κ':'kappa',
  290. 'λ':'lambda',
  291. 'μ':'mu',
  292. 'ν':'nu',
  293. 'ξ':'xi',
  294. 'ο':'omicron',
  295. 'π':'pi',
  296. 'ρ':'rho',
  297. 'ς':'sigmaf',
  298. 'σ':'sigma',
  299. 'τ':'tau',
  300. 'υ':'upsilon',
  301. 'φ':'phi',
  302. 'χ':'chi',
  303. 'ψ':'psi',
  304. 'ω':'omega',
  305. 'u03d1':'thetasym',
  306. 'u03d2':'upsih',
  307. 'u03d6':'piv'
  308. } ;
  309. for ( e in oEntities )
  310. {
  311. FCKXHtmlEntities.Entities[ e ] = oEntities[ e ] ;
  312. sChars += e ;
  313. }
  314. oEntities = null ;
  315. }
  316. }
  317. else
  318. {
  319. FCKXHtmlEntities.Entities = {
  320. '>':'gt' // Opera and Safari don't encode it in their implementation
  321. } ;
  322. sChars = '>';
  323. // Even if we are not processing the entities, we must render the &nbsp;
  324. // correctly. As we don't want HTML entities, let's use its numeric
  325. // representation (&#160).
  326. sChars += ' ' ;
  327. }
  328. // Create the Regex used to find entities in the text.
  329. var sRegexPattern = '[' + sChars + ']' ;
  330. if ( FCKConfig.ProcessNumericEntities )
  331. sRegexPattern = '[^ -~]|' + sRegexPattern ;
  332. var sAdditional = FCKConfig.AdditionalNumericEntities ;
  333. if ( sAdditional && sAdditional.length > 0 )
  334. sRegexPattern += '|' + FCKConfig.AdditionalNumericEntities ;
  335. FCKXHtmlEntities.EntitiesRegex = new RegExp( sRegexPattern, 'g' ) ;
  336. }