Модуль:FetchData2: відмінності між версіями

нема опису редагування
Немає опису редагування
Немає опису редагування
Рядок 48: Рядок 48:
     end
     end
      
      
     local html = mw.html.create('div')
     -- Будуємо HTML вручну
        :addClass('l-box')
    local html_parts = {}
        :css('position', 'fixed')
        :css('top', '20px')
        :css('left', '20px')
        :css('z-index', '100')
        :css('border-radius', '16px')
        :css('background-color', '#23232c')
        :css('width', '220px')
        :css('box-sizing', 'border-box')
        :css('overflow', 'hidden')
      
      
     html:tag('div')
     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;">')
        :css('padding', '15px 20px')
        :css('font-weight', 'bold')
        :css('font-size', '15px')
        :css('color', '#fff')
        :css('border-bottom', '1px solid rgba(255,255,255,0.1)')
        :wikitext('Зміст')
      
      
    -- Заголовок
    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>')
   
    -- Пункти меню
     for i, section in ipairs(sections) do
     for i, section in ipairs(sections) do
         local anchor = mw.ustring.gsub(section, " ", "_")
         local anchor = mw.ustring.gsub(section, " ", "_")
         local link = html:tag('a')
         local border = ""
            :attr('href', '#' .. anchor)
            :css('display', 'block')
            :css('padding', '12px 20px')
            :css('color', '#ccc')
            :css('text-decoration', 'none')
            :wikitext(section)
       
         if i < #sections then
         if i < #sections then
             link:css('border-bottom', '1px solid rgba(255,255,255,0.05)')
             border = "border-bottom:1px solid rgba(255,255,255,0.05);"
         end
         end
       
        table.insert(html_parts, string.format(
            '<div class="l-box-item" style="padding:12px 20px; %s">[[#%s|%s]]</div>',
            border, anchor, section
        ))
     end
     end
      
      
     return tostring(html)
    table.insert(html_parts, '</div>')
   
     return table.concat(html_parts, '\n')
end
end


return p
return p