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/BrownHairedGirl/xyz
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!
local p = {} function make_cat_link(catname, disp) local displaytext if (disp ~= "") then displaytext = disp else displaytext = catname end local link = "[[:Category:" .. catname .. "|" .. displaytext .. "]]" local fmtlink local linktitle = mw.title.new( catname, "Category" ) if (linktitle.exists) then fmtlink = link else fmtlink = "<span style=\"color:#888\">" .. displaytext .. "</span>" end return fmtlink end function make_cat_link4(catname, disp) local link = "{{LinkCatIfExists2|" .. catname if (disp ~= "") then link = link .. "|" .. disp end link = link .. "}}" return link end function make_decade_cat_link(prefix, start, rest, decadenum) local decadestart = (prefix * 100) + (decadenum * 10) local decadename = decadestart .. "s" return make_cat_link(start .. decadename .. rest, decadename) end function ordinal_numbers(n) local ordinal, digit = {"st", "nd", "rd"}, string.sub(n, -1) if tonumber(digit) > 0 and tonumber(digit) <= 3 and mw.ustring.sub(n,-2) ~= 11 and mw.ustring.sub(n,-2) ~= 12 and mw.ustring.sub(n,-2) ~= 13 then return n .. ordinal[tonumber(digit)] else return n .. "th" end end function make_century_name(n) local centuryordinal = ordinal_numbers(n) return centuryordinal .. " century" end function p.main(frame) local pagename local nilly if (frame.args[1] ~= "") then -- a parameter was supplied, so use it as page title nilly = "no nil. value='" .. frame.args[1] .. "'" if (string.match(frame.args[1], "^Category *: *")) then pagename = mw.ustring.gsub(frame.args[1], "^Category *: *", ""); else pagename = frame.args[1] end else -- use the page title nilly = "nil" pagename = mw.title.getCurrentTitle().text end if (false) then return nilly end local dddo = mw.ustring.match(pagename, "%d%d*0s") if (dddo == nil) then return "Error: no 'YYOs' in '" .. pagename .. "'" end local dd = mw.ustring.match(dddo, "^%d*") local yy = (dd - (dd % 100))/ 100 local startoftitle = mw.ustring.gsub(pagename, dddo .. ".*$", "") local restoftitle = mw.ustring.gsub(pagename, "^.*" .. dddo, "") local diagnotics = "; pagename\n* " .. pagename .. "\n;dddo\n*" .. dddo .. "\n;dd\n*" .. dd diagnotics = diagnotics .. "\n;yy\n*" .. yy .. "\n;startoftitle\n*<code>'" .. startoftitle .. "'</code>" diagnotics = diagnotics .. "\n;restoftitle\n*<code>'" .. restoftitle .. "'</code>" local retval retval = "{| class=\"toccolours\" style=\"border:1px solid black; padding:5px\"\n|-\n|style=\"text-align:center\"| '''" .. startoftitle if (startoftitle == "") then retval = retval .. "Decades " else retval = retval .. " decades " end retval = retval .. " of the " .. make_century_name(yy+1) .. restoftitle .. "'''\n|-\n| " retval = retval .. "<small>''" .. make_decade_cat_link(yy, startoftitle, restoftitle, -1) .. " • " .. "''</small>" local i; for i = 0, 9 do retval = retval .. make_decade_cat_link(yy, startoftitle, restoftitle, i) if i < 9 then retval = retval .. " • " end end retval = retval .. "<small>''" .. " • " .. make_decade_cat_link(yy, startoftitle, restoftitle, 10) .. "''</small>" retval = retval .. "\n|}" return retval 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/BrownHairedGirl/xyz/doc
(
edit
)