MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 194: Line 194:
         if (!label.hasAttribute('data-deva')) label.setAttribute('data-deva', orig);
         if (!label.hasAttribute('data-deva')) label.setAttribute('data-deva', orig);
         if (translatableSpans.indexOf(label) === -1) translatableSpans.push(label);
         if (translatableSpans.indexOf(label) === -1) translatableSpans.push(label);
    }
    // Which script is on screen, published to CSS. Common.css §2b uses it to
    // swap the reading area onto --font-indic while a transliteration is
    // showing: most rules here name Adishila directly, which has no Tamil,
    // Kannada or Telugu letters, so without this the switched text fell back
    // to whatever serif the visitor's machine happened to have — the reason
    // it looked uneven from one line to the next.
    function markScriptOnRoot(script) {
        try {
            var el = document.documentElement;
            if (!el) return;
            if (!script || script === 'deva') el.removeAttribute('data-gr-script');
            else el.setAttribute('data-gr-script', script);
        } catch (e) { }
     }
     }


     function applyScript(script) {
     function applyScript(script) {
         currentScript = script;
         currentScript = script;
        markScriptOnRoot(script);
         translatableSpans.forEach(function (span) {
         translatableSpans.forEach(function (span) {
             if (!span.parentNode) return;
             if (!span.parentNode) return;