Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 2: | Строка 2: | ||
-- Функции как локальные переменные | -- Функции как локальные переменные | ||
local loadData, findDataById, formatContent, getContentsOutput, processNestedSelectors, getTableOutput, getContainedOutput, getChemOutput | local loadData, findDataById, formatContent, getContentsOutput, processNestedSelectors, getTableOutput, getContainedOutput, getChemOutput, handleGroupSelector, handleAllSelector, handleNestedSelector | ||
-- Функция для загрузки данных | -- Функция для загрузки данных | ||
| Строка 70: | Строка 70: | ||
result = result .. formatContent(child) | result = result .. formatContent(child) | ||
elseif child["!type"] == "NestedSelector" and child.tableId then | elseif child["!type"] == "NestedSelector" and child.tableId then | ||
result = result .. handleNestedSelector(child | result = result .. handleNestedSelector(child) | ||
elseif child["!type"] == "GroupSelector" then | elseif child["!type"] == "GroupSelector" then | ||
result = result .. handleGroupSelector(child) | result = result .. handleGroupSelector(child) | ||
| Строка 86: | Строка 86: | ||
if tableData['!type:GroupSelector'] and tableData['!type:GroupSelector'].children then | if tableData['!type:GroupSelector'] and tableData['!type:GroupSelector'].children then | ||
return handleGroupSelector(tableData['!type:GroupSelector']) | |||
elseif tableData['!type:AllSelector'] and tableData['!type:AllSelector'].children then | elseif tableData['!type:AllSelector'] and tableData['!type:AllSelector'].children then | ||
return processNestedSelectors(tableData['!type:AllSelector'].children) | return processNestedSelectors(tableData['!type:AllSelector'].children) | ||
| Строка 138: | Строка 117: | ||
for _, child in ipairs(children) do | for _, child in ipairs(children) do | ||
if child["!type"] == "NestedSelector" and child.tableId then | if child["!type"] == "NestedSelector" and child.tableId then | ||
result = result .. handleNestedSelector(child | result = result .. handleNestedSelector(child) | ||
elseif child["!type"] == "GroupSelector" then | elseif child["!type"] == "GroupSelector" then | ||
result = result .. handleGroupSelector(child) | result = result .. handleGroupSelector(child) | ||
| Строка 172: | Строка 151: | ||
return "" | return "" | ||
end | end | ||
for _, child in ipairs(groupSelector.children) do | for _, child in ipairs(groupSelector.children) do | ||
| Строка 181: | Строка 156: | ||
result = result .. handleGroupSelector(child) | result = result .. handleGroupSelector(child) | ||
elseif child["!type"] == "AllSelector" then | elseif child["!type"] == "AllSelector" then | ||
result = result .. handleAllSelector(child) | result = result .. handleAllSelector(child) | ||
elseif child.id then | elseif child.id then | ||
result = result .. formatContent(child) | result = result .. formatContent(child) | ||
| Строка 190: | Строка 163: | ||
end | end | ||
end | end | ||
return result | return result | ||
| Строка 203: | Строка 174: | ||
for _, child in ipairs(allSelector.children) do | for _, child in ipairs(allSelector.children) do | ||
if child["!type"] == "NestedSelector" and child.tableId then | if child["!type"] == "NestedSelector" and child.tableId then | ||
result = result .. handleNestedSelector(child | result = result .. handleNestedSelector(child) | ||
elseif child.id then | elseif child.id then | ||
result = result .. formatContent(child) | result = result .. formatContent(child) | ||
| Строка 213: | Строка 184: | ||
-- Обработка NestedSelector | -- Обработка NestedSelector | ||
handleNestedSelector = function(nestedSelector | handleNestedSelector = function(nestedSelector) | ||
local result = '' | local result = '' | ||
local tableId = nestedSelector.tableId | local tableId = nestedSelector.tableId | ||
| Строка 228: | Строка 199: | ||
end | end | ||
-- Обёртка div с классами | -- Обёртка div с классами | ||
local classString = table.concat(classes, ' ') | |||
result = result .. string.format('<div class="%s">', classString) | |||
result = result .. getTableOutput(tableId) | result = result .. getTableOutput(tableId) | ||
result = result .. '</div>' | |||
return result | return result | ||