Subversion Repositories LCARS

Rev

Rev 227 | Rev 234 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 PointedEar 1
var klingon_texts = null;
2
 
3
var klingon_map = {
4
  "A": "\uF8D0",
5
  "B": "\uF8D1",
6
  "CH": "\uF8D2",
7
  "D": "\uF8D3",
8
  "E": "\uF8D4",
9
  "GH": "\uF8D5",
10
  "H": "\uF8D6",
11
  "I": "\uF8D7",
12
  "J": "\uF8D8",
13
  "L": "\uF8D9",
14
  "M": "\uF8DA",
15
  "N": "\uF8DB",
16
  "NG": "\uF8DC",
17
  "O": "\uF8DD",
18
  "P": "\uF8DE",
19
  "Q": "\uF8DF",
20
  "QH": "\uF8E0",
21
  "R": "\uF8E1",
22
  "S": "\uF8E2",
23
  "T": "\uF8E3",
24
  "TLH": "\uF8E4",
25
  "U": "\uF8E5",
26
  "V": "\uF8E6",
27
  "W": "\uF8E7",
28
  "Y": "\uF8E8",
29
  "'": "\uF8E9",
30
  "0": "\uF8F0",
31
  "1": "\uF8F1",
32
  "2": "\uF8F2",
33
  "3": "\uF8F3",
34
  "4": "\uF8F4",
35
  "5": "\uF8F5",
36
  "6": "\uF8F6",
37
  "7": "\uF8F7",
38
  "8": "\uF8F8",
39
  "9": "\uF8F9",
40
  ",": "\uF8FD",
41
  ".": "\uF8FE",
42
 
43
  /* mummification glyph, symbol of the empire */
44
  "Δ": "\uF8FF"
45
};
46
 
47
var rxKlingon = jsx.object.getKeys(klingon_map);
48
rxKlingon.sort(function (a, b) { return b.length - a.length; });
49
rxKlingon = new RegExp(
50
  rxKlingon.filter(function (e) { return e.length > 1; }).join("|")
51
    + "|[" + rxKlingon.filter(function (e) { return e.length === 1; }). join("") + "]",
52
  "ig");
53
 
54
//jsx.object.flip = function (obj) {
55
//  var flipped = jsx.object.inheritFrom(obj);
56
//  var keys = jsx.object.getKeys(obj);
57
//
58
//  for (var i = 0, len = keys.length; i < len; ++i)
59
//  {
60
//    var key = keys[i];
61
//    var value = obj[key];
62
//    if (typeof value != "function")
63
//    {
64
//      flipped[value] = key;
65
//    }
66
//  }
67
//
68
//  return flipped;
69
//};
70
 
71
var media_caption;
72
 
73
function pIqaD (button)
74
{
75
  klingon_texts = jsx.dom.xpath.evaluate(
228 PointedEar 76
    './/*[@class = "text" and (@lang = "' + LANG_KLINGON
77
      + '" or parent::*[@lang = "' + LANG_KLINGON + '"])]',
227 PointedEar 78
    document.body);
79
 
80
  if (!klingon_texts)
81
  {
82
    return;
83
  }
84
 
85
  var previous_parent = null;
86
 
87
  for (var i = 0, len = klingon_texts.length; i < len; ++i)
88
  {
89
    var text = klingon_texts[i];
90
 
228 PointedEar 91
    text.style.fontFamily = "pIqaD, Constructium, Code2000, serif";
227 PointedEar 92
    text.style.fontSize = "90%";
93
 
94
    if (!text.hasAttribute("data-html"))
95
    {
96
      text.setAttribute("data-html", text.innerHTML);
97
 
98
      if (!text.title)
99
      {
100
        text.title = text.textContent;
101
      }
102
    }
103
 
104
    var text_nodes = jsx.dom.xpath.evaluate(
105
      './/text()[parent::*[not(@lang) or (@lang = "' + LANG_KLINGON + '")]]',
106
      text);
107
 
108
    for (var j = 0, len2 = text_nodes.length; j < len2; ++j)
109
    {
110
      var text_node = text_nodes[j];
111
 
228 PointedEar 112
      text_node.nodeValue = text_node.nodeValue.toUpperCase().replace(
113
        rxKlingon,
114
        function (s) {
115
          return jsx.object.getProperty(klingon_map, s.replace(/\s+/g, " "), s);
116
        });
227 PointedEar 117
    }
118
 
119
    text.parentNode.lang = "tlh-pIqaD";
120
  }
121
 
228 PointedEar 122
  if (button && lcars.language == LANG_KLINGON)
227 PointedEar 123
  {
228 PointedEar 124
    button.setAttribute("data-caption", button.firstChild.textContent);
227 PointedEar 125
    button.firstChild.textContent = "Latin";
228 PointedEar 126
    button.firstChild.style.fontFamily = "";
127
    button.firstChild.style.fontSize = "";
227 PointedEar 128
  }
129
}
130
 
131
function klingonLatinScript (button)
132
{
133
  for (var i = 0, len = klingon_texts.length; i < len; ++i)
134
  {
135
    var text = klingon_texts[i];
136
 
137
    text.style.fontFamily = "";
138
    text.style.fontSize = "";
139
    text.innerHTML = text.getAttribute('data-html');
140
    text.parentNode.lang = "tlh-Latn";
141
  }
142
 
228 PointedEar 143
  if (lcars.language == LANG_KLINGON)
144
  {
145
    button.firstChild.textContent = button.getAttribute("data-caption");
146
  }
227 PointedEar 147
}