Jump to content

Module:IncrementParams: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Townie (talk | contribs)
No edit summary
Townie (talk | contribs)
Undid revision 799875187 by Townie (talk)
Line 2: Line 2:


-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign.
-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign.
local increment = 5
local increment = 1


-- STEP 3: Replace the example template text with the template text that you wish to increment.
-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
local templatetext = [==========[
|header3 = Section 1
| label2 = Operació
|label5 = Label A
| data2 = {{{operació|}}}
|data5 = Data A

| label3 = Front
|label7 = Label C
| data3 = {{{front|}}}
|data7 = Data C
|header10 = Section 2

|label12 = Label D
| label4 = Campanya
| data4 =
|data12 = Data D

| label5 = [[Casus belli]]
| data5 = {{{casus|}}}

| label6 = Data
| data6 = {{{data|}}}

| label7 = Municipi
| data7 = {{{municipi|}}}

| label8 = Escenari
| data8 = {{{escenari|}}}

| label9 = Resultat
| data9 = {{{resultat|}}}

| label10 = Conseqüències
| data10 = {{{data|{{{date|}}}}}}

| label11 = Coordenades
| data11 = {{{idioma|{{{language|}}}}}}

| label12 =
| data12 = {{#if:{{{imatge_mapa|}}}
| {{#invoke:InfoboxImage|InfoboxImage|image={{{imatge_mapa|}}} |size=225px
|sizedefault=frameless|upright=1|alt= |title={{{peu_mapa|}}}
|suppressplaceholder=yes}}
| {{#if:{{{draw_mapa|}}}
| {{{draw_mapa|}}}
| {{#ifeq:{{{mapaWD|}}}|no|<!--no es vol mapa -->|
<!--coordenades? -->{{#if:{{both|{{{lat_dec|}}}|{{{long_dec|}}} }} {{lat wd|item={{{item|}}} }}
<!--punt sortida?--> {{#invoke:Wikidata|claim |property=P1427| qualifier=P625|item={{{item|}}} }}
<!--punt arribada?--> {{#invoke:Wikidata|claim |property=P1444| qualifier=P625|item={{{item|}}} }}
|{{map draw |height=300 |width= 300|zoom = {{if empty|{{{zoom|}}}|auto}} |text={{{peu_mapa|}}}
| latitude= {{if empty|{{{lat_dec|}}} | {{lat wd|item={{{item|}}} }}
|{{#invoke:Wikidata|claim |property=P1427| qualifier=P625|item={{{item|}}}|formatting=latitude}}
|{{#invoke:Wikidata|claim |property=P1444| qualifier=P625|item={{{item|}}}|formatting=latitude}} }}
| longitude= {{if empty|{{{long_dec|}}}|{{lon wd|item={{{item|}}} }}
|{{#invoke:Wikidata|claim |property=P1427| qualifier=P625|item={{{item|}}}|formatting=longitude}}
|{{#invoke:Wikidata|claim |property=P1444| qualifier=P625|item={{{item|}}}|formatting=longitude}} }}
| marker-symbol={{{marcador|}}}
| marker-size={{{marcador_mida|small}}}
| marker-color={{if empty|{{{marcador_color|}}} | FF0000}}
|geotype1=Point
|title1= {{if empty|{{{nom_marcador|}}}
| {{#invoke:Wikidata|claim |property=P1427|item={{{item|}}} }}
| {{{nom|{{PAGENAME}} }}} (inici) }}
|coordinates1={{if empty|{{{lat_dec|}}}
|{{#invoke:Wikidata|claim |property=P1427| qualifier=P625|item={{{item|}}}|formatting=latitude}}
| {{lat wd|item={{{item|}}} }}
}}, {{if empty|{{{long_dec|}}}
|{{#invoke:Wikidata|claim |property=P1427| qualifier=P625|item={{{item|}}}|formatting=longitude}}
| {{lon wd|item={{{item|}}} }}
}}
|description1=
|image1={{#if:{{#property:P885|qualifier= P18|from={{{item|}}} }}
|{{#invoke:Wikidata | claim | property=P885|qualifier=p18
| list=false |item={{{item|}}} }}
}}
|geotype2=Point
|title2= {{if empty|{{{nom_marcador2|}}}
| {{#invoke:Wikidata|claim |property=P1444|item={{{item|}}} }}
| {{{nom|{{PAGENAME}} }}} (final) }}
|coordinates2={{if empty|{{{lat_dec2|}}}
|{{#invoke:Wikidata|claim |property=P1444| qualifier=P625|item={{{item|}}}|formatting=latitude}}
| {{lat wd|item={{{item|}}} }}
}}, {{if empty|{{{long_dec2|}}}
|{{#invoke:Wikidata|claim |property=P1444| qualifier=P625|item={{{item|}}}|formatting=longitude}}
| {{lon wd|item={{{item|}}} }}
}}
|description2=
|image2={{#if:{{#property:P1444|qualifier= P18|from={{{item|}}} }}
|{{#invoke:Wikidata | claim |property=P1444 |qualifier=p18
| list=false |item={{{item|}}} }}
}}
|marker-symbol1 = {{#if:{{{lat_dec2|}}}
{{#invoke:Wikidata|claim |property=P1444| qualifier=P625|item={{{item|}}}}}
|a
}}
|marker-symbol2 = {{#if:{{{lat_dec2|}}}
{{#invoke:Wikidata|claim |property=P1444| qualifier=P625|item={{{item|}}}}}
|b
}}
}}<!-- Fi map draw-->
}}<!--fi no es vol mapa -->
}}<!--fi no hi ha coordenades -->
}}<!--fi map draw aportat -->
}}<!--fi mapa en imatge -->

| label13 =
| data13 =

| label14 =
| data14 =

| label15 =
| data15 =

| label16 =
| data16 =

| label17 =
| data17 =

| label18 =
| data18 =

| label19 =
| data19 =

| header20 = {{#if:{{{bàndol1|}}}{{{bàndol2|}}}{{{bàndol3|}}} | Bàndols}}
| data20 =

| header21 = {{{bàndol1|}}}
| label22 = Components
| data22 = {{{components1|}}}

| label23 = General(s)
| data23 = {{{general1|}}}

| label24 = Comandant(s)
| data24 = {{{comandant1|}}}

| label25 = Oficial(s)
| data25 = {{{oficial1|}}}

| label26 = Cavaller(s)
| data26 = {{{cavaller1|}}}

| label27 = Força numèrica
| data27 = {{{força_numèrica1|}}}

| label28 = Baixes
| data28 = {{{baixes1|}}}

| label29 =
| data29 =

| label30 =
| data30 =

| label31 =
| data31 =

| label32 =
| data32 =

| label33 =
| data33 =

| label34 =
| data34 =

| header35 = {{{bàndol2|}}}

| label36 = Components
| data36 = {{{components2|}}}

| label37 = General(s)
| data37 = {{{general2|}}}

| label38 = Comandant(s)
| data38 = {{{comandant2|}}}

| label39 = Oficial(s)
| data39 = {{{oficial2|}}}

| label40 = Cavaller(s)
| data40 = {{{cavaller2|}}}

| label41 = Força numèrica
| data41 = {{{força_numèrica2|}}}

| label42 = Baixes
| data42 = {{{baixes2|}}}

| label43 =
| data43 =

| label44 =
| data44 =

| label45 =
| data45 =

| label46 =
| data46 =

| label47 =
| data47 =

| label48 =
| data48 =

| header49 = {{{bàndol3|}}}

| label50 = Components
| data50 = {{{components3|}}}

| label51 = General(s)
| data51 = {{{general3|}}}

| label52 = Comandant(s)
| data52 = {{{comandant3|}}}

| label53 = Oficial(s)
| data53 = {{{oficial3|}}}

| label54 = Cavaller(s)
| data54 = {{{cavaller3|}}}

| label55 = Força numèrica
| data55 = {{{força_numèrica3|}}}

| label56 = Baixes
| data56 = {{{baixes3|}}}

| label57 =
| data57 =

| label58 =
| data58 =

| label59 =
| data59 =

| label60 =
| data60 =

| label61 =
| data61 =

| label62 =
| data62 =

| label63 =
| data63 =

| label64 =
| data64 =

| label65 =
| data65 =

| label66 =
| data66 =

| label67 =
| data67 =

| label68 =
| data68 =

| label69 =
| data69 =

| header70 = Cronologia de batalles de la {{{conflicte|}}}

| label71 =
| data71 = {{align|left|&larr;}} {{align|right|&rarr;}}
]==========]
]==========]



Revision as of 10:08, 10 September 2017

-- STEP 1: Click on the "edit" tab at the top of the page to edit this module.

-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign. 
local increment = 1

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
|header3  = Section 1
|label5   = Label A
|data5    = Data A
|label7   = Label C
|data7    = Data C
|header10 = Section 2
|label12  = Label D
|data12   = Data D
]==========]

-- STEP 4: Save this module.

-- 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.

-- 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