Template:File Summary: Difference between revisions
Template page
More actions
No edit summary Tag: Reverted |
Tag: Undo |
||
| Line 2: | Line 2: | ||
<head> | <head> | ||
<style> | <style> | ||
table { | |||
border: 1px solid #aaa; | border: 1px solid #aaa; | ||
background-color: #f9f9f9; | background-color: #f9f9f9; | ||
border-collapse: collapse; | border-collapse: collapse; | ||
width: | width: 100%; | ||
font-size: 90%; | font-size: 90%; | ||
margin: 1em | margin-bottom: 1em; | ||
} | } | ||
th { | |||
background-color: #e6e6e6; | background-color: #e6e6e6; | ||
border-bottom: 1px solid #aaa; | border-bottom: 1px solid #aaa; | ||
| Line 17: | Line 16: | ||
padding: 5px 10px; | padding: 5px 10px; | ||
} | } | ||
td { | |||
padding: 5px 10px; | padding: 5px 10px; | ||
border-bottom: 1px solid #ddd; | border-bottom: 1px solid #ddd; | ||
| Line 24: | Line 23: | ||
</head> | </head> | ||
<body> | <body> | ||
<table id="dynamicTable"> | |||
<table | |||
<tr> | <tr> | ||
<th colspan="2"> | <th colspan="2">Summary</th> | ||
</tr> | </tr> | ||
</table> | </table> | ||
<script> | <script> | ||
// | // Data (add only fields you want to show) | ||
const | const data = { | ||
Description: "Custom description for Bhikitia", | Description: "Custom description for Bhikitia", | ||
Date: "16 September 2023", | Date: "16 September 2023", | ||
Source: "Own work", | Source: "Own work", | ||
Author: "Chabe01", | Author: "Chabe01", | ||
}; | }; | ||
// | // Render the table dynamically | ||
const | const table = document.getElementById("dynamicTable"); | ||
for (const [key, value] of Object.entries( | for (const [key, value] of Object.entries(data)) { | ||
if (value) { // Only include rows where value is not empty | if (value) { // Only include rows where the value is not empty | ||
const row = document.createElement("tr"); | const row = document.createElement("tr"); | ||
const cellKey = document.createElement("td"); | const cellKey = document.createElement("td"); | ||
| Line 55: | Line 50: | ||
row.appendChild(cellKey); | row.appendChild(cellKey); | ||
row.appendChild(cellValue); | row.appendChild(cellValue); | ||
table.appendChild(row); | |||
} | } | ||
} | } | ||
Revision as of 23:13, 3 December 2024
| Summary |
|---|