Subversion Repositories LCARS

Rev

Rev 210 | Rev 228 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

1
var vulcan_texts = null;

var media_map = {
  S: "?",
  T: "Y",
  P: "]",
  K: "ß",
  R: "²",
  L: "ζ",
  A: "Ŧ",
  D: "S",
  O: "Ŋ",
  E: "σ",
  V: "³",
  U: "¶",
  H: "ξ",
  G: "^",
  Ch: ")",
  I: "ƒ",
  N: "(",
  Z: "ε",
  M: "δ",
  Y: "ς",
  F: "[",
  W: "¬",
  B: "Ξ",
  SH: "§",
  TH: "λ",
  KH: "Φ",
  ZH: "ω",
  TS: "θ",
  DZH: "C",
  J: "C",
  KS: "φ",
  X: "φ",
  LL: "μ",
  M: "&",
  NG: "ρ",
  NN: "þ",
  SS: "β",
  TCH: "M"
};

var rxVulcan = jsx.object.getKeys(media_map);
rxVulcan.sort(function (a, b) { return b.length - a.length; });
rxVulcan = new RegExp(
  rxVulcan.filter(function (e) { return e.length > 1; }).join("|")
    + "|[" + rxVulcan.filter(function (e) { return e.length === 1; }). join("") + "]",
  "ig");

//jsx.object.flip = function (obj) {
//  var flipped = jsx.object.inheritFrom(obj);
//  var keys = jsx.object.getKeys(obj);
//
//  for (var i = 0, len = keys.length; i < len; ++i)
//  {
//    var key = keys[i];
//    var value = obj[key];
//    if (typeof value != "function")
//    {
//      flipped[value] = key;
//    }
//  }
//
//  return flipped;
//};

var media_caption;

var media_script_used = false;

function mediaScript (button)
{
  vulcan_texts = jsx.dom.xpath.evaluate(
    './/*[@lang = "' + LANG_VULCAN + '"]//*[(not(@lang) or (@lang = "' + LANG_VULCAN + '")) and (@class = "text")]',
    document.body);

  if (!vulcan_texts)
  {
    return;
  }

  var previous_parent = null;

  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
  {
    var text = vulcan_texts[i];

    text.style.textTransform = "none";
    if (!text.hasAttribute("data-html"))
    {
      text.setAttribute("data-html", text.innerHTML);

      if (!text.title)
      {
        text.title = text.textContent;
      }
    }

    var text_nodes = jsx.dom.xpath.evaluate(
      './/text()[parent::*[not(@lang) or (@lang = "' + LANG_VULCAN + '")]]',
      text);

    for (var j = 0, len2 = text_nodes.length; j < len2; ++j)
    {
      var text_node = text_nodes[j];

      if (text_node.parentNode.lang != LANG_VULCAN)
      {
        text_node.nodeValue = text_node.nodeValue.replace(
          rxVulcan,
          function (s) {
            return jsx.object.getProperty(media_map, s.replace(/\s+/g, " ").toUpperCase(), s);
          });
      }
    }

    text.parentNode.lang = "vuh-Media-Gol-modern";
  }

  if (button)
  {
    media_caption = button.firstChild.textContent;
    button.firstChild.textContent = "Latin-Zukitan";
  }

  media_script_used = true;
}

function latinScript (button)
{
  for (var i = 0, len = vulcan_texts.length; i < len; ++i)
  {
    var text = vulcan_texts[i];

    text.style.textTransform = "";
    text.innerHTML = text.getAttribute('data-html');
    text.parentNode.lang = "vuh-Latn-Gol-modern";
  }

  button.firstChild.textContent = media_caption;

  media_script_used = false;
}