MediaWiki:Common.js: Skillnad mellan sidversioner

Från Gonjo wiktionary
Hoppa till navigering Hoppa till sök
Ingen redigeringssammanfattning
Ingen redigeringssammanfattning
 
(38 mellanliggande sidversioner av samma användare visas inte)
Rad 1: Rad 1:
/* JavaScript som skrivs här körs varje gång en användare laddar en sida. */
$(document).ready(function() {
  // Use mw.loader.using to ensure compatibility with Mediawiki's module loading system
  mw.loader.using(['mediawiki.util'], function() {
    // Customized transcription table
    var transcriptionTable = {
  "α":"a",
  "ἁ":"â",
  "β":"v",
  "γ":"g",
  "δ":"d",
  "ε":"e",
  "ἑ":"ê",
  "ϛ":"ņ",
  "η":"h",
  "ἡ":"ļ",
  "θ":"þ",
  "ι":"i",
  "ἱ":"î",
  "ϊ":":ï",
  "κ":"k",
  "λ":"l",
  "μ":"m",
  "ν":"n",
  "ο":"o",
  "ὁ":"ô",
  "π":"p",
  "ϙ":"q",
  "ρ":"r",
  "ῥ":"ŗ",
  "σ":"s",
  "ϲ":"c",
  "τ":"ț",
  "υ":"y",
  "ὑ":"ŷ",
  "ϋ":"ÿ",
  "φ":"f",
  "χ":"x",
  "ψ":"ps",
  "ω":"u",
  "ὡ":"û",
  "ϣ":"ñ",
  "ϥ":"ș",
  "ϧ":"ŋ",
  "ϗ":"ķ",
  "ₓ":"x"
      // Add more mappings as needed
    };


$(function () {
    // Function to transcribe a string based on the transcription table
    function transcribeString() {
      var element = document.getElementById("convert-go");
      if (element) {
        var input = element.textContent || element.innerText;
        var output = "";
        for (var i = 0; i < input.length; i++) {
          var character = input[i].toLowerCase();
          var transcription = transcriptionTable[character];
          if (transcription) {
            output += transcription;
          } else {
            output += input[i];
          }
        }
        element.textContent = output; // Update the text content of the element with the transcribed string
      }
    }


 
    // Automatically transcribe when the page finishes loading
var Latinise={};Latinise.latin_map={"Á":"A",
    transcribeString();
"Ă":"A",
  });
"Ắ":"A",
});
"Ặ":"A",
"Ằ":"A",
"Ẳ":"A",
"Ẵ":"A",
"Ǎ":"A",
"ᵣ":"r",
"ᵤ":"u",
"ᵥ":"v",
"ₓ":"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()}
 
$('#transcribe-go').html('<script>document.write("ẴẴdẴ".latinize());</script>');
}());

Nuvarande version från 11 juni 2023 kl. 17.16

$(document).ready(function() {
  // Use mw.loader.using to ensure compatibility with Mediawiki's module loading system
  mw.loader.using(['mediawiki.util'], function() {
    // Customized transcription table
    var transcriptionTable = {
  "α":"a",
  "ἁ":"â",
  "β":"v",
  "γ":"g",
  "δ":"d",
  "ε":"e",
  "ἑ":"ê",
  "ϛ":"ņ",
  "η":"h",
  "ἡ":"ļ",
  "θ":"þ",
  "ι":"i",
  "ἱ":"î",
  "ϊ":":ï",
  "κ":"k",
  "λ":"l",
  "μ":"m",
  "ν":"n",
  "ο":"o",
  "ὁ":"ô",
  "π":"p",
  "ϙ":"q",
  "ρ":"r",
  "ῥ":"ŗ",
  "σ":"s",
  "ϲ":"c",
  "τ":"ț",
  "υ":"y",
  "ὑ":"ŷ",
  "ϋ":"ÿ",
  "φ":"f",
  "χ":"x",
  "ψ":"ps",
  "ω":"u",
  "ὡ":"û",
  "ϣ":"ñ",
  "ϥ":"ș",
  "ϧ":"ŋ",
  "ϗ":"ķ",
  "ₓ":"x"
      // Add more mappings as needed
    };

    // Function to transcribe a string based on the transcription table
    function transcribeString() {
      var element = document.getElementById("convert-go");
      if (element) {
        var input = element.textContent || element.innerText;
        var output = "";
        for (var i = 0; i < input.length; i++) {
          var character = input[i].toLowerCase();
          var transcription = transcriptionTable[character];
          if (transcription) {
            output += transcription;
          } else {
            output += input[i];
          }
        }
        element.textContent = output; // Update the text content of the element with the transcribed string
      }
    }

    // Automatically transcribe when the page finishes loading
    transcribeString();
  });
});