Module:RFX report: Difference between revisions

Content deleted Content added
Lets use words when using abbreviation tags
use TemplateStyles (supports mobile now better and generally customizing stuff); remove style= as it was almost exclusively setting float and clear (and removing the style on the background, which should probably just be the default wikitable rather than white); moved some table paddings to be margins
Line 48:
return nil
end
local style = ''
local styleInline = ''
local status = rfxObject:getStatus()
if status == 'pending closure' then
style = ' style="background: #f8cdc6;" |'
styleInline = ' background: #f8cdc6;'
end
local page = rfxObject:getTitleObject().prefixedText
local user = rfxObject.user or rfxObject:getTitleObject().subpageText
Line 70 ⟶ 64:
votes = mw.ustring.format( [==[
| styleclass="textrfx-align: right;%sreport-number" | [[%s#Support|%d]]
| styleclass="textrfx-align: right;%sreport-number" | [[%s#Oppose|%d]]
| styleclass="textrfx-align: right;%sreport-number" | [[%s#Neutral|%d]]
| styleclass="textrfx-align:report-number right;rfx-report-percent" style="background: #%s;" | %d]==],
styleInline, page, supports,
styleInline, page, opposes,
styleInline, page, neutrals,
colour, percent
)
else
votes = '\n| colspan="4" styleclass="background: #f8cdc6;rfx-report-error" | Error parsing votes'
end
if status then
Line 87 ⟶ 81:
status = 'Pending closure...'
end
status = mw.ustring.format( '\n| %s %s', style,.. status )
else
status = '\n| styleclass="background: #f8cdc6;rfx-report-error" | Error getting status'
end
local endTime = rfxObject.endTime
Line 96 ⟶ 90:
local time
if endTime and timeLeft then
time = mw.ustring.format( '\n| %s %s\n| %s %s', style, endTime, style, timeLeft )
else
time = '\n| colspan="2" styleclass="background: #f8cdc6;rfx-report-error" | Error parsing end time'
end
local dupes = rfxObject:dupesExist()
if dupes then
dupes = '<span class="'''rfx-report-dupes-yes">yes</span>'''"
elseif dupes == false then
dupes = 'no'
Line 110 ⟶ 104:
local report = rfxObject:getReport()
if report then
report = mw.ustring.format( '\n|%s [%s report]', style, tostring( report ) )
else
report = '\n| styleclass="background: #f8cdc6;rfx-report-error" | Report not found'
end
local styleInlinepending_class = ''
if status == 'pending closure' then
pending_class = 'class="rfx-report-pending"'
end
return mw.ustring.format(
'\n|-%s\n|%s [[%s|%s]]%s%s%s\n| styleclass="textrfx-align: center;%sreport-dupes" | %s%s',
stylepending_class, page, user, votes, status, time, styleInline, dupes, report
)
end
Line 131 ⟶ 129:
end
return mw.ustring.format(
'\n|-\n! scope="col" | %s candidate !! scope="col" | <abbr title="Support">S</abbr> !! scope="col" | <abbr title="Oppose">O</abbr> !! scope="col" | <abbr title="Neutral">N</abbr> !! scope="col" | <abbr title="Support percentage (%%)">S %%</abbr> !! scope="col" | Status !! scope="col" | Ending (UTC) !! scope="col" | Time left !! scope="col" | <abbr title="Has duplicate votes?">Dups?</abbr> !! scope="col" | Report',
rfxCaps
)
Line 180 ⟶ 178:
local purgeLink = mw.title.getCurrentTitle():fullUrl( 'action=purge' )
local header = mw.ustring.format(
'\n|+ Requests for [[Wikipedia:Requests for adminship|adminship]] and [[Wikipedia:Requests for bureaucratship|bureaucratship]] <span class="rfx-report-purge plainlinks" style="float: right;"><small>[%s update]</small></span>',
purgeLink
)
local rows = makeReportRows() or ''
if rows == '' then
rows = '\n|-\n| colspan="10" | No current discussions. <smallspan class="rfx-report-recent">[[WP:Requests for adminship by year|Recent RfAs]], recent RfBs: ([[Wikipedia:Successful bureaucratship candidacies|successful]], [[Wikipedia:Unsuccessful bureaucratship candidacies|unsuccessful]])</smallspan>'
end
)
local style = args.style
local clearfloat = args.clearfloat or 'left'args.align
if not style then
if localnot float =or argsmw.text.trim(float) or args.align or== 'right' then
float = nil
local clear = args.clear or 'left'
style = mw.ustring.format(
'style="white-space:wrap; clear: %s; margin-top: 0em; margin-bottom: .5em; float: %s; padding: .5em 0em 0em 1.4em; background: #ffffff; border-collapse: collapse; border-spacing: 0;"',
clear, float
)
end
local styleclear = args.styleclear
return mw.ustring.format( '\n{| class="wikitable" %s%s%s\n|-\n|}', style, header, rows )
if not clear or mw.text.trim(clear) == '' then
clear = nil
end
local style = ''
if notfloat styleor clear then
style = mw.ustringstring.format(
'style="%s%s"',
clear and ('clear: ' .. clear .. ';') or '',
float and ('float: ' .. float .. ';') or ''
)
end
 
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:RFX report/styles.css' }
} .. mw.ustring.format(
return mw.ustring.format( '\n{| class="wikitable rfx-report" %s%s%s\n|-\n|}', style, header, rows )
style,
header,
rows
)
end