MediaWiki:Common.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 251: | Line 251: | ||
var ullekhaUrl = wikiUrl( primarySlug + '/Ullekha' ); | var ullekhaUrl = wikiUrl( primarySlug + '/Ullekha' ); | ||
var | /* ── Button visibility rules ──────────────────────────────────────── | ||
* | |||
* Three separate concepts share the label "मूल" depending on page type: | |||
* | |||
* 1. On a BHASHYA page (e.g. Bhagavadgitabhashya): | |||
* मूलम् → /Moola (verse-text-only filtered view of the same doc) | |||
* Shown when the importer set data-has-moola on .gr-doc-title. | |||
* | |||
* 2. On a TEEKA page (e.g. Nyayasudha): | |||
* मूल → the primary bhashya this teeka comments on (Anuvyakhyana) | |||
* Always shown on teeka pages (teekaPage div is present). | |||
* | |||
* उल्लेख: | |||
* Shown on bhashya pages when data-has-ullekha is set, or on | |||
* teeka pages (links to primary bhashya's Ullekha page). | |||
* ──────────────────────────────────────────────────────────────── */ | |||
var docTitleEl = document.querySelector( '.gr-doc-title' ); | |||
var hasMoolaPage = docTitleEl && docTitleEl.getAttribute( 'data-has-moola' ) === '1'; | |||
var hasUllekhaPage = docTitleEl && docTitleEl.getAttribute( 'data-has-ullekha' ) === '1'; | |||
/* On a bhashya page, मूलम् links to the /Moola sub-page */ | |||
var moolaPageUrl = wikiUrl( primarySlug + '/Moola' ); | |||
/* On a teeka page, मूल links to the primary bhashya (already in moolaUrl) */ | |||
var showMoolaPage = !teekaPage && hasMoolaPage; /* bhashya → /Moola */ | |||
var showMoolaBack = !!teekaPage; /* teeka → primary bhashya */ | |||
var showUllekha = hasUllekhaPage || !!teekaPage; | |||
if ( !showMoolaPage && !showMoolaBack && !showUllekha ) return; | |||
var nav = document.createElement( 'div' ); | var nav = document.createElement( 'div' ); | ||
| Line 280: | Line 306: | ||
} | } | ||
if ( | /* Bhashya page: show मूलम् (→ /Moola filtered view) */ | ||
nav.appendChild( | if ( showMoolaPage ) nav.appendChild( makeBtn( moolaPageUrl, 'मूलम्', '#b04b00', '#fff3e0' ) ); | ||
/* Teeka page: show मूल (→ primary bhashya) */ | |||
if ( showMoolaBack ) nav.appendChild( makeBtn( moolaUrl, 'मूल', '#b04b00', '#fff3e0' ) ); | |||
/* Either page type: show उल्लेख when available */ | |||
if ( showUllekha ) nav.appendChild( makeBtn( ullekhaUrl, 'उल्लेख', '#1a5f8a', '#e8f4fc' ) ); | |||
var tocContents = toc.querySelector( '.vector-toc-contents' ); | var tocContents = toc.querySelector( '.vector-toc-contents' ); | ||