var vulcan_texts = null; var media_map = { S: "?", T: "Y", P: "]", K: "ß", R: "²", L: "ζ", A: "Ŧ", D: "S", O: "Ŋ", E: "σ", V: "³", U: "¶", H: "ξ", G: "^", CH: ")", I: "ƒ", N: "(", Z: "ε", M: "δ", Y: "ς", F: "[", W: "¬", B: "Ξ", SH: "§", TH: "λ", KH: "Φ", ZH: "ω", TS: "θ", DZH: "C", KS: "φ", // LL: "μ", // M: "&", // NG: "ρ", // NN: "þ", // SS: "β", // TCH: "M" }; var rxVulcan = jsx.object.getKeys(media_map); rxVulcan.sort(function (a, b) { return b.length - a.length; }); rxVulcan = new RegExp( rxVulcan.filter(function (e) { return e.length > 1; }).join("|") + "|[" + rxVulcan.filter(function (e) { return e.length === 1; }). join("") + "]", "ig"); function mediaTranscribe (s) { return s.toUpperCase().replace( rxVulcan, function (s) { return jsx.object.getProperty(media_map, s.replace(/\s+/g, " "), s); }); } var LANG_VULCAN_MEDIA = "vuh-Media-Gol-modern"; function mediaScript (button) { vulcan_texts = jsx.dom.xpath.evaluate( './/*[@class = "text" and (@lang = "' + LANG_VULCAN + '" or parent::*[@lang = "' + LANG_VULCAN + '"])]', document.body); if (!vulcan_texts) { return; } if (document.documentElement.lang == LANG_VULCAN) { var title = document.getElementsByTagName("title")[0]; title.setAttribute("data-text", document.title); document.title = mediaTranscribe(document.title); } for (var i = 0, len = vulcan_texts.length; i < len; ++i) { var text = vulcan_texts[i]; text.style.textTransform = "none"; if (!text.hasAttribute("data-html")) { text.setAttribute("data-html", text.innerHTML); if (!text.title) { text.title = text.textContent; } else { text.setAttribute("data-title", text.title); text.title = mediaTranscribe(text.title); } } var text_nodes = jsx.dom.xpath.evaluate( './/text()[parent::*[not(@lang) or (@lang = "' + LANG_VULCAN + '")]]', text); for (var j = 0, len2 = text_nodes.length; j < len2; ++j) { var text_node = text_nodes[j]; text_node.nodeValue = mediaTranscribe(text_node.nodeValue); } if (text.lang == LANG_VULCAN) { text.lang = LANG_VULCAN_MEDIA; } else if (text.parentNode.lang == LANG_VULCAN) { text.parentNode.lang = LANG_VULCAN_MEDIA; } } if (button) { button.firstChild.lang = LANG_VULCAN; } var html = document.documentElement; if (html.lang == LANG_VULCAN) { html.lang = LANG_VULCAN_MEDIA; } } function latinScript (button) { var title = document.getElementsByTagName("title")[0]; if (document.documentElement.lang == LANG_VULCAN_MEDIA) { document.title = title.getAttribute("data-text"); title.removeAttribute("data-text") } for (var i = 0, len = vulcan_texts.length; i < len; ++i) { var text = vulcan_texts[i]; text.style.textTransform = ""; text.innerHTML = text.getAttribute('data-html') || ""; text.title = text.getAttribute("data-title") || ""; if (text.lang == LANG_VULCAN_MEDIA) { text.lang = LANG_VULCAN; } else if (text.parentNode.lang == LANG_VULCAN_MEDIA) { text.parentNode.lang = LANG_VULCAN; } } if (button) { button.firstChild.lang = LANG_VULCAN_MEDIA; } var html = document.documentElement; if (html.lang == LANG_VULCAN_MEDIA) { html.lang = LANG_VULCAN; } }