Fix more code consistency in weekly-view

This commit is contained in:
pr3cast 2022-03-21 15:18:25 -04:00
parent b921a2f86a
commit fbc9709b66

View File

@ -22,20 +22,20 @@ export default async function ({ web }, db) {
document.querySelectorAll(viewSelector).forEach(async ($view) => {
let currentText;
// Get view controls children nodes, convert to array, filter out non-text
const viewNodes = []
const $viewNodes = []
.slice.call($view.querySelector(viewControlSelector).children)
.filter(node => node.tagName.toLowerCase().match(/(div|span)/g));
// Find current view by analyzing children (which changes on viewport)
if (viewNodes.length === 1)
if ($viewNodes.length === 1)
{
// Mobile: Simple dropdown button (like legacy), text is current view
currentText = viewNodes[0].innerText.toLowerCase();
currentText = $viewNodes[0].innerText.toLowerCase();
} else {
// Wide/Desktop: Tabs listed, current view indicated by border style
currentText = viewNodes
currentText = $viewNodes
// Find selected view by border style (possibly fragile)
.filter((e) => e.children[0].style.borderBottomWidth.toString() === '2px')[0]
.filter(($e) => $e.children[0].style.borderBottomWidth.toString() === '2px')[0]
.innerText.toLowerCase();
}