Module:TreeChart: रिवीजन सभ के बीचा में अंतर
Appearance
Content deleted Content added
imported>The Mol Man o |
छो ७५ revisions imported from en:Module:TreeChart |
||
(3 प्रयोगकर्ता लोग के कइल 23 बीच के रिवीजन नइखे देखावल जात) | |||
लाइन 1: | लाइन 1: | ||
require('Module:No globals') |
|||
local p = {} |
local p = {} |
||
local cells = mw.loadData('Module: |
local cells = mw.loadData('Module:TreeChart/data') |
||
function p. |
function p._main(cell_args) |
||
local |
local ret = mw.html.create() |
||
local |
local top = ret:tag('tr') |
||
⚫ | |||
⚫ | |||
⚫ | |||
local w = mw.text.trim(v) |
|||
⚫ | |||
if not w:find('%S') then |
|||
:css{ height = '1px', |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
if |
if type(v) == 'string' then |
||
⚫ | |||
cell_x.box = nil |
|||
bottom:wikitext(cells[v].b) |
|||
cell_x.name = w |
|||
else |
else |
||
⚫ | |||
cell_x.name = mw.text.trim(v) |
|||
:attr{ colspan = v.colspan or cell_args.colspan or 6, |
|||
⚫ | |||
rowspan = v.rowspan or cell_args.rowspan or 2 } |
|||
cell_x.box = true |
|||
⚫ | |||
cell_x.colspan = args['colspan_'..w] or args['colspan_ '..w] or args.colspan or '6' |
|||
⚫ | |||
cell_x.rowspan = args['rowspan_'..w] or args['rowspan_ '..w] or args.rowspan or '2' |
|||
:cssText(v.boxstyle or cell_args.boxstyle) |
|||
cell_x.thick = args['border_'..w] or args['border_ '..w] or args.border or '2' |
|||
:wikitext(v.text) |
|||
cell_x.css = args['boxstyle_'..w] or args['boxstyle_ '..w] or args.boxstyle or '' |
|||
end |
end |
||
⚫ | |||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
function p. |
function p.main(frame) |
||
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Chart', trim = false, removeBlanks = false}) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local ret2 = mw.html.create('tr') |
|||
border = args.border, |
|||
:css({ ['height'] = '1px', |
|||
boxstyle = args.boxstyle |
|||
⚫ | |||
} |
|||
⚫ | |||
⚫ | |||
if v.box then |
|||
local trimmedVal = val:match('^%s*(.-)%s*$') |
|||
ret:node(make_box(ret,v)) |
|||
if trimmedVal == '' then |
|||
trimmedVal = '$' |
|||
⚫ | |||
if cells[trimmedVal] then |
|||
table.insert(cell_args, trimmedVal) |
|||
else |
else |
||
-- Unnamed params behave weirdly |
|||
ret:node(make_cell(ret,v.name,'t')) |
|||
-- white space at the front counts for param_{{{1}}}, but not whitespace at the end, so remove it |
|||
ret2:node(make_cell(ret2,v.name,'b')) |
|||
local rightTrimmedVal = val:gsub('%s+$','') |
|||
⚫ | |||
⚫ | |||
colspan = args['colspan_'..rightTrimmedVal], |
|||
rowspan = args['rowspan_'..rightTrimmedVal], |
|||
border = args['border_'..rightTrimmedVal], |
|||
boxstyle = args['boxstyle_'..rightTrimmedVal] |
|||
}) |
|||
end |
end |
||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
function make_cell(builder,name,key) |
|||
local props = cells[name][key] |
|||
if not props then |
|||
return |
|||
end |
|||
for i, v in ipairs(props) do |
|||
builder:tag(v.tag,{selfClosing=true}) |
|||
:css(v.style or {}) |
|||
:attr(v.attr or {}) |
|||
end |
|||
end |
|||
function make_box(builder,tbl) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:cssText(tbl.css) |
|||
⚫ | |||
:done() |
|||
end |
end |
||
21:58, 23 मई 2016 ले भइल नया बदलाव
You might want to बनाईं a documentation page for this Scribunto module. संपादक लोग एह मॉड्यूल के अभ्यासपन्ना (सैंडबाक्स) (बनाईं | मिरर करीं) आ टेस्टकेस (बनाईं) पन्ना पर अभ्यास भा प्रयोग (टेस्टिंग) क सकत बाटे। अनुरोध बा कि अगर श्रेणी जोड़े के होखे तब /doc उपपन्ना (सबपेज) पर जोड़ल जाय। एह मॉड्यूल के उपपन्ना (सबपेज) देखीं। |
require('Module:No globals')
local p = {}
local cells = mw.loadData('Module:TreeChart/data')
function p._main(cell_args)
local ret = mw.html.create()
local top = ret:tag('tr')
:css{ height = '1px',
['text-align'] = 'center' }
local bottom = ret:tag('tr')
:css{ height = '1px',
['text-align'] = 'center' }
for _, v in ipairs(cell_args) do
if type(v) == 'string' then
top:wikitext(cells[v].t)
bottom:wikitext(cells[v].b)
else
top:tag('td')
:attr{ colspan = v.colspan or cell_args.colspan or 6,
rowspan = v.rowspan or cell_args.rowspan or 2 }
:css{ padding = '0.2em',
border = (v.border or cell_args.border or '2') .. 'px solid black' }
:cssText(v.boxstyle or cell_args.boxstyle)
:wikitext(v.text)
end
end
return tostring(ret)
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Chart', trim = false, removeBlanks = false})
local cell_args = {
colspan = args.colspan,
rowspan = args.rowspan,
border = args.border,
boxstyle = args.boxstyle
}
for _, val in ipairs(args) do
local trimmedVal = val:match('^%s*(.-)%s*$')
if trimmedVal == '' then
trimmedVal = '$'
end
if cells[trimmedVal] then
table.insert(cell_args, trimmedVal)
else
-- Unnamed params behave weirdly
-- white space at the front counts for param_{{{1}}}, but not whitespace at the end, so remove it
local rightTrimmedVal = val:gsub('%s+$','')
table.insert(cell_args, {
text = args[trimmedVal] or ('{{{'..trimmedVal..'}}}'),
colspan = args['colspan_'..rightTrimmedVal],
rowspan = args['rowspan_'..rightTrimmedVal],
border = args['border_'..rightTrimmedVal],
boxstyle = args['boxstyle_'..rightTrimmedVal]
})
end
end
return p._main(cell_args)
end
return p