יחידה:פרמטרים: הבדלים בין גרסאות בדף

יצירת דף עם התוכן "function foo(frame) local ans = "" local pframe = frame:getParent() local numbered = 0 local mustnum = tonumber(frame.args[1]) for k, v in pairs( pframe.arg..."
 
מ 215 גרסאות של הדף wikipedia:he:יחידה:פרמטרים יובאו
 
(215 גרסאות ביניים של 10 משתמשים אינן מוצגות)
שורה 1: שורה 1:
function foo(frame)
-- This function is used for תבנית:הערה parameters control
local ans = ""
function equal(frame)
local pframe = frame:getParent()
local pframe = frame:getParent()
local numbered = 0
type = mw.ustring.sub(pframe:getTitle(), 7)
local mustnum = tonumber(frame.args[1])
oldargs = pframe.args
for k, v in pairs( pframe.args ) do
local newargs = {}
if type( k ) == 'string' then
local kinds = frame.args
ans = checknamed(k, ans, frame)
local stop
else
for p, pp in pairs(oldargs) do
numbered = numbered + 1
stop = false
if tostring(p) == tostring(kinds[1]) and newargs[p] == nil then
newargs[p] = pp
stop = true
elseif tostring(p) == tostring(kinds[1]) then
equalerror("תוכן כפול: " .. newargs[p] .. " וגם " .. pp)
stop = true
else
for z, zz in ipairs(kinds) do
if tostring(p) == tostring(zz) then
newargs[p] = pp
stop = true
do
break
end
end
end
end
if not stop then
local kind = newargs[kinds[1]] or newargs[tonumber(kinds[1])]
if kind ~= nil then
equalerror("תוכן כפול: " .. kind .. " וגם " .. p .. "=" .. pp)
else newargs[kinds[1]] = p .. "=" .. pp
end
end
end
end
end
if (mustnum < numbered) then
return frame:expandTemplate({title = frame.args["קוד"], args = newargs})
ans = out (ans, "צריך מקסימום " .. mustnum .. "פרמטרים, ישנם " .. numbered)
end
 
function equalerror(message)
error("[[קטגוריה:שגיאות קריאה לתבנית " .. type .. "]] (בקריאה ל[[תבנית:" .. type .. "]]) " .. message, 0)
end
 
function decode(frame)
return mw.uri.decode(frame.args[1])
end
 
function googleurl(frame)
--return a .. mw.uri.parseQueryString( frame.args[1] )['http://www.google.co.il/url?url']
--p = ''
--for k, v in pairs(mw.uri.new( frame.args[1] ).query['url'])
--do return 'a' .. k .. 'c' end --p = p .. '+++' .. k .. ':' .. v end
--return p--
local q = mw.uri.new(frame.args[1]).query
return q and (q['url'] or q['q']) or ''
--or mw.uri.parseQueryString( frame.args[1] )['http://www.google.co.il/url?url'] or ''
end
 
function biur(frame)
pframe = frame:getParent()
local newargs = {}
for a, aa in pairs(pframe.args) do
if a == "קבוצה" then
error('פרמטר "קבוצה" כפול[[category:' ..
tostring(mw.message.new("Cite-tracking-category-cite-error")) .. ']]', 0)
end
newargs[a] = aa
end
end
if (ans == "") then
newargs["קבוצה"] = frame.args[1] or "hebrew"
return ans
return frame:expandTemplate{title = "הערה", args = newargs}
end
return "a<div class=error>'''שגיאת פרמטרים ב[[" .. pframe:getTitle() .. "]]:<br/>"
.. ans .. "'''</div>[[קטגוריה:שגיות פרמטריות]]b"  .. " "  
end
end


function checknamed(k, ans, frame)
function showparams( frame )
local i = 2
local ans = '', k
while (frame.args[i] ~= nil) do
for i, v in pairs(frame.args) do
if (frame.args[i] == k) then
if tonumber(i) then
return ans
k = v
else
k = i
end
end
i = i + 1
k = mw.ustring.gsub(k, '\n', '')
if mw.ustring.find(k, '|') then
k = k .. ' (' .. mw.ustring.sub(k, 3, mw.ustring.find(k, '|') - 1) .. ')'
end
ans = ans .. '#' .. k .. '\n'
end
end
return out(ans, "פרמטר לא ידוע: ''" .. k .. "''")
return ans
end
end


function out(ans, new)
return ans .. new .. "</br>"
end


local function main() end
return {
return {
['main'] = foo
main = main,
equal = equal,
decode = decode,
googleurl = googleurl,
biur = biur,
showparams = showparams,
}
}