|
|
| Line 1: |
Line 1: |
| /* MediaWiki:Common.js — grantha.io (v7) */ | | /* MediaWiki:Common.js */ |
|
| |
|
| (function () { | | (function () { |
| Line 5: |
Line 5: |
| var LS_SCRIPT_KEY = 'grantha_reader_script'; | | var LS_SCRIPT_KEY = 'grantha_reader_script'; |
| var currentScript = 'deva'; | | var currentScript = 'deva'; |
| | |
| | function devanagariToTamil(text) { |
| | var CONSONANTS = { |
| | 'क': 'க', 'ख': 'க', 'ग': 'க', 'घ': 'க', 'ङ': 'ங', |
| | 'च': 'ச', 'छ': 'ச', 'ज': 'ஜ', 'झ': 'ஜ', 'ञ': 'ஞ', |
| | 'ट': 'ட', 'ठ': 'ட', 'ड': 'ட', 'ढ': 'ட', 'ण': 'ண', |
| | 'त': 'த', 'थ': 'த', 'द': 'த', 'ध': 'த', 'न': 'ந', |
| | 'प': 'ப', 'फ': 'ப', 'ब': 'ப', 'भ': 'ப', 'म': 'ம', |
| | 'य': 'ய', 'र': 'ர', 'ल': 'ல', 'ळ': 'ள', 'व': 'வ', |
| | 'श': 'ஶ', 'ष': 'ஷ', 'स': 'ஸ', 'ह': 'ஹ' |
| | }; |
| | var DIACRITICS = { |
| | 'ा': 'ா', 'ि': 'ி', 'ी': 'ீ', 'ु': 'ு', 'ू': 'ூ', |
| | 'े': 'ே', 'ै': 'ை', 'ो': 'ோ', 'ौ': 'ௌ' |
| | }; |
| | var VOWELS = { |
| | 'अ': 'அ', 'आ': 'ஆ', 'इ': 'இ', 'ई': 'ஈ', 'उ': 'உ', 'ऊ': 'ஊ', |
| | 'ए': 'ஏ', 'ऐ': 'ஐ', 'ओ': 'ஓ', 'औ': 'ஔ', 'ऽ': 'ऽ' |
| | }; |
| | var MISC = { |
| | 'ं':'ம்', 'ः':':', 'ँ':'ம்', 'ॐ':'ௐ', |
| | '०': '0', '१': '1', '२': '2', '३': '3', '४': '4', |
| | '५': '5', '६': '6', '७': '7', '८': '8', '९': '9' |
| | }; |
| | var HALANTA = '्'; |
| | var chars = Array.from(text), result = '', i = 0; |
| | while (i < chars.length) { |
| | var ch = chars[i], next = chars[i + 1]; |
| | if (CONSONANTS[ch]) { |
| | var base = CONSONANTS[ch]; |
| | if (next === HALANTA) { result += base + '்'; i += 2; } |
| | else if (next === 'ृ') { result += base + '்ரி'; i += 2; } |
| | else if (next === 'ॄ') { result += base + '்ரீ'; i += 2; } |
| | else if (DIACRITICS[next]) { result += base + DIACRITICS[next]; i += 2; } |
| | else { result += base; i++; } // inherent 'a' |
| | } |
| | else if (ch === 'ऋ') { result += 'ரி'; i++; } |
| | else if (ch === 'ॠ') { result += 'ரீ'; i++; } |
| | else if (VOWELS[ch]) { result += VOWELS[ch]; i++; } |
| | else if (MISC[ch]) { result += MISC[ch]; i++; } |
| | else { result += ch; i++; } |
| | } |
| | return result; |
| | } |
|
| |
|
| function devanagariToIAST(text) { | | function devanagariToIAST(text) { |
| Line 30: |
Line 74: |
| }; | | }; |
| var HALANTA = '्'; | | var HALANTA = '्'; |
| var chars = Array.from(text); | | var chars = Array.from(text), result = '', i = 0; |
| var result = '';
| |
| var i = 0;
| |
| while (i < chars.length) { | | while (i < chars.length) { |
| var ch = chars[i]; | | var ch = chars[i], next = chars[i + 1]; |
| var next = chars[i + 1];
| |
| if (CONSONANTS[ch]) { | | if (CONSONANTS[ch]) { |
| var base = CONSONANTS[ch]; | | var base = CONSONANTS[ch]; |
| Line 42: |
Line 83: |
| else if (next === 'ं' || next === 'ः') { result += base + 'a' + MISC[next]; i += 2; } | | else if (next === 'ं' || next === 'ः') { result += base + 'a' + MISC[next]; i += 2; } |
| else { result += base + 'a'; i++; } | | else { result += base + 'a'; i++; } |
| } else if (VOWELS[ch]) { result += VOWELS[ch]; i++; } | | } |
| | else if (VOWELS[ch]) { result += VOWELS[ch]; i++; } |
| else if (DIACRITICS[ch]) { result += DIACRITICS[ch]; i++; } | | else if (DIACRITICS[ch]) { result += DIACRITICS[ch]; i++; } |
| else if (MISC[ch]) { result += MISC[ch]; i++; } | | else if (MISC[ch]) { result += MISC[ch]; i++; } |
| Line 52: |
Line 94: |
| var SCRIPT_MAP = { | | var SCRIPT_MAP = { |
| kn: { | | kn: { |
| 'अ': 'ಅ', 'आ': 'ಆ', 'इ': 'ಇ', 'ई': 'ಈ', 'उ': 'ಉ', 'ऊ': 'ಊ', 'ऋ': 'ಋ', | | 'अ': 'ಅ', 'आ': 'ಆ', 'इ': 'ಇ', 'ई': 'ಈ', 'उ': 'ಉ', 'ऊ': 'ಊ', 'ऋ': 'ಋ', 'ॠ': 'ೠ', |
| 'ए': 'ಏ', 'ऐ': 'ಐ', 'ओ': 'ಓ', 'औ': 'ಔ', 'ऽ': 'ಽ', | | 'ए': 'ಏ', 'ऐ': 'ಐ', 'ओ': 'ಓ', 'औ': 'ಔ', 'ऽ': 'ಽ', |
| 'क': 'ಕ', 'ख': 'ಖ', 'ग': 'ಗ', 'घ': 'ಘ', 'ङ': 'ಙ', | | 'क': 'ಕ', 'ख': 'ಖ', 'ग': 'ಗ', 'घ': 'ಘ', 'ङ': 'ಙ', |
| Line 59: |
Line 101: |
| 'त': 'ತ', 'थ': 'ಥ', 'द': 'ದ', 'ध': 'ಧ', 'न': 'ನ', | | 'त': 'ತ', 'थ': 'ಥ', 'द': 'ದ', 'ध': 'ಧ', 'न': 'ನ', |
| 'प': 'ಪ', 'फ': 'ಫ', 'ब': 'ಬ', 'भ': 'ಭ', 'म': 'ಮ', | | 'प': 'ಪ', 'फ': 'ಫ', 'ब': 'ಬ', 'भ': 'ಭ', 'म': 'ಮ', |
| 'य': 'ಯ', 'र': 'ರ', 'ल': 'ಲ', 'व': 'ವ', | | 'य': 'ಯ', 'र': 'ರ', 'ल': 'ಲ', 'ळ': 'ಳ', 'व': 'ವ', |
| 'श': 'ಶ', 'ष': 'ಷ', 'स': 'ಸ', 'ह': 'ಹ', | | 'श': 'ಶ', 'ष': 'ಷ', 'स': 'ಸ', 'ह': 'ಹ', |
| 'ा': 'ಾ', 'ि': 'ಿ', 'ी': 'ೀ', 'ु': 'ು', 'ू': 'ೂ', | | 'ा': 'ಾ', 'ि': 'ಿ', 'ी': 'ೀ', 'ु': 'ು', 'ू': 'ೂ', |
| 'ृ': 'ೃ', 'े': 'ೇ', 'ै': 'ೈ', 'ो': 'ೋ', 'ौ': 'ೌ', | | 'ृ': 'ೃ', 'ॄ': 'ೄ', 'े': 'ೇ', 'ै': 'ೈ', 'ो': 'ೋ', 'ौ': 'ೌ', |
| 'ं': 'ಂ', 'ः': 'ಃ', '्': '್', | | 'ं': 'ಂ', 'ः': 'ಃ', '्': '್', 'ँ': 'ಁ', |
| '०': '೦', '१': '೧', '२': '೨', '३': '೩', '४': '೪', | | '०': '೦', '१': '೧', '२': '೨', '३': '೩', '४': '೪', |
| '५': '೫', '६': '೬', '७': '೭', '८': '೮', '९': '೯' | | '५': '೫', '६': '೬', '७': '೭', '८': '೮', '९': '೯' |
| }, | | }, |
| ta: { | | te: { |
| 'अ': 'அ', 'आ': 'ஆ', 'इ': 'இ', 'ई': 'ஈ', 'उ': 'உ', 'ऊ': 'ஊ', | | 'अ': 'అ', 'आ': 'ఆ', 'इ': 'ఇ', 'ई': 'ఈ', 'उ': 'ఉ', 'ऊ': 'ఊ', 'ऋ': 'ఋ', 'ॠ': 'ౠ', |
| 'ऋ': 'ரு', 'ॠ': 'ரூ',
| | 'ए': 'ఏ', 'ऐ': 'ఐ', 'ओ': 'ఓ', 'औ': 'ఔ', 'ऽ': 'ఽ', |
| 'ए': 'ஏ', 'ऐ': 'ஐ', 'ओ': 'ஓ', 'औ': 'ஔ', | | 'क': 'క', 'ख': 'ఖ', 'ग': 'గ', 'घ': 'ఘ', 'ङ': 'ఙ', |
| 'क': 'க', 'ख': 'க', 'ग': 'க', 'घ': 'க', 'ङ': 'ங', | | 'च': 'చ', 'छ': 'ఛ', 'ज': 'జ', 'झ': 'ఝ', 'ञ': 'ఞ', |
| 'च': 'ச', 'छ': 'ச', 'ज': 'ஜ', 'झ': 'ஜ', 'ञ': 'ஞ', | | 'ट': 'ట', 'ठ': 'ఠ', 'ड': 'డ', 'ढ': 'ఢ', 'ण': 'ణ', |
| 'ட': 'ட', 'ठ': 'ட', 'ड': 'ட', 'ढ': 'ட', 'ண': 'ண', | | 'त': 'త', 'थ': 'థ', 'द': 'ద', 'ध': 'ధ', 'न': 'న', |
| 'त': 'த', 'थ': 'த', 'द': 'த', 'ध': 'த', 'न': 'ந', | | 'प': 'ప', 'फ': 'ఫ', 'ब': 'బ', 'भ': 'భ', 'म': 'మ', |
| 'प': 'ப', 'फ': 'ப', 'ब': 'ப', 'भ': 'ப', 'म': 'ம', | | 'य': 'య', 'र': 'ర', 'ल': 'ల', 'ळ': 'ళ', 'व': 'వ', |
| 'य': 'ய', 'र': 'ர', 'ल': 'ல', 'ळ': 'ழ', 'व': 'வ', | | 'श': 'శ', 'ष': 'ష', 'स': 'స', 'ह': 'హ', |
| 'श': 'ஶ', 'ष': 'ஷ', 'स': 'ஸ', 'ह': 'ஹ', | | 'ा': 'ా', 'ि': 'ి', 'ी': 'ీ', 'ु': 'ు', 'ू': 'ూ', |
| 'ा': 'ா', 'ि': 'ி', 'ी': 'ீ', 'ु': 'ு', 'ू': 'ூ', | | 'ृ': 'ృ', 'ॄ': 'ౄ', 'े': 'ే', 'ै': 'ై', 'ो': 'ో', 'ौ': 'ౌ', |
| 'ृ': 'ு', 'ॄ': 'ூ', | | 'ं': 'ం', 'ः': 'ః', '्': '్', 'ँ': 'ఁ', |
| 'े': 'ே', 'ை': 'ை', 'ो': 'ோ', 'ौ': 'ௌ',
| | '०': '౦', '१': '౧', '२': '౨', '३': '౩', '४': '౪', |
| 'ं': 'ம்', 'ः': ':', 'ँ': 'ம்', '्': '்', 'ॐ': 'ௐ', 'ऽ': 'ௗ', | | '५': '౫', '६': '౬', '७': '౭', '८': '౮', '९': '౯' |
| '०': '0', '१': '1', '२': '2', '३': '3', '४': '4', | |
| '५': '5', '६': '6', '७': '7', '८': '8', '९': '9' | |
| } | | } |
| }; | | }; |
| Line 95: |
Line 135: |
| function transliterateText(text, script) { | | function transliterateText(text, script) { |
| if (script === 'en') return devanagariToIAST(text); | | if (script === 'en') return devanagariToIAST(text); |
| | if (script === 'ta') return devanagariToTamil(text); |
| var map = SCRIPT_MAP[script]; | | var map = SCRIPT_MAP[script]; |
| if (!map) return text; | | if (!map) return text; |
| Line 598: |
Line 639: |
| try { localStorage.setItem('gr_home_view', v); } catch (e) { } | | try { localStorage.setItem('gr_home_view', v); } catch (e) { } |
| } | | } |
| function initHomeToggle() {
| |
| var gBtn = document.getElementById('gr-toggle-grantha');
| |
| var aBtn = document.getElementById('gr-toggle-author');
| |
| if (!gBtn || !aBtn) return;
| |
| gBtn.addEventListener('click', function () { grHomeView('grantha'); });
| |
| aBtn.addEventListener('click', function () { grHomeView('author'); });
| |
| [gBtn, aBtn].forEach(function (btn) { btn.addEventListener('keydown', function (e) { if (e.key === 'Enter' || e.key === ' ') btn.click(); }); });
| |
| var saved; try { saved = localStorage.getItem('gr_home_view'); } catch (e) { }
| |
| if (saved === 'author') grHomeView('author');
| |
| }
| |
| if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initHomeToggle);
| |
| else initHomeToggle();
| |
| }()); | | }()); |
|
| |
|
| Line 941: |
Line 970: |
|
| |
|
| }()); | | }()); |
|
| |
| /* ═══════════════════════════════════════════════════════════════
| |
| Mobile addon — only runs on Minerva (mobile) skin
| |
| ═══════════════════════════════════════════════════════════════ */
| |
| (function () {
| |
| if (!document.body.classList.contains('skin-minerva')) return;
| |
| function injectCSS() {
| |
| if (document.getElementById('gr-mob-css')) return;
| |
| var s = document.createElement('style');
| |
| s.id = 'gr-mob-css';
| |
| s.textContent =
| |
| 'body,#mw-mf-viewport,#mw-mf-page-center{padding-top:0!important;margin-top:0!important;}' +
| |
| 'html,body,#mw-mf-viewport,#mw-mf-page-center{overflow-x:hidden!important;max-width:100vw!important;}' +
| |
| 'header.header-container{background:#b5451b!important;position:sticky!important;top:0!important;z-index:300!important;}' +
| |
| '.minerva-header{background:#b5451b!important;min-height:54px!important;}' +
| |
| '.minerva-header .search-toggle,.minerva-header .minerva-user-notifications{display:none!important;}' +
| |
| '.branding-box a{display:flex!important;align-items:center!important;text-decoration:none!important;max-width:calc(100vw - 80px)!important;}' +
| |
| '.branding-box a::before{content:"";display:block;width:30px;height:30px;flex-shrink:0;background:url("/favicon.png") center/contain no-repeat;margin-right:8px;}' +
| |
| '.branding-box a span{color:#fff!important;font-size:16px!important;font-weight:700!important;font-family:system-ui,sans-serif!important;line-height:1.2!important;flex:1 1 auto!important;min-width:0!important;}' +
| |
| '.minerva-header svg path,.minerva-header svg rect,.minerva-header svg circle{fill:#fff!important;}' +
| |
| '.minerva-header label{color:#fff!important;}' +
| |
| '.minerva-tabs,.mw-portlet-associated-pages,.page-actions-menu,#page-secondary-actions,.last-modified-bar,.minerva-anon-talk-link{display:none!important;}' +
| |
| '#gr-mob-menu-items{display:block!important;}' +
| |
| '.mw-footer.minerva-footer,.footer-places,.footer-info,.minerva-footer-logo,#footer-places-about,#footer-places-disclaimers,#footer-places-privacy{display:none!important;}' +
| |
| '#gr-static-bar{position:sticky!important;top:54px!important;z-index:200!important;}' +
| |
| '.mf-section-0,.mf-section-1,.mf-section-2,.mf-section-3,.mf-section-4,.mf-section-5,.mf-section-6,.mf-section-7,.mf-section-8,.mf-section-9,.mf-section-10{display:block!important;visibility:visible!important;}' +
| |
| '.collapsible-block{display:block!important;}' +
| |
| '.section-heading .indicator,.collapsible-heading .indicator{display:none!important;}' +
| |
| '.section-heading,.collapsible-heading{pointer-events:none!important;}' +
| |
| '.gr-home-grid{flex-direction:column!important;flex-wrap:nowrap!important;gap:12px!important;width:100%!important;}' +
| |
| '.gr-home-card{width:100%!important;max-width:100%!important;min-width:unset!important;box-sizing:border-box!important;flex:none!important;}' +
| |
| '.gr-home-toggle{flex-wrap:wrap!important;}' +
| |
| '.mw-parser-output{font-size:18px!important;line-height:1.8!important;}' +
| |
| '.mw-parser-output h2,.mw-parser-output h3{width:100%!important;}' +
| |
| '.bhashyam-block{margin-left:8px!important;}' +
| |
| '#footer,.mw-footer,.catlinks,#catlinks{display:none!important;}' +
| |
| '.gr-mob-toc-panel{position:fixed!important;top:0!important;left:0!important;bottom:0!important;width:82vw!important;max-width:340px!important;background:#fff!important;z-index:10400!important;box-shadow:4px 0 28px rgba(0,0,0,0.22)!important;overflow-y:auto!important;padding:0 0 40px!important;transform:translateX(-110%)!important;transition:transform 0.26s cubic-bezier(0.4,0,0.2,1)!important;display:block!important;}' +
| |
| '.gr-mob-toc-panel.open{transform:translateX(0)!important;}' +
| |
| '.gr-mob-toc-backdrop{display:none!important;position:fixed!important;inset:0!important;background:rgba(0,0,0,0.4)!important;z-index:10399!important;}' +
| |
| '.gr-mob-toc-backdrop.open{display:block!important;}' +
| |
| '.gr-mob-toc-header{position:sticky!important;top:0!important;background:#fff!important;display:flex!important;align-items:center!important;justify-content:space-between!important;padding:16px 16px 12px!important;border-bottom:1px solid #f0ebe6!important;z-index:1!important;}' +
| |
| '.gr-mob-toc-title{font-size:13px!important;font-weight:700!important;text-transform:uppercase!important;letter-spacing:0.08em!important;color:#b5451b!important;font-family:system-ui,sans-serif!important;}' +
| |
| '.gr-mob-toc-close{background:none!important;border:none!important;font-size:22px!important;color:#999!important;cursor:pointer!important;padding:4px 8px!important;}' +
| |
| '.gr-mob-toc-body{padding:12px 16px!important;}' +
| |
| '.gr-mob-toc-body a{display:block!important;font-size:16px!important;line-height:1.6!important;color:#2c1810!important;text-decoration:none!important;padding:8px 0!important;border-bottom:1px solid #f5f0ed!important;}';
| |
| document.head.appendChild(s);
| |
| }
| |
| function expandSections() {
| |
| document.querySelectorAll('[class*="mf-section-"], .collapsible-block').forEach(function (el) { el.removeAttribute('hidden'); el.style.setProperty('display', 'block', 'important'); el.style.setProperty('visibility', 'visible', 'important'); el.removeAttribute('aria-hidden'); });
| |
| document.querySelectorAll('.section-heading, .collapsible-heading').forEach(function (el) { el.setAttribute('aria-expanded', 'true'); el.style.setProperty('pointer-events', 'none', 'important'); });
| |
| }
| |
| function watchSections() {
| |
| var t = null;
| |
| var obs = new MutationObserver(function (ms) { if (ms.some(function (m) { return m.attributeName === 'hidden'; })) { clearTimeout(t); t = setTimeout(expandSections, 30); } });
| |
| obs.observe(document.querySelector('#mw-content-text') || document.body, { subtree: true, attributes: true, attributeFilter: ['hidden', 'aria-hidden'] });
| |
| }
| |
| function watchBodyPadding() {
| |
| new MutationObserver(function () { if (document.body.style.paddingTop && document.body.style.paddingTop !== '0px') document.body.style.paddingTop = ''; }).observe(document.body, { attributes: true, attributeFilter: ['style'] });
| |
| }
| |
| function injectMenuLinks() {
| |
| if (document.getElementById('gr-mob-menu-items')) return;
| |
| var navDrawer = document.querySelector('.navigation-drawer');
| |
| if (!navDrawer) return;
| |
| var wrap = document.createElement('div'); wrap.id = 'gr-mob-menu-items'; wrap.style.cssText = 'width:100%;background:#fff;margin-top:8px;';
| |
| var itemStyle = 'display:flex;align-items:center;gap:14px;padding:15px 20px;font-size:16px;color:#2c1810;text-decoration:none;font-family:system-ui,sans-serif;border-bottom:1px solid #f0ebe6;background:#fff;';
| |
| function makeItem(href, label) { var a = document.createElement('a'); a.href = href; a.style.cssText = itemStyle; a.innerHTML = '<span>' + label + '</span>'; return a; }
| |
| wrap.appendChild(makeItem('/Main_Page', 'Home'));
| |
| wrap.appendChild(makeItem('/My_wiki:Help', 'Help'));
| |
| wrap.appendChild(makeItem('/My_wiki:About', 'About'));
| |
| var userName = window.mw ? mw.config.get('wgUserName') : null;
| |
| if (userName) {
| |
| wrap.appendChild(makeItem((window.mw && mw.util && mw.util.getUrl) ? mw.util.getUrl('Special:Profile') : '/Special:Profile', 'Profile'));
| |
| var la = document.querySelector('a[href*="action=logout"]');
| |
| wrap.appendChild(makeItem(la ? la.href : '/index.php?title=Special:UserLogout', 'Log out'));
| |
| }
| |
| else wrap.appendChild(makeItem('/index.php?title=Special:UserLogin', 'Log in'));
| |
| var pageLeft = document.getElementById('mw-mf-page-left');
| |
| if (pageLeft) { while (pageLeft.firstChild) pageLeft.removeChild(pageLeft.firstChild); pageLeft.style.removeProperty('display'); pageLeft.appendChild(wrap); }
| |
| else navDrawer.appendChild(wrap);
| |
| }
| |
| var _tocDone = false;
| |
| function initToc() {
| |
| if (_tocDone) return;
| |
| var tocList = document.querySelector('.vector-toc-contents, .vector-toc .vector-toc-list');
| |
| if (!tocList || !tocList.querySelector('li')) return;
| |
| _tocDone = true;
| |
| var bd = document.createElement('div'); bd.className = 'gr-mob-toc-backdrop'; document.body.appendChild(bd);
| |
| var panel = document.createElement('div'); panel.className = 'gr-mob-toc-panel';
| |
| var hdr = document.createElement('div'); hdr.className = 'gr-mob-toc-header';
| |
| var ttl = document.createElement('div'); ttl.className = 'gr-mob-toc-title'; ttl.textContent = 'विषयसूची';
| |
| var cls = document.createElement('button'); cls.className = 'gr-mob-toc-close'; cls.textContent = '✕';
| |
| hdr.appendChild(ttl); hdr.appendChild(cls); panel.appendChild(hdr);
| |
| var body = document.createElement('div'); body.className = 'gr-mob-toc-body'; body.appendChild(tocList.cloneNode(true)); panel.appendChild(body); document.body.appendChild(panel);
| |
| var btn = document.createElement('button'); btn.id = 'gr-mob-toc-btn'; btn.innerHTML = '☰ Contents';
| |
| btn.style.cssText = 'position:fixed;bottom:148px;left:16px;z-index:9100;background:#fff;border:1.5px solid #b5451b;border-radius:24px;padding:10px 16px;font-size:15px;font-family:system-ui,sans-serif;color:#b5451b;font-weight:600;box-shadow:0 3px 14px rgba(0,0,0,0.15);cursor:pointer;';
| |
| document.body.appendChild(btn);
| |
| function open() { panel.classList.add('open'); bd.classList.add('open'); document.body.style.overflow = 'hidden'; }
| |
| function close() { panel.classList.remove('open'); bd.classList.remove('open'); document.body.style.overflow = ''; }
| |
| btn.onclick = open; cls.onclick = close; bd.onclick = close;
| |
| body.querySelectorAll('a').forEach(function (a) { a.onclick = close; });
| |
| }
| |
| function injectMoolaUllekhaLinks() {
| |
| if (document.getElementById('gr-mob-doc-nav')) return;
| |
| var pageName = (window.mw && mw.config && mw.config.get('wgPageName')) || '';
| |
| if (pageName === 'Main_Page' || !pageName) return;
| |
| function wikiUrl(slug) { if (window.mw && mw.util && mw.util.getUrl) return mw.util.getUrl(slug); return ((window.mw && mw.config.get('wgArticlePath')) || '/wiki/$1').replace('$1', encodeURIComponent(slug).replace(/%2F/g, '/')); }
| |
| var teekaPage = document.querySelector('.gr-teeka-page');
| |
| var primarySlug = teekaPage ? (teekaPage.getAttribute('data-primary') || pageName.split('/')[0]) : pageName.split('/')[0];
| |
| 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';
| |
| var showMoolam = !!teekaPage || hasMoolaPage, showUllekha = hasUllekhaPage || !!teekaPage;
| |
| if (!showMoolam && !showUllekha) return;
| |
| var nav = document.createElement('div'); nav.id = 'gr-mob-doc-nav';
| |
| nav.style.cssText = 'display:flex;gap:10px;padding:10px 16px 8px;background:#fdf8f5;border-bottom:1px solid #f0e0d6;font-family:system-ui,sans-serif;';
| |
| function makeLink(href, label) { var a = document.createElement('a'); a.href = href; a.textContent = label; a.style.cssText = 'display:inline-flex;align-items:center;padding:5px 16px;border-radius:20px;background:#fff;border:1.5px solid #e8cfc4;color:#b5451b;font-size:14px;font-weight:600;text-decoration:none;'; return a; }
| |
| if (teekaPage) nav.appendChild(makeLink(wikiUrl(primarySlug), 'मूल'));
| |
| else if (hasMoolaPage) nav.appendChild(makeLink(wikiUrl(primarySlug + '/Moola'), 'मूलम्'));
| |
| if (showUllekha) nav.appendChild(makeLink(wikiUrl(primarySlug + '/Ullekha'), 'उल्लेख'));
| |
| var h1 = document.getElementById('firstHeading') || document.querySelector('.page-heading, h1.firstHeading, .mw-first-heading');
| |
| if (h1 && h1.parentNode) h1.parentNode.insertBefore(nav, h1.nextSibling);
| |
| else { var ct = document.getElementById('mw-content-text'); if (ct) ct.insertBefore(nav, ct.firstChild); }
| |
| }
| |
| injectCSS(); watchBodyPadding();
| |
| function boot() { expandSections(); watchSections(); injectMenuLinks(); injectMoolaUllekhaLinks();[100, 400, 900, 1800].forEach(function (ms) { setTimeout(expandSections, ms); }); setTimeout(initToc, 700); }
| |
| if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot);
| |
| else boot();
| |
| if (window.mw) mw.hook('wikipage.content').add(function () { setTimeout(function () { expandSections(); injectMenuLinks(); injectMoolaUllekhaLinks(); initToc(); }, 300); });
| |
| }());
| |
|
| |
|
| |
|
| (function () { | | (function () { |
| Line 1,106: |
Line 1,005: |
| var ap = (window.mw && mw.config && mw.config.get('wgArticlePath')) || '/wiki/$1'; | | var ap = (window.mw && mw.config && mw.config.get('wgArticlePath')) || '/wiki/$1'; |
| return ap.replace('$1', title); | | return ap.replace('$1', title); |
| }
| |
|
| |
| function buildLogoutForm(token) {
| |
| token = token || '';
| |
| var esc = String(token).replace(/"/g, '"');
| |
| var script = (window.mw && mw.util && mw.util.wikiScript) ? mw.util.wikiScript() : '/index.php';
| |
| var form = document.createElement('form');
| |
| form.method = 'post';
| |
| form.action = script + '?title=Special:UserLogout';
| |
| form.style.display = 'none';
| |
| form.innerHTML =
| |
| '<input type="hidden" name="wpEditToken" value="' + esc + '">' +
| |
| '<input type="hidden" name="title" value="Special:UserLogout">' +
| |
| '<input type="hidden" name="returnto" value="Main Page">';
| |
| document.body.appendChild(form);
| |
| return form;
| |
| } | | } |
| }()); | | }()); |
| //Welcome banner
| |
| $( function () {
| |
| if ( !document.body.classList.contains( 'page-Welcome' ) ) {
| |
| return;
| |
| }
| |
| var go = function () {
| |
| window.location.href = 'https://anandamakaranda.in/';
| |
| };
| |
| document.body.addEventListener( 'click', go );
| |
| document.addEventListener( 'keydown', function ( e ) {
| |
| if ( e.key === 'Enter' ) {
| |
| go();
| |
| }
| |
| } );
| |
| } );
| |