活动问卷
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

wxDiscode.js 6.3 KiB

pirms 10 mēnešiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // HTML 支持的数学符号
  2. function strNumDiscode(str) {
  3. str = str.replace(/∀/g, '∀');
  4. str = str.replace(/∂/g, '∂');
  5. str = str.replace(/∃/g, '∃');
  6. str = str.replace(/∅/g, '∅');
  7. str = str.replace(/∇/g, '∇');
  8. str = str.replace(/∈/g, '∈');
  9. str = str.replace(/∉/g, '∉');
  10. str = str.replace(/∋/g, '∋');
  11. str = str.replace(/∏/g, '∏');
  12. str = str.replace(/∑/g, '∑');
  13. str = str.replace(/−/g, '−');
  14. str = str.replace(/∗/g, '∗');
  15. str = str.replace(/√/g, '√');
  16. str = str.replace(/∝/g, '∝');
  17. str = str.replace(/∞/g, '∞');
  18. str = str.replace(/∠/g, '∠');
  19. str = str.replace(/∧/g, '∧');
  20. str = str.replace(/∨/g, '∨');
  21. str = str.replace(/∩/g, '∩');
  22. str = str.replace(/∪/g, '∪');
  23. str = str.replace(/∫/g, '∫');
  24. str = str.replace(/∴/g, '∴');
  25. str = str.replace(/∼/g, '∼');
  26. str = str.replace(/≅/g, '≅');
  27. str = str.replace(/≈/g, '≈');
  28. str = str.replace(/≠/g, '≠');
  29. str = str.replace(/≤/g, '≤');
  30. str = str.replace(/≥/g, '≥');
  31. str = str.replace(/⊂/g, '⊂');
  32. str = str.replace(/⊃/g, '⊃');
  33. str = str.replace(/⊄/g, '⊄');
  34. str = str.replace(/⊆/g, '⊆');
  35. str = str.replace(/⊇/g, '⊇');
  36. str = str.replace(/⊕/g, '⊕');
  37. str = str.replace(/⊗/g, '⊗');
  38. str = str.replace(/⊥/g, '⊥');
  39. str = str.replace(/⋅/g, '⋅');
  40. return str;
  41. }
  42. // HTML 支持的希腊字母
  43. function strGreeceDiscode(str) {
  44. str = str.replace(/Α/g, 'Α');
  45. str = str.replace(/Β/g, 'Β');
  46. str = str.replace(/Γ/g, 'Γ');
  47. str = str.replace(/Δ/g, 'Δ');
  48. str = str.replace(/Ε/g, 'Ε');
  49. str = str.replace(/Ζ/g, 'Ζ');
  50. str = str.replace(/Η/g, 'Η');
  51. str = str.replace(/Θ/g, 'Θ');
  52. str = str.replace(/Ι/g, 'Ι');
  53. str = str.replace(/Κ/g, 'Κ');
  54. str = str.replace(/Λ/g, 'Λ');
  55. str = str.replace(/Μ/g, 'Μ');
  56. str = str.replace(/Ν/g, 'Ν');
  57. str = str.replace(/Ξ/g, 'Ν');
  58. str = str.replace(/Ο/g, 'Ο');
  59. str = str.replace(/Π/g, 'Π');
  60. str = str.replace(/Ρ/g, 'Ρ');
  61. str = str.replace(/Σ/g, 'Σ');
  62. str = str.replace(/Τ/g, 'Τ');
  63. str = str.replace(/Υ/g, 'Υ');
  64. str = str.replace(/Φ/g, 'Φ');
  65. str = str.replace(/Χ/g, 'Χ');
  66. str = str.replace(/Ψ/g, 'Ψ');
  67. str = str.replace(/Ω/g, 'Ω');
  68. str = str.replace(/α/g, 'α');
  69. str = str.replace(/β/g, 'β');
  70. str = str.replace(/γ/g, 'γ');
  71. str = str.replace(/δ/g, 'δ');
  72. str = str.replace(/ε/g, 'ε');
  73. str = str.replace(/ζ/g, 'ζ');
  74. str = str.replace(/η/g, 'η');
  75. str = str.replace(/θ/g, 'θ');
  76. str = str.replace(/ι/g, 'ι');
  77. str = str.replace(/κ/g, 'κ');
  78. str = str.replace(/λ/g, 'λ');
  79. str = str.replace(/μ/g, 'μ');
  80. str = str.replace(/ν/g, 'ν');
  81. str = str.replace(/ξ/g, 'ξ');
  82. str = str.replace(/ο/g, 'ο');
  83. str = str.replace(/π/g, 'π');
  84. str = str.replace(/ρ/g, 'ρ');
  85. str = str.replace(/ς/g, 'ς');
  86. str = str.replace(/σ/g, 'σ');
  87. str = str.replace(/τ/g, 'τ');
  88. str = str.replace(/υ/g, 'υ');
  89. str = str.replace(/φ/g, 'φ');
  90. str = str.replace(/χ/g, 'χ');
  91. str = str.replace(/ψ/g, 'ψ');
  92. str = str.replace(/ω/g, 'ω');
  93. str = str.replace(/ϑ/g, 'ϑ');
  94. str = str.replace(/ϒ/g, 'ϒ');
  95. str = str.replace(/ϖ/g, 'ϖ');
  96. str = str.replace(/·/g, '·');
  97. return str;
  98. }
  99. function strcharacterDiscode(str) {
  100. // 加入常用解析
  101. str = str.replace(/ /g, ' ');
  102. str = str.replace(/ /g, ' ');
  103. str = str.replace(/ /g, ' ');
  104. str = str.replace(/"/g, "'");
  105. str = str.replace(/&/g, '&');
  106. str = str.replace(/&lt;/g, '<');
  107. str = str.replace(/&gt;/g, '>');
  108. str = str.replace(/&#8226;/g, '•');
  109. return str;
  110. }
  111. // HTML 支持的其他实体
  112. function strOtherDiscode(str) {
  113. str = str.replace(/&OElig;/g, 'Œ');
  114. str = str.replace(/&oelig;/g, 'œ');
  115. str = str.replace(/&Scaron;/g, 'Š');
  116. str = str.replace(/&scaron;/g, 'š');
  117. str = str.replace(/&Yuml;/g, 'Ÿ');
  118. str = str.replace(/&fnof;/g, 'ƒ');
  119. str = str.replace(/&circ;/g, 'ˆ');
  120. str = str.replace(/&tilde;/g, '˜');
  121. str = str.replace(/&ensp;/g, '');
  122. str = str.replace(/&emsp;/g, '');
  123. str = str.replace(/&thinsp;/g, '');
  124. str = str.replace(/&zwnj;/g, '');
  125. str = str.replace(/&zwj;/g, '');
  126. str = str.replace(/&lrm;/g, '');
  127. str = str.replace(/&rlm;/g, '');
  128. str = str.replace(/&ndash;/g, '–');
  129. str = str.replace(/&mdash;/g, '—');
  130. str = str.replace(/&lsquo;/g, '‘');
  131. str = str.replace(/&rsquo;/g, '’');
  132. str = str.replace(/&sbquo;/g, '‚');
  133. str = str.replace(/&ldquo;/g, '“');
  134. str = str.replace(/&rdquo;/g, '”');
  135. str = str.replace(/&bdquo;/g, '„');
  136. str = str.replace(/&dagger;/g, '†');
  137. str = str.replace(/&Dagger;/g, '‡');
  138. str = str.replace(/&bull;/g, '•');
  139. str = str.replace(/&hellip;/g, '…');
  140. str = str.replace(/&permil;/g, '‰');
  141. str = str.replace(/&prime;/g, '′');
  142. str = str.replace(/&Prime;/g, '″');
  143. str = str.replace(/&lsaquo;/g, '‹');
  144. str = str.replace(/&rsaquo;/g, '›');
  145. str = str.replace(/&oline;/g, '‾');
  146. str = str.replace(/&euro;/g, '€');
  147. str = str.replace(/&trade;/g, '™');
  148. str = str.replace(/&larr;/g, '←');
  149. str = str.replace(/&uarr;/g, '↑');
  150. str = str.replace(/&rarr;/g, '→');
  151. str = str.replace(/&darr;/g, '↓');
  152. str = str.replace(/&harr;/g, '↔');
  153. str = str.replace(/&crarr;/g, '↵');
  154. str = str.replace(/&lceil;/g, '⌈');
  155. str = str.replace(/&rceil;/g, '⌉');
  156. str = str.replace(/&lfloor;/g, '⌊');
  157. str = str.replace(/&rfloor;/g, '⌋');
  158. str = str.replace(/&loz;/g, '◊');
  159. str = str.replace(/&spades;/g, '♠');
  160. str = str.replace(/&clubs;/g, '♣');
  161. str = str.replace(/&hearts;/g, '♥');
  162. str = str.replace(/&diams;/g, '♦');
  163. str = str.replace(/&#39;/g, "'");
  164. return str;
  165. }
  166. function strDiscode(str) {
  167. str = strNumDiscode(str);
  168. str = strGreeceDiscode(str);
  169. str = strcharacterDiscode(str);
  170. str = strOtherDiscode(str);
  171. return str;
  172. }
  173. function urlToHttpUrl(url, domain) {
  174. if (/^\/\//.test(url)) {
  175. return `https:${url}`;
  176. } else if (/^\//.test(url)) {
  177. return `https://${domain}${url}`;
  178. }
  179. return url;
  180. }
  181. export default {
  182. strDiscode,
  183. urlToHttpUrl,
  184. };