FANDOM


local z = {} local HtmlBuilder = require( 'Module:HtmlBuilder' ) local WikitextLC = require( 'Module:WikitextLC' )

function Tcode( args )

   if args.T == nil or args.T ==  then
       return 
   end
   local builder = HtmlBuilder.create()
   local div = builder.tag( 'div' )
       .attr( 'id', 'noteTA-title' )
       .attr( 'data-noteta-code', mw.uri.encode( args.T ) )
       .wikitext( WikitextLC.title( args.T ) )
   if args.dt ~= nil and args.dt ~=  then
       div.attr( 'data-noteta-desc', mw.uri.encode( args.dt ) )
   end
   return tostring( builder )

end

function group( name, frame )

   if name == nil or name ==  then
       return 
   end
   local title = mw.title.makeTitle( 'Template', 'CGroup/' .. name )
   if title.exists then
       return frame:expandTemplate{ title = title }
   else
       return tostring( HtmlBuilder.create()
           .tag( 'div' )
               .attr( 'id', 'noteTA-group-' .. mw.uri.anchorEncode( name ) )
               .attr( 'class', 'noteTA-missing' )
               .attr( 'data-noteta-group', name )
           .allDone() )
   end

end

function Gcode( args, frame )

   local code = {}
   for i = 1, 30 do
       table.insert( code, group( args['G' .. i], frame ) )
   end
   code = table.concat( code )
   if code ~=  then
       code = tostring( HtmlBuilder.create()
           .tag( 'div' )
               .attr( 'id', 'noteTA-group' )
               .wikitext( code )
           .allDone() )
       if args.G31 ~= nil then
           code = code .. 
       end
   end
   return code

end

function local_( i, code, desc )

   if code == nil or code ==  then
       return 
   end
   local builder = HtmlBuilder.create()
   local div = builder.tag( 'div' )
       .attr( 'id', 'noteTA-local-' .. i )
       .attr( 'data-noteta-code', mw.uri.encode( code ) )
       .wikitext( WikitextLC.hidden( code ) )
   if desc ~= nil and desc ~=  then
       div.attr( 'data-noteta-desc', mw.uri.encode( desc ) )
   end
   return tostring( builder )

end

function Lcode( args )

   local code = {}
   for i = 1, 30 do
       table.insert( code, local_( i, args[i], args['d' .. i] ) )
   end
   code = table.concat( code )
   if code ~=  then
       code = tostring( HtmlBuilder.create()
           .tag( 'div' )
               .attr( 'id', 'noteTA-local' )
               .wikitext( code )
           .allDone() )
       if args[31] ~= nil then
           code = code .. 
       end
   end
   return code

end

function z.main( frame )

   local args = frame:getParent().args
   local Tc = Tcode( args )
   local Gc = Gcode( args, frame )
   local Lc = Lcode( args )
   local code = Tc .. Gc .. Lc
   if code ~=  then
       code = frame:expandTemplate{
           title = 'topicon',
           args = {
               id = 'noteTA-topicon',
               image = 'Zh conversion icon m.svg',
               alt = '本页使用了标题或全文手工转换',
               title = '本页使用了标题或全文手工转换',
               link = ,
               size = '35px',
           },
       } .. tostring( HtmlBuilder.create()
           .tag( 'div' )
               .attr( 'id', 'noteTA' )
               .wikitext( code )
           .allDone() )
   end
   return code

end

return z