function translateDropdown(src, tgt, lngId, thisLang, i) {
  var text = document.getElementById(src).innerText;
  var language = document.getElementById(lngId).value;
  const target = document.getElementById(tgt);
  const label = document.getElementById(thisLang);

  var params = new URLSearchParams();
  params.append("text", text);
  params.append("lang", language);
  var request = new Request("/translate-data", {method: "POST", body: params});
  
  target.innerText = "Loading translation...";
  fetch(request).then(result => result.text()).then(
    function(translatedText) {
    target.innerText = translatedText;
    var langName = "??";
    if(langs.hasOwnProperty(language)) {
      langName = langs[language];
    }
    label.innerText = "Language: " + langName;
    if(i >= 0) {
      var icon = document.getElementsByClassName("plus")[i];
      var text = document.getElementsByClassName("dropdown-text")[i];
      var textContent = document.getElementsByClassName("dropdown-text-content")[i];
      if(icon.classList.contains("clicked")) {
        text.style.height = (textContent.clientHeight + 60) + "px";
      } 
    }
  });
}
/**
 * Translates content from the webpage and resizes dropdown container, if appplicable.
 *
 * @param {string} src Id of document element with source text.
 * @param {string} tgt Id of document element to place translated text.
 * @param {string} lngId Id of document dropdown containing language code. 
 * @param {string} thisLang Id of document element displaying current language.
 * @param {number} i Index of dropdown container on the page.
 */
Translates content from the webpage and resizes dropdown container, if appplicable.
@param {string} src Id of document element with source text.
@param {string} tgt Id of document element to place translated text.
@param {string} lngId Id of document dropdown containing language code.
@param {string} thisLang Id of document element displaying current language.
@param {number} i Index of dropdown container on the page.
Translates content from the webpage and resizes dropdown container if appplicable . @param { string } src Id of document element with source text . @param { string } tgt Id of document element to place translated text . @param { string } lngId Id of document dropdown containing language code . @param { string } thisLang Id of document element displaying current language . @param { number } i Index of dropdown container on the page .
function translateDropdown(src, tgt, lngId, thisLang, i) {
  var text = document.getElementById(src).innerText;
  var language = document.getElementById(lngId).value;
  const target = document.getElementById(tgt);
  const label = document.getElementById(thisLang);
  var params = new URLSearchParams();
  params.append("text", text);
  params.append("lang", language);
  var request = new Request("/translate-data", {method: "POST", body: params});
  target.innerText = "Loading translation...";
  fetch(request).then(result => result.text()).then(
    function(translatedText) {
    target.innerText = translatedText;
    var langName = "??";
    if(langs.hasOwnProperty(language)) {
      langName = langs[language];
    }
    label.innerText = "Language: " + langName;
    if(i >= 0) {
      var icon = document.getElementsByClassName("plus")[i];
      var text = document.getElementsByClassName("dropdown-text")[i];
      var textContent = document.getElementsByClassName("dropdown-text-content")[i];
      if(icon.classList.contains("clicked")) {
        text.style.height = (textContent.clientHeight + 60) + "px";
      } 
    }
  });
}
function translateDropdown ( src , tgt , lngId , thisLang , i ) { var text = document . getElementById ( src ) . innerText ; var language = document . getElementById ( lngId ) . value ; const target = document . getElementById ( tgt ) ; const label = document . getElementById ( thisLang ) ; var params = new URLSearchParams ( ) ; params . append ( "text" , text ) ; params . append ( "lang" , language ) ; var request = new Request ( "/translate-data" , { method : "POST" , body : params } ) ; target . innerText = "Loading translation..." ; fetch ( request ) . then ( result => result . text ( ) ) . then ( function ( translatedText ) { target . innerText = translatedText ; var langName = "??" ; if ( langs . hasOwnProperty ( language ) ) { langName = langs [ language ] ; } label . innerText = "Language: " + langName ; if ( i >= 0 ) { var icon = document . getElementsByClassName ( "plus" ) [ i ] ; var text = document . getElementsByClassName ( "dropdown-text" ) [ i ] ; var textContent = document . getElementsByClassName ( "dropdown-text-content" ) [ i ] ; if ( icon . classList . contains ( "clicked" ) ) { text . style . height = ( textContent . clientHeight + 60 ) + "px" ; } } } ) ; }
Translates content from the webpage and resizes dropdown container, if appplicable.
Translates content from the webpage and resizes dropdown container if appplicable .