Subversion Repositories LCARS

Rev

Rev 210 | Rev 228 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 210 Rev 227
1
var vulcan_texts = null;
1
var vulcan_texts = null;
2
2
3
var media_map = {
3
var media_map = {
4
  S: "?",
4
  S: "?",
5
  T: "Y",
5
  T: "Y",
6
  P: "]",
6
  P: "]",
7
  K: "ß",
7
  K: "ß",
8
  R: "²",
8
  R: "²",
9
  L: "ζ",
9
  L: "ζ",
10
  A: "Ŧ",
10
  A: "Ŧ",
11
  D: "S",
11
  D: "S",
12
  O: "Ŋ",
12
  O: "Ŋ",
13
  E: "σ",
13
  E: "σ",
14
  V: "³",
14
  V: "³",
15
  U: "¶",
15
  U: "¶",
16
  H: "ξ",
16
  H: "ξ",
17
  G: "^",
17
  G: "^",
18
  Ch: ")",
18
  Ch: ")",
19
  I: "ƒ",
19
  I: "ƒ",
20
  N: "(",
20
  N: "(",
21
  Z: "ε",
21
  Z: "ε",
22
  M: "δ",
22
  M: "δ",
23
  Y: "ς",
23
  Y: "ς",
24
  F: "[",
24
  F: "[",
25
  W: "¬",
25
  W: "¬",
26
  B: "Ξ",
26
  B: "Ξ",
27
  SH: "§",
27
  SH: "§",
28
  TH: "λ",
28
  TH: "λ",
29
  KH: "Φ",
29
  KH: "Φ",
30
  ZH: "ω",
30
  ZH: "ω",
31
  TS: "θ",
31
  TS: "θ",
32
  DZH: "C",
32
  DZH: "C",
33
  J: "C",
33
  J: "C",
34
  KS: "φ",
34
  KS: "φ",
35
  X: "φ",
35
  X: "φ",
36
  LL: "μ",
36
  LL: "μ",
37
  M: "&",
37
  M: "&",
38
  NG: "ρ",
38
  NG: "ρ",
39
  NN: "þ",
39
  NN: "þ",
40
  SS: "β",
40
  SS: "β",
41
  TCH: "M",
41
  TCH: "M"
42
  ", ": " - ",
-
 
43
  ":": " – ",
-
 
44
  " – ": " – ",
-
 
45
  " — ": " – ",
-
 
46
  "…": "—",
-
 
47
  "~": "=",
-
 
48
  "!": "..",
-
 
49
  "!!!": "...",
-
 
50
  "(": "|",
-
 
51
  ")": "|",
-
 
52
  "[": "||",
-
 
53
  "]": "||",
-
 
54
  "&": "•",
-
 
55
  "°": "¯"
-
 
56
};
42
};
57
43
-
 
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
58
//jsx.object.flip = function (obj) {
51
//jsx.object.flip = function (obj) {
59
//  var flipped = jsx.object.inheritFrom(obj);
52
//  var flipped = jsx.object.inheritFrom(obj);
60
//  var keys = jsx.object.getKeys(obj);
53
//  var keys = jsx.object.getKeys(obj);
61
//
54
//
62
//  for (var i = 0, len = keys.length; i < len; ++i)
55
//  for (var i = 0, len = keys.length; i < len; ++i)
63
//  {
56
//  {
64
//    var key = keys[i];
57
//    var key = keys[i];
65
//    var value = obj[key];
58
//    var value = obj[key];
66
//    if (typeof value != "function")
59
//    if (typeof value != "function")
67
//    {
60
//    {
68
//      flipped[value] = key;
61
//      flipped[value] = key;
69
//    }
62
//    }
70
//  }
63
//  }
71
//
64
//
72
//  return flipped;
65
//  return flipped;
73
//};
66
//};
74
67
75
var media_caption;
68
var media_caption;
76
69
-
 
70
var media_script_used = false;
-
 
71
77
function mediaScript (button)
72
function mediaScript (button)
78
{
73
{
79
  vulcan_texts = jsx.dom.xpath.evaluate(
74
  vulcan_texts = jsx.dom.xpath.evaluate(
80
    './/*[@lang = "' + LANG_VULCAN + '"]//*[(not(@lang) or (@lang = "' + LANG_VULCAN + '")) and (@class = "text")]',
75
    './/*[@lang = "' + LANG_VULCAN + '"]//*[(not(@lang) or (@lang = "' + LANG_VULCAN + '")) and (@class = "text")]',
81
    document.body);
76
    document.body);
82
77
83
  if (!vulcan_texts)
78
  if (!vulcan_texts)
84
  {
79
  {
85
    return;
80
    return;
86
  }
81
  }
87
82
88
  var previous_parent = null;
83
  var previous_parent = null;
89
84
90
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
85
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
91
  {
86
  {
92
    var text = vulcan_texts[i];
87
    var text = vulcan_texts[i];
93
88
94
    text.style.textTransform = "none";
89
    text.style.textTransform = "none";
95
    if (!text.hasAttribute("data-html"))
90
    if (!text.hasAttribute("data-html"))
96
    {
91
    {
97
      text.setAttribute("data-html", text.innerHTML);
92
      text.setAttribute("data-html", text.innerHTML);
98
93
99
      if (!text.title)
94
      if (!text.title)
100
      {
95
      {
101
        text.title = text.textContent;
96
        text.title = text.textContent;
102
      }
97
      }
103
    }
98
    }
104
99
105
    var text_nodes = jsx.dom.xpath.evaluate(
100
    var text_nodes = jsx.dom.xpath.evaluate(
106
      './/text()[parent::*[not(@lang) or (@lang = "' + LANG_VULCAN + '")]]',
101
      './/text()[parent::*[not(@lang) or (@lang = "' + LANG_VULCAN + '")]]',
107
      text);
102
      text);
108
103
109
    for (var j = 0, len2 = text_nodes.length; j < len2; ++j)
104
    for (var j = 0, len2 = text_nodes.length; j < len2; ++j)
110
    {
105
    {
111
      var text_node = text_nodes[j];
106
      var text_node = text_nodes[j];
112
107
113
      if (text_node.parentNode.lang != LANG_VULCAN)
108
      if (text_node.parentNode.lang != LANG_VULCAN)
114
      {
109
      {
115
        text_node.nodeValue = text_node.nodeValue.replace(
110
        text_node.nodeValue = text_node.nodeValue.replace(
116
          /Tch|Ch|Sh|Th|Kh|Zh|Ts|Dzh|Ks|Ll|Ng|Nn|Ss| [–—] |, |!!!|[!STPKRLADOEVUHGINZMYFWBJX:()[\]&°…~]/gi,
111
          rxVulcan,
117
          function (s) {
112
          function (s) {
118
            return jsx.object.getProperty(media_map, s.toUpperCase(), s);
113
            return jsx.object.getProperty(media_map, s.replace(/\s+/g, " ").toUpperCase(), s);
119
          });
114
          });
120
      }
115
      }
121
    }
116
    }
122
117
123
    text.parentNode.lang = "vuh-Media-Gol-modern";
118
    text.parentNode.lang = "vuh-Media-Gol-modern";
124
  }
119
  }
125
120
126
  if (button)
121
  if (button)
127
  {
122
  {
128
    media_caption = button.firstChild.textContent;
123
    media_caption = button.firstChild.textContent;
129
    button.firstChild.textContent = "Latin-Zukitan";
124
    button.firstChild.textContent = "Latin-Zukitan";
130
    button.onclick = function () {
-
 
131
      latinScript(this);
-
 
132
    };
-
 
133
  }
125
  }
-
 
126
-
 
127
  media_script_used = true;
134
}
128
}
135
129
136
function latinScript (button)
130
function latinScript (button)
137
{
131
{
138
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
132
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
139
  {
133
  {
140
    var text = vulcan_texts[i];
134
    var text = vulcan_texts[i];
141
135
142
    text.style.textTransform = "";
136
    text.style.textTransform = "";
143
    text.innerHTML = text.getAttribute('data-html');
137
    text.innerHTML = text.getAttribute('data-html');
144
    text.parentNode.lang = "vuh-Latn-Gol-modern";
138
    text.parentNode.lang = "vuh-Latn-Gol-modern";
145
  }
139
  }
146
140
147
  button.firstChild.textContent = media_caption;
141
  button.firstChild.textContent = media_caption;
148
  button.onclick = function () {
-
 
-
 
142
149
    mediaScript(this);
143
  media_script_used = false;
150
  };
-
 
151
}
144
}
152
 
145