Module:Songtable:修订间差异

添加1,178字节 、​ 2024年4月17日 (星期三)
无编辑摘要
(重构,移除infoList的下标引用)
无编辑摘要
 
(未显示1个用户的5个中间版本)
第40行: 第40行:
end
end


function bydMark(byd, name, inNs, nsByd)
function diffMark(diffText, byd, name, inNs, nsByd)
    local diff, mark = mw.html.create('div'), mw.html.create('div')
    local diff, mark = mw.html.create('div'), mw.html.create('div')
    diff:wikitext('[Beyond]')
    diff:wikitext(diffText)
    mark:wikitext('仅移动版')
    mark:wikitext('仅移动版')
    if byd and inNs and not(nsByd)
    if byd and inNs and not(nsByd)
第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
第235行: 第240行:
    end
    end
    
    
    -- 判断byd谱面是否存在 ;先假定NS不会有beyond等级
    -- 判断byd谱面是否存在。
    local byd, nsByd
    local byd, nsByd
    if args['Beyond等级'] or data('bydRating') then byd = true else byd = false end
    if args['Beyond等级'] or data('bydRating') then byd = true else byd = false end
    if args['Beyond等级NS'] or dataNs('bydRating') then nsByd = true else nsByd = false end
    if args['Beyond等级NS'] or dataNs('bydRating') then nsByd = true else nsByd = false end
   -- 判断etr谱面是否存在;先假定NS不会有eternal等级。
   local etr
   if args['Eternal等级'] or data('etrRating') then etr = true else etr = false end


    -- 处理谱师参数,未填写的等级谱师向前级复制(向下兼容)
    -- 处理谱师参数,未填写的等级谱师向前级复制(向下兼容)
    local getChartDesigner = {
    local getChartDesigner = {
     [1] =
      {'PastNote编写', 'note编写', 'pstChartDesigner'},
      {'mobile', 'PastNote编写', 'note编写', 'pstChartDesigner'},
      {'PresentNote编写', 'note编写', 'prsChartDesigner'},
     [2] =
      {'FutureNote编写', 'note编写', 'ftrChartDesigner'},
      {'mobile', 'PresentNote编写', 'note编写', 'prsChartDesigner'},
     {'BeyondNote 编写', 'note编写', 'bydChartDesigner'}
     [3] =
   }
      {'mobile', 'FutureNote 编写', 'note编写', 'ftrChartDesigner'},
   -- 假定 etr 与 byd 不会同时出现
      [4] = 
   if etr then
     {'mobile', 'BeyondNote 编写', 'note编写', 'bydChartDesigner'}}
      getChartDesigner[4]={'EternalNote 编写', 'note编写', 'etrChartDesigner'}
   end


    local chartDesigner = {}
    local chartDesigner = {}
    for i, k in ipairs(getChartDesigner)
    for i, k in ipairs(getChartDesigner)
      do
      do
        if args[k[2]]
        if args[k[1]] then
          then
          chartDesigner[i] = args[k[1]]
       elseif args[k[2]] then
          chartDesigner[i] = args[k[2]]
          chartDesigner[i] = args[k[2]]
        else
        else
          if args[k[3]]
          chartDesigner[i] = choice(link({'谱师', tostring(data(k[3]))}), data(k[3]), '', true)
           then
           chartDesigner[i] = args[k[3]]
         else
           chartDesigner[i] = choice(link({'谱师', tostring(data(k[4]))}), data(k[4]), '', true)
         end
        end
        end
    end
    end
第269行: 第274行:
    -- 依据byd是否存在处理单元格合并参数。
    -- 依据byd是否存在处理单元格合并参数。
    local span
    local span
    if byd then
    if byd or etr then
      span = merge({chartDesigner[1], chartDesigner[2], chartDesigner[3], chartDesigner[4]})
      span = merge({chartDesigner[1], chartDesigner[2], chartDesigner[3], chartDesigner[4]})
    else
    else
第279行: 第284行:
    local imageA = getImage(data('id'), args['图片'], args['Past曲绘'], args['Present曲绘'], args['Future曲绘'], args['Beyond曲绘'], args['第二曲绘图片'], args['画师'], args['Beyond画师'], data('ftrJacketDesigner'), data('bydJacketDesigner'), byd, 'a', args['图片显示控制'])
    local imageA = getImage(data('id'), args['图片'], args['Past曲绘'], args['Present曲绘'], args['Future曲绘'], args['Beyond曲绘'], args['第二曲绘图片'], args['画师'], args['Beyond画师'], data('ftrJacketDesigner'), data('bydJacketDesigner'), byd, 'a', args['图片显示控制'])
    local imageB = getImage(data('id'), args['图片'], args['Past曲绘'], args['Present曲绘'], args['Future曲绘'], args['Beyond曲绘'], args['第二曲绘图片'], args['画师'], args['Beyond画师'], data('ftrJacketDesigner'), data('bydJacketDesigner'), byd, 'b', args['图片显示控制'])
    local imageB = getImage(data('id'), args['图片'], args['Past曲绘'], args['Present曲绘'], args['Future曲绘'], args['Beyond曲绘'], args['第二曲绘图片'], args['画师'], args['Beyond画师'], data('ftrJacketDesigner'), data('bydJacketDesigner'), byd, 'b', args['图片显示控制'])
   -- 生成Grid表格的信息表;在后文中依据格式进行生成。
   --


    local pstRating = args['Past等级'] or data('pstRating')
    local pstRating = args['Past等级'] or data('pstRating')
第287行: 第289行:
    local ftrRating = args['Future等级'] or data('ftrRating')
    local ftrRating = args['Future等级'] or data('ftrRating')
    local bydRating = args['Beyond等级'] or data('bydRating')
    local bydRating = args['Beyond等级'] or data('bydRating')
   local etrRating = args['Eternal等级'] or data('etrRating')
   local additionalDiffMark
   local additionalDiffMarkClass='byd-label'
   if byd then
     additionalDiffMark = diffMark('[Beyond]', byd, args['曲名'], inNs, nsByd)
     additionalDiffMarkClass='byd-label'
   elseif etr then
     additionalDiffMark = diffMark('[Eternal]', etr, args['曲名'], inNs, false)
     additionalDiffMarkClass='etr-label'
   end
   -- 生成Grid表格的信息表;在后文中依据格式进行生成。


    local infoList = {
    local infoList = {
第306行: 第321行:
      { '[Present]', { class = 'prs-label'}},
      { '[Present]', { class = 'prs-label'}},
      { '[Future]', { class = 'ftr-label'}},
      { '[Future]', { class = 'ftr-label'}},
      { bydMark(byd, args['曲名'], inNs, nsByd), { class = 'byd-label'}},
      { additionalDiffMark, { class = additionalDiffMarkClass}},
      { '等级', { class = 'label'}},
      { '等级', { class = 'label'}},
      { pstRating, { class = 'pst-data'}},
      { pstRating, { class = 'pst-data'}},
      { prsRating, { class = 'prs-data'}},
      { prsRating, { class = 'prs-data'}},
      { ftrRating, { class = 'ftr-data'}},
      { ftrRating, { class = 'ftr-data'}},
      { bydRating, { class = 'byd-data'}},
      { bydRating or etrRating, { class = 'byd-data'}},
      { 'note数量', { class = 'label'}},
      { 'note数量', { class = 'label'}},
      { args['PastNote'] or '空', { class = 'pst-data'}},
      { args['PastNote'] or '空', { class = 'pst-data'}},
      { args['PresentNote'] or '空', { class = 'prs-data'}},
      { args['PresentNote'] or '空', { class = 'prs-data'}},
      { args['FutureNote'] or '空', {class = 'ftr-data'}},
      { args['FutureNote'] or '空', {class = 'ftr-data'}},
      { args['BeyondNote'] or '空', { class = 'byd-data'}},
      { args['BeyondNote'] or args['EternalNote'] or '空', { class = 'byd-data'}},
      { '谱面设计', { class = 'label'}},
      { '谱面设计', { class = 'label'}},
      { chartDesigner[1] or '空', { class = 'pst-data'}, span[1]},
      { chartDesigner[1] or '空', { class = 'pst-data'}, span[1]},
第327行: 第342行:
      { '[Present]', { class = 'prs-label ns'}},
      { '[Present]', { class = 'prs-label ns'}},
      { '[Future]', { class = 'ftr-label ns'}},
      { '[Future]', { class = 'ftr-label ns'}},
      { bydMark(byd, args['曲名'], inNs, nsByd), { class = 'byd-label ns'}},
      { additionalDiffMark, { class = additionalDiffMarkClass..' ns'}},
      { 'note数量', { class = 'label ns'}},
      { 'note数量', { class = 'label ns'}},
      { args['PastNoteNS'] or args['PastNote'], { class = 'pst-data ns'}},
      { args['PastNoteNS'] or args['PastNote'], { class = 'pst-data ns'}},
第338行: 第353行:
      { '更新时间', { id = 'update-data-label', class = 'label'}},
      { '更新时间', { id = 'update-data-label', class = 'label'}},
      { dateCov(args['更新版本'], args['更新时间'], labelText('移动版'), 'arg') or dateCov(data('version'), tonumber(data('date')), labelText('移动版'), 'data'), { id = 'mobile-date-normal', class = 'data'}},
      { dateCov(args['更新版本'], args['更新时间'], labelText('移动版'), 'arg') or dateCov(data('version'), tonumber(data('date')), labelText('移动版'), 'data'), { id = 'mobile-date-normal', class = 'data'}},
      { dateCov(args['Beyond更新版本'], args['Beyond更新时间'], labelText('移动版'), 'arg') or '空', { id = 'mobile-date-byd', class = 'data'}},
      { dateCov(args['Beyond更新版本'], args['Beyond 更新时间'], labelText('移动版'), 'arg') or dateCov(args['Eternal更新版本'], args['Eternal 更新时间'], labelText('移动版'), 'arg') or '空', { id = 'mobile-date-byd', class = 'data'}},
      { dateCov(args['更新版本NS'], args['更新时间NS'], labelText('NS版'), 'arg') or dateCov(dataNs('version'), tonumber(dataNs('date')), labelText('NS版'), 'data'), { id = 'ns-date-normal', class = 'data ns'}},
      { dateCov(args['更新版本NS'], args['更新时间NS'], labelText('NS版'), 'arg') or dateCov(dataNs('version'), tonumber(dataNs('date')), labelText('NS版'), 'data'), { id = 'ns-date-normal', class = 'data ns'}},
      { '空', { id = 'ns-date-byd', class = 'data ns'}}
      { '空', { id = 'ns-date-byd', class = 'data ns'}}
第347行: 第362行:
    --样式控制
    --样式控制
    box:addClass("arcaeabox")
    box:addClass("arcaeabox")
    if byd then box:addClass("byd") end
   -- 假定 etr 与 byd 不会同时出现,etr 暂时复用 byd 的逻辑
    if byd or etr then box:addClass("byd") end
    if dataNs('side') == 1 or args['侧'] == '1'
    if dataNs('side') == 1 or args['侧'] == '1'
    then
    then
第361行: 第377行:
      end
      end
    end
    end
    if args['Beyond更新版本'] and args['Beyond更新时间'] then box:addClass('mobile-byd-date') end
   -- 假定 etr 与 byd 不会同时出现,etr 暂时复用 byd 的逻辑
    if (args['Beyond更新版本'] and args['Beyond更新时间']) or (args['Eternal更新版本'] and args['Eternal更新时间'])  then box:addClass('mobile-byd-date') end
    if nsByd then box:addClass('ns-byd-date') box:addClass('ns-date-span') end
    if nsByd then box:addClass('ns-byd-date') box:addClass('ns-date-span') end
    if not(args['更新版本'] or args['更新时间'] or data('id')) then box:addClass('no-mobile') end
    if not(args['更新版本'] or args['更新时间'] or data('id')) then box:addClass('no-mobile') end
第381行: 第398行:
    end
    end


    if dataNs('pstChange') or dataNs('prsChange') or dataNs('ftrChange') then category = category..'[[分类:多模式谱面有差异的曲目]]' end
    if dataNs('pstChange') or dataNs('prsChange') or dataNs('ftrChange') or dataNs('bydChange') then category = category..'[[分类:多模式谱面有差异的曲目]]' end


    if not(data('id') or dataNs('id') or #args > 1) then category = category..'[[分类:未登陆的曲目]]' end
    if not(data('id') or dataNs('id') or #args > 1) then category = category..'[[分类:未登陆的曲目]]' end
第414行: 第431行:
      end
      end
      if byd and bydRating then category = category..'[[分类:BYD'..bydRating .. '级曲目]]' end
      if byd and bydRating then category = category..'[[分类:BYD'..bydRating .. '级曲目]]' end
     if etr and etrRating then category = category..'[[分类:ETR'..etrRating .. '级曲目]]' end


      category = category..'[[分类:采用'..(args['背景'] or data('bg') or dataNs('bg')) .. '背景的曲目]]'
      category = category..'[[分类:采用'..(args['背景'] or data('bg') or dataNs('bg')) .. '背景的曲目]]'
第466行: 第484行:
      noticeText = noticeText..'<li>此模板的NS版更新版本是未完整状态。请添加<code>更新版本NS</code>与<code>更新时间NS</code>参数。</li>'
      noticeText = noticeText..'<li>此模板的NS版更新版本是未完整状态。请添加<code>更新版本NS</code>与<code>更新时间NS</code>参数。</li>'
    end
    end
   -- noticeText = noticeText..'<li>调试信息:'..mw.dumpObject(nil)..'</li>'


    local notice
    local notice
1,015

个编辑