Jump to content

Module:IncrementParams

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by The RedBurn (talk | contribs) at 18:05, 9 June 2022. 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 = 1

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
| label1 = Codename
| data1 = {{{codename|}}}
| label50 = Also known as
| data50  = {{{aka|}}}{{{also known as|}}}
| label2  = [[Brand]]
| class2  = brand
| data2   = {{{brand|}}}
| label3  = Developer
| class3  = brand
| data3   = {{{developer|}}}
| label4  = [[List of mobile phone makers by country|Manufacturer]]
| class4  = brand
| data4   = {{{manufacturer|}}}
| label5  = [[Slogan]]
| data5   = {{{slogan|}}}
| label6   = [[Color]]s
| data6   = {{{colors|}}}
| label7  = {{#if:{{{serieslabel|}}}|{{{serieslabel}}}|Series}}
| data7   = {{{series|}}}
| label51 = Family
| data51  = {{{family|}}}
| label8  = Model
| data8   = {{{modelnumber|}}}
| label9  = [[Comparison_of_mobile_phone_standards|Compatible network]]s
| data9   = {{{networks|}}}
| label10 = First released
| data10  = {{{released|{{{releasedate|}}}}}}
| label11 = Availability by region
| data11  = {{{available|}}}
| label12 = Discontinued
| data12  = {{{discontinuation_date|{{{discontinued|{{{Discontinued|}}} }}} }}}
| label13 = Units sold
| data13  = {{{unitssold|}}}
| label14 = Units shipped
| data14  = {{{unitsshipped|}}}
| label15 = Predecessor
| data15  = {{{predecessor|}}}
| label16 = Successor
| data16  = {{{successor|}}}
| label17 = Related
| data17  = {{{related|}}}
| label18 = Type
| data18  = {{{type|}}}
| label19 = [[Form factor (mobile phones)|Form factor]]
| data19  = {{{form|{{{form factor|}}}}}}
| label20 = Dimensions
| data20  = {{{size|{{{dimensions|}}}}}}
| label21 = Mass
| data21  = {{{weight|}}}
| label22 = [[Mobile operating system|Operating system]]
| data22  = {{{operatingsystem|{{{os|}}}}}}
| label23 = [[System on a chip|System on chip]]
| data23  = {{{soc|}}}
| label24 = [[Central processing unit|CPU]]
| data24  = {{{cpu|}}}
| label25 = [[Graphics processing unit|GPU]]
| data25  = {{{gpu|}}}
| label26 = [[Modem]]
| data26  = {{{modem|}}}
| label27 = Memory
| data27  = {{{memory|}}}
| label28 = Storage
| data28  = {{{storage|}}}
| label29 = [[Removable media|Removable storage]]
| data29  = {{{memory_card|}}}
| label30 = [[SIM card|SIM]]
| data30  = {{{sim|}}}
| label31 = [[Battery (electricity)|Battery]]
| data31  = {{{battery|}}}
| label32 = Charging
| data32  = {{{charging|}}}
| label34 = Display
| data34  = {{{display|{{{screen|{{{Screen|}}} }}} }}}
| label35 = External display
| data35  = {{{external_display|{{{ext_display|{{{exterior_screen|{{{ext_screen|}}} }}} }}} }}}
| label38 = [[Portable media player|Media]]
| data38  = {{{media|}}}
| label39 = Sound
| data39  = {{{sound|}}}
| label36 = Rear [[Camera phone|camera]]
| data36  = {{{rear_camera|{{{camera|}}} }}}
| label37 = [[Front-facing camera|Front camera]]
| data37  = {{{front_camera|{{{2nd_camera|}}} }}}
| label40 = Connectivity
| data40  = {{{connectivity|}}}
| label33 = Data inputs
| data33  = {{{input|}}}
| label41 = [[IP Code#Second digit: Liquid ingress protection|Water resistance]]
| data41  = {{{water_resist|{{{water_resistance|{{{ip_rating|}}} }}} }}}
| label42 = Other
| data42  = {{{other|}}}
| label43 = Development status
| data43  = {{{status|}}}
| label44 = [[Specific absorption rate|SAR]]
| data44  = {{{sar|}}}
| label45 = [[Hearing aid#Compatibility with telephones|Hearing aid compatibility]]
| data45  = {{{hac|}}}
| label46 = Test mode
| data46  = {{{test_mode|}}}
| label47 = Made in
| data47  = {{{country|{{{made_in|}}} }}}
| label48 = Website
| data48  = {{{website|}}}
| label49 = References
| data49  = {{{references|}}}
]==========]

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