Module:Sandbox/Valeriej/Wish

local p = {} --Takes in a list of role names and returns a string of image links function p.roles( frame ) --Set up variables local i = 0 local returnS = "" local linkBase = "User:Valeriej/WishingWellSandbox/Definitions" local imageSize = "30px" local imageLink = "" if frame.args[i+1] == nil then return returnS end repeat i = i + 1 if frame.args[i] == "builder" then imageLink = "Community_Noun_project_2280.svg" elseif frame.args[i] == "designer" then imageLink = "Vitruvian_Man_Noun_project_6674.svg" elseif frame.args[i] == "researcher" then imageLink = "Noun_project_8974.svg" else imageLink = "Question_Noun_project_2185.svg" end returnS = returnS .. " "       mw.log(returnS) until frame.args[i+1] == nil return returnS end

function p._roles(roleList) --Set up variables returnS = "" linkBase = "User:Valeriej/WishingWellSandbox/Definitions" imageSize = "30px" imageLink = "" for token in mw.ustring.gmatch( roleList, "%w+" ) do        if token == "builder" then imageLink = "Community_Noun_project_2280.svg" elseif token == "designer" then imageLink = "Vitruvian_Man_Noun_project_6674.svg" elseif token == "researcher" then imageLink = "Noun_project_8974.svg" else imageLink = "Question_Noun_project_2185.svg" end returnS = returnS .. " "       mw.log(returnS) end return returnS end

--Read in usernames and return a list of links to their user pages. function p.participants( frame ) --Set up variables i = 0 userLinks = "" if frame.args[i+1] ~= nil then repeat i = i + 1 userLinks = userLinks .. ""..frame.args[i].."" if frame.args[i+1] ~= nil then userLinks = userLinks .. ", "           end mw.log(userLinks) until frame.args[i+1] == nil end return userLinks end

--Read in usernames and return a list of links to their user pages. function p._participants( userList ) --Set up variables i = 0 userLinks = "" for token in mw.ustring.gmatch( userList, "%w+_*%.*%!*%?*%:*%w*%.*%!*" ) do        if(i ~= 0) then userLinks = userLinks..", " end userLinks = userLinks .. ""..token.."" i=i+1 mw.log(userLinks) end return userLinks end

function p.stat( frame ) i = 1 statusText = "" if    frame.args[i] == "Open" then              statusText = frame.args[i] elseif frame.args[i] == "In Progress" then      statusText = frame.args[i] elseif frame.args[i] == "Ready to Deploy" then  statusText = frame.args[i] elseif frame.args[i] == "Wish Granted" then     statusText = frame.args[i] elseif frame.args[i] == "Experiment" then       statusText = frame.args[i].."in Progress" elseif frame.args[i] == "Closed" then         statusText =  frame.args[i] else                                            statusText = "Invalid Status" end return statusText

end

function p.row( frame ) --Builds up a row in the Wishing Well table tablerow = "|" .. frame.args['wishName'].." ||"..p._participants(frame.args['genies']).." ||"..p._roles(frame.args['geniesNeeded']) tablerow = tablerow.."||"..frame.args['stat'].."||"..frame.args['createdOn'].."||"..frame.args['lastUpdated'].."\n|-" return tablerow

end

return p