Module:TextCopy: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
-- | -- | ||
-- This module implements {{TextCopy}} | -- This module implements {{TextCopy}} | ||
-- =p.main{text='testtext'} | |||
-- | -- | ||
require('Module:No globals') | require('Module:No globals') | ||
Line 7: | Line 8: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
function p. | function p.main(frame, args) | ||
if not args then | if not args then | ||
args = getArgs(frame) | args = getArgs(frame) | ||
mw.log('got args') | |||
end | end | ||
local root = mw.html.create('div') | local root = mw.html.create('div') | ||
Line 17: | Line 19: | ||
:tag('div') | :tag('div') | ||
:addClass('copyleft') | :addClass('copyleft') | ||
local sdiv = root:tag('div') | |||
:addClass('textcopyright') | :addClass('textcopyright') | ||
if args.text then | |||
sdiv:wikitext(args.text) | |||
else | |||
sdiv:wikitext('no text given') | |||
end | |||
sdiv:tag('span') | |||
:attr('onclick','textCopyStringToClipboard(this)') | |||
:attr('role','button') | |||
:wikitext('📋') | |||
:addClass('textcopybutton') | |||
return tostring(root) | |||
end | end | ||
return p | return p |
Revision as of 18:16, 18 December 2023
Documentation for this module may be created at Module:TextCopy/doc
-- -- This module implements {{TextCopy}} -- =p.main{text='testtext'} -- require('Module:No globals') local p = {} local getArgs = require('Module:Arguments').getArgs function p.main(frame, args) if not args then args = getArgs(frame) mw.log('got args') end local root = mw.html.create('div') root :addClass('textcopyouter') :tag('div') :addClass('copyleft') local sdiv = root:tag('div') :addClass('textcopyright') if args.text then sdiv:wikitext(args.text) else sdiv:wikitext('no text given') end sdiv:tag('span') :attr('onclick','textCopyStringToClipboard(this)') :attr('role','button') :wikitext('📋') :addClass('textcopybutton') return tostring(root) end return p