Subversion Repositories LCARS

Rev

Rev 227 | Go to most recent revision | 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: "^",
18
  Ch: ")",
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
  J: "C",
34
  KS: "φ",
35
  X: "φ",
36
  LL: "μ",
37
  M: "&",
38
  NG: "ρ",
39
  NN: "þ",
40
  SS: "β",
227 PointedEar 41
  TCH: "M"
210 PointedEar 42
};
43
 
227 PointedEar 44
var rxVulcan = jsx.object.getKeys(media_map);
45
rxVulcan.sort(function (a, b) { return b.length - a.length; });
46
rxVulcan = new RegExp(
47
  rxVulcan.filter(function (e) { return e.length > 1; }).join("|")
48
    + "|[" + rxVulcan.filter(function (e) { return e.length === 1; }). join("") + "]",
49
  "ig");
50
 
210 PointedEar 51
//jsx.object.flip = function (obj) {
52
//  var flipped = jsx.object.inheritFrom(obj);
53
//  var keys = jsx.object.getKeys(obj);
54
//
55
//  for (var i = 0, len = keys.length; i < len; ++i)
56
//  {
57
//    var key = keys[i];
58
//    var value = obj[key];
59
//    if (typeof value != "function")
60
//    {
61
//      flipped[value] = key;
62
//    }
63
//  }
64
//
65
//  return flipped;
66
//};
67
 
227 PointedEar 68
var media_script_used = false;
69
 
210 PointedEar 70
function mediaScript (button)
71
{
72
  vulcan_texts = jsx.dom.xpath.evaluate(
228 PointedEar 73
    './/*[@class = "text" and (@lang = "' + LANG_VULCAN
74
      + '" or parent::*[@lang = "' + LANG_VULCAN + '"])]',
210 PointedEar 75
    document.body);
76
 
77
  if (!vulcan_texts)
78
  {
79
    return;
80
  }
81
 
82
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
83
  {
84
    var text = vulcan_texts[i];
85
 
86
    text.style.textTransform = "none";
87
    if (!text.hasAttribute("data-html"))
88
    {
89
      text.setAttribute("data-html", text.innerHTML);
90
 
91
      if (!text.title)
92
      {
93
        text.title = text.textContent;
94
      }
95
    }
96
 
97
    var text_nodes = jsx.dom.xpath.evaluate(
98
      './/text()[parent::*[not(@lang) or (@lang = "' + LANG_VULCAN + '")]]',
99
      text);
100
 
101
    for (var j = 0, len2 = text_nodes.length; j < len2; ++j)
102
    {
103
      var text_node = text_nodes[j];
104
 
228 PointedEar 105
      text_node.nodeValue = text_node.nodeValue.replace(
106
        rxVulcan,
107
        function (s) {
108
          return jsx.object.getProperty(media_map, s.replace(/\s+/g, " ").toUpperCase(), s);
109
        });
210 PointedEar 110
    }
111
 
112
    text.parentNode.lang = "vuh-Media-Gol-modern";
113
  }
114
 
228 PointedEar 115
  if (button && lcars.language == LANG_VULCAN)
210 PointedEar 116
  {
228 PointedEar 117
    button.setAttribute("data-caption", button.firstChild.textContent);
210 PointedEar 118
    button.firstChild.textContent = "Latin-Zukitan";
119
  }
227 PointedEar 120
 
121
  media_script_used = true;
210 PointedEar 122
}
123
 
124
function latinScript (button)
125
{
126
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
127
  {
128
    var text = vulcan_texts[i];
129
 
130
    text.style.textTransform = "";
131
    text.innerHTML = text.getAttribute('data-html');
132
    text.parentNode.lang = "vuh-Latn-Gol-modern";
133
  }
134
 
228 PointedEar 135
  if (lcars.language == LANG_VULCAN)
136
  {
137
    button.firstChild.textContent = button.getAttribute("data-caption");
138
  }
227 PointedEar 139
 
140
  media_script_used = false;
210 PointedEar 141
}