Jump to content

Module:IncrementParams

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Amadalvarez (talk | contribs) at 17:15, 16 July 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
| label304 = {{GetLabelFix|P463|lang={{{lang|}}}}}
|  data304 = {{{membrede|}}} 
| label305 = {{GetLabelFix|P3441|lang={{{lang|}}}}}
|  data305 = {{{codi_fifa|}}}

<!-- paràmetres activitat Museus - Biblios -->
| label306 = {{GetLabelFix|T0049|lang={{{lang|}}}}} 
|  data306 = {{{ambit|}}}
| label307 = {{GetLabelFix|P2046|lang={{{lang|}}}}} 
|  data307 =  {{{superficie|}}}
| label308 = {{GetLabelFix|T0050|lang={{{lang|}}}}} 
|  data308 = {{{coleccions|}}}
| label310 = {{GetLabelFix|T0051|lang={{{lang|}}}}} 
|  data310 = {{{tipus_documents|}}}
| label312 = {{GetLabelFix|P1436|lang={{{lang|}}}}}
|  data312 = {{{volum_coleccio|}}}
| label316 = {{GetLabelFix|P1174|lang={{{lang|}}}}}
|  data316 = {{{visitants|}}}
| label318 = {{GetLabelFix|Q3777645|lang={{{lang|}}}}}
|  data318 = {{{prestecs_anuals|}}}
| label320 = {{GetLabelFix|T0053|lang={{{lang|}}}}} 
|  data320 = {{{nom_habitants|}}}
| label322 = {{GetLabelFix|P6801|lang={{{lang|}}}}}
|  data322 = {{{llits|}}}
| label324 = {{GetLabelFix|P414|lang={{{lang|}}}}}
| data324  = {{{cotitzen_borsa|}}}
| label326 = {{GetLabelFix|P6427|lang={{{lang|}}}}}
| data326  = {{{nom_comercial|}}} 
| label328 = {{GetLabelFix|Q1799072|lang={{{lang|}}}}}
|  data328 = {{if empty|{{{metodes|}}} |{{{metode|}}} }}
| label330 = {{GetLabelFix|P2196|lang={{{lang|}}}}} 
|  data330 = {{{alumnes|}}}
| label331 = {{if empty|{{{etiqueta_membres|}}}|{{GetLabelFix|T0054|lang={{{lang|}}}}} }} 
|  data331 = {{{membres|}}}
| label332 = {{if empty|{{{etiqueta_membres2|}}}|Altres membres}}<!-- +++++ -->
|  data332 = {{{membres2|}}}
| label333 = {{if empty|{{{etiqueta_membres3|}}}|&nbsp;}}<!--si no hi ha etiq., força espais per alinear amb membres2 -->
|  data333 = {{{membres3|}}}
|  data335 = {{{membres_llista|}}} <!-- Alternatiu a membres, membres2, membres3 -->
| label337 = {{GetLabelFix|P6125|lang={{{lang|}}}}}
|  data337 = {{{voluntaris|}}}

<!-- paràmetres activitat grups de música -->
| label340 = {{GetLabelFix|P6125|lang={{{lang|}}}}}  
|  data340 = {{{membres_anteriors|}}}
| label342 = {{GetLabelFix|P264|lang={{{lang|}}}}}
|  data342 = {{{discografica|}}}
| label344 = {{GetLabelFix|Q55567783|lang={{{lang|}}}}} 
|  data344 = {{{artistes_relacionats|}}}
| label345  = {{GetLabelFix|Q735|lang={{{lang|}}}}} 
| data345   = {{{art|}}}
| label346 = {{GetLabelFix|P136|lang={{{lang|}}}}}Gènere artístic
|  data346 = {{{genere|}}}
| label347  = {{GetLabelFix|P135|lang={{{lang|}}}}}
| data347   = {{{moviment|}}}
| label348  = {{GetLabelFix|Q1292119|lang={{{lang|}}}}}
| data348   = {{{estil|}}}
]==========]

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