Modul:Cycling race: Forskelle mellem versioner

Content deleted Content added
m opdatering
update
Linje 1:
local p = {}
flag_table = {}
 
function victories_translate(wiki,x)
l10nDef["fr"] = {"Date", "Course", "Pays", "Classe", "Vainqueur"}
l10nDef["en"] = {"Date", "Race", "Country", "Class", "Winner"}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["fr"] end -- default
return l10n[x]
end
 
function stageinfobox_translate(wiki,x)
Line 15 ⟶ 24:
"General classification after stage", "Leader", "Second", "Third",
"Secondary classifications after stage", "Points", "Mountain", "Sprints", "Young", "Combativity", "Combinated", "Metas volantes", "Regularity",
"ÉquipeTeam", "ÉquipeTeam auxby points",
"Image", "LégendeLegend", "CarteCard", "VueSectional en coupeview", "Documentation"}
l10nDef["da"] = {"Etapedetaljer", "Rute", "Type", "Dato", "Datoer", "Distance", "Land", "Lande", "Startby", "Målby", "Startende ryttere",
"Fuldførende ryttere", "Gennemsnitlig fart", "Omkostninger", "Etaperesultat", "Vinder", "Toer", "Treer", "Mest angrebsivrige",
Line 29 ⟶ 38:
"Lagkonkurranse", "Lagkonkurranse etter poeng",
"Bilde", "Bildetekst", "Kart", "Profil", "Dokumentasjon"}
l10nDef["pt"] = {"Detalhes da corrida", "Corrida", "Tipo", "Data", "Datas", "Distância", "País", "Países", "Origem da viagem", "Local de chegada", "Partida dos ciclistas",
"Chegada dos ciclistas", "Velocidade média", "Custo", "Resultados da etapa", "Vencedor", "Segundo", "Terceiro", "Combativo",
"Classificação geral após a etapa", "Líder", "Segundo", "Terceiro",
"Classificação secundária após a etapa", "Pontos", "Montanha", "Corridas de velocidade", "Jovem", "Combatividade", "Combinados", "Metas volantes", "Regularidade",
"Equipe", "Equipe por pontos",
"Imagem", "Legenda", "Ficha", "Vista secional", "Documentação"}
 
local l10n = l10nDef[wiki]
Line 77 ⟶ 92:
{'Q33881', 'points', '+1968', '+1968', 'Q26919974', 'Q175399'}, -- Jersey red.svg
{'Q33881', 'points', '+1969', '+2500', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'jeune', '+1975', '+2500', 'Q24645383', 'Q175399Q2254180'}, -- Jersey white.svg
{'Q33881', 'winner_fighting', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'winner_fighting2', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'equipe', '+2006', '+2500', 'Q27644112', 'Q1436680'}, -- Jersey yellow number.svg
Line 152 ⟶ 168:
local t_g = {show=true, name='', icon='', picture='', caption='', course= '', race={}, is_a='', startplace='', endplace='', time='',
length='', length_unit='', speed='', speed_unit='', nr_participants_start="", nr_participants_end='', country={},
series_ordinal_previous="", series_ordinal_next="", map='', sectional_view='',previous="", next=""}
local t_s = {order={'results', 'classement_gen', 'classement_annex'},
results={show=false, header=15, order = {'first','second','third','winner_fighting','winner_fighting2'},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
first={"", 16, "", '', "", "", '', '', '', ''},
second={"", 17, "", '', '', "", '', '', '', ''},
third={"", 18, "", '', '', "", '', '', '', ''},
winner_fighting={"", 19, "", '', '', '', '', '', ''}, ''},
winner_fighting2={"", 19, "", '', '', '', '', '', '', ''}},
 
classement_gen={show=false, header=20, order = {"leader", "deuxieme", "troisieme"},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
leader={"", 21, "", '', "", "", '', '', '', ''},
deuxieme={"", 22, "", '', '', "", '', '', '', ''},
troisieme={"", 23, "", '', '', "", '', '', '', ''}},
 
classement_annex={show=false, header=24, order={"points","montagne","sprints","jeune","super_combatif","combine",
"stage_volantes","regularite","equipe","equipe_points"},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
points={"", 25, "", '', "", '', "", '', '', ''},
montagne={"", 26, "", '', '', '', "", '', '', ''},
sprints={"", 27, "", '', '', '', "", '', '', ''},
jeune={"", 28, "", '', '', '', '', '', '', ''},
super_combatif={"", 29, "", '', "", "", '', '', '', ''},
combine={"", 30, "", '', '', "", '', '', '', ''},
stage_volantes={"",31,'','','','','','', '', ''},
regularite={"",32,'','','','','','', '', ''},
equipe={"", 33, "", '', '', "", '', '', '', ''},
equipe_points={"", 34, "", '', '', '', '', '', '', ''}}
}
 
Line 192 ⟶ 209:
a1, b1 = pcall(fooA, 'numeric-id', entity, 'P31', 1) -- If stage is a "stage" or a timetrial stage
if a1 == true and b1~='18131152' then t_g.is_a = 'Q'.. b1 end
 
if t_g.is_a=='Q2266066' or t_g.is_a=='Q2348250' or t_g.is_a=='Q485321' then t_g.icon = " [[File:Cycling (track) pictogram.svg|35px]]"
Line 296 ⟶ 313:
if wiki == "da" then t_g.speed_unit = 'km/t' end
if wiki == "nl" then t_g.speed_unit = 'km/u' end
if wiki == "no" then t_g.speed_unit = 'km/t' end
if wiki == "mk" then t_g.speed_unit = 'км/ч' end
if wiki == "ru" then t_g.speed_unit = 'км/ч' end
Line 312 ⟶ 330:
if a1 == true and t_g.map == "" then t_g.map = b1 end
a1, b1 = pcall(fooA, 'value', entity, 'P2713', 1) -- sectional view
if a1 == true and t_g.mapsectional_view == "" then t_g.mapsectional_view = b1 end
 
a1, b1 = pcall(fooA, 'numeric-id', entity, 'P155', 1)
Line 327 ⟶ 345:
end
 
local qual, id, id_team, id_time, id_time_gap, id_speed, id_points_a, id_points_b
local t_P642 = {[20882747]={'results', 'first'}, [20882748]={'results', 'second'}, [20882749]={'results', 'third'}, [21686770]={'results', 'winner_fighting'},
[20882763]={'classement_gen', 'leader'}, [20882764]={'classement_gen', 'deuxieme'}, [20882765]={'classement_gen', 'troisieme'},
Line 333 ⟶ 350:
[20883329]={'classement_annex', 'sprints'}, [20893984]={'classement_annex', 'super_combatif'}, [20965880]={'classement_annex', 'combine'},
[27104688]={'classement_annex', 'stage_volantes'}, [27104684]={'classement_annex', 'regularite'}, [20882922]={'classement_annex', 'equipe'},
[27104271]={'classement_annex', 'equipe_points'} ,
[20882667]={'classement_gen', 'leader'}, [20882668]={'classement_gen', 'deuxieme'}, [20882669]={'classement_gen', 'troisieme'},
[20883212]={'classement_annex', 'montagne'}, [20883139]={'classement_annex', 'jeune'}, [20883007]={'classement_annex', 'points'},
[20883328]={'classement_annex', 'sprints'}, [20893983]={'classement_annex', 'super_combatif'}, [20893979]={'classement_annex', 'combine'},
[27067359]={'classement_annex', 'stage_volantes'}, [27067170]={'classement_annex', 'regularite'}, [20882921]={'classement_annex', 'equipe'},
[27104269]={'classement_annex', 'equipe_points'}
}
 
ifa1, b1 = pcall(foo3fooA, 'numeric-id', entity, "P1346", 1, "P642", 1) then
if a1 == true then
local deprecated, qual, id, id_team, id_time, id_time_gap, id_speed, id_points_a, id_points_b
for k, v in pairs(entity.claims["P1346"]) do
id_team, id_speed, id_time, id_time_gap, id_points_a, id_points_b = '', '', '', '', '', ''
Line 342 ⟶ 366:
if a == true then id_team = 'Q'..b end
 
if pcall(function()
id=v.mainsnak.datavalue.value['numeric-id'] end) then else id=nil end -- id = rider id
deprecated = entity.claims["P1346"][k].rank
end) then
else id=nil end
if id ~= nil then
--timeofrace = "+2016-03-00T00:00:00Z"
-- function timeStartEnd finds the team of the rider at the time (timeofrace) of the race
if id_team == '' and timeofrace ~= nil and timeofrace ~= '' then
a, b = timeStartEnd('Q'..id, 'P54', 'numeric-id', timeofrace)
if a == true and b ~= nil then id_team = 'Q' .. b end
end
end
 
-- looks into race item if the winner has a P54 statement for beeng a member of a national team
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P54']) do
id_team = national_team(wiki, 'Q'..id, timeofrace, entity, 'P1346', k) -- timeofrace -> startOfSeason ?????
if id_team == nil then id_team = '' end
end
end)
 
pcall(function() -- for property 'race time'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2781']) do
id_time = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'time gap'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2911']) do
id_time_gap = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'speed'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2052']) do
id_speed = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'points for'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P1358']) do
id_points_a = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'number of points/goals/set scored'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P1351']) do
id_points_b = tonumber(v.datavalue.value.amount)
end
end)
 
-- looks into race item if the winner has a P642 statement for showing the type of winner (points, mountain, ..)
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P642']) do
qual=vv.datavalue.value['numeric-id']
 
if id~=nil and qual~=nil and v.rank~='deprecated' then
if qual==21686770 and t_s['results']['winner_fighting'][1] ~= '' then t_P642[qual][2] = 'winner_fighting2' end
pcall(function() -- inserts WD data into table t_s
pcall(function() -- inserts WD data into table t_s
t_s[t_P642[qual][1]][t_P642[qual][2]][1]='Q'..id
t_s[t_P642[qual][1]][t_P642[qual][2]][51]=id_team'Q'..id
if id_time~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][65]=id_time endid_team
if id_time_gap~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][710]=id_time_gap enddeprecated
if id_points_aid_time~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][86]=id_points_aid_time end
if id_points_bid_time_gap~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][87]=id_points_bid_time_gap end
if id_speedid_points_a~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][98]=id_speedid_points_a end
if id_points_b~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][8]=id_points_b end
end)
if id_speed~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][9]=id_speed end
if qual==27104271 and t_s.classement_annex.equipe_points[1]=='' then t_s.classement_annex.equipe_points[1]='Q'..id end
end)
if qual==20882922 and t_s.classement_annex.equipe[1]=='' then t_s.classement_annex.equipe[1]='Q'..id end
if qual==27104271 and t_s.classement_annex.equipe_points[1]=='' then t_s.classement_annex.equipe_points[1]='Q'..id end
if qual==20882922 and t_s.classement_annex.equipe[1]=='' then t_s.classement_annex.equipe[1]='Q'..id end
 
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject('Q'..id), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'm' -- men
elseif b1 == 6581072 then t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'f' -- female
end
else t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'f' -- female
end
end
else t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'f' -- female
end
end)
end
end)
end
end
local rank, deprecated
local order = {'first', 'second', 'third'}
local property = 'P2417'
a1, b1 = pcall(fooA, 'numeric-id', entity, property, 1)
if a1 == true then
for k, _ in pairs(entity.claims[property]) do -- look into P2417, stage classification
Line 429 ⟶ 459:
rank = tonumber(v.datavalue.value.amount)
deprecated = entity.claims[property][k].rank
if deprecated~= 'deprecated' then break else rank = 0 end
end
if rank == 1 or rank == 2 or rank == 3 then
if t_s.results[order[rank]][110] == '' then -- name or rider / teamdeprecated
if t_s.results[order[rank]][1] == 'Q' ..or entityt_s.claimsresults[property]order[krank]].mainsnak.datavalue.value[10] == 'numeric-idnormal'] end then -- name or rider / team
if t_s.results[order[rank]][71] == 'Q' and.. t_sentity.resultsclaims[orderproperty][rank]k].mainsnak.datavalue.value[6] == 'numeric-id' then ]
if t_s.results[order[rank]][7] == '' and t_s.results[order[rank]][6] == '' then
pcall(function()
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
t_s.results[order[rank]][7] = tonumber(v.datavalue.value.amount)
t_s.results[order[rank]][7] = tonumber(v.datavalue.value.amount)
end
end)
end)
if t_s.results[order[rank]][7] == '' and t_s.results[order[rank]][6] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
t_s.results[order[rank]][6] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.results[order[rank]][9] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2052']) do -- for property 'speed'
t_s.results[order[rank]][9] = tonumber(v.datavalue.value.amount)
end
end)
end
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(t_s.results[order[rank]][1]), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s.results[order[rank]][3] = 'm' -- men
elseif b1 == 6581072 then t_s.results[order[rank]][3] = 'f' -- female
end
else if t_s.results[order[rank]][37] == 'f' --and t_s.results[order[rank]][6] == '' femalethen
pcall(function()
end
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
t_s.results[order[rank]][6] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.results[order[rank]][9] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2052']) do -- for property 'speed'
t_s.results[order[rank]][9] = tonumber(v.datavalue.value.amount)
end
end)
end
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(t_s.results[order[rank]][1]), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s.results[order[rank]][3] = 'm' -- men
elseif b1 == 6581072 then t_s.results[order[rank]][3] = 'f' -- female
end
else t_s.results[order[rank]][3] = 'f' -- female
end
end
end
end
end
order = {'leader', 'deuxieme', 'troisieme'}
property = 'P2321'
a1, b1 = pcall(fooA, 'numeric-id', entity, property, 1)
if a1 == true then
for k, _ in pairs(entity.claims[property]) do -- look into P2321, stage classification
for _, v in pairs(entity.claims[property][k].qualifiers['P1352']) do -- for property 'rank'
rank = tonumber(v.datavalue.value.amount)
deprecated = entity.claims[property][k].rank
if deprecated~= 'deprecated' then break else rank = 0 end
end
if rank == 1 or rank == 2 or rank == 3 then
if t_s.classement_gen[order[rank]][110] == '' then -- name or rider / teamdeprecated
if t_s.classement_gen[order[rank]][1] == 'Q' ..or entityt_s.claimsclassement_gen[property]order[krank]].mainsnak.datavalue.value[10] == 'numeric-idnormal'] end then -- name or rider / team
if t_s.classement_gen[order[rank]][71] == 'Q' and.. t_sentity.classement_genclaims[orderproperty][rank]k].mainsnak.datavalue.value[6] == 'numeric-id' then ]
if t_s.classement_gen[order[rank]][7] == '' and t_s.classement_gen[order[rank]][6] == '' then
pcall(function()
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
t_s.classement_gen[order[rank]][7] = tonumber(v.datavalue.value.amount)
t_s.classement_gen[order[rank]][7] = tonumber(v.datavalue.value.amount)
end
end)
end)
if t_s.classement_gen[order[rank]][7] == '' and t_s.classement_gen[order[rank]][6] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
t_s.classement_gen[order[rank]][6] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.classement_gen[order[rank]][9] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2052']) do -- for property 'speed'
t_s.classement_gen[order[rank]][9] = tonumber(v.datavalue.value.amount)
end
end)
end
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(t_s.classement_gen[order[rank]][1]), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s.classement_gen[order[rank]][3] = 'm' -- men
elseif b1 == 6581072 then t_s.classement_gen[order[rank]][3] = 'f' -- female
end
else if t_s.classement_gen[order[rank]][37] == 'f' --and t_s.classement_gen[order[rank]][6] == '' femalethen
pcall(function()
end
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
t_s.classement_gen[order[rank]][6] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.classement_gen[order[rank]][9] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2052']) do -- for property 'speed'
t_s.classement_gen[order[rank]][9] = tonumber(v.datavalue.value.amount)
end
end)
end
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(t_s.classement_gen[order[rank]][1]), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s.classement_gen[order[rank]][3] = 'm' -- men
elseif b1 == 6581072 then t_s.classement_gen[order[rank]][3] = 'f' -- female
end
else t_s.classement_gen[order[rank]][3] = 'f' -- female
end
end
end
end
Line 653 ⟶ 685:
if value_order~='classement_annex' then
if t_s[value_order][value][4] == "" then
if (value_order == 'results') and (value == 'winner_fighting' or value=='winner_fighting2') then
tab=tab..stageinfobox_translate(wiki,t_s[value_order][value][2])
else tab=tab..number(t_s[value_order][value][3], key, wiki) end
else
Line 667 ⟶ 700:
else tab=tab.."[[File:"..t_s[value_order][value][4].."|20px|link="..jerseyWPID.."]]" .. title end end
end
if t_s[value_order][value][10] == 'deprecated' then
tab=tab.."</span>".. "'''</td><td style='padding:0 0.5em 0 0.5em'>".. '<s>' .. transform(t_s[value_order][value][1],'f', timeofrace) .. '</s>'
else tab=tab.."</span>".. "'''</td><td style='padding:0 0.5em 0 0.5em'>".. transform(t_s[value_order][value][1],'f', timeofrace) end
tab=tab.."</td><td nowrap style='text-align:right;font-size:85%;'>"
if t_s[value_order][value][6]~='' then tab=tab.. calculate_time(wiki,t_s[value_order][value][6]) end
Line 692 ⟶ 727:
 
if t_g.map ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. t_g.map .."|center|300px]]".."</td></tr>" end
if t_g.sectional_view ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. t_g.sectional_view .."|center|300px]]".."</td></tr>" end
tab = tab.."<tr><td>"..t_g.previous.."</td><td style='text-align:right'>" .. t_g.next .. "</td></tr>"
local s = "d:Wikidata:WikiProject Cycling/Documentation/stageinfobox"
Line 1.016 ⟶ 1.052:
l10nDef["mk"] = {"", "ч ", "' ", "", ' км/ч', " pt", " pts"}
l10nDef["nl"] = {"", "u", "'", '"', ' km/u', " pt", " pts"}
l10nDef["no"] = {"", "t ", "' ", '"', ' km/ht', " pt", " pts"}
l10nDef["pt"] = {"", "h", "m", "s", ' km/h', " pt", " pts"}
l10nDef["ru"] = {"", "ч ", "' ", "", ' км/ч', " очко", " очко"}
Line 1.155 ⟶ 1.191:
if wiki == 'da' then unit = ' km/t' end
if wiki == 'nl' then unit = ' km/u' end
if wiki == 'no' then unit = ' km/t' end
if wiki == 'mk' or wiki == 'ru' then unit = ' км/ч' end
local i = 1
Line 1.791 ⟶ 1.828:
if wiki == "da" then t.speed_unit = 'km/t' end
if wiki == "nl" then t.speed_unit = 'km/u' end
if wiki == "no" then t.speed_unit = 'km/t' end
if wiki == "mk" then t.speed_unit = 'км/ч' end
if wiki == "ru" then t.speed_unit = 'км/ч' end