Subversion Repositories LCARS

Rev

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",
  ", ": " - ",
  ":": " – ",
  " – ": " – ",
  " — ": " – ",
  "…": "—",
  "~": "=",
  "!": "..",
  "!!!": "...",
  "(": "|",
  ")": "|",
  "[": "||",
  "]": "||",
  "&": "•",
  "°": "¯"
};

//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;

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(
          /Tch|Ch|Sh|Th|Kh|Zh|Ts|Dzh|Ks|Ll|Ng|Nn|Ss| [–—] |, |!!!|[!STPKRLADOEVUHGINZMYFWBJX:()[\]&°…~]/gi,
          function (s) {
            return jsx.object.getProperty(media_map, s.toUpperCase(), s);
          });
      }
    }

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

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

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;
  button.onclick = function () {
    mediaScript(this);
  };
}