/* Validate SVG
* =============================================================================
* Description: Add a link to an SVG validation service on SVG images in the
* file namespace. This is a variation on my CSS validation script:
* [[User:Dlrohrer2003/validate-css.js]]
* Which is itself inspired by a gadget on the Wikimedia Commons:
* [[Commons:MediaWiki:Gadget-CSSValidate.js]]
*
* Author: [[User:Dlrohrer2003]]
*
* Categories: [[Category:Wikipedia scripts]]
*/
mw.loader.using( [ 'mediawiki.util' ], function () {
'use strict';
const conf = mw.config.get( [ 'wgNamespaceNumber', 'wgServer', 'wgTitle' ] );
if ( conf.wgNamespaceNumber === 6 && conf.wgTitle.match( /\.svg$/i ) && !document.getElementById( 'ca-validate-svg' ) ) {
const svgFileURL = window.location.protocol + conf.wgServer + mw.util.getUrl( 'Special:Filepath/' + conf.wgTitle );
const svgValidator = 'https://validator.w3.org/check?' + $.param( { doctype: 'Inline', ss: '1', uri: svgFileURL } );
mw.util.addPortletLink( 'p-cactions', svgValidator, 'Validate SVG', 'ca-validate-svg', 'Validate SVG file', '', null );
}
});