From WikiChip
Difference between revisions of "Module:chip"
(clock mult) |
|||
Line 40: | Line 40: | ||
:attr('colspan', '2') | :attr('colspan', '2') | ||
:wikitext('[[name::' .. frame.args.title .. ']]') | :wikitext('[[name::' .. frame.args.title .. ']]') | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 76: | Line 70: | ||
-- designer | -- designer | ||
if frame.args.designer then | if frame.args.designer then | ||
− | local designers = mw.html.create('td'):wikitext(frame.args.designer) | + | local designers = mw.html.create('td'):wikitext('[[designer::' .. frame.args.designer .. ']]') |
for i = 2, 10 do | for i = 2, 10 do | ||
if not frame.args['designer_' .. i] then break end | if not frame.args['designer_' .. i] then break end | ||
Line 86: | Line 80: | ||
-- manufacturer | -- manufacturer | ||
if frame.args.manufacturer then | if frame.args.manufacturer then | ||
− | local manufacturers = mw.html.create('td'):wikitext(frame.args.manufacturer) | + | local manufacturers = mw.html.create('td'):wikitext('[[manufacturer::' .. frame.args.manufacturer .. ']]') |
for i = 2, 10 do | for i = 2, 10 do | ||
if not frame.args['manufacturer_' .. i] then break end | if not frame.args['manufacturer_' .. i] then break end | ||
Line 101: | Line 95: | ||
-- part number | -- part number | ||
if frame.args.part_number then | if frame.args.part_number then | ||
− | local parts = mw.html.create('td'):wikitext(frame.args.part_number) | + | local parts = mw.html.create('td'):wikitext('[[part number::' .. frame.args.part_number .. ']]') |
for i = 1, 10 do | for i = 1, 10 do | ||
if not frame.args['part_number_' .. i] then break end | if not frame.args['part_number_' .. i] then break end | ||
Line 107: | Line 101: | ||
end | end | ||
infobox:node(p.add_entry('Part Number', parts)) | infobox:node(p.add_entry('Part Number', parts)) | ||
+ | end | ||
+ | |||
+ | -- s-spec | ||
+ | if frame.args.s_spec or frame.args.s_spec_qs then | ||
+ | local parts = mw.html.create('td') | ||
+ | if frame.args.s_spec then | ||
+ | parts:wikitext('[[s-spec::' .. frame.args.s_spec .. ']]') | ||
+ | for i = 2, 30 do | ||
+ | if not frame.args['s_spec_' .. i] then break end | ||
+ | parts:wikitext(',<br>[[s-spec::' .. frame.args['s_spec_' .. i] .. ']]') | ||
+ | end | ||
+ | end | ||
+ | if frame.args.s_spec_qs then | ||
+ | parts:wikitext('[[s-spec (qs)::' .. frame.args.s_spec_qs .. ']]') | ||
+ | for i = 2, 30 do | ||
+ | if not frame.args['s_spec_qs' .. i] then break end | ||
+ | parts:wikitext(',<br>[[s-spec (qs)::' .. frame.args['s_spec_qs' .. i] .. ']]') | ||
+ | end | ||
+ | end | ||
+ | infobox:node(p.add_entry('S-Spec', parts)) | ||
end | end | ||
-- market segment | -- market segment | ||
if frame.args.market then | if frame.args.market then | ||
− | local markets = mw.html.create('td'):wikitext(frame.args.market) | + | local markets = mw.html.create('td'):wikitext('[[market segment::' .. frame.args.market .. ']]') |
for i = 2, 5 do | for i = 2, 5 do | ||
if not frame.args['market_' .. i] then break end | if not frame.args['market_' .. i] then break end | ||
Line 175: | Line 189: | ||
-- frequency | -- frequency | ||
if frame.args.frequency then | if frame.args.frequency then | ||
− | local frequencies = mw.html.create('td'):wikitext(frame.args.frequency) | + | local frequencies = mw.html.create('td'):wikitext('[[base frequency::' .. frame.args.frequency .. ']]') |
for i = 2, 10 do | for i = 2, 10 do | ||
if not frame.args['frequency_' .. i] then break end | if not frame.args['frequency_' .. i] then break end |
Revision as of 23:46, 3 January 2017
To add this template, simple add
{{chip}}to the page and save. The chip infobox will have a small
[Edit Values]
button at the top-right corner which can be used to add values using a form.
local p = {}
function p.add_file_prefix(str)
if string.match(string.lower(str), '^file:') then
return str
else
return 'File:' .. str
end
end
function p.add_separator(title)
return mw.html.create('tr')
:tag('td')
:attr('class', 'chip-infobox-sep')
:attr('colspan', '2')
:wikitext(title)
end
function p.add_entry(value, right)
local e = mw.html.create('tr')
e:tag('th')
:attr('class', 'chip-infobox-entry')
:wikitext(value)
e:node(right)
return e
end
function p.chip(frame)
local infobox = mw.html.create('table')
infobox
:attr('class', 'chip-infobox')
-- header
if frame.args.title then
infobox
:tag('tr')
:tag('td')
:attr('class', 'chip-infobox-header')
:attr('colspan', '2')
:wikitext('[[name::' .. frame.args.title .. ']]')
end
-- image
if frame.args.image or frame.args.no_image ~= 'true' then
local image = frame.args.image and p.add_file_prefix(frame.args.image) or "File:no photo (ic).svg"
local image_size = frame.args.image_size or "200px"
infobox
:tag('tr')
:tag('td')
:attr('class', 'chip-infobox-pic')
:attr('colspan', '2')
:wikitext('[[image::' .. image .. '| ]][[' .. image .. '|' .. image_size .. ']]')
-- add a caption, if provided
if frame.args.caption then
infobox
:tag('tr')
:tag('td')
:attr('class', 'chip-infobox-pic-caption')
:attr('colspan', '2')
:wikitext('[[image capation::' .. frame.args.caption .. ']]')
end
end
-- ####################################################################
-- some general info first
infobox:node(p.add_separator('General Info'))
-- designer
if frame.args.designer then
local designers = mw.html.create('td'):wikitext('[[designer::' .. frame.args.designer .. ']]')
for i = 2, 10 do
if not frame.args['designer_' .. i] then break end
designers:wikitext(', [[designer::' .. frame.args['designer_' .. i] .. ']][[category:microprocessor models by ' .. mw.ustring.lower(frame.args['designer_' .. i]) .. ']]')
end
infobox:node(p.add_entry('Designer', designers))
end
-- manufacturer
if frame.args.manufacturer then
local manufacturers = mw.html.create('td'):wikitext('[[manufacturer::' .. frame.args.manufacturer .. ']]')
for i = 2, 10 do
if not frame.args['manufacturer_' .. i] then break end
manufacturers:wikitext(', [[manufacturer::' .. frame.args['manufacturer_' .. i] .. ']][[category:microprocessor models by ' .. mw.ustring.lower(frame.args['manufacturer_' .. i]) .. ']]')
end
infobox:node(p.add_entry('Manufacturer', manufacturers))
end
-- model number
if frame.args.model_number then
infobox:node(p.add_entry('Model Number', mw.html.create('td'):wikitext('[[model number::' .. frame.args.model_number .. ']]')))
end
-- part number
if frame.args.part_number then
local parts = mw.html.create('td'):wikitext('[[part number::' .. frame.args.part_number .. ']]')
for i = 1, 10 do
if not frame.args['part_number_' .. i] then break end
parts:wikitext(', [[part number::' .. frame.args['part_number_' .. i] .. ']]')
end
infobox:node(p.add_entry('Part Number', parts))
end
-- s-spec
if frame.args.s_spec or frame.args.s_spec_qs then
local parts = mw.html.create('td')
if frame.args.s_spec then
parts:wikitext('[[s-spec::' .. frame.args.s_spec .. ']]')
for i = 2, 30 do
if not frame.args['s_spec_' .. i] then break end
parts:wikitext(',<br>[[s-spec::' .. frame.args['s_spec_' .. i] .. ']]')
end
end
if frame.args.s_spec_qs then
parts:wikitext('[[s-spec (qs)::' .. frame.args.s_spec_qs .. ']]')
for i = 2, 30 do
if not frame.args['s_spec_qs' .. i] then break end
parts:wikitext(',<br>[[s-spec (qs)::' .. frame.args['s_spec_qs' .. i] .. ']]')
end
end
infobox:node(p.add_entry('S-Spec', parts))
end
-- market segment
if frame.args.market then
local markets = mw.html.create('td'):wikitext('[[market segment::' .. frame.args.market .. ']]')
for i = 2, 5 do
if not frame.args['market_' .. i] then break end
markets:wikitext(', [[market segment::' .. frame.args['market_' .. i] .. ']]')
end
infobox:node(p.add_entry('Market', markets))
end
-- release date
if frame.args.first_launched or frame.args.first_announced then
local release = mw.html.create('td')
if frame.args.first_announced then
release:wikitext('[[first launched::' .. frame.args.first_announced .. ']] (announced)')
end
if frame.args.first_launched then
if frame.args.first_announced then
release:wikitext('<br>')
end
release:wikitext('[[first launched::' .. frame.args.first_launched .. ']] (launch)')
end
infobox:node(p.add_entry('Release', release))
end
-- EOL
if frame.args.last_order or frame.args.last_shipment then
local release = mw.html.create('td')
if frame.args.last_order then
release:wikitext('[[last order::' .. frame.args.last_order .. ']] (last order)')
end
if frame.args.last_shipment then
if frame.args.last_order then
release:wikitext('<br>')
end
release:wikitext('[[last shipment::' .. frame.args.last_shipment .. ']] (last order)')
end
infobox:node(p.add_entry('End-of-life', release))
end
-- release price
if frame.args.release_price then
infobox:node(p.add_entry('Release Price', mw.html.create('td'):wikitext('[[release price::' .. frame.args.release_price .. ']]')))
end
-- ####################################################################
-- some general specs
infobox:node(p.add_separator('General Specs'))
-- family
if frame.args.family then
infobox:node(p.add_entry('Family', mw.html.create('td'):wikitext('[[microprocessor family::' .. frame.args.family .. ']]')))
end
-- series
if frame.args.series then
infobox:node(p.add_entry('Series', mw.html.create('td'):wikitext('[[microprocessor series::' .. frame.args.series .. ']]')))
end
-- locked?
if frame.args.locked then
infobox:node(p.add_entry('Locked', mw.html.create('td'):wikitext('[[has unlocked clock multiplier::' .. frame.args.locked .. ']]')))
end
-- frequency
if frame.args.frequency then
local frequencies = mw.html.create('td'):wikitext('[[base frequency::' .. frame.args.frequency .. ']]')
for i = 2, 10 do
if not frame.args['frequency_' .. i] then break end
frequencies:wikitext(', [[base frequency::' .. frame.args['frequency_' .. i] .. ']]')
end
infobox:node(p.add_entry('Frequency', frequencies))
end
-- turbo frequency
if frame.args.turbo_frequency then
local turbo = mw.html.create('td')
for i = 1, 30 do
--sometimes turbo is not specified for odd-cores, so skip 2 each time, so we can't break
--if not frame.args['turbo_frequency' .. i] then break end
if frame.args['turbo_frequency' .. i] then
local s = i > 1 and 's' or ''
local br = i > 1 and ',<br>' or ''
turbo:wikitext(br .. ' [[turbo frequency (' .. i .. ' core' .. s .. ')::' .. frame.args['turbo_frequency' .. i] .. '| ]]' ..
frame.args['turbo_frequency' .. i] .. ' (' .. i .. ' core' .. s .. ')')
end
end
infobox:node(p.add_entry('Turbo Frequency', turbo))
end
-- bus type
if frame.args.bus_type then
infobox:node(p.add_entry('Bus type', mw.html.create('td'):wikitext('[[bus type::' .. frame.args.bus_type .. ']]')))
end
-- bus speed
if frame.args.bus_speed then
infobox:node(p.add_entry('Bus speed', mw.html.create('td'):wikitext('[[bus speed::' .. frame.args.bus_speed .. ']]')))
end
-- bus rate
if frame.args.bus_rate then
local links = ''
if frame.args.bus_links then
links = '[[bus links::' .. frame.args.bus_links .. ']] × '
end
infobox:node(p.add_entry('Bus rate', mw.html.create('td'):wikitext(links .. '[[bus rate::' .. frame.args.bus_rate .. ']]')))
end
-- clock mult
if frame.args.clock_multiplier then
infobox:node(p.add_entry('Clock multiplier', mw.html.create('td'):wikitext('[[clock multiplier::' .. frame.args.clock_multiplier .. ']]')))
end
return infobox
end
return p