Module:Module sandbox: Difference between revisions
Content deleted Content added
No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
No edit summary Tags: Reverted Mobile edit Mobile web edit Advanced mobile edit |
||
Line 20: | Line 20: | ||
local showButtonHtml = mw.html.create('button') |
local showButtonHtml = mw.html.create('button') |
||
:addClass('show-button') |
:addClass('show-button') |
||
:attr('onclick', 'document.getElementById(" |
:attr('onclick', 'document.getElementById("ani").style.display = "block";') |
||
:wikitext('Show') |
:wikitext('Show') |
||
local hideButtonHtml = mw.html.create('span') |
local hideButtonHtml = mw.html.create('span') |
||
:addClass('hide-button') |
:addClass('hide-button') |
||
:attr('onclick', 'document.getElementById(" |
:attr('onclick', 'document.getElementById("ani").style.display = "none";') |
||
:wikitext('Hide') |
:wikitext('Hide') |
||
Revision as of 13:00, 13 April 2024
Welcome to Module:Module sandbox, a Wikipedia module sandbox. This page is itself a module, and it allows you to carry out experiments related to module editing. If you wish to experiment with article editing, use the Wikipedia Sandbox or your own user sandbox.
To edit, click the edit tab above, make your changes and click the Publish changes button when finished. Please do not place malicious Lua code here, or copyrighted, offensive, illegal or libelous content in the sandboxes. For assistance with Lua coding, try the technical forum at the Village Pump. There are also several template sandboxes you can use to carry out experiments:
You can also conduct tests using the Wikipedia Sandbox. For instance, to invoke this module there, edit it so that it includes: {{#invoke:Module sandbox}} |
More info
Sandbox games |
Usage
{{#invoke:Module sandbox|function_name}}
local p = {}
function p.dropdownPopupWithButtons(frame)
local args = frame.args
local id = args.id or 'dropdown'
local options = args.options or ''
local dropdownHtml = mw.html.create('div')
:attr('id', id)
:addClass('dropdown-popup')
:css('display', 'none')
local listHtml = dropdownHtml:tag('ul')
for option in options:gmatch("[^,]+") do
listHtml:tag('li')
:wikitext(option)
end
local showButtonHtml = mw.html.create('button')
:addClass('show-button')
:attr('onclick', 'document.getElementById("ani").style.display = "block";')
:wikitext('Show')
local hideButtonHtml = mw.html.create('span')
:addClass('hide-button')
:attr('onclick', 'document.getElementById("ani").style.display = "none";')
:wikitext('Hide')
dropdownHtml:node(showButtonHtml)
dropdownHtml:node(hideButtonHtml)
return tostring(dropdownHtml)
end
return p