پودمان:Legal terms: تفاوت میان نسخه‌ها

از ویکی حقوق
پرش به ناوبری پرش به جستجو
(صفحه‌ای تازه حاوی «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 = subText .. '</span> <small><span class="content-improvement-item__number-smal">' loc...» ایجاد کرد)
 
بدون خلاصۀ ویرایش
برچسب: برگردانده‌شده
(۴ نسخهٔ میانیِ ایجادشده توسط همین کاربر نشان داده نشد)
خط ۲۳: خط ۲۳:
     local result = ""
     local result = ""
     local dataShuffled = FYShuffle(data)
     local dataShuffled = FYShuffle(data)
     for i = 1, 4, 1 do
     for i = 1, #dataShuffled do
         result = result .. dataShuffled[i]
         result = result .. dataShuffled[i]
     end
     end

نسخهٔ ‏۲۱ ژوئن ۲۰۲۴، ساعت ۱۳:۴۱

توضیحات این پودمان می‌تواند در پودمان:Legal terms/توضیحات قرار گیرد.

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 = subText .. '</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-red', '-icon-editUndo', 'اصطلاحات حقوق خصوصی', 'اصطلاحات حقوق خصوصی'),
    createItem('-color-red', '-icon-tableMergeCells', 'اصطلاحات حقوق جزا', 'اصطلاحات حقوق کیفری'),
    createItem('-color-red', '-icon-searchCaseSensitive', 'اصطلاحات حقوق عمومی', 'اصطلاحات حقوق عمومی'),
    createItem('-color-red', '-icon-alert', 'اصطلاحات فقهی', 'اصطلاحات فقهی'),
}

function p.main(frame)
    local result = ""
    local dataShuffled = FYShuffle(data)
    for i = 1, #dataShuffled 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