Jump to content

Module:Pagination: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Codemini (talk | contribs)
No edit summary
Codemini (talk | contribs)
In accordance with the one on simple english wikipedia
Line 1: Line 1:
local pk = {}
local p = {}
function pk.pagination(frame)
function p.pagination(frame)
args = frame.args
args = frame.args
prevcolor = args.prevcolor or ''
prevcolor = args.prevcolor or ''
Line 6: Line 6:
previous = args[1] or args.previous
previous = args[1] or args.previous
nextEl = args[2] or args.next
nextEl = args[2] or args.next
msg = {
msg = '<strong class="error">PaginationScriptError: You must provide a link for the</strong>'
nopreviousLink = 'no link for the previous button ([[template:Pagination#Errors|help]])',
nonextLink = 'no link for the next button ([[template:Pagination#Errors|help]])',
noLink = 'no link for both the previous and next buttons ([[template:Pagination#Errors|help]])'
}
p = '<span class="prev-btn" style="background-color: ' .. prevcolor .. ';>[[' .. previous .. '|Previous]]</span>'
p = '<span class="prev-btn" style="background-color: ' .. prevcolor .. ';>[[' .. previous .. '|Previous]]</span>'
--[[ if not previous then
--[[ if not previous then
Line 17: Line 21:
pn = '' .. p .. ' ' .. n .. ''
pn = '' .. p .. ' ' .. n .. ''
if previous == '' and nextEl == '' then
if previous == '' and nextEl == '' then
return '<strong class="error">' .. msg .. ' previous and next buttons</strong>'
return string.format('<strong class="error">"%s"</strong>', msg.noLink)
else
else
return pn
return pn
Line 23: Line 27:


end
end
return pk
return p

Revision as of 08:52, 30 May 2025

local p = {}
function p.pagination(frame)
 args = frame.args
 prevcolor = args.prevcolor or ''
 nextcolor = args.nextcolor or ''
 previous = args[1] or args.previous
 nextEl = args[2] or args.next
 msg = {
nopreviousLink = 'no link for the previous button ([[template:Pagination#Errors|help]])',
nonextLink = 'no link for the next button ([[template:Pagination#Errors|help]])',
noLink = 'no link for both the previous and next buttons ([[template:Pagination#Errors|help]])'
}
 p = '<span class="prev-btn" style="background-color: ' .. prevcolor .. ';>[[' .. previous .. '|Previous]]</span>'
--[[  if not previous then
   return n
  elseif not nextEl then
   return p
  else return pn
  end --]]
 n = '<span class="next-btn" style="background-color: ' .. nextcolor .. ';>[[' .. nextEl .. '|Next]]</span>'
 pn = '' .. p .. ' ' .. n .. ''
if previous == '' and nextEl == '' then
 return string.format('<strong class="error">"%s"</strong>', msg.noLink)
else
 return pn
end 

end
return p