root / trunk / web / dojo / dojox / html / entities.js @ 12
History | View | Annotate | Download (5.31 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.html.entities"]){ |
9 |
dojo._hasResource["dojox.html.entities"]=true; |
10 |
dojo.provide("dojox.html.entities");
|
11 |
(function(){
|
12 |
var _1=function(_2,_3){ |
13 |
var _4,_5;
|
14 |
if(_3._encCache&&_3._encCache.regexp&&_3._encCache.mapper&&_3.length==_3._encCache.length){
|
15 |
_4=_3._encCache.mapper; |
16 |
_5=_3._encCache.regexp; |
17 |
}else{
|
18 |
_4={}; |
19 |
_5=["["];
|
20 |
var i;
|
21 |
for(i=0;i<_3.length;i++){ |
22 |
_4[_3[i][0]]="&"+_3[i][1]+";"; |
23 |
_5.push(_3[i][0]);
|
24 |
} |
25 |
_5.push("]");
|
26 |
_5=new RegExp(_5.join(""),"g"); |
27 |
_3._encCache={mapper:_4,regexp:_5,length:_3.length}; |
28 |
} |
29 |
_2=_2.replace(_5,function(c){
|
30 |
return _4[c];
|
31 |
}); |
32 |
return _2;
|
33 |
}; |
34 |
var _6=function(_7,_8){ |
35 |
var _9,_a;
|
36 |
if(_8._decCache&&_8._decCache.regexp&&_8._decCache.mapper&&_8.length==_8._decCache.length){
|
37 |
_9=_8._decCache.mapper; |
38 |
_a=_8._decCache.regexp; |
39 |
}else{
|
40 |
_9={}; |
41 |
_a=["("];
|
42 |
var i;
|
43 |
for(i=0;i<_8.length;i++){ |
44 |
var e="&"+_8[i][1]+";"; |
45 |
if(i){
|
46 |
_a.push("|");
|
47 |
} |
48 |
_9[e]=_8[i][0];
|
49 |
_a.push(e); |
50 |
} |
51 |
_a.push(")");
|
52 |
_a=new RegExp(_a.join(""),"g"); |
53 |
_8._decCache={mapper:_9,regexp:_a,length:_8.length}; |
54 |
} |
55 |
_7=_7.replace(_a,function(c){
|
56 |
return _9[c];
|
57 |
}); |
58 |
return _7;
|
59 |
}; |
60 |
dojox.html.entities.html=[["&","amp"],["\"","quot"],["<","lt"],[">","gt"],[" ","nbsp"]]; |
61 |
dojox.html.entities.latin=[["¡","iexcl"],["¢","cent"],["£","pound"],["€","euro"],["¤","curren"],["¥","yen"],["¦","brvbar"],["§","sect"],["¨","uml"],["©","copy"],["ª","ordf"],["«","laquo"],["¬","not"],["","shy"],["®","reg"],["¯","macr"],["°","deg"],["±","plusmn"],["²","sup2"],["³","sup3"],["´","acute"],["µ","micro"],["¶","para"],["·","middot"],["¸","cedil"],["¹","sup1"],["º","ordm"],["»","raquo"],["¼","frac14"],["½","frac12"],["¾","frac34"],["¿","iquest"],["À","Agrave"],["Á","Aacute"],["Â","Acirc"],["Ã","Atilde"],["Ä","Auml"],["Å","Aring"],["Æ","AElig"],["Ç","Ccedil"],["È","Egrave"],["É","Eacute"],["Ê","Ecirc"],["Ë","Euml"],["Ì","Igrave"],["Í","Iacute"],["Î","Icirc"],["Ï","Iuml"],["Ð","ETH"],["Ñ","Ntilde"],["Ò","Ograve"],["Ó","Oacute"],["Ô","Ocirc"],["Õ","Otilde"],["Ö","Ouml"],["×","times"],["Ø","Oslash"],["Ù","Ugrave"],["Ú","Uacute"],["Û","Ucirc"],["Ü","Uuml"],["Ý","Yacute"],["Þ","THORN"],["ß","szlig"],["à","agrave"],["á","aacute"],["â","acirc"],["ã","atilde"],["ä","auml"],["å","aring"],["æ","aelig"],["ç","ccedil"],["è","egrave"],["é","eacute"],["ê","ecirc"],["ë","euml"],["ì","igrave"],["í","iacute"],["î","icirc"],["ï","iuml"],["ð","eth"],["ñ","ntilde"],["ò","ograve"],["ó","oacute"],["ô","ocirc"],["õ","otilde"],["ö","ouml"],["÷","divide"],["ø","oslash"],["ù","ugrave"],["ú","uacute"],["û","ucirc"],["ü","uuml"],["ý","yacute"],["þ","thorn"],["ÿ","yuml"],["ƒ","fnof"],["Α","Alpha"],["Β","Beta"],["Γ","Gamma"],["Δ","Delta"],["Ε","Epsilon"],["Ζ","Zeta"],["Η","Eta"],["Θ","Theta"],["Ι","Iota"],["Κ","Kappa"],["Λ","Lambda"],["Μ","Mu"],["Ν","Nu"],["Ξ","Xi"],["Ο","Omicron"],["Π","Pi"],["Ρ","Rho"],["Σ","Sigma"],["Τ","Tau"],["Υ","Upsilon"],["Φ","Phi"],["Χ","Chi"],["Ψ","Psi"],["Ω","Omega"],["α","alpha"],["β","beta"],["γ","gamma"],["δ","delta"],["ε","epsilon"],["ζ","zeta"],["η","eta"],["θ","theta"],["ι","iota"],["κ","kappa"],["λ","lambda"],["μ","mu"],["ν","nu"],["ξ","xi"],["ο","omicron"],["π","pi"],["ρ","rho"],["ς","sigmaf"],["σ","sigma"],["τ","tau"],["υ","upsilon"],["φ","phi"],["χ","chi"],["ψ","psi"],["ω","omega"],["ϑ","thetasym"],["ϒ","upsih"],["ϖ","piv"],["•","bull"],["…","hellip"],["′","prime"],["″","Prime"],["‾","oline"],["⁄","frasl"],["℘","weierp"],["ℑ","image"],["ℜ","real"],["™","trade"],["ℵ","alefsym"],["←","larr"],["↑","uarr"],["→","rarr"],["↓","darr"],["↔","harr"],["↵","crarr"],["⇐","lArr"],["⇑","uArr"],["⇒","rArr"],["⇓","dArr"],["⇔","hArr"],["∀","forall"],["∂","part"],["∃","exist"],["∅","empty"],["∇","nabla"],["∈","isin"],["∉","notin"],["∋","ni"],["∏","prod"],["∑","sum"],["−","minus"],["∗","lowast"],["√","radic"],["∝","prop"],["∞","infin"],["∠","ang"],["∧","and"],["∨","or"],["∩","cap"],["∪","cup"],["∫","int"],["∴","there4"],["∼","sim"],["≅","cong"],["≈","asymp"],["≠","ne"],["≡","equiv"],["≤","le"],["≥","ge"],["⊂","sub"],["⊃","sup"],["⊄","nsub"],["⊆","sube"],["⊇","supe"],["⊕","oplus"],["⊗","otimes"],["⊥","perp"],["⋅","sdot"],["⌈","lceil"],["⌉","rceil"],["⌊","lfloor"],["⌋","rfloor"],["〈","lang"],["〉","rang"],["◊","loz"],["♠","spades"],["♣","clubs"],["♥","hearts"],["♦","diams"],["Œ","Elig"],["œ","oelig"],["Š","Scaron"],["š","scaron"],["Ÿ","Yuml"],["ˆ","circ"],["˜","tilde"],[" ","ensp"],[" ","emsp"],[" ","thinsp"],["","zwnj"],["","zwj"],["","lrm"],["","rlm"],["–","ndash"],["—","mdash"],["‘","lsquo"],["’","rsquo"],["‚","sbquo"],["“","ldquo"],["”","rdquo"],["„","bdquo"],["†","dagger"],["‡","Dagger"],["‰","permil"],["‹","lsaquo"],["›","rsaquo"]]; |
62 |
dojox.html.entities.encode=function(_b,m){ |
63 |
if(_b){
|
64 |
if(!m){
|
65 |
_b=_1(_b,dojox.html.entities.html); |
66 |
_b=_1(_b,dojox.html.entities.latin); |
67 |
}else{
|
68 |
_b=_1(_b,m); |
69 |
} |
70 |
} |
71 |
return _b;
|
72 |
}; |
73 |
dojox.html.entities.decode=function(_c,m){ |
74 |
if(_c){
|
75 |
if(!m){
|
76 |
_c=_6(_c,dojox.html.entities.html); |
77 |
_c=_6(_c,dojox.html.entities.latin); |
78 |
}else{
|
79 |
_c=_6(_c,m); |
80 |
} |
81 |
} |
82 |
return _c;
|
83 |
}; |
84 |
})(); |
85 |
} |