×
Einen neuen Artikel erstellen
Schreibe den Seitennamen hierhin:
Wir haben derzeit 9.055 Artikel auf Vaultpedia. Gib deinen Artikelnamen oberhalb von oder klicke auf einen der unten stehenden Titel und beginne zu schreiben! ein



    Vaultpedia
    9.055Artikel

    Modul:Icons: Unterschied zwischen den Versionen

    Tritt unserem Discord bei und informiere dich auf unserem Twitter-Kanal über die aktuellsten Themen rund um Fallout!
    Die Seite wurde neu angelegt: „local p = {} local util = require( 'Module:Util' ) --[[ Icon data is now stored on the sub page /data to seperate functional code for the dataset users will often need to update. This reduces the risk of breaking the code by entering data in the wrong place and makes it easier to manage the code itself by not having to pass through the large dataset at the top. ]] require( 'Module:Icons/data' ) local iconSize = { --[[ All sizes are co…“
     
    Huu.Psii (Diskussion | Beiträge)
    KKeine Bearbeitungszusammenfassung
     
    Zeile 1: Zeile 1:
    local p = {}
    local p = {}
    local util = require( 'Module:Util' )
    local util = require( 'Modul:Util' )
    --[[
    --[[
    Icon data is now stored on the sub page /data to seperate functional code
    Icon data is now stored on the sub page /data to seperate functional code
    Zeile 9: Zeile 9:
    ]]
    ]]


    require( 'Module:Icons/data' )  
    require( 'Modul:Icons/data' )  


    local iconSize = {
    local iconSize = {
    Zeile 17: Zeile 17:
         ]]
         ]]
         ["small"]          = "x10px",
         ["small"]          = "x10px",
        ["klein"]          = "x10px",
         ["medium"]          = "x14px",
         ["medium"]          = "x14px",
        ["mittel"]          = "x14px",
         ["normal"]          = "x14px",
         ["normal"]          = "x14px",
         ["big"]            = "x20px",
         ["big"]            = "x20px",
        ["groß"]            = "x20px",
    }
    }


    Zeile 87: Zeile 90:
                 currentIcon = "Icon question.png"
                 currentIcon = "Icon question.png"
                 currentTip = "Unrecognized icon name"
                 currentTip = "Unrecognized icon name"
                 result = result .. "[[Category:Modules with invalid parameters]]"
                 result = result .. "[[Kategorie:Module mit ungültigen Parametern]]"
             end
             end
              
              
             --Create wikitext icon
             --Create wikitext icon
    dataLine = '[[File:' .. currentIcon .. '|' .. iconSetting
    dataLine = '[[Datei:' .. currentIcon .. '|' .. iconSetting
             if util.exists(iconLinks, k) then
             if util.exists(iconLinks, k) then
                 dataLine = dataLine .. '|link=' .. iconLinks[k]
                 dataLine = dataLine .. '|link=' .. iconLinks[k]
    Zeile 136: Zeile 139:
            a consistent line height
            a consistent line height
         ]]
         ]]
        ["small"]          = "x10px",
        ["small"]          = "x10px",
        ["medium"]          = "x14px",
        ["klein"]          = "x10px",
        ["normal"]          = "x14px",
        ["medium"]          = "x14px",
        ["big"]            = "x20px"
        ["mittel"]          = "x14px",
        ["normal"]          = "x14px",
        ["big"]            = "x20px",
        ["groß"]            = "x20px",
    }
    }
         return _generate(iconList, iconSetting, iconLinks, tipOverride, iconClass, iconSize)     
         return _generate(iconList, iconSetting, iconLinks, tipOverride, iconClass, iconSize)     
    Zeile 167: Zeile 173:
                 createPlatform:addClass('va-icon')
                 createPlatform:addClass('va-icon')
                 :attr('title', currentIcon.tip)
                 :attr('title', currentIcon.tip)
                 :wikitext('[[File:'  
                 :wikitext('[[Datei:'  
                 .. currentIcon.icon  
                 .. currentIcon.icon  
                 .. '|alt='
                 .. '|alt='
    Zeile 184: Zeile 190:
                 createPlatformDark:addClass('va-icon')
                 createPlatformDark:addClass('va-icon')
                 :attr('title', currentDarkIcon.tip)
                 :attr('title', currentDarkIcon.tip)
                 :wikitext('[[File:'  
                 :wikitext('[[Datei:'  
                 .. currentDarkIcon.icon  
                 .. currentDarkIcon.icon  
                 .. '|alt='
                 .. '|alt='
    Zeile 203: Zeile 209:
         end
         end
         if result == '' then
         if result == '' then
             result = '<sup>[Platforms needed]</sup>[[Category:Platforms needed]]'
             result = '<sup>[Plattformen fehlen]</sup>[[Kategorie:Plattformen benötigt]]'
         end
         end
          
          
    Zeile 224: Zeile 230:
             newFile = mw.html.create(span)
             newFile = mw.html.create(span)
             --:addClass(class[i.class])
             --:addClass(class[i.class])
             :wikitext('[[File:' .. iconData[v].icon .. '|25px]]')
             :wikitext('[[Datei:' .. iconData[v].icon .. '|25px]]')
             else
             else
             newFile = mw.html.create(span)
             newFile = mw.html.create(span)
             :wikitext('[[File:' .. iconData[v].icon .. '|25px]]')
             :wikitext('[[Datei:' .. iconData[v].icon .. '|25px]]')
             end
             end
             result = result .. '||' .. tostring(newFile)
             result = result .. '||' .. tostring(newFile)

    Aktuelle Version vom 29. Oktober 2024, 12:02 Uhr

    Die Dokumentation für dieses Modul kann unter Modul:Icons/Doku erstellt werden

    local p = {}
    local util = require( 'Modul:Util' )
    --[[
    	Icon data is now stored on the sub page /data to seperate functional code
    	for the dataset users will often need to update. This reduces the risk of
    	breaking the code by entering data in the wrong place and makes it easier to
    	manage the code itself by not having to pass through the large dataset at 
    	the top.
    ]]
    
    require( 'Modul:Icons/data' ) 
    
    local iconSize = {
        --[[
            All sizes are controlled on the height to ensure a string of icons maintain 
            a consistent line height
        ]]
        ["small"]           = "x10px",
        ["klein"]           = "x10px",
        ["medium"]          = "x14px",
        ["mittel"]          = "x14px",
        ["normal"]          = "x14px",
        ["big"]             = "x20px",
        ["groß"]            = "x20px",
    }
    
    --[[ 28/Oct/2021 Added class control table to array as to handle light/dark 
    	themes. This was originally put into the frontend template, when class
    	handling should be back end. Adding the ['class'] = 'light' or 
    	['class'] = 'dark' parameter to a icon's dataset on /data will enable it to
    	access a class if needed.
    	]]
    
    --[[ 08/Nov/2021 Remove the class definition as to be able to just pass straight through
    local class = {
    	['light'] = 'lighticon',
    	['dark'] = 'darkicon',
    	['general'] = 'generalicon'
    }
    ]]
    
    function _generate(iconList, iconSetting, iconLinks, tipOverride, iconClass, iconSize)
        if util.exists(iconSetting)  then 
        	iconSetting = util.trim(iconSetting)
            if util.exists(iconSize[iconSetting]) then
                iconSetting = iconSize[iconSetting]
            end
        else
            iconSetting = iconSize["medium"]
        end
        -- This is for calls from other Lua modules as the above will result in nil
        if util.exists(iconSetting) == false then
        	if util.exists(iconSize) then
    			iconSetting = iconSize
    		else
    			iconSetting = 'x14px'
    		end
        end
        
        if util.exists(iconLinks) then
            iconLinks = mw.text.split(iconLinks, ",")
        end
            
        if util.exists(tipOverride) then
            tipOverride = mw.text.split(tipOverride, ",")
        end
        
        if util.exists(iconClass)then
        	iconClass = "|class=" .. tostring(iconClass);
        else
        	iconClass = ""
        end
    
        local result = ""
    
        for k, v in ipairs(iconList) do
            newIcon = iconData[util.trim(v)]
            if util.exists(newIcon) then
                currentIcon = newIcon.icon
                if util.exists(tipOverride, k) then
                    currentTip = tipOverride[k]
                else
                    if util.exists(iconLinks, k) then
                        currentTip = iconLinks[k]
                    else
                        currentTip = newIcon.tip
                    end
                end
            else
                currentIcon = "Icon question.png"
                currentTip = "Unrecognized icon name"
                result = result .. "[[Kategorie:Module mit ungültigen Parametern]]"
            end
            
            --Create wikitext icon
    		dataLine = '[[Datei:' .. currentIcon .. '|' .. iconSetting
            if util.exists(iconLinks, k) then
                dataLine = dataLine .. '|link=' .. iconLinks[k]
            else
                dataLine = dataLine .. '|link='
            end
            if currentTip ~= nil then
                dataLine = dataLine .. '|' .. currentTip
            end
    
            dataLine = dataLine .. iconClass .. ']]'
    
    		createTip = mw.html.create('span')
            	createTip:addClass( 'va-icon' )
            	:attr('title', currentTip)
            	:wikitext(dataLine)
            result = result .. tostring(createTip)
            
            if k < table.getn(iconList) then
            	result = result .. " "
            end
        end
        
        return result
    end
    
    -- Calls from other modules
    function p.innerIcon(iconList, iconSetting, iconLinks, tipOverride, iconClass, iconSize)
    	iconList = mw.text.split(iconList, ',')
    	return _generate(iconList, iconSetting, iconLinks, tipOverride, iconClass, iconSize)
    end
    
    function p.Icons(frame) 
    	--[[All icons are now lower case to reduce script errors from 
    	incorrectly entering the icon code in a different case to the list]]
        local iconList = mw.text.split(string.lower(frame.args[1]), ",")
        local iconSetting = frame.args[2]
        local iconLinks = frame.args[3]
        local tipOverride = frame.args[4]
        local iconClass = frame.args[5]	
    	local iconSize = {
        	--[[
        	    All sizes are controlled on the height to ensure a string of icons maintain 
    	        a consistent line height
        	]]
        ["small"]           = "x10px",
        ["klein"]           = "x10px",
        ["medium"]          = "x14px",
        ["mittel"]          = "x14px",
        ["normal"]          = "x14px",
        ["big"]             = "x20px",
        ["groß"]            = "x20px",
    	}
        return _generate(iconList, iconSetting, iconLinks, tipOverride, iconClass, iconSize)    
    end
    
    function p.platforms(frame)
    	--[[All icons are now lower case to reduce script errors from 
    	incorrectly entering the icon code in a different case to the list]]
        local icons = mw.text.split(string.lower(frame.args[1]), ",")
        local result = ""
        
        for k, v in ipairs(icons) do
            currentIcon = iconData[util.trim(v)]
            
            if util.exists(currentIcon, 'platform') == true then
            	
                createSM = mw.html.create('span')
                	createSM:css('display', 'none')
                	:wikitext('[[Has platform::' .. currentIcon.tip .. ']]')
                	:allDone()
                createPlatform = mw.html.create('span')
                	if (util.exists(currentIcon.class)) then
    			    	iconClass = "|class=" .. tostring(currentIcon.class);
    			    else
    			    	iconClass = ""
    			    end
                	createPlatform:addClass('va-icon')
                		:attr('title', currentIcon.tip)
                		:wikitext('[[Datei:' 
                			.. currentIcon.icon 
                			.. '|alt='
                			.. currentIcon.tip
                			.. '|x14px|link='
                			.. iconClass..']]')
                		:allDone()
                if (util.exists(iconData[util.trim(v)..' dark'])) then
                	currentDarkIcon = iconData[util.trim(v)..' dark']
                	createPlatformDark = mw.html.create('span')
                	if (util.exists(currentDarkIcon.class)) then
    			    	iconClass = "|class=" .. tostring(currentDarkIcon.class);
    			    else
    			    	iconClass = ""
    			    end
                	createPlatformDark:addClass('va-icon')
                		:attr('title', currentDarkIcon.tip)
                		:wikitext('[[Datei:' 
                			.. currentDarkIcon.icon 
                			.. '|alt='
                			.. currentDarkIcon.tip
                			.. '|x14px|link='
                			.. iconClass..']]')
                		:allDone()
                	createPlatform = tostring(createPlatform)..tostring(createPlatformDark)
                end
                	--[[ Uncommenting tostring(createSM) below will enable 
                	Semantic Mediawiki data tracking]]
                	result = result .. tostring(createSM) 
                			.. tostring(createPlatform)
                if k < table.getn(icons) then
                    result = result .. " "
                end
            end
        end
        if result == '' then
            result = '<sup>[Plattformen fehlen]</sup>[[Kategorie:Plattformen benötigt]]'
        end
        
        return result
    end    
    
    function p.documentation()
        keys = {}
        for k in pairs(iconData) do
            table.insert(keys, k)
        end
     
        table.sort(keys)
        result = '{| class="va-table va-table-full"\n|-\n !prefix!!Icon!!prefix!!Icon!!prefix!!Icon\n|-\n'
        set = 1
        for k,v in ipairs(keys) do
    		i = iconData[v]
            result = result .. "||'''" .. v .. "'''"
            if util.exists(i) == true and i.class ~= nil then
            	newFile = mw.html.create(span)
            		--:addClass(class[i.class])
            		:wikitext('[[Datei:' .. iconData[v].icon .. '|25px]]')
            else
            	newFile = mw.html.create(span)
            		:wikitext('[[Datei:' .. iconData[v].icon .. '|25px]]')
            end
            result = result .. '||' .. tostring(newFile)
     
            if set == 3 then
                result = result .. '\n|-\n'
            end
     
            if set < 3 then
                set = set + 1
            else
                set = 1
            end
        end
     
        result = result .. '\n|}'
     
        return result
    end
    
    function p.Test(frame) 
    	--Please empty when done debugging so other users know it is free to use
    
    end
    
    return p