Subversion Repositories LCARS

Rev

Rev 210 | Rev 228 | 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
 
68
var media_caption;
69
 
227 PointedEar 70
var media_script_used = false;
71
 
210 PointedEar 72
function mediaScript (button)
73
{
74
  vulcan_texts = jsx.dom.xpath.evaluate(
75
    './/*[@lang = "' + LANG_VULCAN + '"]//*[(not(@lang) or (@lang = "' + LANG_VULCAN + '")) and (@class = "text")]',
76
    document.body);
77
 
78
  if (!vulcan_texts)
79
  {
80
    return;
81
  }
82
 
83
  var previous_parent = null;
84
 
85
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
86
  {
87
    var text = vulcan_texts[i];
88
 
89
    text.style.textTransform = "none";
90
    if (!text.hasAttribute("data-html"))
91
    {
92
      text.setAttribute("data-html", text.innerHTML);
93
 
94
      if (!text.title)
95
      {
96
        text.title = text.textContent;
97
      }
98
    }
99
 
100
    var text_nodes = jsx.dom.xpath.evaluate(
101
      './/text()[parent::*[not(@lang) or (@lang = "' + LANG_VULCAN + '")]]',
102
      text);
103
 
104
    for (var j = 0, len2 = text_nodes.length; j < len2; ++j)
105
    {
106
      var text_node = text_nodes[j];
107
 
108
      if (text_node.parentNode.lang != LANG_VULCAN)
109
      {
110
        text_node.nodeValue = text_node.nodeValue.replace(
227 PointedEar 111
          rxVulcan,
210 PointedEar 112
          function (s) {
227 PointedEar 113
            return jsx.object.getProperty(media_map, s.replace(/\s+/g, " ").toUpperCase(), s);
210 PointedEar 114
          });
115
      }
116
    }
117
 
118
    text.parentNode.lang = "vuh-Media-Gol-modern";
119
  }
120
 
121
  if (button)
122
  {
123
    media_caption = button.firstChild.textContent;
124
    button.firstChild.textContent = "Latin-Zukitan";
125
  }
227 PointedEar 126
 
127
  media_script_used = true;
210 PointedEar 128
}
129
 
130
function latinScript (button)
131
{
132
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
133
  {
134
    var text = vulcan_texts[i];
135
 
136
    text.style.textTransform = "";
137
    text.innerHTML = text.getAttribute('data-html');
138
    text.parentNode.lang = "vuh-Latn-Gol-modern";
139
  }
140
 
141
  button.firstChild.textContent = media_caption;
227 PointedEar 142
 
143
  media_script_used = false;
210 PointedEar 144
}