MediaWiki:Common.js: Skillnad mellan sidversioner

Från Gonjo wiktionary
Hoppa till navigering Hoppa till sök
Ingen redigeringssammanfattning
Ingen redigeringssammanfattning
Rad 44: Rad 44:
};
};


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

Versionen från 11 juni 2023 kl. 17.08

// 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 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
    document.addEventListener("DOMContentLoaded", transcribeString);