پودمان:Ayat-Navigator
توضیحات این پودمان میتواند در پودمان:Ayat-Navigator/توضیحات قرار گیرد.
require('strict')
local p = {}
local args = {}
local num_con = require('Module:Numeral converter').convert
local getArgs = require('Module:Arguments').getArgs
--local cfg = mw.loadData('Module:Ayat-Navigator/configs')
local function getData(sure, data_type)
if (data_type=="len") then
return require('Module:Ayat-Navigator/Sure-Lengths')
end
if (data_type=="joze_hezb") then
return require('Module:Ayat-Navigator/Joze-Hezb')
end
local title = mw.title.new('Module:Ayat-Navigator/' .. sure)
if not (title and title.exists) then return nil end
return require('Module:Ayat-Navigator/' .. sure)
end
function p.named_gen(frame)
local listitems = ""
args = getArgs(frame)
local sure_num = args["sure_num"]
if getData(num_con("en", sure_num), "ayat_data") then
local data = getData(num_con("en", sure_num), "ayat_data")
if data.ayat_namdar then
for k, v in pairs(data.ayat_namdar) do
listitems = listitems .. '\n* ' .. v
end
end
end
return listitems
end
function p.ayat_gen(frame)
local listitems = ""
args = getArgs(frame)
local aye_num = num_con("en", args["aye_num"])
local sure_num = num_con("en", args["sure_num"])
local sure = args["sure"]
if getData(sure_num, "len") then
local data = getData(sure_num, "len")
if tonumber(aye_num) then
for i = 1, tonumber(data.lengths[sure_num]) do
listitems = listitems ..
'\n* [[آیه ' .. num_con("fa", i) .. ' سوره ' .. sure .. '|'
.. num_con("fa", i) .. ']]'
end
end
end
return listitems
end
function p.mortabet(frame)
local listitems = ""
args = getArgs(frame)
local sure_num = args["sure_num"]
if getData(num_con("en", sure_num), "ayat_data") then
local data = getData(num_con("en", sure_num), "ayat_data")
if data.mortabet then
for k, v in pairs(data.mortabet) do
listitems = listitems .. '\n* ' .. v
end
end
end
return listitems
end
local function hezb_calculator(surenum, ayenum)
if getData(surenum, "joze_hezb") and
tonumber(surenum) and
tonumber(ayenum) then
local data = getData(surenum, "joze_hezb")
local hezbs = data.hezbs
for i= 1, 120 do
local hezb_ini_sure = tonumber(hezbs[i].AzAvaleAye[1])
local hezb_fin_sure = tonumber(hezbs[i].TaAkharAye[1])
local hezb_ini_aye = tonumber(hezbs[i].AzAvaleAye[2])
local hezb_fin_aye = tonumber(hezbs[i].TaAkharAye[2])
if (hezb_ini_sure <= surenum) and
(hezb_fin_sure >= surenum) and
(hezb_ini_sure == hezb_fin_sure) then
if (hezb_ini_aye <= ayenum) and
(hezb_fin_aye >= ayenum) then
return i
end
elseif (hezb_ini_sure <= surenum) and
(hezb_fin_sure >= surenum) and
(hezb_ini_sure < hezb_fin_sure) then
if (surenum == hezb_ini_sure) then
if (hezb_ini_aye <= ayenum) then
return i
end
elseif (surenum > hezb_ini_sure) and
(surenum < hezb_fin_sure) then
return i
elseif (surenum == hezb_fin_sure) then
if (ayenum <= hezb_fin_aye) then
return i
end
end
end
end
end
end
function p.get_hezb(frame)
args = getArgs(frame)
local aye_num = tonumber(num_con("en", args["aye_num"]))
local sure_num = tonumber(num_con("en", args["sure_num"]))
return hezb_calculator(sure_num, aye_num)
end
function p.get_joze(frame)
args = getArgs(frame)
local aye_num = tonumber(num_con("en", args["aye_num"]))
local sure_num = tonumber(num_con("en", args["sure_num"]))
if getData(sure_num, "joze_hezb") then
local data = getData(sure_num, "joze_hezb")
local hezbs = data.hezbs
local hezb = hezb_calculator(sure_num, aye_num)
for i= 1, 120 do
if (hezb == i) then
return hezbs[i].JozeHezb[1]
end
end
end
end
return p