1,508
个编辑
(重构,移除infoList的下标引用) |
(重构,merge支持任意长度的列表) |
||
第177行: | 第177行: | ||
function merge(list) | function merge(list) | ||
local | local span = {} | ||
local lastUniqueIndex = nil | |||
if list[ | local currentIndex = 1 | ||
while currentIndex<=#list do | |||
if lastUniqueIndex and list[lastUniqueIndex] == list[currentIndex] then | |||
span[lastUniqueIndex] = span[lastUniqueIndex] + 1 | |||
span[currentIndex] = 0 | |||
else | |||
lastUniqueIndex = currentIndex | |||
span[currentIndex] = 1 | |||
end | |||
currentIndex = currentIndex + 1 | |||
end | end | ||
local merge = {} | |||
for i = 1, | for i = 1, #list do | ||
if | if span[i] == 0 then | ||
merge[i] = 'display:none' | merge[i] = 'display:none' | ||
else | else | ||
merge[i] = 'grid-column-start: span '.. | merge[i] = 'grid-column-start: span '..span[i] .. ';' | ||
end | end | ||
end | end |
个编辑