From 45e9e5230ce328fd474af2d12fd96f8061510c8f Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Sun, 7 Jul 2019 00:09:55 -0600 Subject: [PATCH] Correctly show/hide homonymn number --- src/js/wordManagement.js | 2 +- src/php/api/Dictionary.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/wordManagement.js b/src/js/wordManagement.js index e037beb..fe95e2c 100644 --- a/src/js/wordManagement.js +++ b/src/js/wordManagement.js @@ -90,7 +90,7 @@ export function parseReferences(detailsMarkdown) { if (homonymn < 1 && homonymnIndexes.length > 0) { homonymn = 1; } - const homonymnSubHTML = homonymn > 0 ? '' + homonymn.toString() + '' : ''; + const homonymnSubHTML = homonymnIndexes.length > 1 && homonymn - 1 >= 0 ? '' + homonymn.toString() + '' : ''; const wordMarkdownLink = `[${translateOrthography(wordToFind)}${homonymnSubHTML}](#${existingWordId})`; detailsMarkdown = detailsMarkdown.replace(new RegExp(reference, 'g'), wordMarkdownLink); } diff --git a/src/php/api/Dictionary.php b/src/php/api/Dictionary.php index 21fb3d4..fc7412a 100644 --- a/src/php/api/Dictionary.php +++ b/src/php/api/Dictionary.php @@ -217,7 +217,7 @@ VALUES ($new_id, ?, ?, ?, ?, ?)"; if ($homonymn < 1) { $homonymn = 1; } - $homonymn_sub_html = $homonymn > 0 ? '' . $homonymn . '' : ''; + $homonymn_sub_html = count($reference_ids) > 1 && $homonymn - 1 >= 0 ? '' . $homonymn . '' : ''; $site_root = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], $dictionary_id)); $markdown_link = '' . '' . $this->translateOrthography($word_to_find, $dictionary_id) . '' . $homonymn_sub_html