InfoHelp

Матеріал з Українські вікі
Перейти до навігаціїПерейти до пошуку

local infohelp = {}

function infohelp.gender(frame)

   local total
   local lg = string.lower(frame.args[1])
   if 
       lg == "man" or 
       lg == "m" or 
       lg == "male" or 
       lg == "чоловік" or 
       lg == "чол" or 
       lg == "ч" 
   then
       total = "http://vignette2.wikia.nocookie.net/wikies/images/b/b1/Male.png/revision/latest?cb=20160414102747&path-prefix=uk"
   elseif 
       lg == "woman" or 
       lg == "w" or 
       lg == "f" or 
       lg == "female" or 
       lg == "жінка" or 
       lg == "жін" or 
       lg == "ж" 
   then
       total = "http://vignette4.wikia.nocookie.net/wikies/images/9/99/Female.png/revision/latest?cb=20160414103131&path-prefix=uk"
   end
   return total

end

function infohelp.check( frm )

   local wo = mw.text.split( frm, '%.')
   local pageexists = mw.title.makeTitle('File', frm).fileExists
   local result = "—"

   if pageexists then
       result = '150px'
   end

   return result

end

function infohelp.img( frame )

   local e1 = string.find( frame.args[1], "^%[%[" )
   local e2 = string.find( frame.args[1], "^http(s?)://")
   local e3 = string.find( frame.args[1], "^[a-zA-Zа-яА-Я0-9%[]" )
   local result = ""

   if e2 or not e3 then
       result = frame.args[1]
   elseif e1 then
       result = infohelp.check(mw.text.split(mw.text.trim(frame.args[1]), '[:|%]]')[2])
   else
       result = infohelp.check(frame.args[1])
   end

   return result

end

function infohelp.prof(frame)

   local abilities = mw.text.split(frame.args[1], "[,%s]+")
   local total = ""
   local border = ''
   for i, v in ipairs(abilities) do
       local lv = string.lower(v)
       if
           lv == "forum/chat" or 
           lv == "ф" or lv == "ч" or 
           lv == "f" or lv == "c" or 
           lv == "forum" or 
           lv == "chat" or 
           lv == "форум" or 
           lv == "чат" or 
           lv == "форум/чат" or 
           lv == "f/c" or 
           lv == "ф/ч" 
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "help" or 
           lv == "helper" or 
           lv == "помічник" or 
           lv == "хелп" 
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "edit" or 
           lv == "editor" or 
           lv == "редактор" or 
           lv == "с" 
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "design" or 
           lv == "designer" or 
           lv == "дизайн" or 
           lv == "дизайнер" or 
           lv == "д" 
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "dev" or 
           lv == "code" or 
           lv == "develop" or 
           lv == "script" or 
           lv == "developer" or 
           lv == "п" or 
           lv == "програміст" or 
           lv == "розробник" 
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "admin" or 
           lv == "administrator" or 
           lv == "адмін" or 
           lv == "адміністратор" or 
           lv == "а" 
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "blog" or 
           lv == "blogger" or 
           lv == "блоги" or 
           lv == "блогер" or 
           lv == "б" 
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "staff" or 
           lv == "стаф" or 
           lv == "співробітник" 
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "tem" or 
           lv == "temp" or
           lv == "template" or
           lv == "ш" or
           lv == "шаблони"
       then
           total = total..
                   border..

'

'..

                   ''
       elseif 
           lv == "vstf" or 
           lv == "vstf" 
       then
           total = total..
                   border..

'

'..

                   ''
       end
   end

return "

"..
               total..
"

"

end

function infohelp.skill(frame)

   local block = '" style="'..
                   'background: white;'.. 
                   'border: 1px solid #6C93B1;'.. 
                   'color: #6C93B1;'.. 
                   'width: 35px;'..
                   'height: 35px;'..
                   'display: inline-block;'.. 
                   'margin: 2px;'..
                   'cursor: help;'..
                   'line-height: 33px;'
   end2 = '">'

local ennd = ''

   local start = '<div title="'
   local total = ""
   local abilities = mw.text.split(frame.args[1], "[,%s]+")
   for i, v in ipairs(abilities) do
       abilities[i] = mw.text.split(v, "-")
   end
   for i, uv in ipairs(abilities) do
       local v = string.lower(uv[1])
       local lvl = ""
       local lvl2 = ""
       if uv[2] == "0" then
           lvl = ' (на рівні копіювати/вставити)'
           lvl2 = 'border: 2px solid #B36D6D;'
       elseif uv[2] == "1" then
           lvl = ' (на низькому рівні)'
           lvl2 = 'border: 2px solid #B38840;'
       elseif uv[2] == "2" then
           lvl = ' (на середньому рівні)'
           lvl2 = 'border: 2px solid #B3B35B;'
       elseif uv[2] == "3" then
           lvl = ' (на високому рівні)'
           lvl2 = 'border: 2px solid #7DB368;'
       else
           lvl2 = 'border: 2px solid #B3B3B3;'
       end
       if 
           v == "html" or 
           v == "h" 
       then
           total = total..
                   start..
                   "Цей користувач володіє HTML"..
                   lvl..
                   block..
                   lvl2..
                   end2..
                   '</>'..
                   '
'.. ennd elseif v == "css" then total = total.. start.. "Цей користувач володіє CSS".. lvl.. block.. lvl2.. end2.. '.CSS'.. '
'.. ennd elseif v == "js" or v == "javascript" then total = total.. start.. "Цей користувач володіє JavaScript".. lvl.. block.. lvl2.. end2.. '{JS;}'.. '
'.. ennd elseif v == "wikitext" or v == "wt" or v == "вікітекст" or v == "розмітка" or v == "вікірозмітка" or v == "w" then total = total.. start.. "Цей користувач володіє вікі-розміткою".. lvl.. block.. lvl2.. end2.. ''.. mw.text.nowiki("W").. ''.. '
'.. ennd elseif v == "bot" or v == "бот" then total = total.. start.. "Цей користувач має власного бота".. block.. 'border: 2px solid #6C93B1;'.. end2.. 'БОТ'.. '
'.. ennd elseif v == "lua" then total = total.. start.. "Цей користувач володіє Lua".. lvl.. block.. lvl2.. end2.. 'Lua'.. '
'.. ennd end end

return "

"..total..'

'

end

function infohelp.lang(frame)

   local total = ""
   local langs = mw.text.split(frame.args[1], "[,%s]+")
   for i, v in ipairs(langs) do
       langs[i] = mw.text.split(v, "-")
   end
   for i, v in ipairs(langs) do
       local length
       if #v == 3 then
           v[1] = v[1]..'-'..v[2]
           v[2] = v[#v]
           v[3] = nil
       end
       local lang = mw.language.fetchLanguageName(v[1])
       if v[1] == 'nan' then
           lang = mw.language.fetchLanguageName('zh-min-nan')
       end
       if #v[1] == 2 then
           length = '16px'
       elseif #v[1] == 3 then
           length = '14px'
       elseif #v[1] == 4 then
           length = '12px'
       elseif #v[1] == 5 then
           length = '10px'
       elseif #v[1] == 6 or #v[1] == 7 then
           length = '8px'
       elseif #v[1] >= 8 then
           length = '7px'
       end
       if mw.text.trim(lang) ~=  then
       if v[#v] == "N" or v[#v] == "n" then
           total = total..
                   '<div'..
                       ' title="'..lang..'"'.. 
                       ' style="'..
                           'background: #4A8533; '..
                           'color: black; '..
                           'width: 37px;'.. 
                           'height: 37px;'.. 
                           'display: inline-block;'..
                           'vertical-align: middle;'..
                           'margin: 2px;'..
                           'line-height: 20px;'..
                           'font-size: '..length..';'..
                           'cursor: help;'..
                   '">'..
                       string.upper(v[1])..

'

'..
                           'Рідна'..
'

'.. ''

       elseif v[#v] == "5" then
           total = total..
                   "<div"..
                       ' title="'..lang..'"'.. 
                       ' style="'..
                           "background: #59BC33; "..
                           'color: black; '..
                           'width: 37px;'.. 
                           'height: 37px;'.. 
                           'display: inline-block;'..
                           'vertical-align: middle;'..
                           'margin: 2px;'..
                           'line-height: 20px;'..
                           'font-size: '..length..';'..
                           'cursor: help;'..
                   "\">"..
                       string.upper(v[1])..

"

"..
                           "LVL 5"..
"

".. ""

       elseif v[#v] == "4" then
           total = total..
                   "<div"..
                       ' title="'..lang..'"'.. 
                       ' style="'..
                           "background: #80C833; "..
                           'color: black; '..
                           'width: 37px;'.. 
                           'height: 37px;'.. 
                           'display: inline-block;'..
                           'vertical-align: middle;'..
                           'margin: 2px;'..
                           'line-height: 20px;'..
                           'font-size: '..length..';'..
                           'cursor: help;'..
                   "\">"..
                       string.upper(v[1])..

"

"..
                           "LVL 4"..
"

".. ""

       elseif v[#v] == "3" then
           total = total..
                   "<div"..
                       ' title="'..lang..'"'.. 
                       ' style="'..
                           "background: #B6FF39; "..
                           'color: black; '..
                           'width: 37px;'.. 
                           'height: 37px;'.. 
                           'display: inline-block;'..
                           'vertical-align: middle;'..
                           'margin: 2px;'..
                           'line-height: 20px;'..
                           'font-size: '..length..';'..
                           'cursor: help;'..
                   "\">"..
                       string.upper(v[1])..

"

"..
                           "LVL 3"..
"

".. ""

       elseif v[#v] == "2" then
           total = total..
                   "<div"..
                       ' title="'..lang..'"'.. 
                       ' style="'..
                           "background: #F1F133; "..
                           'color: black; '..
                           'width: 37px;'.. 
                           'height: 37px;'.. 
                           'display: inline-block;'..
                           'vertical-align: middle;'..
                           'margin: 2px;'..
                           'line-height: 20px;'..
                           'font-size: '..length..';'..
                           'cursor: help;'..
                   "\">"..
                       string.upper(v[1])..

"

"..
                           "LVL 2"..
"

".. ""

       elseif v[#v] == "1" then
           total = total..
                   "<div"..
                       ' title="'..lang..'"'.. 
                       ' style="'..
                           "background: #EF9B0F; "..
                           'color: black; '..
                           'width: 37px;'.. 
                           'height: 37px;'.. 
                           'display: inline-block;'..
                           'vertical-align: middle;'..
                           'margin: 2px;'..
                           'line-height: 20px;'..
                           'font-size: '..length..';'..
                           'cursor: help;'..
                   "\">"..
                       string.upper(v[1])..

"

"..
                           "LVL 1"..
"

".. ""

       elseif v[#v] == "0" then
           total = total..
                   "<div"..
                       ' title="'..lang..'"'.. 
                       ' style="'..
                           "background: #FF3333; "..
                           'color: black; '..
                           'width: 37px;'.. 
                           'height: 37px;'.. 
                           'display: inline-block;'..
                           'vertical-align: middle;'..
                           'margin: 2px;'..
                           'line-height: 20px;'..
                           'font-size: '..length..';'..
                           'cursor: help;'..
                   "\">"..
                       string.upper(v[1])..

"

"..
                           "LVL 0"..
"

".. ""

       elseif v[#v] == "?" then
           total = total..
                   "<div"..
                       ' title="'..lang..'"'.. 
                       ' style="'..
                           "background: #959595; "..
                           'color: black; '..
                           'width: 37px;'.. 
                           'height: 37px;'.. 
                           'display: inline-block;'..
                           'vertical-align: middle;'..
                           'margin: 2px;'..
                           'line-height: 20px;'..
                           'font-size: '..length..';'..
                           'cursor: help;'..
                   "\">"..
                       string.upper(v[1])..

"

"..
                           "???"..
"

".. ""

       end
       end
   end

return '

'..total..'

'

end

return infohelp