Implements {{DartsOrakel}}
require('strict');
local p = {}
local error_msg = '<span style=\"font-size:100%\" class=\"error\"><code style=\"color:inherit; border:inherit; padding:inherit;\">|_template=</code> missing or empty</span>';
local tcats= ''
local tcatsp=''
local templateArgs = {} -- contains arguments from template involking module
local function getArgs(frame)
local parents = mw.getCurrentFrame():getParent()
for k,v in pairs(parents.args) do
--check content
if v and v ~= "" then
templateArgs[k]=v --parents.args[k]
end
end
for k,v in pairs(frame.args) do
--check content
if v and v ~= "" then
templateArgs[k]=v --parents.args[k]
end
end
-- allow empty caption to blank default
if parents.args['caption'] then templateArgs['caption'] = parents.args['caption'] end
end
local function loadData(frame)
local source = frame.args[1] -- source of rankings Players
local data = require('Module:DartsOrakel/data/Players');
end
local function noAc(str)
local tableAccents = {}
tableAccents["À"] = "A"
tableAccents["Á"] = "A"
tableAccents["Â"] = "A"
tableAccents["Ã"] = "A"
tableAccents["Ä"] = "A"
tableAccents["Å"] = "A"
tableAccents["Æ"] = "AE"
tableAccents["Ç"] = "C"
tableAccents["È"] = "E"
tableAccents["É"] = "E"
tableAccents["Ê"] = "E"
tableAccents["Ë"] = "E"
tableAccents["Ì"] = "I"
tableAccents["Í"] = "I"
tableAccents["Î"] = "I"
tableAccents["Ï"] = "I"
tableAccents["Ð"] = "D"
tableAccents["Ñ"] = "N"
tableAccents["Ò"] = "O"
tableAccents["Ó"] = "O"
tableAccents["Ô"] = "O"
tableAccents["Õ"] = "O"
tableAccents["Ö"] = "O"
tableAccents["Ø"] = "O"
tableAccents["Ù"] = "U"
tableAccents["Ú"] = "U"
tableAccents["Û"] = "U"
tableAccents["Ü"] = "U"
tableAccents["Ý"] = "Y"
tableAccents["Þ"] = "P"
tableAccents["ß"] = "s"
tableAccents["à"] = "a"
tableAccents["á"] = "a"
tableAccents["â"] = "a"
tableAccents["ã"] = "a"
tableAccents["ä"] = "a"
tableAccents["å"] = "a"
tableAccents["æ"] = "ae"
tableAccents["ç"] = "c"
tableAccents["č"] = "c"
tableAccents["ć"] = "c"
tableAccents["è"] = "e"
tableAccents["é"] = "e"
tableAccents["ê"] = "e"
tableAccents["ë"] = "e"
tableAccents["ì"] = "i"
tableAccents["í"] = "i"
tableAccents["î"] = "i"
tableAccents["ï"] = "i"
tableAccents["ł"] = "l"
tableAccents["ð"] = "eth"
tableAccents["ñ"] = "n"
tableAccents["ò"] = "o"
tableAccents["ó"] = "o"
tableAccents["ô"] = "o"
tableAccents["õ"] = "o"
tableAccents["ö"] = "o"
tableAccents["ø"] = "o"
tableAccents["ù"] = "u"
tableAccents["ú"] = "u"
tableAccents["û"] = "u"
tableAccents["ü"] = "u"
tableAccents["ý"] = "y"
tableAccents["þ"] = "p"
tableAccents["ÿ"] = "y"
local normalisedString = ''
local normalisedString = str: gsub("[%z\1-\127\194-\244][\128-\191]*", tableAccents)
return normalisedString
end
local function nameEqual(str1, str2)
return string.lower(noAc(str1)):gsub( "%W", "")==string.lower(noAc(str2)):gsub( "%W", "")
end
function p.main(frame)
getArgs(frame) -- returns args table having checked for content
loadData(frame)
local data = require('Module:DartsOrakel/data/Players');
local outputString = ""
local validCode = false
local player = templateArgs[2] -- player name passed as parameter
local rank, move
for _,u in pairs(data.library) do -- run through the list
if nameEqual(u[2], player) then -- if code = passed parameter
outputString = '[https://app.dartsorakel.com/player/details/'
.. u[1] .. ' ' .. u[2] .. ' player profile at Darts Orakel]'
end
end
return outputString
end
return p