MediaWiki:Common.js: Difference between revisions

Undo revision 5588 by Chandrashekars (talk)
Tag: Undo
No edit summary
Line 14: Line 14:
  *    sub-path install (e.g. /My_wiki/). Points to "My_wiki:About".
  *    sub-path install (e.g. /My_wiki/). Points to "My_wiki:About".
  *  8. TOC customisations skipped on Main_Page and About pages.
  *  8. TOC customisations skipped on Main_Page and About pages.
*  9. BUG FIX: setupToc now waits for gr-toc-anchor spans before building;
*    MW hook guard prevents rebuild once TOC is already built.
  */
  */


Line 93: Line 95:
       'त':'த','थ':'த','द':'த','ध':'த','न':'ந',
       'त':'த','थ':'த','द':'த','ध':'த','न':'ந',
       'प':'ப','फ':'ப','ब':'ப','भ':'ப','म':'ம',
       'प':'ப','फ':'ப','ब':'ப','भ':'ப','म':'ம',
       'य':'ய','र':'ர','':'ல','ळ':'ழ','व':'வ',
       'य':'ய','र':'ர','':'ல','ळ':'ழ','व':'வ',
       'श':'ஶ','ष':'ஷ','स':'ஸ','ह':'ஹ',
       'श':'ஶ','ष':'ஷ','स':'ஸ','ह':'ஹ',
       'ा':'ா','ि':'ி','ी':'ீ','':'ு','ू':'ூ',
       'ा':'ா','ि':'ி','ी':'ீ','':'ு','ू':'ூ',
       'ृ':'ு','ॄ':'ூ',
       'ृ':'ு','ॄ':'ூ',
       'े':'ே','ை':'ை','ो':'ோ','ौ':'ௌ',
       'े':'ே','ை':'ை','ो':'ோ','ौ':'ௌ',
Line 661: Line 663:


   // ── Run all TOC customisations ───────────────────────────────────
   // ── Run all TOC customisations ───────────────────────────────────
  // FIX v8: Wait for gr-toc-anchor spans before building; once built never rebuild.
   function setupToc() {
   function setupToc() {
     if ( _tocBuilt ) {
     if ( _tocBuilt ) {
       // TOC already built — just re-run label/nav parts
       // TOC already built — just re-run label/nav parts, never rebuild
       renameTocTitle();
       renameTocTitle();
       injectTocDocNav();
       injectTocDocNav();
      return;
    }
    // Only build if gr-toc-anchor spans are already in the DOM
    var anchors = document.querySelectorAll( '.mw-parser-output .gr-toc-anchor' );
    if ( !anchors.length ) {
      // Anchors not yet in DOM — skip this call, retry will catch it
       return;
       return;
     }
     }
Line 812: Line 821:
         }
         }
         if ( currentScript !== 'deva' ) applyScript( currentScript );
         if ( currentScript !== 'deva' ) applyScript( currentScript );
         setupToc();
         // FIX v8: Only call setupToc if not already built
        if ( !_tocBuilt ) setupToc();
       }, 150 );
       }, 150 );
     } );
     } );