Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/AlphaZeta/test4
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--[[ Infobox biography 1. Sets default colors and styles 2. Finds any input fields for death and birth dates and formats the date according to Swedish standard and calculates and displays age or age at death ]] local p = {}; -- Default style ------------- local default_bodystyle='border-spacing:3px;width:22em;border:1px solid #AAAAAA; border-top:0px;' local default_titlestyle='border:1px solid #AAAAAA; border-bottom:0px;background:#ccd9e8;padding-top:5px;padding-bottom:5px;' local default_labelstyle='' local default_headerstyle='background:#BFD2EB;' local default_belowstyle='background:#BFD2EB;' ------------------------------ local Infobox = require('Module:Infobox') local DateHelper = require('Module:Sandbox/AlphaZeta/test3') function p.infobox(frame) -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. if frame == mw.getCurrentFrame() then inputargs = frame:getParent().args else inputargs = frame end -- Set default style if inputargs.bodystyle ~= nil then default_bodystyle = default_bodystyle..inputargs.bodystyle end inputargs.bodystyle=default_bodystyle if inputargs.titlestyle ~= nil then default_titlestyle = default_titlestyle..inputargs.titlestyle end inputargs.titlestyle=default_titlestyle if inputargs.labelstyle ~= nil then default_labelstyle = default_labelstyle..inputargs.labelstyle end inputargs.labelstyle=default_labelstyle if inputargs.headerstyle ~= nil then default_headerstyle = default_headerstyle..inputargs.headerstyle end inputargs.headerstyle=default_headerstyle if inputargs.belowstyle ~= nil then default_belowstyle = default_belowstyle..inputargs.belowstyle end inputargs.belowstyle=default_belowstyle -- Check all data fields to find and format -- Birthdate (marked with @birth@) -- Death date (marked with @death@) -- Other dates (marked with @date@) local birthDateField local deathDateField local birth_date='' local death_date='' for name, value in pairs(inputargs) do if (name:sub(1,4)=='data') then if value:sub(1,7)=='@birth@' then birthDateField=name birth_date=value:sub(8) inputargs[name]=DateHelper.format(birth_date,'link',true) elseif value:sub(1,7)=='@death@' then deathDateField=name death_date=value:sub(8) inputargs[name]=DateHelper.format(death_date,'link',true) elseif value:sub(1,6)=='@date@' then inputargs[name]=DateHelper.format(value:sub(7),'',true) elseif value:sub(1,10)=='@datelink@' then inputargs[name]=DateHelper.format(value:sub(11),'link',true) end end end -- calcuate age, either alive or dead local ageAlive='' local ageDeath='' if birth_date~=nil and birth_date~='' then if death_date==nil or death_date=='' then ageAlive=DateHelper.yearsBetween(birth_date) if ageAlive~='' then ageAlive=' ('..ageAlive..')' end else ageDeath=DateHelper.yearsBetween(birth_date,death_date) if ageDeath~='' then ageDeath=' ('..ageDeath..')' end end end -- add age to date fields if birthDateField~=nil then inputargs[birthDateField]=inputargs[birthDateField]..ageAlive end if deathDateField~=nil then inputargs[deathDateField]=inputargs[deathDateField]..ageDeath end return Infobox.infobox(inputargs) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/AlphaZeta/test4/doc
(
edit
)