Rev 228 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
210 | PointedEar | 1 | var vulcan_texts = null; |
2 | |||
3 | var media_map = { |
||
4 | S: "?", |
||
5 | T: "Y", |
||
6 | P: "]", |
||
7 | K: "ß", |
||
8 | R: "²", |
||
9 | L: "ζ", |
||
10 | A: "Ŧ", |
||
11 | D: "S", |
||
12 | O: "Ŋ", |
||
13 | E: "σ", |
||
14 | V: "³", |
||
15 | U: "¶", |
||
16 | H: "ξ", |
||
17 | G: "^", |
||
235 | PointedEar | 18 | CH: ")", |
210 | PointedEar | 19 | I: "ƒ", |
20 | N: "(", |
||
21 | Z: "ε", |
||
22 | M: "δ", |
||
23 | Y: "ς", |
||
24 | F: "[", |
||
25 | W: "¬", |
||
26 | B: "Ξ", |
||
27 | SH: "§", |
||
28 | TH: "λ", |
||
29 | KH: "Φ", |
||
30 | ZH: "ω", |
||
31 | TS: "θ", |
||
32 | DZH: "C", |
||
33 | KS: "φ", |
||
235 | PointedEar | 34 | // LL: "μ", |
35 | // M: "&", |
||
36 | // NG: "ρ", |
||
37 | // NN: "þ", |
||
38 | // SS: "β", |
||
39 | // TCH: "M" |
||
210 | PointedEar | 40 | }; |
41 | |||
227 | PointedEar | 42 | var rxVulcan = jsx.object.getKeys(media_map); |
43 | rxVulcan.sort(function (a, b) { return b.length - a.length; }); |
||
44 | rxVulcan = new RegExp( |
||
45 | rxVulcan.filter(function (e) { return e.length > 1; }).join("|") |
||
46 | + "|[" + rxVulcan.filter(function (e) { return e.length === 1; }). join("") + "]", |
||
47 | "ig"); |
||
48 | |||
235 | PointedEar | 49 | function mediaTranscribe (s) |
50 | { |
||
51 | return s.toUpperCase().replace( |
||
52 | rxVulcan, |
||
53 | function (s) { |
||
54 | return jsx.object.getProperty(media_map, s.replace(/\s+/g, " "), s); |
||
55 | }); |
||
56 | } |
||
210 | PointedEar | 57 | |
235 | PointedEar | 58 | var LANG_VULCAN_MEDIA = "vuh-Media-Gol-modern"; |
227 | PointedEar | 59 | |
210 | PointedEar | 60 | function mediaScript (button) |
61 | { |
||
62 | vulcan_texts = jsx.dom.xpath.evaluate( |
||
228 | PointedEar | 63 | './/*[@class = "text" and (@lang = "' + LANG_VULCAN |
64 | + '" or parent::*[@lang = "' + LANG_VULCAN + '"])]', |
||
210 | PointedEar | 65 | document.body); |
66 | |||
67 | if (!vulcan_texts) |
||
68 | { |
||
69 | return; |
||
70 | } |
||
71 | |||
235 | PointedEar | 72 | if (document.documentElement.lang == LANG_VULCAN) |
73 | { |
||
74 | var title = document.getElementsByTagName("title")[0]; |
||
75 | title.setAttribute("data-text", document.title); |
||
76 | document.title = mediaTranscribe(document.title); |
||
77 | } |
||
78 | |||
210 | PointedEar | 79 | for (var i = 0, len = vulcan_texts.length; i < len; ++i) |
80 | { |
||
81 | var text = vulcan_texts[i]; |
||
82 | |||
83 | text.style.textTransform = "none"; |
||
84 | if (!text.hasAttribute("data-html")) |
||
85 | { |
||
86 | text.setAttribute("data-html", text.innerHTML); |
||
87 | |||
88 | if (!text.title) |
||
89 | { |
||
90 | text.title = text.textContent; |
||
91 | } |
||
235 | PointedEar | 92 | else |
93 | { |
||
94 | text.setAttribute("data-title", text.title); |
||
95 | text.title = mediaTranscribe(text.title); |
||
96 | } |
||
210 | PointedEar | 97 | } |
98 | |||
99 | var text_nodes = jsx.dom.xpath.evaluate( |
||
100 | './/text()[parent::*[not(@lang) or (@lang = "' + LANG_VULCAN + '")]]', |
||
101 | text); |
||
102 | |||
103 | for (var j = 0, len2 = text_nodes.length; j < len2; ++j) |
||
104 | { |
||
105 | var text_node = text_nodes[j]; |
||
106 | |||
235 | PointedEar | 107 | text_node.nodeValue = mediaTranscribe(text_node.nodeValue); |
210 | PointedEar | 108 | } |
109 | |||
235 | PointedEar | 110 | if (text.lang == LANG_VULCAN) |
111 | { |
||
112 | text.lang = LANG_VULCAN_MEDIA; |
||
113 | } |
||
114 | else if (text.parentNode.lang == LANG_VULCAN) |
||
115 | { |
||
116 | text.parentNode.lang = LANG_VULCAN_MEDIA; |
||
117 | } |
||
210 | PointedEar | 118 | } |
119 | |||
235 | PointedEar | 120 | if (button) |
210 | PointedEar | 121 | { |
235 | PointedEar | 122 | button.firstChild.lang = LANG_VULCAN; |
210 | PointedEar | 123 | } |
227 | PointedEar | 124 | |
235 | PointedEar | 125 | var html = document.documentElement; |
126 | if (html.lang == LANG_VULCAN) |
||
127 | { |
||
128 | html.lang = LANG_VULCAN_MEDIA; |
||
129 | } |
||
210 | PointedEar | 130 | } |
131 | |||
132 | function latinScript (button) |
||
133 | { |
||
235 | PointedEar | 134 | var title = document.getElementsByTagName("title")[0]; |
135 | if (document.documentElement.lang == LANG_VULCAN_MEDIA) |
||
136 | { |
||
137 | document.title = title.getAttribute("data-text"); |
||
138 | title.removeAttribute("data-text") |
||
139 | } |
||
140 | |||
210 | PointedEar | 141 | for (var i = 0, len = vulcan_texts.length; i < len; ++i) |
142 | { |
||
143 | var text = vulcan_texts[i]; |
||
144 | |||
145 | text.style.textTransform = ""; |
||
235 | PointedEar | 146 | text.innerHTML = text.getAttribute('data-html') || ""; |
147 | text.title = text.getAttribute("data-title") || ""; |
||
148 | |||
149 | if (text.lang == LANG_VULCAN_MEDIA) |
||
150 | { |
||
151 | text.lang = LANG_VULCAN; |
||
152 | } |
||
153 | else if (text.parentNode.lang == LANG_VULCAN_MEDIA) |
||
154 | { |
||
155 | text.parentNode.lang = LANG_VULCAN; |
||
156 | } |
||
210 | PointedEar | 157 | } |
158 | |||
235 | PointedEar | 159 | if (button) |
228 | PointedEar | 160 | { |
235 | PointedEar | 161 | button.firstChild.lang = LANG_VULCAN_MEDIA; |
228 | PointedEar | 162 | } |
227 | PointedEar | 163 | |
235 | PointedEar | 164 | var html = document.documentElement; |
165 | if (html.lang == LANG_VULCAN_MEDIA) |
||
166 | { |
||
167 | html.lang = LANG_VULCAN; |
||
168 | } |
||
210 | PointedEar | 169 | } |