Module:Comics/Sandbox

local p = {} local h = require("Module:HF") local SC = require("Module:StaffCorrection") local standart = require("Module:StandardizedName") local monthData = mw.loadData( 'Module:Month/data' ) --local m = require("Module:Month") local monthAliases = monthData[1] local monthNumbers = monthData[2] local border_color = '#B5B7CF' local background_color = '#EFF0FF' local staff_fieldname = {"Writer", "Penciler", "Inker", "Colourist", "Letterer", "AdaptedFrom", "Editor", "CoverArtist", "Editor-in-Chief" } local staff_singular = {"Writer", "Penciler", "Inker", "Colourist", "Letterer", "Adapted from original material by", "Editor", "Cover Artist", "Editor-in-Chief"} local staff_plural = {"Writers", "Pencilers", "Inkers", "Colourists", "Letterers", "Adapted Stories", "Editors", "Cover Artists", "Editors-in-Chief"}--, "Directors", "Producers", "CCO"} local staff_category_needed = {true, true, true, true, true, false, true, true, true} local staff_infobox_link = {true, true, true, true, true, true, true, true, true} local page = '' local pagename = '' local sortname = '' local title = {} local title_volume = '' local categories = {} local stories = {}

function p.infobox(frame) local getArgs = require('Dev:Arguments').getArgs local args = getArgs (frame) local year = args['Year'] local month = args['Month'] local season = args['Season'] local releasedate = args['ReleaseDate'] local canceled = args['Canceled'] local reprint_title = {} local reprint_story = {} local storytitles = {} local appearances = {} local synopses = {} local contributors = {} local staff = {} local editor_in_chief = '' local cover_artists = {} local reprint = '' local reprints_content = {} local reprint_storytitles = {} local previous_issue = '' local next_issue = '' local s = '' local n = '' local i = 0 local j = 0 local j = 0 local body = {} local categorize = true page = mw.title.getCurrentTitle pagename = page.text title = { standart.lua_get_title_volume_issue(pagename) } title_volume = title[1]..' Vol '..title[2] sortname = standart.lua_standardized_name_for_sorting(pagename,'Comics') previous_issue = args['PreviousIssue'] or standart.lua_standardized_link(title_volume..tonumber(title[3])-1, 'Comics') next_issue = args['NextIssue'] or standart.lua_standardized_link(title_volume..tonumber(title[3])+1, 'Comics') table.insert(categories, 'Comics' ) table.insert(categories, title_volume ) if string.find(pagename, ' Annual ') then table.insert(categories, 'Annuals' ) end if string.find(pagename, ' Handbook ') then table.insert(categories, 'Handbooks' ) end for j = 1,#staff_fieldname-1 do       table.insert( staff, {} ) end

for i = 1,80 do       table.insert( reprint_title, args['ReprintOf'..i] or '' ) table.insert( reprint_story, args['ReprintOfStory'..i] or '' ) table.insert( storytitles, args['StoryTitle'..i] or '' )

if h.isempty(reprint_title[i]) == false then if p.lua_count_inlist(categories, 'Reprints') == 0 then table.insert(categories, 'Reprints' ) end n = reprint_story[i] or '1' s = standart.lua_standardized_comics_name(reprint_title[i]) --checks if the same comics issue is reprinted several times, if it is, then its content is retrieved from the table, if not, then it returned by getContent - to prevent using getContent several times for the same comics issue --if p.lua_count_inlist(reprint_title, s)>1 --   then --       reprints_content[i] = reprints_content[p.lua_find_inlist(reprint_title, s)] --       reprint = reprints_content[i] --   else reprint = mw.title.new(s):getContent --       table.insert(reprints_content, reprint) table.insert(categories, s..'/Reprints') --end if h.isempty(reprint) == false then s = string.match(reprint, '|%s+StoryTitle'..n..'%s+=%s+(.-)\n') reprint_storytitles[i] = s or '' for j = 1,#staff_fieldname-2 do                           for k = 1,50 do                                s = string.match(reprint, '|%s+'..staff_fieldname[j]..n..'_'..k..'%s+=%s+(.-)\n') staff[j][k] = s or '' end end appearances[i] = p.lua_reprint_appearances( string.match(reprint, '|%s+Appearing'..n..'%s+=%s+(.-)\n|'), pagename ) synopses[i] = string.match(reprint, '|%s+Synopsis'..n..'%s+=%s+(.-)\n|') categorize = false else appearances[i] = '' synopses[i] = '' end else table.insert( appearances, args['Appearing'..i] or '' ) table.insert( synopses, args['Synopsis'..i] or '' ) categorize = true for j = 1,#staff_fieldname-2 do                   for k = 1,50 do                         staff[j][k] = args[staff_fieldname[j]..i..'_'..k] or '' end end end

if h.isempty(storytitles[i]) == false or           h.isempty(reprint_storytitles[i]) == false or           h.isempty(reprint_title[i]) == false or           h.isempty(appearances[i]) == false or           h.isempty(synopses[i]) == false then stories[i] = true else stories[i] = false end if stories[i] == true then storytitles[i] = p.lua_StoryTitle( i, storytitles[i], reprint_storytitles[i] )

body = {} for j = 1,#staff_fieldname-2 do                   table.insert(body, p.lua_infobox_line_staff(staff[j], j, categorize) ) end body = table.concat(body) contributors[i] = p.lua_story_contributors( storytitles[i], body ) end end -- cover artists for k = 1,50 do       s = args[staff_fieldname[#staff_fieldname-1]..k]        if h.isempty(s) == false then s = SC.Correction(s) else s = '' end table.insert( cover_artists, s ) end -- editor-in-chief s = args["Editor-in-Chief"] if h.isempty(s) == false then s = SC.Correction(s) else s = '' end editor_in_chief = ''

for i = 1,#categories do       categories[i] = h.CategoryLink(categories[i], sortname) end

return previous_issue, next_issue--, table.concat(contributors) --return mw.text.listToText( staff[1] ), "_", mw.text.listToText( staff[2] ) --return page.text --return p.lua_link_to_publication_category(dates[1], dates[2], dates[3]) --return mw.text.listToText( storytitles ) --return mw.text.listToText( reprint_title ) end

function p.lua_story_contributors(storytitle, text) local output = '' if h.isempty(text) == false then output = p.show_hide({           collapsed   = false,            titlestyle  = 'width:88%; text-align:left;',            extrastyle  = 'width:100%; center; margin:0px; border:none; border-top:2px solid #B5B7CF; text-align:left;',            title       = h.Link(page.prefixedText..'#Appearing in '..storytitle, storytitle),             body        = text        }) end return output end

--transform the list of contributors into infobox line with or without categorization function p.lua_infobox_line_staff(list, n, cat) local i   local name = '' local corrected = '' local job = '' local output = ''

if h.isempty(list) == false then if staff_infobox_link[n] == true then job = ..staff_singular[n].. else job = staff_plural[n] end for i = 1, #list do               v = list[i] if h.isempty(v) == false then c = SC.Correction(v) if string.lower(v) == 'uncredited' or string.lower(v) == 'n/a' then list[i] = '\nUncredited' else list[i] = '\n'..h.Link(c, v)--..' ' if cat == "yes" then table.insert(categories, c..'/'..staff_plural[n]) end end end end list = table.concat(list) if h.isempty(list) == false then output = p.lua_infobox_line( job, list ) end elseif staff_category_needed[n] == true then table.insert(categories, staff_singular[n]..' Needed') end return output end

--get the list of general contributors (cover artists, editors-in-chief, etc.) function p.GeneralContributors(frame)

local l = mw.text.split( frame.args[1],"*",true ) local t = frame.args[2] local cat = frame.args["category"] local link_name = frame.args["link_name"] local needed = frame.args["needed"] local t2

if t == 'Editor-in-Chief' then t2 = 'Editors-in-Chief' else t2 = t..'s'   end if h.isempty(link_name) == true then link_name = ..t.. end l = p.lua_StoryContributors(l, t, cat) if h.isempty(l) == false then return frame:preprocess( '' ) elseif cat == 'yes' and needed ~= 'no' then return '' else return '' end end

function p.appearances_needed(frame) local getArgs = require('Dev:Arguments').getArgs local args = getArgs (frame) local s = args['Appearing1'] or '' s = mw.text.split(s, '\n', true) local output = 0 local empty = { "Featured Characters:", "* ", "Supporting Characters:", "* ", "Antagonists:", "* ", "Other Characters:", "* ", "Locations:", "* ", "Items:", "* ", "Vehicles:", "* " }   if #s == 14 then for i = 1, #s do               if s[i] == empty[i] then output = output + 1 end end end if output < 14 then output = false else output = true end return output end

--takes a date and formats it according to the syntax - https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##time function p.lua_date_converter(s, t)   local l = mw.language.new('en') local day local month local year local i = 0 local j = 0 --'To comma' = 'F j, Y', "dash" = 'm-d-Y' if h.isempty(t) == true then t = 'Ymd' end if h.isempty(s) == true then s = l:formatDate(t) else i = string.find(s, '-',1,true) j = string.find(s, ', ',1,true) if i ~= nil then j = string.find(s, '-',i+1,true) month = string.sub(s, 1, i-1) month = monthNumbers[string.lower( month )] or month day = string.sub(s, i+1, j-1) if #day == 1 then day = "0"..day end year = string.sub(s, j+1, #s) s = l:formatDate(t, day.."-"..month.."-"..year) elseif j ~= nil then year = string.sub(s, j+2, #s) i = string.find(s, ' ',1,true) month = string.sub(s, 1, i-1) month = monthNumbers[string.lower( month )] or month day = string.sub(s, i+1, j-1) if #day == 1 then day = "0"..day end s = l:formatDate(t, day.."-"..month.."-"..year) else s = l:formatDate(t, s)           end end return s end function p.date_converter(frame) return p.lua_date_converter(frame.args[1], frame.args[2]) end

--compares two dates. Return "true" if 1st date is before the 2nd date, and "false" otherwise. function p.lua_date_comparison(d1, d2) d1 = p.lua_date_converter(d1, 'Ymd') if h.isempty(d2) == true then d2 = '@'..os.time --If 2nd date is ommited, then current date is used for comparison. end d2 = p.lua_date_converter(d2, 'Ymd')

if d1<=d2 then return true else return false end end function p.date_comparison(frame) return p.lua_date_comparison(frame.args[1], frame.args[2]) end

--check if comics is canceled or a solicitation function p.lua_solicit_or_canceled(releasedate, canceled) if h.isempty(canceled) == false or (h.isempty(releasedate) == false and p.lua_date_comparison(releasedate) == false) then return true --it is canceled or a solicitation else return false end end function p.solicit_or_canceled(frame) if p.lua_solicit_or_canceled(frame.args[1], frame.args[2]) == true then return 'yes' else return '' end end function p.not_solicit_or_canceled(frame) if p.lua_solicit_or_canceled(frame.args[1], frame.args[2]) == false then return 'yes' else return 'no' end end

--check if comics is recently released/published function p.lua_recent(releasedate, month, year, season, canceled) local l = mw.language.new('en') local current = l:formatDate('Ymd') local s = ''

if h.isempty(canceled) == true then if h.isempty(month) == true and h.isempty(season) == false then month = season end

if h.isempty(releasedate) == false then releasedate = p.lua_date_converter(releasedate, 'Ymd') if releasedate>=l:formatDate('Ymd', '- 4 months') and releasedate<=current then s = true end elseif h.isempty(year) == false and h.isempty(month) == false then releasedate = p.lua_date_converter(monthAliases[string.lower( month )]..' 1, '..year, 'Ymd') if releasedate>=l:formatDate('Ymd', '- 2 months') and releasedate<=current then s = true end end end return s end function p.recent(frame) return p.lua_recent(frame.args[1], frame.args[2], frame.args[3], frame.args[4], frame.args[5]) end

--returns number of week function p.lua_release_week(d, t)   local y    if h.isempty(t) == true then d = 'Week '..p.lua_date_converter(d, 'W')..', '..p.lua_date_converter(d, 'Y') else d = (d-1) * 7 + 1 y = '01-01-'..p.lua_date_converter('','Y') d = p.lua_date_converter(y..' + '..d..' days', 'F j, Y') end return d end

--returns release week category function p.release_week_category(frame) local d = frame.args[1] or '' if h.isempty(d) == false then return '' else return '' end end

--returns link to release week category function p.lua_link_to_release_week_category(d) local w   if h.isempty(d) == false then w = p.lua_release_week(d) d = p.lua_date_converter(d, 'F j, Y') return ..d.. else return '' end end function p.link_to_release_week_category(frame) return p.lua_link_to_release_week_category(frame.args[1]) end

--returns publication category function p.publication_category(frame) local year = frame.args[1] local month = frame.args[2] local season = frame.args[3] local pagename = standart.lua_remove_the(frame.args[4]) local s = ''

if h.isempty(month) == true and h.isempty(season) == false then month = season end

if h.isempty(year) == false then if h.isempty(month) == false then month = monthAliases[string.lower( month )] s = s..'' else s = s..'' end s = s..p.lua_era(year) end return s end

--returns link to date of publication category function p.lua_link_to_publication_category(year, month, season) local s = '' if h.isempty(month) == true and h.isempty(season) == false then month = season end

if h.isempty(year) == false then if h.isempty(month) == false then month = monthAliases[string.lower( month )] s = ..month..', '..year.. else s = ..year.. end end return s end function p.link_to_publication_category(frame) return p.lua_link_to_publication_category(frame.args[1], frame.args[2], frame.args[3]) end

--returns era based on year function p.lua_era(year, t)   if h.isempty(year) == false then if h.isempty(t) == true then t = '' else t = ' '..t           end year = tonumber(year) if year<1955 then return '' end if year>=1955 and year<1970 then return '' end if year>=1970 and year<1983 then return '' end if year>=1983 and year<1992 then return '' end if year>=1992 then return '' end else return '' end end function p.era(frame) return p.lua_era(frame.args[1], frame.args[2]) end

function p.links_to_release_publication_dates(frame) local year = frame.args[1] local month = frame.args[2] local season = frame.args[3] local release = p.lua_link_to_release_week_category(frame.args[4]) local canceled = frame.args[5] local published = p.lua_link_to_publication_category(year, month, season) local s = '' local s1 = '' local s2 = '' if h.isempty(canceled) == false then s1 = 'Intended Publication Date' s2 = 'Intended Release Date' else s1 = 'Published' s2 = 'Released' end

if h.isempty(published) == false then if h.isempty(release) == false then s = ' ' else s = ' ' end elseif h.isempty(release) == false then s = ' ' end return s end

-- --events, arcs, storylines function p.events_and_arcs(frame) local events = mw.text.split( frame.args[1],"@@@",true ) local events_names = mw.text.split( frame.args[2],"@@@",true ) local arcs = mw.text.split( frame.args[3],"@@@",true ) local arcs_names = mw.text.split( frame.args[4],"@@@",true ) local storylines = mw.text.split( frame.args[5],"@@@",true ) local storylines_names = mw.text.split( frame.args[6],"@@@",true ) local i   local j    local e = {} local a = {} local sl = {} local s = '' j = 1 for i = 1,#events do       if h.isempty(events[i]) == false then if h.isempty(events_names[i]) == true then events_names[i] = events[i] end e[j] = '"'..events_names[i]..'"' j = j + 1 end end if #e > 0 then s = 'Part of the ' if #e > 1 then s = s..mw.text.listToText( e )..' events' else s = s..e[1]..' event' end s = s..' ' end j = 1 for i = 1,#arcs do       if h.isempty(arcs[i]) == false then if h.isempty(arcs_names[i]) == true then arcs_names[i] = arcs[i] end a[j] = '"'..arcs_names[i]..'"' j = j + 1 end end if #a > 0 then if s ~= '' then s = s..' ' end s = s..'Part of the ' if #a > 1 then s = s..mw.text.listToText( a )..' story arcs' else s = s..a[1]..' story arc' end s = s..' ' end j = 1 for i = 1,#storylines do       if h.isempty(storylines[i]) == false then if h.isempty(storylines_names[i]) == true then storylines_names[i] = storylines[i] end sl[j] = '"'..storylines_names[i]..'"' j = j + 1 end end if #sl > 0 then if s ~= '' then s = s..' ' end s = s..'Part of the ' if #sl > 1 then s = s..mw.text.listToText( sl )..' storylines' else s = s..sl[1]..' storyline' end s = s..' ' end

return s end

--display a quote from the original comics without autocategorization function p.reprint_quote(frame) local l = mw.text.split( frame.args[1],"@@@",true ) local q = l[1] or '' local s = l[2] or '' local bq = l[3] or '' if h.isempty(bq) == false then bq = mw.ustring.gsub(bq, '%[%[Category:.-%]%]', '' ) return bq       elseif h.isempty(q) == false then return frame:preprocess( '"'..q..'"

- '..s..' ' )           else return ''    end end

--returns story title, story title from reprint or story number if none of them exists function p.lua_StoryTitle(number,st,reprint_st) if number % 10 == 1 then number = number..'st' elseif number % 10 == 2-- in (2,22,32,42,52,62,72) then number = number..'nd' elseif number % 10 == 3 --in (3,23,33,43,53,63,73) then number = number..'rd' else number = number..'th' end number = number..' story' if h.isempty(st) == true then st = reprint_st end if h.isempty(st) == false then if string.sub(st,1,1) ~= '"'               then st = '"'..st..'"'            end        else            st = number    end

return st end function p.StoryTitle(frame) local number = frame.args[1] local st = frame.args[2] or '' local reprint_st = frame.args[3] or '' return p.lua_StoryTitle(number,st,reprint_st) end

-- check if main/textless cover exists function p.lua_cover(s_page, s_type) --s_page = string.gsub(s_page,'/',' ') --s_page = string.gsub(s_page,':','') title, volume, issue, padded_issue, padded_volume, title_for_files = standart.lua_get_title_volume_issue(s_page) volume = ' Vol '..volume..' ' s_page = title_for_files..volume..issue if s_type == 'Textless' then s_page = s_page.." Textless.jpg" else s_page = s_page..".jpg" end

if mw.title.new("File:"..s_page).exists == true then return s_page else return '' end end function p.cover(frame) local s_page = frame.args[1] local s_type = frame.args[2] or 'Textless' return p.lua_cover(s_page, s_type) end

-- get the list of images and captions and transform them into gallery of alternate covers function p.covers(frame) local l_covers = mw.text.split( frame.args[1],"@@@",true ) local l_captions = mw.text.split( frame.args[2],"@@@",true ) local s_page = frame.args[3] local l = {} local c = {} local i   local j    local k = 0 local s   local res = {} i = 1 j = 1 s_page = string.gsub(s_page,'/',' ') s_page = string.gsub(s_page,':','') s_page = string.gsub(s_page,'&#38;','&') s_page = string.gsub(s_page,'&#39;',"'") s_page = s_page.." Textless.jpg" while next(l_covers,i) ~= nil do       if h.isempty(l_covers[i]) == false then l[j] = l_covers[i] c[j] = l_captions[i] j = j + 1 end i = i + 1 end if l[1] == s_page then c[1] = 'Textless' end

--if (j == 1 or l[1] ~= s_page) and mw.title.new("File:"..s_page).exists == true if l[1] ~= s_page and mw.title.new("File:"..s_page).exists == true then table.insert(l, 1, s_page) table.insert(c, 1, 'Textless') end i = 1 for j=1,#l do       s = ''..c[j]..' ' if i == 3 then s = s..' ' i = 1 else i = i + 1 end table.insert(res, s)   end return table.concat(res) end

-- get the list of appearances formed by dpl query from a comics issue and replace/move all tags to suppress all categoriztion. function p.lua_reprint_appearances(l, pagename) local j   local k    local s1    local s2    local s3    local n    list = mw.text.unstrip(l) list = mw.text.split(l,'\n') n = #list for i = 1,n do       l = list[i] l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, ,  ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, ,  ) l = mw.ustring.gsub(l, ,  ) j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s3 = string.sub( l, i+2, #l ) j = mw.ustring.find(s2, ,1,true)               k = mw.ustring.find(s2, ,1,true) if j ~= nil then s2 = ..string.sub(s2, j+2, k-1 ).. else s2 = mw.text.split( s2,"|",true ) if #s2 == 3 then s2 = ''..s2[2]..' ' elseif #s2 == 2 then s2 = s2[1]..' ' else s2 = s2[1] end end l = s1..s2..s3       end l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, '(', '%2 %1}}' )       l = mw.ustring.gsub(l, ,  )        l = mw.ustring.gsub(l, ,  )        --l = mw.ustring.gsub(l, ,  )        j, k = mw.ustring.find(string.lower(l), ,1,true)        if j ~= nil             then                s1 = string.sub( l, 1, j-1 )                s2 =                 s3 = string.sub( l, k+1, #l )                l = s1..s2..s3        end           l = mw.ustring.gsub(l, '%[%[Category:.-%]%]', '' )        l = mw.ustring.gsub(l, '&lt;', '<' )        l = mw.ustring.gsub(l, '&gt;', '>' )        list[i] = '\n'..l    end    return table.concat(list) end

function p.reprint_appearances(frame) local l = frame.args[1] local pagename = frame.args[2]

return frame:preprocess( p.lua_reprint_appearances(l, pagename) ) end

-- forms a gallery of comics issues in specified volume based on dpl query from vloume category function p.volume(frame) local monthData = mw.loadData( 'Module:Month/data' ) local monthAliases = monthData[1] local getArgs = require('Dev:Arguments').getArgs local args = getArgs (frame) local l = mw.text.split(args["list"],"@@@",true) local parts = {} local above = {} local below = {} local part local a   local b    local s_page local s_image local s_title local i, j, k, f   local v    local s    local t = {} local t2 = {} local cover local textless local title = '' local volume = '' local issue = '' local padded_issue = '' local padded_volume = '' local title_for_files = '' local title_for_sorting = '' local publication_date = '' local link = '' local output = ''

for i = 1,9 do       table.insert(parts, tonumber(standart.lua_padded_issue(args['part'..i]))) table.insert(above, args['part'..i..'_above']) table.insert(below, args['part'..i..'below']) end

i = 1 while next(l,i) ~= nil do       v = mw.text.split(l[i],"*",true) i = i + 1 s_page = v[1] s_image = v[2] s_title = v[3]

publication_date = p.lua_link_to_publication_category(v[4], v[5]) title, volume, issue, padded_issue, padded_volume, title_for_files = standart.lua_get_title_volume_issue(s_page) link = standart.lua_standardized_link(s_page, 'Comics') title_for_files = title_for_files..' Vol '..volume..' '..issue cover = title_for_files..".jpg" textless = title_for_files.." Textless.jpg" if h.isempty(s_image) == true then if mw.title.new("File:"..cover).exists == true then s_image = cover elseif mw.title.new("File:"..textless).exists == true then s_image = textless else s_image = "No Image Cover.jpg" end end if h.isempty(s_title) == true then s_title = "" else s_title = ' "'..s_title..'"' end

s = padded_issue..'@@@'..s_image..'|'..link..s_title..' ('..publication_date..')\n' table.insert(t,s) end table.sort(t) part = tonumber(parts[1]) i = 1 while i <= #t do       v = mw.text.split(t[i],"@@@",true) i = i + 1 if h.isempty(part) == true or part == 0 then table.insert(t2, v[2]) else table.insert(t2, {v[1], v[2]}) end end

if h.isempty(part) == true or part == 0 then output = frame:preprocess('') --output = table.concat(t2) else t = {} k = tonumber( t2[1][1] ) f = parts[1] i = 1 if parts[#parts] < tonumber( t2[#t2][1] ) then table.insert(parts, tonumber( t2[#t2][1] ) ) end while i <=#parts do               part = tonumber(parts[i]) if h.isempty(part) == true or part == 0 then break else a = above[i] or '' b = below[i] or '' part = {} for j = 1, #t2 do                           if tonumber( t2[j][1] ) >= tonumber (k) and tonumber( t2[j][1] ) <= tonumber (f) then table.insert(part, t2[j][2]) end end i = i + 1 k = f+1 f = parts[i] table.insert(t, a..frame:preprocess('')..b)                       --table.insert(t, a..table.concat(part)..b)                end end output = table.concat(t) end return output end

function p.lua_show_hide(title,body,collapsed,clear,border,extrastyle,width,background,extrastyle2,titlestyle,extrastyle3,header,text) title = title or header or ' ' body = body or text or '' collapsed = collapsed or 'mw-collapsed' clear = clear or 'both' border = border or border_color extrastyle = extrastyle or '' extrastyle2 = extrastyle2 or '' extrastyle3 = extrastyle3 or '' width = width or '100%' background = background or background_color titlestyle = titlestyle or ''

local tag_td = mw.html.create( 'td' ) :css( 'margin', '0.5em' ) :css( 'font-size', '1em' ) :wikitext(body) :done if h.isempty(extrastyle3) == false then tag_td:cssText (extrastyle3):done end tag_td = ' '..tostring(tag_td)..' '

local tag_div = mw.html.create( 'div' ) :css( 'font-weight', 'bold' ) :wikitext(title) :done if h.isempty(titlestyle) == false then tag_div:cssText (titlestyle):done end tag_div = tostring(tag_div) local tag_th = mw.html.create( 'th' ) :attr('colspan', '1') :css( 'background-color', background ) :css( 'font-size', '1.1em' ) :wikitext(tag_div) :done if h.isempty(extrastyle2) == false then tag_th:cssText (extrastyle2):done end tag_th = ' '..tostring(tag_th)..' ' local tag_table = mw.html.create( 'table' ) :addClass('mw-collapsible '..collapsed) :css( 'clear', clear ) :css( 'border', '1px solid '..border ) :css( 'font-size', '0.85em' ) :css( 'width', width ) :wikitext(tag_th..tag_td) :done if h.isempty(extrastyle) == false then tag_table:cssText (extrastyle):done end tag_table = tostring(tag_table) return tag_table end

function p.show_hide(frame) local getArgs = require('Dev:Arguments').getArgs local args = getArgs (frame)

local title = args['title'] or args['header'] or ' ' local body = args['body'] or args['text'] or '' local collapsed = args['collapsed'] local clear = args['clear'] or 'both' local border = args['border'] or border_color local extrastyle = args['extrastyle'] or '' local extrastyle2 = args['extrastyle2'] or '' local extrastyle3 = args['extrastyle3'] or '' local width = args['width'] or '100%' local background = args['background'] or background_color local titlestyle = args['titlestyle'] or ''

if h.isempty(collapsed) or collapsed == 'true' then collapsed = ' mw-collapsed' else collapsed = '' end

local tag_td = mw.html.create( 'td' ) :css( 'margin', '0.5em' ) :css( 'font-size', '1em' ) :wikitext(body) :done if h.isempty(extrastyle3) == false then tag_td:cssText (extrastyle3):done end tag_td = ' '..tostring(tag_td)..' '

local tag_div = mw.html.create( 'div' ) :css( 'font-weight', 'bold' ) :wikitext(title) :done if h.isempty(titlestyle) == false then tag_div:cssText (titlestyle):done end tag_div = tostring(tag_div) local tag_th = mw.html.create( 'th' ) :attr('colspan', '1') :css( 'background-color', background ) :css( 'font-size', '1.1em' ) :wikitext(tag_div) :done if h.isempty(extrastyle2) == false then tag_th:cssText (extrastyle2):done end tag_th = ' '..tostring(tag_th)..' ' local tag_table = mw.html.create( 'table' ) :addClass('mw-collapsible'..collapsed) :css( 'clear', clear ) :css( 'border', '1px solid '..border ) :css( 'font-size', '0.85em' ) :css( 'width', width ) :wikitext(tag_th..tag_td) :done if h.isempty(extrastyle) == false then tag_table:cssText (extrastyle):done end return tostring(tag_table) --return p.lua_show_hide(args['title'], args['body'], args['collapsed'], args['clear'], args['border'], args['extrastyle'], args['width'], args['background'], args['extrastyle2'], args['titlestyle'], args['extrastyle3'], args['header'],args['text']) end

function p.lua_infobox_line(left, right, text, width_l, width_r) left = left or '' right = right or '' text = text or '' width_l = width_l or '100px' width_r = width_r or '190px' local tag_l = mw.html.create( 'div' ) :css( 'width', width_l ) :css( 'text-align', 'left' ) :css( 'float', 'left' ) :wikitext(left) :done local tag_r = mw.html.create( 'div' ) :css( 'width', width_r ) :css( 'text-align', 'right' ) :css( 'float', 'left' ) :wikitext(right) :done tag_l = tostring(tag_l) tag_r = tostring(tag_r) local tag = mw.html.create( 'div' ) :css( 'border-top', '1px solid '..border_color ) :css( 'text-align', 'center' ) :css( 'clear', 'left' ) :css( 'font-size', '10px' ) :wikitext(text..tag_l..tag_r) :done return tostring(tag) end

function p.infobox_line(frame) local getArgs = require('Dev:Arguments').getArgs local args = getArgs (frame) local left = args['left'] or '' local right = args['right'] or '' local text = args[1] or '' local width_l = args['width'] or '100px' local width_r = args['widthr'] or '190px' local tag_l = mw.html.create( 'div' ) :css( 'width', width_l ) :css( 'text-align', 'left' ) :css( 'float', 'left' ) :wikitext(left) :done local tag_r = mw.html.create( 'div' ) :css( 'width', width_r ) :css( 'text-align', 'right' ) :css( 'float', 'left' ) :wikitext(right) :done tag_l = tostring(tag_l) tag_r = tostring(tag_r) local tag = mw.html.create( 'div' ) :css( 'border-top', '1px solid '..border_color ) :css( 'text-align', 'center' ) :css( 'clear', 'left' ) :css( 'font-size', '10px' ) :wikitext(text..tag_l..tag_r) :done return tostring(tag) --return p.lua_infobox_line(, args['right'], args[1], args['width'], args['widthr']) end

--counts how many times "text" is found in the "list" function p.lua_count_inlist(list, text) local output = 0 if h.isempty(list) == false and h.isempty(text) == false then for i, v in ipairs( list ) do               if v == text then output = output + 1 end end end return output end

--returns number of "text" element in the "list" function p.lua_find_inlist(list, text) local output = 0 if h.isempty(list) == false and h.isempty(text) == false then for i, v in ipairs( list ) do               if v == text then output = i                       break end end end return output end

return p