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

949 байтів вилучено ,  У понеділок о 17:11
нема опису редагування
Немає опису редагування
Немає опису редагування
 
Рядок 491: Рядок 491:
         table.insert(output, "| finalist = 0")
         table.insert(output, "| finalist = 0")
     end
     end
   
     table.insert(output, "}}")
     table.insert(output, "}}")
     table.insert(output, "")
     table.insert(output, "")
Рядок 508: Рядок 507:
     table.insert(output, facts_code)
     table.insert(output, facts_code)
      
      
     -- ВИПРАВЛЕННЯ: Використовуємо mw.html для створення блоку з кодом
     -- НАЙПРОСТІШЕ РІШЕННЯ: Додаємо пробіл на початку кожного рядка
     local final_code = table.concat(output, "\n")
     local final_code = table.concat(output, "\n")
      
      
     local html = mw.html.create('div')
     -- Розбиваємо на рядки та додаємо пробіл
        :css('background', '#f5f5f5')
     local result = {}
        :css('border', '1px solid #ddd')
     for line in final_code:gmatch("([^\n]*)\n?") do
        :css('padding', '15px')
         if line ~= "" then
        :css('margin', '10px 0')
            table.insert(result, " " .. line)
        :css('border-radius', '4px')
         else
      
            table.insert(result, "")
     html:tag('div')
         end
        :css('margin-bottom', '10px')
    end
        :css('font-weight', 'bold')
         :css('color', '#333')
        :wikitext('📋 Код для сторінки ' .. player_name .. ':')
   
    html:tag('pre')
        :css('background', 'white')
        :css('border', '1px solid #ccc')
        :css('padding', '10px')
        :css('overflow', 'auto')
        :css('max-height', '400px')
        :css('font-family', 'monospace')
        :css('font-size', '12px')
        :css('white-space', 'pre-wrap')
        :css('word-wrap', 'break-word')
        :wikitext(final_code)
   
    html:tag('button')
        :attr('onclick', 'navigator.clipboard.writeText(this.previousElementSibling.textContent); this.textContent="✓ Скопійовано!"; setTimeout(()=>this.textContent="📋 Копіювати код", 2000);')
         :css('background', '#4CAF50')
        :css('color', 'white')
         :css('padding', '8px 16px')
        :css('border', 'none')
        :css('border-radius', '4px')
        :css('cursor', 'pointer')
        :css('font-size', '14px')
        :wikitext('📋 Копіювати код')
      
      
     return tostring(html)
    -- Додаємо заголовок
     return "'''Код для гравця " .. player_name .. ":'''\n\n" .. table.concat(result, "\n")
end
end


-- Генерувати для всіх гравців
-- Генерувати для всіх гравців