FANDOM


local infoboxCharacter = {}
 
--high level - infoboxes group
function infoboxCharacter.blockCreate(frame)
    local args = frame.args
--functions
  --dividing up the line into the massive of the underlines by a determined symbol
    function split(str, separator, reg)
        local result = {}
      --Testing of the example 
        if (not reg) then
            regExp = true
        else
            regExp = false
        end
      --variable of positions
        local n
        local k
      --managing variables
        local s = 0
        local i = 1
      --line polishing
        while k ~= str:len() do
          --separator searching
            local substring
            n, k = str:find(separator, s + 1, regExp)
         --if searching didn't bring any result
            if (k == nil or n == nil) then
                result[i] = str:sub(s + 1, str:len())
                break
            end
         --if the separator is found
            substring = str:sub(s + 1, n - 1)
          --result adding
            if substring ~= ''  then
                result[i] = substring
                i = i + 1
            end
            s = k
        end
        return result
    end
 
  --testing of the parameters
    function paramCheck(param)
        if param and param ~= '' then
            return true
        else
            return false
        end
    end
 
  --infobox creating
    function infoboxCreate(prefix)
    --arguments polishing
        local data = {}
      --name
        if paramCheck(args[prefix..'jmeno']) then
            data.name = args[prefix..'jmeno']
        elseif prefix ~= '' then
            data.name = prefix:sub(1, prefix:len() - 1)
        else
            data.name = tostring(mw.title.getCurrentTitle())
        end
      --title
        if paramCheck(args[prefix..'titul']) then
            data.title = args[prefix..'titul']
        end
      --age
        if paramCheck(args[prefix..'věk']) then
            data.age = mw.ustring.lower(args[prefix..'věk'])
        end
      --type
        if paramCheck(args[prefix..'druh']) then
            data.kind = mw.ustring.lower(args[prefix..'druh'])
        end
      --sex
        if paramCheck(args[prefix..'pohlaví']) then
            data.gender = mw.ustring.lower(args[prefix..'pohlaví'])
        end
      --different information
        data.differentInfo = {}
        --occupation
        if paramCheck(args[prefix..'zaměstnání']) then
            data.differentInfo[#data.differentInfo + 1] = {'Zaměstnání', args[prefix..'zaměstnání']}
        end
        --living place
        if paramCheck(args[prefix..'místo bydlení']) then
            data.differentInfo[#data.differentInfo + 1] = {'Místo bydlení', args[prefix..'místo bydlení']}
        end
        --other
        local dIC = 1
        while paramCheck(args[prefix..'různá informace '..dIC]) do
            local dInfo = split(args[prefix..'různá informace '..dIC], ':')
            if dInfo[2] then
                data.differentInfo[#data.differentInfo + 1] = {dInfo[1], dInfo[2]}
            end
            dIC = dIC + 1
        end
      --sounding
        data.voiceInfo = {}
        --czech
        if paramCheck(args[prefix..'české ozvučování']) then
            data.voiceInfo[#data.voiceInfo + 1] = {'České', args[prefix..'české ozvučování']}
        end
        --english
        if paramCheck(args[prefix..'anglické ozvučování']) then
            data.voiceInfo[#data.voiceInfo + 1] = {'Originální', args[prefix..'anglické ozvučování']}
        end
        --Czech singing
        if paramCheck(args[prefix..'české ozvučování písní']) then
            data.voiceInfo[#data.voiceInfo + 1] = {'České písní', args[prefix..'české ozvučování písní']}
        end
        --English singing
        if paramCheck(args[prefix..'české ozvučování písní']) then
            data.voiceInfo[#data.voiceInfo + 1] = {'Originální písní', args[prefix..'anglické ozvučování písní']}
        end
        --other
        local vIC = 1
        while paramCheck(args[prefix..'другая озвучка '..vIC]) do
            local vInfo = split(args[prefix..'другая озвучка '..vIC], ':')
            if vInfo[2] then
                data.voiceInfo[#data.voiceInfo + 1] = {vInfo[1], vInfo[2]}
            end
            vIC = vIC + 1
        end
      --relatives
        data.relativesInfo = {}
        local rIC = 1
        while paramCheck(args[prefix..'příbuzní '..rIC]) do
            local rInfo = split(args[prefix..'příbuzní '..rIC], ':')
            if rInfo[2] then
                data.relativesInfo[#data.relativesInfo + 1] = {rInfo[1], rInfo[2]}
            end
            rIC = rIC + 1
        end
      --character colours
        data.colorTable = {}
        if paramCheck(args[prefix..'barva']) then
            local colors = split(args[prefix..'barva'], '/')
            data.colorTable[#data.colorTable + 1] = {'Barva', colors}
          --preliminary determination of the colour scheme - background
            data.bgColor = colors[1]
        end
        if paramCheck(args[prefix..'barvy hřívy']) then
            local colors = split(args[prefix..'barvy hřívy'], '/')
            data.colorTable[#data.colorTable + 1] = {'Hříva', colors}
          --preliminary determination of the colour scheme - text
            data.fontColor = colors[1]
        end
        if paramCheck(args[prefix..'barvy očí']) then
            local colors = split(args[prefix..'barvy očí'], '/')
            data.colorTable[#data.colorTable + 1] = {'Oči', colors}
        end
        local ctc = 1
        while args[prefix..'doplňková barva '..ctc] do
            local color = split(args[prefix..'doplňková barva '..ctc], ':')
            if color[2] then
                local parsedColor = split(color[2], '/')
                data.colorTable[#data.colorTable + 1] = {color[1], parsedColor}
            end
            ctc = ctc + 1
        end
      --cutie marks
        data.cutieMarks = {}
        local cMC = 1
        while paramCheck(args[prefix..'zobrazení značky '..cMC]) or paramCheck(args[prefix..'popis značky '..cMC]) do
        data.cutieMarks[cMC] = {}
        --background colour
            if paramCheck(args[prefix..'barva pozadí značky '..cMC]) then
                data.cutieMarks[cMC].cmBackground = args[prefix..'barva pozadí značky '..cMC]
            elseif data.bgColor then
                data.cutieMarks[cMC].cmBackground = data.bgColor
            else
                data.cutieMarks[cMC].cmBackground = 'inherit'
            end
          --size
            if paramCheck(args[prefix..'rozměr značky '..cMC]) then
                data.cutieMarks[cMC].cmSize = args[prefix..'rozměr značky '..cMC]
            else
                data.cutieMarks[cMC].cmSize = '38x38px'
            end
          --image
            if paramCheck(args[prefix..'zobrazení značky '..cMC]) then
                data.cutieMarks[cMC].cmImage = args[prefix..'zobrazení značky '..cMC]
            end
          --description
            if paramCheck(args[prefix..'popis značky '..cMC]) then
                data.cutieMarks[cMC].cmDescription = args[prefix..'popis značky '..cMC]
            end
            cMC = cMC + 1
        end
      --colour theme
        --background colour
        if paramCheck(args[prefix..'barva pozadí titulu']) then 
            data.bgColor = args[prefix..'barva pozadí titulu']
        elseif not data.bgColor then 
            data.bgColor = 'inherit'
        end
        --text colour
        if paramCheck(args[prefix..'barva textu titulu']) then 
            data.fontColor = args[prefix..'barva textu titulu']
        elseif not data.fontColor then
            data.fontColor = 'transparent'
        end
    --contents cover
        local infoboxOuter = mw.html.create('div')
    --infobox basis
        local infobox = mw.html.create('div')
        infoboxOuter:addClass('ib1_infoboxCharacter')
    --functions
----------------------------------------------------------
--images and buttons creation (out of date)
        function imageCreateOld(name, dNone)
            local image = mw.html.create('div')
            image:addClass('infBlock')
            if not args[prefix..'titul'] or args[prefix..'titul'] == '' then
                image:css('margin', '6px 0 0 0')
            end
            if dNone then
                image:css('display', 'none')
            end
            image:wikitext('[[Soubor:'..args[name]..'|250px|link=]]')
            return image
        end
        function buttonCreateOld(name)
            local button = mw.html.create('div')
            button:addClass('infButton')
            button:css('color', data.fontColor)
            button:css('background', data.bgColor)
            button:wikitext(args[name])
            return button
        end
-------------------------------------------------------------
      --creations of sections with the information about the sex and the age
        function kindGenderCreate(text, image)
            local label = mw.html.create('div')
            if image  then
                    local imgBlock = mw.html.create('div')
                    imgBlock:wikitext('[[soubor:'..image..'.png|link=]]')
                    label:css('padding-left', '23px')
                    label:node(imgBlock)
                else
                    label:css('padding-left', '3px')
                end
                label:wikitext(text)
                return label
            end
      --table line creation
        function lineCreate(title, text)
            local line = mw.html.create('tr')
            local leftColumn = mw.html.create('th')
            leftColumn:wikitext(title)
            line:node(leftColumn)
            local rightColumn = mw.html.create('td')
            rightColumn:wikitext(text)
            line:node(rightColumn)
            return line
        end
      --creation of the empty rolling table with the title
        function collapsibleTableCreate(label)
            local colTable = mw.html.create('table')
            colTable:addClass('mw-collapsible mw-collapsed')
            local headerLine = mw.html.create('tr')
            local header = mw.html.create('th')
            header:css('background-color', data.bgColor)
            header:css('color', data.fontColor)
            header:wikitext(label)
            header:attr('colspan', '6')
            headerLine:node(header)
            colTable:node(headerLine)
            return colTable
        end
      --colourbox creation
        function colorBoxCreate(colors, borderColor)
            local colorBox = mw.html.create('div')
            colorBox:addClass('infoboxCharacter_colorBox')
            if (borderColor) then
                colorBox:css('border', '2px solid '..borderColor)
            else
                colorBox:css('border', '1px solid gray')
            end
            width = 100 / #colors
            for i = 1, #colors do
                local innerElement = mw.html.create('div')
                innerElement:css('background-color', colors[i])
                innerElement:css('width', width..'%')
                innerElement:attr('title', colors[i])
                colorBox:node(innerElement)
            end
            return colorBox
        end
    --contents
      --title
        local header = mw.html.create('div')
        header:addClass('infoboxCharacter_header')
        header:css('background-color', data.bgColor)
        local headerText = mw.html.create('div')
        headerText:wikitext(data.name )
        headerText:css('color', data.fontColor)
        header:node(headerText)
      --титул
        local title
        if data.title then
            title = mw.html.create('div')
            title:addClass('infoboxCharacter_title')
            title:wikitext(data.title)
        end
------------------------------
--images and buttons (out of date)
        local imgOld1, imgOld2, imgOld3, imgOld4
        if paramCheck(args[prefix..'obraz']) then
            imgOld1 = imageCreateOld(prefix..'obraz1')
        end
        if paramCheck(args[prefix..'obraz2']) then
            imgOld2 = imageCreateOld(prefix..'obraz2', true)
        end
        if paramCheck(args[prefix..'obraz3']) then
            imgOld3 = imageCreateOld(prefix..'obraz3', true)
        end
        if paramCheck(args[prefix..'obraz4']) then
            imgOld4 = imageCreateOld(prefix..'obraz4', true)
        end
        local butOld
        if paramCheck(args[prefix..'obraz2']) then
            butOld = mw.html.create('div')
            butOld:cssText('width:100%; margin:6px 0 6px; text-align:center')
            butOld:node(buttonCreateOld(prefix..'podpis1'))
            butOld:node(buttonCreateOld(prefix..'podpis2'))
            if paramCheck(args[prefix..'obraz3']) then
                butOld:node(buttonCreateOld(prefix..'podpis3'))
            end
            if paramCheck(args[prefix..'obraz4']) then
                butOld:node(buttonCreateOld(prefix..'podpis4'))
            end
        end
---------------------------
      --type and sex
        local kindGender
        if data.kind or data.gender then
            kindGender = mw.html.create('div')
            kindGender:addClass('infoboxCharacter_kindGender colorlink')
            local customKind
          --type
            if data.kind then
                local kind = mw.html.create('div')
                local textKind
                local kindImg
                if data.kind == 'jednorožec' then
                    textKind = '[[Jednorožci|Jednorožecг]]'
                    kindImg = 'Unicorn picto'
                elseif data.kind == 'pegas' then
                    textKind = '[[Pegasové|Pegas]]'
                    kindImg = 'Pegasus picto'
                elseif data.kind == 'zemní pony' or data.kind == 'zemní poník' then
                    textKind = '[[Zemní poníci|Zemní pony]]'
                    end
                    kindImg = 'Earthpony picto'
                elseif data.kind == 'alicorn' then
                    textKind = '[[Alicorni|Alicorn]]'
                    kindImg = 'Alicorn picto'
                else
                    textKind = data.kind
                    customKind = true
                end
                local kind = kindGenderCreate(textKind, kindImg)
                kindGender:node(kind)
            end
          --sex
            if data.gender and data.gender == 'muž' or data.gender == 'žen' then
                local gender = mw.html.create("div")
                local genderText
                local genderImg
                if data.gender == 'muž' or data.gender == 'mužsky' then
                    if customKind then
                        genderText = 'Muž.'
                    elseif data.age == 'dět' then
                        genderText = 'Hříbě'
                    else
                        genderText = 'Hřebec'
                    end
                    genderImg = 'Male picto'
                else
                    if customKind then
                        genderText = 'Žen.'
                    elseif data.age == 'dět' then
                        genderText = 'Kobylka'
                    else
                        genderText = 'Kobyla'
                    end
                    genderImg = 'Female picto'
                end
                local gender = kindGenderCreate(genderText, genderImg)
                kindGender:node(gender)
            end
        end
      --different information
        local diffInfoTable
        if #data.differentInfo ~= 0 then
            diffInfoTable = mw.html.create('table')
            diffInfoTable:addClass('infoboxCharacter_infoTable')
            for i = 1, #data.differentInfo do
                local line = lineCreate(data.differentInfo[i][1], data.differentInfo[i][2])
                diffInfoTable:node(line)
            end
        end
      --sounding
        local voiceTable
        if #data.voiceInfo ~= 0 then
            voiceTable = collapsibleTableCreate('Ozvučování')
            voiceTable:addClass('infoboxCharacter_collapsibleInfoTable')
            for i = 1, #data.voiceInfo do
                local line = lineCreate(data.voiceInfo[i][1], data.voiceInfo[i][2])
                voiceTable:node(line)
            end
        end
      --relatives
        local relativesTable
        if #data.relativesInfo ~= 0 then
            relativesTable = collapsibleTableCreate('Příbuzní')
            relativesTable:addClass('infoboxCharacter_collapsibleInfoTable')
            for i = 1, #data.relativesInfo do
                local line = lineCreate(data.relativesInfo[i][1], data.relativesInfo[i][2])
                relativesTable:node(line)
            end
        end
      --appearance
        local appearanceTable
        if data.colorTable[1] or data.cmImage or data.cmDescription then
            appearanceTable = collapsibleTableCreate('Vzhled')
            appearanceTable:addClass('infoboxCharacter_appearanceTable')
          --colours
            if data.colorTable[1] then
                local length = #data.colorTable 
                local colspan
                local tr
                for i = 1, length do
                    if length - i == 1 and length % 3 == 2 then
                        colspan = '3'
                    elseif length - i == 0 and length % 3 == 1 then
                        colspan = '6'
                    else
                        colspan = '2'
                    end
                    if i % 3 == 1 then
                        tr = mw.html.create('tr')
                    end
                    local th = mw.html.create('th')
                    th:attr('colspan', colspan)
                    th:wikitext(data.colorTable[i][1]..'<br />')
                    local colorBox = colorBoxCreate(data.colorTable[i][2])
                    th:node(colorBox)
                    tr:node(th)
                    if (i % 3 == 0 or length - i == 0) then
                        appearanceTable:node(tr)
                    end
                end
            end
          --cutie mark
            if #data.cutieMarks > 0 then
                local tr = mw.html.create('tr')
                local td = mw.html.create('td')
                td:attr("colspan", "6")
                local label = mw.html.create('span')
                label:wikitext('Značka')
              --button
                local rButton
                if #data.cutieMarks > 1 then
                  --left
                    local lButton = mw.html.create('div')
                    lButton:addClass('ib1_appearance_lButton ib1_cmButton')
                    lButton:css('background-color', data.bgColor)
                    lButton:attr('title', 'Předchozí značka')
                    local lArrow = mw.html.create('div')
                    lArrow:css('border-right-color', data.fontColor)
                    lButton:node(lArrow)
                  --addition of the left
                    td:node(lButton)
                  --right
                    rButton = mw.html.create('div')
                    rButton:addClass('ib1_appearance_rButton ib1_cmButton')
                    rButton:css('background-color', data.bgColor)
                    rButton:attr('title', 'Příští značka')
                    local rArrow = mw.html.create('div')
                    rArrow:css('border-left-color', data.fontColor)
                    rButton:node(rArrow)
                end
              --description and picture
                for i = 1, #data.cutieMarks do
                  --description
                    local description
                    if data.cutieMarks[i].cmDescription then
                        description = mw.html.create('div')
                        description:node(label)
                        description:wikitext('<br />'..data.cutieMarks[i].cmDescription)
                    end
                  --image
                    local image
                    if data.cutieMarks[i].cmImage then
                        image = mw.html.create('div')
                        image:wikitext('[[soubor:'..data.cutieMarks[i].cmImage..'|'..data.cutieMarks[i].cmSize..'|link=]]')
                        image:css("background-color", data.cutieMarks[i].cmBackground)
                    end
                  --cover
                    local wrapper
                    if description and image then
                        wrapper = mw.html.create('div')
                        wrapper:addClass('ib1_appearance_cmComplete ib1_cm')
                        wrapper:node(description)
                        wrapper:node(image)
                    elseif description then
                        wrapper = description
                        wrapper:addClass('ib1_appearance_cmDescription ib1_cm')
                    else
                        wrapper = mw.html.create('div')
                        wrapper:node(label)
                        wrapper:node(image)
                        wrapper:addClass('ib1_appearance_cmImage ib1_cm')
                    end
                  --hiding the unwanted marks
                    if i > 1 then
                        wrapper:css('display', 'none')
                    end
                  --addition
                    td:node(wrapper)
                end
              --addition of the right button
                if rButton then
                    td:node(rButton)
                end
                tr:node(td)
                appearanceTable:node(tr)
            end
        end
      --gallery
        local gallery
        if paramCheck(args[prefix..'Galerie']) then
            gallery = mw.html.create('div')
            gallery:addClass('infoboxCharacter_gallery colorlink')
            gallery:css('color', data.fontColor)
            gallery:css('background-color', data.bgColor)
            gallery:wikitext('[['..args[prefix..'galerie']..'|Galerie]]')
        end
 
end
 
return infoboxCharacter

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

V síti Wikia

Náhodná Wiki