Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/N8wilson/FAQ item
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
require('strict') local getArgs = require('Module:Arguments').getArgs local mHatnote = require('Module:Hatnote') local templatestyles = 'TemplateStyles sandbox/N8wilson/SeeFAQstyles.css' local p = {} local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame) return p[funcName](args) end end function p.ternary(cond, ctrue, cfalse) if cond then return ctrue end return cfalse end p.pinned = makeInvokeFunc('_pinned') function p._pinned(args) -- Generate FAQ for inclusion as the first discussion at the top of the page. local builder = mw.html.create() builder:tag('div') :addClass('faq-item') :tag('div') :addClass('faq-link-key') :wikitext(p.ternary(args['link-key'], 'π' .. args['link-key'], '')) :done() :tag('span') :addClass('faq-question') :wikitext('Q' .. (args.index or '') .. '. ' .. (args.q or '')) :done() :tag('span') :addClass('faq-answer') :wikitext(args.a or '') return builder -- Do not include <h2> tag. The L2 header needs to be interpreted as wikitext -- (i.e. "== header ==") in order to be properly processed by minerva, -- the mobile skin. If the h2 is included directly, minerva shows it but makes -- the content underneath it inaccessible on mobile interfaces. end p.faqpage = makeInvokeFunc('_faqpage') function p._faqpage(args) -- Generate FAQ as it should render on the FAQ content page with anchors to questions local builder = mw.html.create() builder:tag('div') :addClass('faq-item faq-page') :tag('h3') :addClass('faq-question') :addClass('anchor') :attr('id', ('kFAQ-' .. (args['link-key'] or ''))) :wikitext(args.q or nil) :done() :wikitext(mHatnote._hatnote(tostring(args['link-key'] or ''), {extraclasses='link-key'})) :tag('div') :addClass('faq-short-answer') :wikitext(args['short-a'] or '') :done() :tag('div') :addClass('faq-answer') :wikitext(args.a or '') :done() return builder end p.default = makeInvokeFunc('_default') function p._default(args) -- Generate item as it should render outside of the FAQ page -- (assume ref to single question in discussion) local builder = mw.html.create() builder:tag('span') :addClass('faq-question') :wikitext(args.q or '') builder:tag('span') :addClass('faq-answer') :wikitext(args.a or '') return builder end p.beginsection = makeInvokeFunc('_beginsection') function p._beginsection(args) return mw.html.create('section', {selfClosing = true}) :attr('begin', (args.key or '')) end p.endsection = makeInvokeFunc('_endsection') function p._endsection(args) return mw.html.create('section', {selfClosing = true}) :attr('end', (args.key or '')) end p.main = makeInvokeFunc('_main') function p._main(args) -- make a decision about which format to use based on params if 'FAQ' == mw.title.getCurrentTitle().subpageText then return p._faqpage(args) end if args.format == 'pinned' then return p._pinned(args) end return p._default(args) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/N8wilson/FAQ item/doc
(
edit
)