Moderator, Bürokraten, Checkuser-Berechtigte, developer, emailconfirmed, Oberflächenadministratoren, Oversighter, Administratoren
11.008
Bearbeitungen
Keine Bearbeitungszusammenfassung |
(renderConnectivity) |
||
(6 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 21: | Zeile 21: | ||
function getValueWithUnit(prop) | function getValueWithUnit(prop) | ||
local result = '' | local result = '' | ||
local propValue = prop.mainsnak and prop.mainsnak.datavalue | local propValue = prop.mainsnak and prop.mainsnak.datavalue or prop.datavalue | ||
if propValue and propValue.value and propValue.value.amount then | if propValue and propValue.value and propValue.value.amount then | ||
result = result .. lang:formatNum(tonumber(propValue.value.amount)) | result = result .. lang:formatNum(tonumber(propValue.value.amount)) | ||
Zeile 45: | Zeile 45: | ||
function getScreenSize(property) | function getScreenSize(property) | ||
local result = | local result = nil | ||
local needToClose = false | local needToClose = false | ||
if property then | if property then | ||
result = "" | |||
for key, prop in pairs(property) do | for key, prop in pairs(property) do | ||
if key == 1 then | if key == 1 then | ||
Zeile 66: | Zeile 67: | ||
function getScreenResolution(property) | function getScreenResolution(property) | ||
local result = | local result = nil | ||
if property then | if property then | ||
if property[2] then | if property[2] then | ||
Zeile 78: | Zeile 79: | ||
function getScreenPpi(property) | function getScreenPpi(property) | ||
return getValueWithUnit(property[1]) | if property and property[1] then | ||
return getValueWithUnit(property[1]) | |||
else | |||
return nil | |||
end | |||
end | end | ||
Zeile 102: | Zeile 107: | ||
end | end | ||
result = result .. screenPpi | result = result .. screenPpi | ||
end | |||
return result | |||
end | |||
function dump(o) | |||
if type(o) == 'table' then | |||
local s = '{ ' | |||
for k,v in pairs(o) do | |||
if type(k) ~= 'number' then k = '"'..k..'"' end | |||
s = s .. '['..k..'] = ' .. dump(v) .. ',' | |||
end | |||
return s .. '} ' | |||
else | |||
return tostring(o) | |||
end | |||
end | |||
function getValueLabel(propValue) | |||
if propValue['type'] == 'wikibase-entityid' then | |||
local linkTarget = mw.wikibase.sitelink( "Q" .. propValue.value['numeric-id'] ) | |||
local linkTitle = mw.wikibase.label( "Q" ..propValue.value['numeric-id'] ) | |||
return linkTarget and linkTitle and mw.ustring.format( "[[%s|%s]]", linkTarget, linkTitle ) | |||
or linkTitle | |||
elseif propValue and propValue['type'] == 'string' then | |||
return propValue.value | |||
else | |||
return "" | |||
end | |||
end | |||
function renderSensors() | |||
return renderList('P57') | |||
end | |||
function renderConnectivity() | |||
return renderList('P74') | |||
end | |||
function renderList(claimIdentifier) | |||
local entity = mw.wikibase.getEntityObject() | |||
result = '' | |||
if not entity or not entity.claims then return end --the entity doesnt exist or have no claims | |||
local property = entity.claims[claimIdentifier] | |||
if property then | |||
for key, prop in pairs(property) do | |||
if prop and prop.mainsnak and prop.mainsnak.datavalue then | |||
result = result .. "\n* " .. getValueLabel(prop.mainsnak.datavalue) | |||
end | |||
end | |||
end | |||
return result | |||
end | |||
function renderAmazon(frame) | |||
local entity = mw.wikibase.getEntityObject() | |||
result = '' | |||
if not entity or not entity.claims then return end --the entity doesnt exist or have no claims | |||
local property = entity.claims['P8'] | |||
if property and property[1] and property[1].mainsnak and property[1].mainsnak.datavalue then | |||
result = frame:expandTemplate{ title = 'Amazon', args = { getValueLabel(property[1].mainsnak.datavalue), entity:getLabel() .. " bei Amazon" } } | |||
end | |||
return result | |||
end | |||
function renderCPU() | |||
local entity = mw.wikibase.getEntityObject() | |||
result = '' | |||
if not entity or not entity.claims then return end --the entity doesnt exist or have no claims | |||
local property = entity.claims['P28'] | |||
if property then | |||
local linkRenderer = require( "Modul:PropertyLink" ) | |||
result = result .. linkRenderer.property({ args = { "P28" } }) | |||
if property and property[1] and property[1].mainsnak and property[1].mainsnak.datavalue and property[1].mainsnak.datavalue.value and property[1].mainsnak.datavalue.value["numeric-id"] then | |||
local processorObjectId = "Q" .. property[1].mainsnak.datavalue.value["numeric-id"] | |||
local processorObject = mw.wikibase.getEntityObject(processorObjectId) | |||
if not processorObject or not processorObject.claims then | |||
return result | |||
end | |||
local p2 = processorObject.claims["P2"] | |||
if p2 and p2[1] and p2[1].mainsnak and p2[1].mainsnak.datavalue then | |||
local label = getValueLabel(p2[1].mainsnak.datavalue) | |||
result = label .. " " .. result | |||
end | |||
if property[1].qualifiers['P30'] then | |||
p30 = property[1].qualifiers['P30'][1] | |||
result = result .. ", " .. getValueWithUnit(p30) | |||
end | |||
local p31 = processorObject.claims["P31"] | |||
for key, prop in pairs(p31) do | |||
if prop and prop.mainsnak and prop.mainsnak.datavalue then | |||
local propValue = prop.mainsnak.datavalue | |||
result = result .. ", " .. getValue(prop) .. "-Kern"; | |||
if prop.qualifiers and prop.qualifiers["P32"] and prop.qualifiers["P32"][1] and prop.qualifiers["P32"][1].datavalue then | |||
result = result .. " " .. getValueLabel(prop.qualifiers["P32"][1].datavalue) .. " CPU" | |||
else | |||
result = result .. " unbekannte CPU" | |||
end | |||
end | |||
end | |||
end | |||
end | end | ||
return result | return result | ||
Zeile 107: | Zeile 212: | ||
return { | return { | ||
renderAnzeige = renderAnzeige | renderAnzeige = renderAnzeige, | ||
renderCPU = renderCPU, | |||
renderSensors = renderSensors, | |||
renderConnectivity = renderConnectivity, | |||
renderAmazon = renderAmazon, | |||
} | } |
Bearbeitungen