MediaWiki:Gadget-AbsyFancyBoxy.js: различия между версиями

Нет описания правки
Поддержка переноса строк
Строка 144: Строка 144:
         fileLink = document.createElement( 'a' );
         fileLink = document.createElement( 'a' );
         fileLink.id = 'absyfancyboxy-filelink';
         fileLink.id = 'absyfancyboxy-filelink';
         fileLink.textContent = 'ФАЙЛ';
         fileLink.textContent = 'оригинал';
         fileLink.setAttribute( 'role', 'link' );
         fileLink.setAttribute( 'role', 'link' );
         fileLink.setAttribute( 'tabindex', '0' );
         fileLink.setAttribute( 'tabindex', '0' );
Строка 264: Строка 264:
         imgElement.src = item.src;
         imgElement.src = item.src;
         imgElement.alt = item.caption || '';
         imgElement.alt = item.caption || '';
         captionElement.textContent = item.caption || '';
 
        // Подпись: поддерживаем <br> без innerHTML (безопасно от XSS)
         captionElement.textContent = '';
        var captionText = item.caption || '';
        if ( captionText ) {
            var parts = captionText.split( /<br\s*\/?>/i );
            parts.forEach( function ( part, i ) {
                if ( i > 0 ) captionElement.appendChild( document.createElement( 'br' ) );
                captionElement.appendChild( document.createTextNode( part ) );
            } );
        }
 
         counterElement.textContent = ( currentIndex + 1 ) + ' / ' + gallery.length;
         counterElement.textContent = ( currentIndex + 1 ) + ' / ' + gallery.length;