DPL Test: Difference between revisions

From Illustrations in German Translations of Mark Twain's Works

Undo revision 2581 by HMHTEST (talk)
Tag: Undo
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{Seitenkopf|Bibliography Backbone}}
 
{{#dpl:
|category = Media Pages
|include = {MediaInfo}:publication:year:illustrator:chapter:illustration:title:tags:[[%TITLE%]]
|table = class="wikitable datatable hover" id="DPL"
data-layout='{"top1Start":"searchBuilder"}'
data-language='<nowiki>{"searchPlaceholder":" Quick Search",  "search":"", "searchBuilder":{"add":"Add Search Condition"}}</nowiki>'
data-page-length="50",-,Publication, Year, Illustrator, Chapter, Illustration, Title, Tags,ID
|tablerow=style="width:5%;"¦%%, %%, style="width:5%;"¦%%, %%, style="width:5%;"¦%%, style="width:5%;"¦%%, class="type" style="width:5%;"¦%%,
style="width:5%;"¦%%, style="width:5%;"¦%%
|ordermethod = title
|order=ascending
}}
<html>
<html>
<button id="generateCatalogHTML">
<p>
Generate static catalog HTML
<button id="generateCatalogHTML">Create Raw HTML</button>
</button>
</p>
 
<pre id="catalogOutput" style="margin-top:1em; white-space:pre-wrap;"></pre>
 
<script>
mw.hook('wikipage.content').add(function () {


  const button = document.getElementById('generateCatalogHTML');
<textarea id="outputHTML" style="width:100%; height:600px; font-family:monospace;"></textarea>
  if (!button) return;
 
  function extractFileName(a) {
    if (!a) return null;
 
    const m = a.href.match(/title=([^&]+)/i);
    if (!m) return null;
 
    return decodeURIComponent(m[1]).replace(/\.jpg$/i, '');
  }
 
  button.addEventListener('click', function () {
 
    const table = document.getElementById('DPL');
    if (!table) {
      alert('DPL table not found');
      return;
    }
 
    const rows = table.querySelectorAll('tbody tr');
    if (rows.length <= 1) {
      alert('No data rows found');
      return;
    }
 
    let out = [];
 
    rows.forEach((row, i) => {
      if (i === 0) return; // skip header
 
      const td = row.querySelectorAll('td');
      if (td.length < 8) return;
 
      const file = extractFileName(td[7].querySelector('a'));
      if (!file) return;
 
      out.push(`
<tr>
<td align="left"><font face="Liberation Serif">${td[0].innerText.trim()}</font></td>
<td align="right" sdval="${td[1].innerText.trim()}"><font face="Liberation Serif">${td[1].innerText.trim()}</font></td>
<td align="left"><font face="Liberation Serif">${td[2].innerText.trim()}</font></td>
<td align="center">${td[3].innerText.trim()}</td>
<td align="center">${td[3].innerText.trim()}</td>
<td align="center">${td[4].innerText.trim()}</td>
<td align="left"><font face="Liberation Serif">${td[5].innerText.trim()}</font></td>
<td align="left"><font face="Liberation Serif">-${td[6].innerText.trim().replace(/,\s*/g, ' -')}</font></td>
<td align="left">
  <a href="/index.php/Special:Redirect/file/${file}.jpg">${file}</a>
</td>
</tr>`.trim());
    });
 
    const html = `
<table id="catalog" class="wikitable" style="width:100%">
<thead>
<tr>
<th>Book</th>
<th>Year</th>
<th>Illustrator</th>
<th>Og.Chpt.</th>
<th>Chpt.</th>
<th>Ill. in Chpt.</th>
<th>Illustration Title</th>
<th>Tags</th>
<th>ID</th>
</tr>
</thead>
<tbody>
${out.join('\n')}
</tbody>
</table>`.trim();
 
    document.getElementById('catalogOutput').textContent = html;
  });
 
});
</script>
 
 
</html>
<html>
<button id="testButton">JS TEST</button>


<script>
<div id="status" style="margin-top:10px;"></div>
document.getElementById('testButton').addEventListener('click', function () {
  alert('JavaScript is running');
});
</script>
</html>
</html>

Latest revision as of 00:07, 12 May 2026

Bibliography Backbone