Subversion Repositories LCARS

Rev

Rev 228 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 228 Rev 234
Line 1... Line 1...
1
var klingon_texts = null;
1
var klingon_texts = null;
2
2
3
var klingon_map = {
3
var klingon_map = {
4
  "A": "\uF8D0",
4
  "a": "\uF8D0",
5
  "B": "\uF8D1",
5
  "b": "\uF8D1",
6
  "CH": "\uF8D2",
6
  "ch": "\uF8D2",
7
  "D": "\uF8D3",
7
  "D": "\uF8D3",
8
  "E": "\uF8D4",
8
  "e": "\uF8D4",
9
  "GH": "\uF8D5",
9
  "gh": "\uF8D5",
10
  "H": "\uF8D6",
10
  "H": "\uF8D6",
11
  "I": "\uF8D7",
11
  "I": "\uF8D7",
12
  "J": "\uF8D8",
12
  "j": "\uF8D8",
13
  "L": "\uF8D9",
13
  "l": "\uF8D9",
14
  "M": "\uF8DA",
14
  "m": "\uF8DA",
15
  "N": "\uF8DB",
15
  "n": "\uF8DB",
16
  "NG": "\uF8DC",
16
  "ng": "\uF8DC",
17
  "O": "\uF8DD",
17
  "o": "\uF8DD",
18
  "P": "\uF8DE",
18
  "p": "\uF8DE",
19
  "Q": "\uF8DF",
19
  "q": "\uF8DF",
20
  "QH": "\uF8E0",
20
  "Q": "\uF8E0",
21
  "R": "\uF8E1",
21
  "r": "\uF8E1",
22
  "S": "\uF8E2",
22
  "S": "\uF8E2",
23
  "T": "\uF8E3",
23
  "t": "\uF8E3",
24
  "TLH": "\uF8E4",
24
  "tlh": "\uF8E4",
25
  "U": "\uF8E5",
25
  "u": "\uF8E5",
26
  "V": "\uF8E6",
26
  "v": "\uF8E6",
27
  "W": "\uF8E7",
27
  "w": "\uF8E7",
28
  "Y": "\uF8E8",
28
  "y": "\uF8E8",
29
  "'": "\uF8E9",
29
  "'": "\uF8E9",
30
  "0": "\uF8F0",
30
  "0": "\uF8F0",
31
  "1": "\uF8F1",
31
  "1": "\uF8F1",
32
  "2": "\uF8F2",
32
  "2": "\uF8F2",
33
  "3": "\uF8F3",
33
  "3": "\uF8F3",
Line 66... Line 66...
66
//  }
66
//  }
67
//
67
//
68
//  return flipped;
68
//  return flipped;
69
//};
69
//};
70
70
-
 
71
function pIqaDize (s)
-
 
72
{
71
var media_caption;
73
  return s.replace(
-
 
74
    rxKlingon,
-
 
75
    function (s) {
-
 
76
      return jsx.object.getProperty(klingon_map, s.replace(/\s+/g, " "), s);
-
 
77
    });
-
 
78
}
-
 
79
-
 
80
var LANG_KLINGON_PIQAD = "tlh-pIqaD";
72
81
73
function pIqaD (button)
82
function pIqaD (button)
74
{
83
{
75
  klingon_texts = jsx.dom.xpath.evaluate(
84
  klingon_texts = jsx.dom.xpath.evaluate(
76
    './/*[@class = "text" and (@lang = "' + LANG_KLINGON
85
    './/*[@class = "text" and (@lang = "' + LANG_KLINGON
Line 80... Line 89...
80
  if (!klingon_texts)
89
  if (!klingon_texts)
81
  {
90
  {
82
    return;
91
    return;
83
  }
92
  }
84
93
85
  var previous_parent = null;
-
 
86
-
 
87
  for (var i = 0, len = klingon_texts.length; i < len; ++i)
94
  for (var i = 0, len = klingon_texts.length; i < len; ++i)
88
  {
95
  {
89
    var text = klingon_texts[i];
96
    var text = klingon_texts[i];
90
97
91
    text.style.fontFamily = "pIqaD, Constructium, Code2000, serif";
-
 
92
    text.style.fontSize = "90%";
-
 
93
-
 
94
    if (!text.hasAttribute("data-html"))
98
    if (!text.hasAttribute("data-html"))
95
    {
99
    {
96
      text.setAttribute("data-html", text.innerHTML);
100
      text.setAttribute("data-html", text.innerHTML);
97
101
98
      if (!text.title)
102
      if (!text.title)
Line 107... Line 111...
107
111
108
    for (var j = 0, len2 = text_nodes.length; j < len2; ++j)
112
    for (var j = 0, len2 = text_nodes.length; j < len2; ++j)
109
    {
113
    {
110
      var text_node = text_nodes[j];
114
      var text_node = text_nodes[j];
111
115
112
      text_node.nodeValue = text_node.nodeValue.toUpperCase().replace(
116
      text_node.nodeValue = pIqaDize(text_node.nodeValue);
113
        rxKlingon,
-
 
114
        function (s) {
-
 
115
          return jsx.object.getProperty(klingon_map, s.replace(/\s+/g, " "), s);
-
 
116
        });
-
 
117
    }
117
    }
118
118
-
 
119
    if (text.lang == LANG_KLINGON)
-
 
120
    {
-
 
121
      text.lang = LANG_KLINGON_PIQAD;
-
 
122
    }
-
 
123
    else if (text.parentNode.lang == LANG_KLINGON)
-
 
124
    {
119
    text.parentNode.lang = "tlh-pIqaD";
125
      text.parentNode.lang = LANG_KLINGON_PIQAD;
-
 
126
    }
120
  }
127
  }
121
128
122
  if (button && lcars.language == LANG_KLINGON)
129
  if (button)
123
  {
130
  {
124
    button.setAttribute("data-caption", button.firstChild.textContent);
-
 
125
    button.firstChild.textContent = "Latin";
-
 
126
    button.firstChild.style.fontFamily = "";
-
 
127
    button.firstChild.style.fontSize = "";
131
    button.firstChild.lang = LANG_KLINGON;
128
  }
132
  }
-
 
133
-
 
134
  var html = document.documentElement;
-
 
135
  html.setAttribute("data-lang", html.lang);
-
 
136
  html.lang = LANG_KLINGON_PIQAD;
129
}
137
}
130
138
131
function klingonLatinScript (button)
139
function klingonLatinScript (button)
132
{
140
{
133
  for (var i = 0, len = klingon_texts.length; i < len; ++i)
141
  for (var i = 0, len = klingon_texts.length; i < len; ++i)
134
  {
142
  {
135
    var text = klingon_texts[i];
143
    var text = klingon_texts[i];
136
144
137
    text.style.fontFamily = "";
-
 
138
    text.style.fontSize = "";
-
 
139
    text.innerHTML = text.getAttribute('data-html');
145
    text.innerHTML = text.getAttribute('data-html');
-
 
146
    text.removeAttribute("data-html");
-
 
147
-
 
148
    if (text.lang == LANG_KLINGON_PIQAD)
-
 
149
    {
-
 
150
      text.lang = LANG_KLINGON;
-
 
151
    }
-
 
152
    else if (text.parentNode.lang == LANG_KLINGON_PIQAD)
-
 
153
    {
140
    text.parentNode.lang = "tlh-Latn";
154
      text.parentNode.lang = LANG_KLINGON;
-
 
155
    }
141
  }
156
  }
142
157
143
  if (lcars.language == LANG_KLINGON)
158
  if (button)
144
  {
159
  {
145
    button.firstChild.textContent = button.getAttribute("data-caption");
160
    button.firstChild.lang = LANG_KLINGON_PIQAD;
146
  }
161
  }
-
 
162
-
 
163
  var html = document.documentElement;
-
 
164
  html.lang = html.getAttribute("data-lang");
-
 
165
  html.removeAttribute("data-lang");
147
}
166
}