「モジュール:Toolbar」を編集中

移動先: 案内検索

警告: ログインしていません。編集を行うと、あなたの IP アドレスが公開されます。ログインまたはアカウントを作成すれば、あなたの編集はその利用者名とともに表示されるほか、その他の利点もあります。

この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 編集中の文章
1行目: 1行目:
 
local p = {}
 
local p = {}
 +
local args = {}
  
local function getArgNums(args)
+
-- Get the keys of the numerical arguments that are present.
-- Get the keys of the numerical arguments that are present.
+
local function getArgNums()
local nums = {}
+
    local nums = {}
local tinsert = table.insert
+
    for k, v in pairs(args) do
for k, v in pairs(args) do
+
        if type(k) == 'number' then
if type(k) == 'number' then
+
            table.insert(nums, k)
tinsert(nums, k)
+
        end
end
+
    end
end
+
    table.sort(nums)
table.sort(nums)
+
    return nums
return nums
 
 
end
 
end
  
local function makeToolbarItems(args)
+
local function makeToolbarItems()
local nums = getArgNums(args)
+
    -- Get numerical argument keys.
local sep = (args.separator or 'pipe') .. '-separator'
+
    local nums = getArgNums()
sep = mw.message.new(sep):plain()
+
    -- Get the separator text.
local ret = {}
+
    local sep = (args.separator or 'pipe') .. '-separator'
local tinsert = table.insert
+
    sep = mw.message.new(sep):plain()
for i, v in ipairs(nums) do
+
   
tinsert(ret, args[v])
+
    -- Generate the toolbar items.
end
+
    local ret = ''
if #ret > 0 then
+
    for i, v in ipairs(nums) do
return table.concat(ret, sep)
+
        ret = ret .. args[v]
end
+
        if nums[i + 1] then
 +
            ret = ret .. sep
 +
        end
 +
    end
 +
    return ret
 
end
 
end
  
function p._main(args)
+
local function makeToolbar()
local toolbarItems = makeToolbarItems(args)
+
    local class = (args.class and (' ' .. args.class))  or ''
if not toolbarItems then return '' end -- Return the blank string if no arguments were specified, rather than returning empty brackets
+
    local style = (args.style and (' style="' .. args.style .. '"')) or ''
return mw.ustring.format(
+
   
'<span class="plainlinks%s"%s>(%s)</span>',
+
    local ret = '<span class="plainlinks' .. class .. '"' .. style .. '>'
type(args.class) == 'string' and ' ' .. args.class or '',
+
        .. '(' .. makeToolbarItems() .. ')'
type(args.style) == 'string' and mw.ustring.format(' style="%s"', args.style) or '',
+
        .. '</span>'
toolbarItems
+
   
)
+
    return ret
 
end
 
end
  
 
function p.main(frame)
 
function p.main(frame)
-- If called via #invoke, use the args passed into the invoking template.
+
    -- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
+
    -- Otherwise, for testing purposes, assume args are being passed directly in.
local origArgs
+
    local origArgs
if frame == mw.getCurrentFrame() then
+
    if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
+
        origArgs = frame:getParent().args
for k, v in pairs(frame.args) do
+
    else
origArgs = frame.args
+
        origArgs = frame
break
+
    end
end
+
   
else
+
    -- Strip whitespace and remove nil values
origArgs = frame
+
    for k, v in pairs(origArgs) do
end
+
        v = mw.text.trim(v)
-- Strip whitespace and remove nil values
+
        if v ~= '' then
local args = {}
+
            args[k] = v
for k, v in pairs(origArgs) do
+
        end
if type(v) == 'string' then
+
    end
v = mw.text.trim(v)
+
   
end
+
    return makeToolbar()
if v ~= '' then
 
args[k] = v
 
end
 
end
 
return p._main(args)
 
 
end
 
end
 
+
 
return p
 
return p

ひつじ小屋別館2代目への投稿はすべて、他の投稿者によって編集、変更、除去される場合があります。 自分が書いたものが他の人に容赦なく編集されるのを望まない場合は、ここに投稿しないでください。
また、投稿するのは、自分で書いたものか、パブリック ドメインまたはそれに類するフリーな資料からの複製であることを約束してください(詳細はひつじ小屋別館2代目:著作権を参照)。 著作権保護されている作品は、許諾なしに投稿しないでください!

このページを編集するには、下記の確認用の質問に回答してください (詳細):

取り消し | 編集の仕方 (新しいウィンドウで開きます)