Module:Personal
Documentation for this module may be created at Module:Personal/doc
--require("json") --local bodge = require "Module:gtable" --local subString, lenString = mw.ustring.sub, mw.ustring.len --local split = mw.text.split --local gm = string.gmatch local p = {} local util = require "Module:Utility" local split = util.split local comp = util.comp local subString, lenString = mw.ustring.sub, mw.ustring.len local gm = string.gmatch function p.InCSV(frame) local t={} for n,v in frame:argumentPairs() do table.insert (t,{n,v}) end table.sort (t,comp) tot = 0 r = '{|class="wikitable sortable"\n!name!!value\n' for i,nv in ipairs(t) do val = split(nv[2], ',') val_list = '' for y,x in ipairs(val) do val_list = val_list .. '[['..nv[1]..'::'..x..']],' end r = r..'|-\n|[['..nv[1]..']]||'..val_list..'\n' --r = r..'|-\n|'..nv[1]..'||[['..nv[1]..'::'..nv[2]..']]\n' end r=r..'|}\n' return r end function p.In(frame) local t={} for n,v in frame:argumentPairs() do table.insert (t,{n,v}) end table.sort (t,comp) tot = 0 r = '{|class="wikitable sortable"\n!name!!value\n' for i,nv in ipairs(t) do r = r..'|-\n|'..nv[1]..'||[['..nv[1]..'::'..nv[2]..']]\n' end r=r..'|}\n' return r end function p.Out(frame) local t={} for n,v in frame:argumentPairs() do table.insert (t,{n,v}) end table.sort (t,comp) tot = 0 r = '{|class="wikitable sortable"\n!name!!value\n' for i,nv in ipairs(t) do r = r..'|-\n|'..nv[1]..'||'..nv[2]..'\n' tot = tot + nv[2] end r = r..'|-\n|'..'Tot'..'||'..tot..'\n' r=r..'|}\n' return r end function p.Malattie(frame) local r = '' r = '{|class="wikitable sortable"\n!name!!value\n' n = 'Malattia' v = frame.args[n] val= split( v, ',' ) for y,x in ipairs(val) do r = r..'|-\n|'..n..'||[['..n..'::'..x..']]\n' end r=r..'|}\n' return r end function p.Fumo(frame) local t={} local r = '{|class="wikitable sortable"\n!name!!value\n' local to_calc = { apple="green", orange="orange", banana="yellow" } local sd = frame.args['start_date'] -- myd = split(sd,'-') st = os.time({year=2013, month=3, day=2}) -- r=os.date("today is %Y-%m-%d %H:%M:%S, in %B or %a ") diff = os.difftime (os.time(), st) diff_d = diff/60/60/24 sig = diff_d*20 co = diff_d*7.60 t = { apple="green", orange="orange", banana="yellow" } t = {d=diff_d,s=sig, c =co } for y,x in pairs(t) do -- y = 'aaa' r = r..'|-\n|'..y..'||[['..y..'::'..x..']]\n' end r=r..'|}\n' return r end function p.Calorie(frame) --La Greca Giovanni attivita fisica local t={} local r = '{|class="wikitable sortable"\n!name!!value\n' local sd = frame.args['start_date'] -- myd = split(sd,'-') st = os.time({year=2013, month=3, day=2}) -- r=os.date("today is %Y-%m-%d %H:%M:%S, in %B or %a ") diff = os.difftime (os.time(), st) diff_d = diff/60/60/24 sig = diff_d*20 co = diff_d*7.60 calorie_fumo = 200 cal_j = 4,1867 cfj = calorie_fumo*cal_j cal_d = 1683 cal_dj = cal_d * cal_j t = {La_Greca_Giovanni_alimentazione= cal_d, Alimentazione='Alimentazione', metabolismo = 0, energy = cal_d, calorie = 200 , energia = cfj} for y,x in pairs(t) do r = r..'|-\n|[['..y..']]||[['..y..'::'..x..']]\n' end r=r..'|}\n' return r end function p.MB(frame) local t = tonumber(frame.args['t']) local m = tonumber(frame.args['m']) local l = tonumber(frame.args['l']) local sd = frame.args['start_date'] local res = (10*m + 6.25*l)-5.0*t + 5 local r = '{|class="wikitable sortable"\n!name!!value\n' r = r..'|-\n|[[t]]||[['..t..'::'..t..']]\n' r = r..'|-\n|[[m]]||[['..m..'::'..m..']]\n' r = r..'|-\n|[[l]]||[['..l..'::'..l..']]\n' r = r..'|-\n|[[Res]]||[['..res..'::'..res..']]\n' r=r..'|}\n' return r end function p.Sport(frame) local t_age = tonumber(frame.args['t_age']) local m = tonumber(frame.args['m']) local l_high = tonumber(frame.args['l_high']) local sport = frame.args['sport'] if sport == nil then sport = 'sport' end local res = (10*m + 6.25*l_high)-5.0*t_age + 5 local HRmax = 205.8 - (0.685 * t_age) local r = '{|class="wikitable sortable"\n!name!!value\n' r = r..'|-\n|[[sport]]||[['..sport..'::'..sport..']]\n' r = r..'|-\n|[[t_age]]||[['..t_age..'::'..t_age..']]\n' r = r..'|-\n|[[m]]||[['..m..'::'..m..']]\n' r = r..'|-\n|[[l_high]]||[['..l_high..'::'..l_high..']]\n' r = r..'|-\n|[[HRmax]]||[['..HRmax..'::'..HRmax..']]\n' r = r..'|-\n|[[Res]]||[['..res..'::'..res..']]\n' r=r..'|}\n' return r end return p