MediaWiki:Common.js

Från Gonjo wiktionary
Version från den 11 juni 2023 kl. 17.16 av Niklas (diskussion | bidrag)
(skillnad) ← Äldre version | Nuvarande version (skillnad) | Nyare version → (skillnad)
Hoppa till navigering Hoppa till sök

OBS: Efter du har publicerat sidan kan du behöva tömma din webbläsares cache för att se ändringarna.

  • Firefox / Safari: Håll ned Skift och klicka på Uppdatera sidan eller tryck antingen Ctrl-F5 eller Ctrl-R (⌘-R på Mac)
  • Google Chrome: Tryck Ctrl-Skift-R (⌘-Shift-R på Mac)
  • Internet Explorer / Edge: Håll ned Ctrl och klicka på Uppdatera eller tryck Ctrl-F5

Opera: Tryck Ctrl-F5.

$(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();
  });
});