From 8728ca1d1b5c3a00830093ae780be4884aa65bbd Mon Sep 17 00:00:00 2001 From: Hans5958 Date: Sat, 30 Apr 2022 11:28:20 +0700 Subject: [PATCH] Fix period generation --- web/_js/infoblock.js | 2 +- web/_js/time.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/_js/infoblock.js b/web/_js/infoblock.js index 87c290a5..b41afeb3 100644 --- a/web/_js/infoblock.js +++ b/web/_js/infoblock.js @@ -43,7 +43,7 @@ function createInfoBlock(entry, isPreview) { else { let targetPeriod = formatPeriod(currentPeriod, currentPeriod, currentVariation) linkElement.href = "#" + entry.id - if (targetPeriod) linkElement.href += "/" + targetPeriod + if (targetPeriod && targetPeriod != defaultPeriod) linkElement.href += "/" + targetPeriod }; const linkNameElement = document.createElement("span"); linkNameElement.className = "flex-grow-1 text-break"; diff --git a/web/_js/time.js b/web/_js/time.js index 98a19cf1..1450b193 100644 --- a/web/_js/time.js +++ b/web/_js/time.js @@ -263,12 +263,16 @@ function parsePeriod(periodString) { } function formatPeriod(start, end, variation) { - let periodString + let periodString, variationString + variationString = variationsConfig[variation].code if (start === end) { - if (start === variationsConfig[variation].default) periodString = "" + if (start === variationsConfig[variation].default && variation !== defaultVariation) { + periodString = "" + } else periodString = start } else periodString = start + "-" + end - if (variation !== "default") return variationsConfig[variation].code + ":" + periodString + if (periodString && variationString) return variationsConfig[variation].code + ":" + periodString + if (variationString) return variationString return periodString } \ No newline at end of file