跳到内容

Module:Songtable:修订间差异

添加57字节 、​ 2024年3月12日 (星期二)
重构,merge支持任意长度的列表
(重构,移除infoList的下标引用)
(重构,merge支持任意长度的列表)
第177行: 第177行:


function merge(list)
function merge(list)
    local merge
    local span = {}
   if list[4] then merge = {1, 1, 1, 1} else merge = {1, 1, 1} end
   local o
   if list[4] then o = 4 else o = 3 end


    if list[4] then
    local lastUniqueIndex = nil
      if list[4] == list[3] then merge[3] = merge[3] + merge[4] merge[4] = 0 end
   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


    if list[3] == list[2] then merge[2] = merge[2] + merge[3] merge[3] = 0 end
    local merge = {}
 
   if list[2] == list[1] then merge[1] = merge[1] + merge[2] merge[2] = 0 end


    for i = 1, o do
    for i = 1, #list do
      if merge[i] == 0 then
      if span[i] == 0 then
        merge[i] = 'display:none'
        merge[i] = 'display:none'
      else
      else
        merge[i] = 'grid-column-start: span '..merge[i] .. ';'
        merge[i] = 'grid-column-start: span '..span[i] .. ';'
      end
      end
    end
    end
1,508

个编辑