6194
редагування
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
| Рядок 1: | Рядок 1: | ||
local p = {} | local p = {} | ||
local page_cache = {} | local page_cache = {} | ||
| Рядок 22: | Рядок 18: | ||
return content | return content | ||
end | end | ||
local function get_section_content(content, section_start) | local function get_section_content(content, section_start) | ||
| Рядок 60: | Рядок 52: | ||
return count | return count | ||
end | end | ||
function p.section_menu(frame) | function p.section_menu(frame) | ||
| Рядок 80: | Рядок 68: | ||
if section_name and section_name ~= "" then | if section_name and section_name ~= "" then | ||
local display_name = section_name | local display_name = mw.ustring.gsub(section_name, "%{%{.-%}%}", "") | ||
local anchor = | display_name = mw.ustring.gsub(display_name, "%s*%([^%)]*%)%s*", "") | ||
display_name = mw.text.trim(display_name) | |||
local anchor = display_name | |||
local section_pos = mw.ustring.find(content, line, 1, true) | local section_pos = mw.ustring.find(content, line, 1, true) | ||
local count = nil | local count = nil | ||
if section_pos then | |||
if | local section_content = get_section_content(content, section_pos) | ||
if | if mw.ustring.match(display_name, "Нагороди") or mw.ustring.match(display_name, "Сезони") then | ||
count = count_table_rows(section_content) | count = count_table_rows(section_content) | ||
elseif mw.ustring.match(display_name, "Цікаві факти") then | |||
count = count_bullet_points(section_content) | count = count_bullet_points(section_content) | ||
end | end | ||
end | end | ||
if count and count > 0 then | if count and count > 0 then | ||
display_name = display_name .. " (" .. count .. ")" | display_name = display_name .. " (" .. count .. ")" | ||
end | end | ||
anchor = mw.ustring.gsub(anchor, " ", "_") | anchor = mw.ustring.gsub(anchor, " ", "_") | ||
| Рядок 151: | Рядок 106: | ||
end | end | ||
local html_parts = {} | local html_parts = {} | ||
table.insert(html_parts, '<div class="l-box" style="position:fixed; top:20px; left:20px; z-index:100; border-radius:16px; background-color:#23232c; width:220px; box-sizing:border-box; overflow:hidden;">') | table.insert(html_parts, '<div class="l-box" style="position:fixed; top:20px; left:20px; z-index:100; border-radius:16px; background-color:#23232c; width:220px; box-sizing:border-box; overflow:hidden;">') | ||
table.insert(html_parts, '<div style="padding:15px 20px; font-weight:bold; font-size:15px; color:#fff; border-bottom:1px solid rgba(255,255,255,0.1);">Зміст</div>') | table.insert(html_parts, '<div style="padding:15px 20px; font-weight:bold; font-size:15px; color:#fff; border-bottom:1px solid rgba(255,255,255,0.1);">Зміст</div>') | ||