I’m building a simple blog to learn SSG and also for fun.
I came from Python. I have no knowledge in Ruby, no knowledge in Liquid, no knowledge in JavaScript.
I just picked up javascript a few days ago and only learnt some of the syntax I needed.
I want to make a table but I don’t want to hardcode everything in html, so I decided to write the table in javascript.
THE CODE
<script>
let table_labels, uploaders, resolutions, encodings, bit_depths, audios, subtitles, download_urls, aired_episode;
table_labels = ['Source', 'Resolution', 'Encoding', 'Bit Depth', 'Audio', ' Subtitle'];
uploaders = ['AkihitoSubs Weekly (WEB)', 'Judas (WEB)'];
resolutions = ['1920 x 1080'];
encodings = ['HEVC'];
bit_depths = ['10 bits'];
audios = ['Japanese'];
subtitles = ['English'];
download_urls = [
'https://drive.shiro39.tk/0:/Anime/Lycoris%20Recoil/%5BASW%5D%20(WEB%20-%201080p%20-%20HEVC%20-%2010-bit%20-%20AAC)',
'https://drive.shiro39.tk/0:/Anime/Lycoris%20Recoil/%5BJudas%5D%20(WEB%20-%201080p%20-%20HEVC%20-%2010-bit%20-%20AAC)'
];
aired_episode = 7;
document.write(`
<h2>Mediainfo</h2>
<div class="mdui-table-fluid">
<table class="mdui-table mdui-color-grey-900">
<thead>
<tr>
`);
for (const table_label of table_labels) {
document.write(`<th class="mdui-text-color-white-secondary" style="text-align: center;">${table_label}</th>`);
}
document.write(`
</tr>
</thead>
<tbody>
`);
for (i = 0; i < uploaders.length; i++) {
if (uploaders.length === 1) {
document.write(`
<tr>
<td class="mdui-text-color-white" style="text-align: center;">${uploaders[0]}</td>
`);
} else {
document.write(`
<tr>
<td class="mdui-text-color-white" style="text-align: center;">${uploaders[i]}</td>
`);
}
if (resolutions.length === 1) {
document.write(`<td class="mdui-text-color-white" style="text-align: center;">${resolutions[0]}</td>`);
} else {
document.write(`<td class="mdui-text-color-white" style="text-align: center;">${resolutions[i]}</td>`);
}
if (encodings.length === 1) {
document.write(`<td class="mdui-text-color-white" style="text-align: center;">${encodings[0]}</td>`);
} else {
document.write(`<td class="mdui-text-color-white" style="text-align: center;">${encodings[i]}</td>`);
}
if (bit_depths.length === 1) {
document.write(`<td class="mdui-text-color-white" style="text-align: center;">${bit_depths[0]}</td>`);
} else {
document.write(`<td class="mdui-text-color-white" style="text-align: center;">${bit_depths[i]}</td>`);
}
if (audios.length === 1) {
document.write(`<td class="mdui-text-color-white" style="text-align: center;">${audios[0]}</td>`);
} else {
document.write(`<td class="mdui-text-color-white" style="text-align: center;">${audios[i]}</td>`);
}
if (subtitles.length === 1) {
document.write(`
<td class="mdui-text-color-white" style="text-align: center;">${subtitles[0]}</td>
</tr>
`);
} else {
document.write(`
<td class="mdui-text-color-white" style="text-align: center;">${subtitles[i]}</td>
</tr>
`);
}
}
document.write(`
</tbody>
</table>
</div>
<h2>Download</h2>
`);
uploaders.forEach((uploader, i) => {
document.write(`
<div class="mdui-table-fluid">
<table class="mdui-table mdui-color-grey-900">
<thead>
<tr>
<th class="mdui-text-color-white-secondary" style="text-align: center;">${uploader}</th>
<th class="mdui-text-color-white-secondary" style="text-align: center;">Downlad</th>
</tr>
</thead>
<tbody>
`);
for (let index = 0; index < aired_episode; index++) {
document.write(`
<tr>
<td class="mdui-text-color-white" style="text-align: center;">Episode ${("0" + (index + 1)).slice(-2)}</td>
<td class="mdui-text-color-white" style="text-align: center;">
<a href="${download_urls[i]}/Episode ${('0' + (index + 1)).slice(-2)}.mkv">Download</a>
</td>
</tr>
`);
}
document.write(`
</tbody>
</table>
</div>
`);
})
</script>
I put the code into the markdown file.
only the table loaded, not the whole page.
but if I added it as an external file in the /assets/, the page loads but the table won’t load.
after I manually refreshed the page, everything is loaded.
I have no idea what’s wrong…