Jump to content

Module:Shortdesc helper JS

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Galobtter (talk | contribs) at 05:04, 5 July 2019 (fix). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

local prepend = [[
window.sdh = {};

/* These messages can be changed to localize Shortdesc helper for your wiki. 
** If that is not necessary, then this can be removed, and English-language messages will be used. */
]]
local append = [[
mw.loader.getScript( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-libSettings.js&action=raw&ctype=text/javascript' ).then (
function() {
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-Shortdesc-helper.css&action=raw&ctype=text/css', 'text/css');
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-Shortdesc-helper.js&action=raw&ctype=text/javascript' );
});
]]

function p.main(frame)
	local text = mw.title.new('MediaWiki:Gadget-Shortdesc-helper.js'):getContent()
	local content = text
		:match('var messages.-;')
		:gsub('var messages', 'window.sdh.messages')
		:gsub('\t\t', '\t')
		:gsub('\t};', '};')
	content = prepend..content..'\n\n'..append
	return frame:extensionTag ('syntaxhighlight', content, {lang = 'js'})
end

function p.append()
	return append
end

return p