https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3ASports_career%2Fsandbox Module:Sports career/sandbox - Revision history 2025-06-13T19:26:57Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.5 https://en.wikipedia.org/w/index.php?title=Module:Sports_career/sandbox&diff=1150240040&oldid=prev Lemondoge: Create sandbox version of Module:Sports career; simplify regex and improve efficiency slightly 2023-04-17T01:41:02Z <p>Create sandbox version of <a href="/wiki/Module:Sports_career" title="Module:Sports career">Module:Sports career</a>; simplify regex and improve efficiency slightly</p> <p><b>New page</b></p><div>local p = {}<br /> <br /> local function isnotempty(s)<br /> return s and s:find(&#039;%S&#039;)<br /> end<br /> <br /> function p.main(frame)<br /> local player = {}<br /> local coach = {}<br /> local pargs = frame:getParent().args<br /> local tracking = &#039;&#039;<br /> local iargs = {}<br /> local pmax = tonumber(frame.args[&#039;pmax&#039;] or 40) or 40<br /> local cmax = tonumber(frame.args[&#039;cmax&#039;] or 30) or 30<br /> for k,v in pairs(pargs) do<br /> if type(k) == &#039;string&#039; and isnotempty(v) then<br /> if k:match(&#039;^team%d+$&#039;) then<br /> local num = mw.ustring.gsub(k,&#039;^team(%d+)$&#039;,&#039;%1&#039;)<br /> table.insert(player, {tonumber(num) or 0, pargs[&#039;years&#039; .. num] or &#039;&#039;, v})<br /> elseif k:match(&#039;^cteam%d%d*$&#039;) then<br /> local num = mw.ustring.gsub(k,&#039;^cteam(%d+)$&#039;,&#039;%1&#039;)<br /> table.insert(coach, {tonumber(num) or 0, pargs[&#039;cyears&#039; .. num] or &#039;&#039;, v})<br /> end<br /> end<br /> end<br /> <br /> table.sort(player, function (a, b) return a[1] &lt; b[1] end)<br /> table.sort(coach, function (a, b) return a[1] &lt; b[1] end)<br /> <br /> local i = 1<br /> if #player &gt; 0 then<br /> iargs[&#039;header&#039; .. i] = frame.args[&#039;pheader&#039;] or &#039;As player:&#039;<br /> i = i + 1<br /> for k,v in ipairs(player) do<br /> if v[2] ~= &#039;&#039; then iargs[&#039;label&#039; .. i] = v[2] end<br /> if v[3] ~= &#039;&#039; then iargs[&#039;data&#039; .. i] = v[3] end<br /> i = i + 1<br /> end<br /> end<br /> if #coach &gt; 0 then<br /> iargs[&#039;header&#039; .. i] = frame.args[&#039;cheader&#039;] or &#039;As coach:&#039;<br /> i = i + 1<br /> for k,v in ipairs(coach) do<br /> if v[2] ~= &#039;&#039; then iargs[&#039;label&#039; .. i] = v[2] end<br /> if v[3] ~= &#039;&#039; then iargs[&#039;data&#039; .. i] = v[3] end<br /> i = i + 1<br /> end<br /> end<br /> <br /> if i &gt; 1 then<br /> iargs[&#039;child&#039;] = &#039;yes&#039;<br /> iargs[&#039;labelstyle&#039;] = &#039;font-weight: normal;&#039; .. (frame.args[&#039;yearstyle&#039;] or &#039;&#039;)<br /> iargs[&#039;headerstyle&#039;] = &#039;line-height: 1.2em;text-align: left;&#039; .. (frame.args[&#039;headerstyle&#039;] or &#039;&#039;)<br /> iargs[&#039;datastyle&#039;] = &#039;line-height: 1.2em;text-align: left;&#039; .. (frame.args[&#039;teamstyle&#039;] or &#039;&#039;)<br /> if #player &gt; pmax then<br /> tracking = tracking .. (frame.args[&#039;pmaxcat&#039;] or &#039;&#039;)<br /> end<br /> if #coach &gt; cmax then<br /> tracking = tracking .. (frame.args[&#039;cmaxcat&#039;] or &#039;&#039;)<br /> end<br /> return (frame.args[&#039;title&#039;] or &#039;Career history&#039;) .. require(&#039;Module:Infobox&#039;).infobox(iargs) .. tracking<br /> end<br /> <br /> return tracking<br /> end<br /> <br /> return p</div> Lemondoge