跳转到内容

模組:IncrementParams

维基百科,自由的百科全书

这是本页的一个历史版本,由Richardcai留言 | 贡献2020年10月11日 (日) 11:06编辑。这可能和当前版本存在着巨大的差异。

-- 第一步:點擊頁面頂部「編輯」按鈕開始編輯本模組。
-- STEP 1: Click on the "edit" tab at the top of the page to edit this module.

-- 第二步:如果你想加上1之外的數目,請修改等號後的數字。
-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign. 
local increment = 2

-- 第三步:用你想增加數字的模板部分替換下方內容。
-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
|label21 = 所属班级
|data21 = {{#ifeq:{{{所属团体|{{{所屬團體|}}}}}}|GNZ48|{{{所属班级|{{{所屬班級|}}}}}}|{{#ifeq:{{{所属团体|{{{所屬團體|}}}}}}|GNZ48|{{{所属班级|{{{所屬班級|}}}}}}|}}}}
|label22 = 前属团体
|data22 = {{{前属团体|{{{前屬團體|}}}}}}
|label23 = 前属隊伍
|data23 = {{{前属队伍|{{{前屬隊伍|}}}}}}
|label24 = 曾兼任团体
|data24 = {{{曾兼任团体|{{{曾兼任團體|}}}}}}
|label25 = 曾兼任隊伍
|data25 = {{{曾兼任队伍|{{{曾兼任隊伍|}}}}}}
|label26 = 兼任职务
|data26 = {{{兼任职务|{{{兼任職務|}}}}}}
|label27 = 所属小分队
|data27 = {{#switch:{{{所属团体|{{{所屬團體|}}}}}}|IDOLS Ft|SNH48 Group海外练习生|SNH48 Group海外練習生=|#default={{#if:{{{所属小分队|{{{所屬小分隊|}}}}}}|{{#switch:{{{所属小分队|{{{所屬小分隊|}}}}}}|HO2=[[HO2 (偶像团体)|HO2]]|#default=[[{{{所属小分队|{{{所屬小分隊|}}}}}}]]}}|}}}}
|label28 = 前属小分队
|data28 = {{{前属小分队|{{{前屬小分隊|}}}}}}
|label29 = 相關團體
|data29 = {{#ifeq:{{{嵌套|{{{embed}}}}}}|yes||{{{相关团体|{{{相關團體|}}}}}}}}
|header30 = {{#ifeq:{{{选拔次数|{{{選拔次數|}}}}}}||{{#ifeq:{{{第一届总选举排名|{{{第一屆總選舉排名|}}}}}}||{{#ifeq:{{{第二届总选举排名|{{{第二屆總選舉排名|}}}}}}||{{#ifeq:{{{第三届总选举排名|{{{第三屆總選舉排名|}}}}}}||{{#ifeq:{{{第四届总选举排名|{{{第四屆總選舉排名|}}}}}}||{{#ifeq:{{{第五届总选举排名|{{{第五屆總選舉排名|}}}}}}|||选拔与选举}}|选拔与选举}}|选拔与选举}}|选拔与选举}}|选拔与选举}}|选拔与选举}}
|label31 = 選拔次數
|data31 = {{{选拔次数|{{{選拔次數|}}}}}}
|label32 =  - SNH48
|data32 = {{{SNH48选拔次数|{{{SNH48選拔次數|}}}}}}
|label33 =  - BEJ48
|data33 = {{{BEJ48选拔次数|{{{BEJ48選拔次數|}}}}}}
|label34 =  - GNZ48
|data34 = {{{GNZ48选拔次数|{{{GNZ48選拔次數|}}}}}}
|label35 =  - SHY48
|data35 = {{{SHY48选拔次数|{{{SHY48選拔次數|}}}}}}
|label36 =  - CKG48
|data36 = {{{CKG48选拔次数|{{{CKG48選拔次數|}}}}}}
|label37 = 担任中心成员次数
|data37 = {{{担任中心成员次数|{{{擔任中心成員次數|}}}}}}
|label38 = [[SNH48第一屆總選舉|第一屆總選舉排名]]
|data38 = {{{第一届总选举排名|{{{第一屆總選舉排名|}}}}}}
|label39 = [[SNH48第二屆總選舉|第二屆總選舉排名]]
|data39 = {{{第二届总选举排名|{{{第二屆總選舉排名|}}}}}}
|label40 = [[SNH48第三屆總選舉|第三屆總決選排名]]
|data40 = {{{第三届总选举排名|{{{第三屆總選舉排名|}}}}}}
|label41 = [[SNH48 Group第四屆總選舉|第四屆總決選排名]]
|data41 = {{{第四届总选举排名|{{{第四屆總選舉排名|}}}}}}
|label42 = [[SNH48 Group第五屆總選舉|第五屆總決選排名]]
|data42 = {{{第五届总选举排名|{{{第五屆總選舉排名|}}}}}}
|label43 = [[SNH48 Group第六届总决选|第六届总选举排名]]
|data43 = {{{第六届总选举排名|{{{第六屆總選舉排名|}}}}}}
|label44 = [[SNH48 Group第七届总决选|第七届总选举排名]]
|data44 = {{{第七届总选举排名|{{{第七屆總選舉排名|}}}}}}
]==========]

-- 第四步:保存本模組。
-- STEP 4: Save this module.

-- 第五步:你現在可以通過以下代碼輸出數字增加後的代碼:
--                {{subst:#invoke:IncrementParams|main}}
-- 又或者直接拷貝下方模組文檔中的修改後的代碼。
-- STEP 5: You can now output the incremented text with the following code:
--                {{subst:#invoke:IncrementParams|main}}
-- Or you can simply copy and paste the text from this module's documentation.

-- 第六步:檢查輸出內容!在某些情況下本模組可能會產生部分假陽性結果。
-- 比如它會將「[[Some link|foo3=bar]]」修改為「[[Some link|foo4=bar]]」。
-- 你可以通過模板編輯頁面中「顯示變更」按鈕檢查是否有假陽性結果存在。
-- STEP 6: Check the output! In rare cases this module might produce false positives.
-- For example, it will change the text "[[Some link|foo3=bar]]" to "[[Some link|foo4=bar]]".
-- You can use the "show changes" function in the edit window of the template you are editing
-- to find any false positives.

-- 第七步:當你完成後,撤回你於本模組的編輯,避免下一個使用本模組的人對使用方法感到混淆。
-- 謝謝使用本模組!
-- STEP 7: When you are finished, undo your changes to this page, so that the next person
-- won't be confused by seeing any non-default values. Thanks for using this module!

local p = {}
 
local function replace(prefix, num, suffix)
    return '|' .. prefix .. tostring(tonumber(num) + increment) .. suffix .. '='
end
 
function p.main(frame)
    -- Increment the template text.
    templatetext = mw.ustring.gsub(templatetext, '|(%s*%a?[%a_%-]-%s*)([1-9]%d*)(%s*[%a_%-]-%a?%s*)=', replace)
    -- Add pre tags and escape html etc. if the pre option is set.
    if frame and frame.args and frame.args.pre and frame.args.pre ~= '' then
        templatetext = mw.text.nowiki(templatetext)
        templatetext = '<pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; '
            .. 'white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">' 
            .. templatetext .. '</pre>'
    end
    return templatetext
end
 
return p