MediaWiki:Common.js: Skillnad mellan sidversioner

Från Gonjo wiktionary
Hoppa till navigering Hoppa till sök
Ingen redigeringssammanfattning
Ingen redigeringssammanfattning
Rad 59: Rad 59:
$(function() {
$(function() {
   var paragraph = document.getElementById("transcribe-go");
   var paragraph = document.getElementById("transcribe-go");
   var currentName = {{PAGENAME}}; // Replace this with the current page name
   if (paragraph) {
  paragraph.textContent = currentName.latinize();
    var currentName = {{PAGENAME}}; // Replace this with the actual page name
    paragraph.textContent = currentName.latinize();
  } else {
    console.error("Could not find 'transcribe-go' element.");
  }
});
});

Versionen från 6 mars 2023 kl. 03.28

var Latinise = {};

Latinise.latin_map = {
  "Á":"A",
  "α":"a",
  "ἁ":"â",
  "β":"v",
  "γ":"g",
  "δ":"d",
  "ε":"e",
  "ἑ":"ê",
  "ϛ":"ņ",
  "η":"h",
  "ἡ":"ļ",
  "θ":"þ",
  "ι":"i",
  "ἱ":"î",
  "ϊ":":ï",
  "κ":"k",
  "λ":"l",
  "μ":"m",
  "ν":"n",
  "ο":"o",
  "ὁ":"ô",
  "π":"p",
  "ϙ":"q",
  "ρ":"r",
  "ῥ":"ŗ",
  "σ":"s",
  "ϲ":"c",
  "τ":"ț",
  "υ":"y",
  "ὑ":"ŷ",
  "ϋ":"ÿ",
  "φ":"f",
  "χ":"x",
  "ψ":"ps",
  "ω":"u",
  "ὡ":"û",
  "ϣ":"ñ",
  "ϥ":"ș",
  "ϧ":"ŋ",
  "ϗ":"ķ",
  "ₓ":"x"
};

String.prototype.latinise = function() {
  return this.replace(/[^A-Za-z0-9\[\] ]/g, function(a) {
    return Latinise.latin_map[a] || a;
  });
};

String.prototype.latinize = String.prototype.latinise;

String.prototype.isLatin = function() {
  return this == this.latinise();
};

$(function() {
  var paragraph = document.getElementById("transcribe-go");
  if (paragraph) {
    var currentName = {{PAGENAME}}; // Replace this with the actual page name
    paragraph.textContent = currentName.latinize();
  } else {
    console.error("Could not find 'transcribe-go' element.");
  }
});