|
|
| Line 1: |
Line 1: |
| local p = {} | | local p = {} |
|
| |
| local function put_adjacent_x_links(title, s, prev_x, next_x)
| |
| return s .. '<table style="width: 100%; margin: 0"><tr>'
| |
| .. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: smaller">'
| |
| .. (prev_x or '')
| |
| .. '</td>'
| |
| .. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center">'
| |
| .. title
| |
| .. '</td>'
| |
| .. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: smaller">'
| |
| .. (next_x or '')
| |
| .. '</td>'
| |
| .. '</tr></table>'
| |
| end
| |
|
| |
| local function put_adjacent_x_links(title, s, prev_x, next_x)
| |
| return s .. '<table style="width: 100%; margin: 0"><tr>'
| |
| .. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: smaller">'
| |
| .. (prev_x or '')
| |
| .. '</td>'
| |
| .. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center">'
| |
| .. title
| |
| .. '</td>'
| |
| .. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: smaller">'
| |
| .. (next_x or '')
| |
| .. '</td>'
| |
| .. '</tr></table>'
| |
| end
| |
|
| |
|
| function p.build(title, entries, prev_link, next_link) | | function p.build(title, entries, prev_link, next_link) |
| Line 46: |
Line 18: |
| local has_adjacent = (prev_link and #prev_link > 0) or (next_link and #next_link > 0) | | local has_adjacent = (prev_link and #prev_link > 0) or (next_link and #next_link > 0) |
| if has_adjacent then | | if has_adjacent then |
| s = put_adjacent_x_links(title, s, prev_link, next_link)
| |
| else
| |
| s = s .. title
| |
| end
| |
| s = s .. '\n'
| |
| for i, entry in ipairs(entries) do
| |
| if #entry > 1 then
| |
| local caption = entry[1]
| |
| local text = entry[2]
| |
| s = s .. '|-\n' ..
| |
| '| style="text-align:right; padding-right: 0.25em" | ' .. caption .. '\n' ..
| |
| '| style="background-color: white; padding-left: 0.25em; font-weight: bold" | ' .. text .. '\n'
| |
| elseif #entry == 1 then
| |
| local text = entry[1]
| |
| s = s .. '|-\n'
| |
| .. '| colspan="2" style="text-align: center;" | ' .. text .. '\n'
| |
| end
| |
| end
| |
| s = s .. '|}</div>'
| |
| return s
| |
| end
| |
|
| |
| function p.build(title, entries, prev_x, next_x, prev_y, next_y)
| |
|
| |
| local s = '<div style="\n' ..
| |
| 'border: 1px solid #999;\n' ..
| |
| 'margin: 0;\n' ..
| |
| 'margin-left: 1em;\n' ..
| |
| 'margin-bottom: 0.5em;\n' ..
| |
| 'padding: 0.5em;\n' ..
| |
| 'background-color: #f0f0f0;\n' ..
| |
| 'min-width: 15em;\n' ..
| |
| 'float: right;\n' ..
| |
| 'max-width: 100%;\n' ..
| |
| 'overflow: auto;\n' ..
| |
| '">\n' ..
| |
| '{| width="100%" style="border-collapse: collapse;"\n' ..
| |
| '|+ style="font-weight: bold; text-align: center;" | '
| |
| local has_adjacent_x = (prev_x and #prev_x > 0) or (next_x and #next_x > 0)
| |
| local has_adjacent_y = (prev_y and #prev_y > 0) or (next_y and #next_y > 0)
| |
|
| |
| if prev_y then -- prev y
| |
| s = s .. '<table style="width: 100%; margin: 0"><tr>' | | s = s .. '<table style="width: 100%; margin: 0"><tr>' |
| .. '<td></td><td style="\n'
| |
| .. 'width: 50%; padding-left: 1em; padding-right: 1em; text-align: center; font-size: smaller">'
| |
| .. prev_y
| |
| .. '\n</td><td></td>'
| |
| .. '\n<tr>'
| |
| .. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: smaller">' | | .. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: smaller">' |
| .. (prev_x or '') | | .. (prev_link or '') |
| .. '</td>' | | .. '</td>' |
| .. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center">' | | .. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center">' |
| Line 101: |
Line 26: |
| .. '</td>' | | .. '</td>' |
| .. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: smaller">' | | .. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: smaller">' |
| .. (next_x or '') | | .. (next_link or '') |
| .. '</td>'
| |
| .. '</tr>'
| |
| if next_y then
| |
| s = s .. '<tr>'
| |
| .. '<td></td><td style="\n'
| |
| .. 'width: 50%; padding-left: 1em; padding-right: 1em; text-align: center; font-size: smaller">'
| |
| .. next_y
| |
| .. '\n</td><td></td>'
| |
| .. '</tr>'
| |
| end
| |
| s = s .. '</table>'
| |
| elseif has_adjacent_x then -- no prev y, has adjacent x
| |
| s = s .. '<table style="width: 100%; margin: 0"><tr>'
| |
| .. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: smaller">'
| |
| .. (prev_x or '')
| |
| .. '</td>'
| |
| .. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center">'
| |
| .. title
| |
| .. '</td>'
| |
| .. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: smaller">'
| |
| .. (next_x or '')
| |
| .. '</td>'
| |
| .. '</tr>'
| |
| if next_y then
| |
| s = s .. '<tr><td></td>'
| |
| .. '<td style="\n'
| |
| .. 'width: 50%; padding-left: 1em; padding-right: 1em; text-align: center; font-size: smaller">'
| |
| .. next_y
| |
| .. '\n</td><td></td>'
| |
| .. '</tr>'
| |
| end
| |
| s = s .. '</table>'
| |
| elseif next_y then -- no prev y, no adjacent x, so first row should be title in center
| |
| s = s .. '<table style="width: 100%; margin: 0"><tr>'
| |
| .. '<td>'
| |
| .. '</td>'
| |
| .. '<td>'
| |
| .. title
| |
| .. '</td>'
| |
| .. '<td>'
| |
| .. '</td>' | | .. '</td>' |
| .. '</tr>' | | .. '</tr></table>' |
| .. '<tr><td></td>'
| |
| .. '<td style="\n'
| |
| .. 'width: 50%; text-align: left; white-space: nowrap; font-size: smaller">'
| |
| .. next_y
| |
| .. '\n</td><td></td>'
| |
| .. '</tr>'
| |
| .. '</table>'
| |
| else | | else |
| s = s .. title | | s = s .. title |