# Module:All legals

From faraghaib
Jump to navigation Jump to search

Documentation for this module may be created at Module:All legals/doc

Script error: Lua error: Cannot create process: proc_open is not available. Check PHP's "disable_functions" configuration directive.

    local p = {}
    local converter = require("Module:Numeral converter")

    function createItem(colorModifier, iconModifier, catName, subText)
        local s1 = '<div class="content-improvement-item ' .. colorModifier .. ' ' .. iconModifier .. '">'
        local s2 = '[[:رده:' .. catName .. '|<span class="content-improvement-item__subtext-big">'
        local s3 = '<b>' .. subText .. '</b></span> <small><span class="content-improvement-item__number-smal">'
        local s4 = converter.convert("fa", mw.site.stats.pagesInCategory(catName, pages))
        local s5 = ' مورد</span></small></span>]]</div>'
        return s1 .. s2 .. s3 .. s4 .. s5
    end

    local data = {
        createItem('-color-blue', '-icon-editUndo', 'قوانین', 'فهرست کامل قوانین'),
    }

    function p.main(frame)
        local result = ""
        local dataShuffled = FYShuffle(data)
        for i = 1, 1, 1 do
            result = result .. dataShuffled[i]
        end
        return result
    end

    -- Source: https://stackoverflow.com/questions/35572435/how-do-you-do-the-fisher-yates-shuffle-in-lua
    function FYShuffle(tInput)
        math.randomseed(os.time())
        local tReturn = {}
        for i = #tInput, 1, -1 do
            local j = math.random(i)
            tInput[i], tInput[j] = tInput[j], tInput[i]
            table.insert(tReturn, tInput[i])
        end
        return tReturn
    end

    return p

Retrieved from "https://en.faraghaib.ir/w/index.php?title=Module:All_legals&oldid=972"
Category:

- Scribunto modules with errors