Module:TextCopy: Difference between revisions

No edit summary
No edit summary
 
Line 17: Line 17:
root
root
:addClass('textcopyouter')
:addClass('textcopyouter')
:tag('div')
:addClass('copyleft')


local sdiv = root:tag('div')
local fdiv = root:tag('div')
:addClass('textcopyright')
    :addClass('copyleft')
                :attr('id','text')
     if args.text then
     if args.text then
  sdiv:wikitext(args.text)
  fdiv:wikitext(args.text)
     else
     else
       sdiv:wikitext('no text given')
       fdiv:wikitext('no text given')
     end
     end
local sdiv = root:tag('div')
:addClass('textcopyright')
     sdiv:tag('span')
     sdiv:tag('span')
       :attr('onclick','textCopyStringToClipboard(this)')
       :attr('onclick','textCopyStringToClipboard(this)')

Latest revision as of 18:22, 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')

	local fdiv = root:tag('div')
			     :addClass('copyleft')
                 :attr('id','text')
    if args.text then
	  fdiv:wikitext(args.text)
    else
      fdiv:wikitext('no text given')
    end
	local sdiv = root:tag('div')
			:addClass('textcopyright')
    sdiv:tag('span')
      :attr('onclick','textCopyStringToClipboard(this)')
      :attr('role','button')
      :wikitext('📋')
      :addClass('textcopybutton')
   return tostring(root)
end

return p