Benutzer:Andreas Plank/JavaScript: Unterschied zwischen den Versionen

Aus Open Source Ecology - Germany
Zur Navigation springen Zur Suche springen
 
Zeile 7: Zeile 7:
 
// var liedtext=""; jQuery('.table-borderless.texts td:first-child').each(function(){ liedtext+=jQuery(this).text() + ' ' ; }); liedtext;
 
// var liedtext=""; jQuery('.table-borderless.texts td:first-child').each(function(){ liedtext+=jQuery(this).text() + ' ' ; }); liedtext;
 
var liedtext=""; jQuery('.table-borderless.texts td:first-child').each(function(){ liedtext+=jQuery(this).text() + '<br/>' ; });  jQuery('.table-borderless.texts').after(jQuery("<p>").html(liedtext));
 
var liedtext=""; jQuery('.table-borderless.texts td:first-child').each(function(){ liedtext+=jQuery(this).text() + '<br/>' ; });  jQuery('.table-borderless.texts').after(jQuery("<p>").html(liedtext));
 +
 +
 +
function removeEmptyColumns() {
 +
  $('#Literatur_Tabellenergebnis table tr th').each(function(i) {
 +
    //select all td in this column
 +
    var tds = $(this).parents('table')
 +
      .find(`tr td:nth-child(${i + 1})`);
 +
    // check if all the cells in this column are empty
 +
    // Note: Empty strings return 'false' - trim whitespace before.
 +
    if (tds.toArray().every(td => !td.textContent.trim())) {
 +
      //hide header
 +
      $(this).hide();
 +
      //hide cells
 +
      tds.hide();
 +
    }
 +
  });
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Aktuelle Version vom 28. September 2023, 17:54 Uhr

// Texte Weihnachtsoratorium https://www.vmii.org/bwv-248-weihnachts-oratorium/9-ach-mein-herzliebes-jesulein?r=%2F
var scr = document.createElement("script");
scr.src = "https://code.jquery.com/jquery-1.9.1.min.js";
document.body.appendChild(scr);
// Seiten-Code nach Zeitdauer, Titel, Zeitangabe durchsuchen und in JavaScript Konsole ausgeben
// var liedtext=""; jQuery('.table-borderless.texts td:first-child').each(function(){ liedtext+=jQuery(this).text() + ' ' ; }); liedtext;
var liedtext=""; jQuery('.table-borderless.texts td:first-child').each(function(){ liedtext+=jQuery(this).text() + '<br/>' ; });  jQuery('.table-borderless.texts').after(jQuery("<p>").html(liedtext));


function removeEmptyColumns() {
  $('#Literatur_Tabellenergebnis table tr th').each(function(i) {
    //select all td in this column
    var tds = $(this).parents('table')
      .find(`tr td:nth-child(${i + 1})`);
    // check if all the cells in this column are empty
    // Note: Empty strings return 'false' - trim whitespace before.
    if (tds.toArray().every(td => !td.textContent.trim())) {
      //hide header
      $(this).hide();
      //hide cells
      tds.hide();
    }
  });
}