Модуль:Переключатель проекта: различия между версиями

Нет описания правки
Нет описания правки
 
(не показаны 3 промежуточные версии этого же участника)
Строка 3: Строка 3:


local DEFAULT_VALUE = 'Corvax, Goob'
local DEFAULT_VALUE = 'Corvax, Goob'
local SPECIAL_SKIP_VALUE = 'Corvax'


local function trim(s)
local function trim(s)
Строка 18: Строка 17:
end
end
return out
return out
end
local function isSkipValue(value)
return mw.ustring.lower(trim(value)) == mw.ustring.lower(SPECIAL_SKIP_VALUE)
end
end


Строка 34: Строка 29:


local first = projects[1]
local first = projects[1]
local result = ''
local result = ''
 
result = result .. '{{#varexists:JsonPath| |{{#vardefine:JsonPath|' .. first .. '}}}}'
if not isSkipValue(first) then
result = result .. '{{#vardefine:JsonPath|' .. first .. '}}'
end
 
if #projects == 1 then
return frame:preprocess(result)
end
 
result = result .. '<div style="display:none;" class="js-project-selection-generator">'
result = result .. '<div style="display:none;" class="js-project-selection-generator">'
.. mw.text.encode(table.concat(projects, ', '))
.. mw.text.encode(table.concat(projects, ', '))