「モジュール:Tracklist」の版間の差分
提供: MONACA Wiki
その他の操作
今川 凌 (MONACA) (トーク | 投稿記録) 編集の要約なし |
今川 凌 (MONACA) (トーク | 投稿記録) 編集の要約なし |
||
| (同じ利用者による、間の20版が非表示) | |||
| 10行目: | 10行目: | ||
local width = {} --列幅格納用テーブル | local width = {} --列幅格納用テーブル | ||
local collapsed = false --折りたたみ可否 | local collapsed = false --折りたたみ可否 | ||
local writer, lyrics, music, arranger, extra, length = function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end --基本セル関数 | local writer, lyrics, music, arranger, strings_arrange, brass_arrange, horn_arrange, orchestra_arrange, remix, singer, extra, length = function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end, function() return '' end --基本セル関数 | ||
local md = true --microdata on/off | local md = true --microdata on/off | ||
| 203行目: | 203行目: | ||
arranger = function(x) return '<td>' .. (x.arranger or all.arrangements and all.arrangements[2] or all.producing and all.producing[2] or all.all and all.all[2] or ' ') .. '</td>' end | arranger = function(x) return '<td>' .. (x.arranger or all.arrangements and all.arrangements[2] or all.producing and all.producing[2] or all.all and all.all[2] or ' ') .. '</td>' end | ||
end | end | ||
if credits.strings_arrange then | |||
result = result .. '<th scope="col" style="width:' .. (args.strings_arrange_width or width.credits) .. ';">ストリングスアレンジ</th>' | |||
-- ストリングスアレンジセル関数再定義 | |||
strings_arrange = function(x) return '<td>' .. (x.strings_arrange or ' ') .. '</td>' end | |||
end | |||
if credits.brass_arrange then | |||
-- ブラスアレンジ列追加 | |||
result = result .. '<th scope="col" style="width:' .. (args.brass_arrange_width or width.credits) .. ';">ブラスアレンジ</th>' | |||
-- ブラスアレンジセル関数再定義 | |||
brass_arrange = function(x) return '<td>' .. (x.brass_arrange or ' ') .. '</td>' end | |||
end | |||
if credits.horn_arrange then | |||
-- ホーンアレンジ列追加 | |||
result = result .. '<th scope="col" style="width:' .. (args.horn_arrange_width or width.credits) .. ';">ホーンアレンジ</th>' | |||
-- ホーンアレンジセル関数再定義 | |||
horn_arrange = function(x) return '<td>' .. (x.horn_arrange or ' ') .. '</td>' end | |||
end | |||
if credits.orchestra_arrange then | |||
-- オーケストラアレンジ列追加 | |||
result = result .. '<th scope="col" style="width:' .. (args.orchestra_arrange_width or width.credits) .. ';">オーケストラアレンジ</th>' | |||
-- オーケストラアレンジセル関数再定義 | |||
orchestra_arrange = function(x) return '<td>' .. (x.orchestra_arrange or ' ') .. '</td>' end | |||
end | |||
if credits.remix then | |||
-- リミックス列追加 | |||
result = result .. '<th scope="col" style="width:' .. (args.remix_width or width.credits) .. ';">リミックス</th>' | |||
-- オーケストラアレンジセル関数再定義 | |||
remix = function(x) return '<td>' .. (x.remix or ' ') .. '</td>' end | |||
end | |||
if credits.singer then | |||
-- 歌列追加 | |||
result = result .. '<th scope="col" style="width:' .. (args.singer_width or width.credits) .. ';">歌</th>' | |||
-- オーケストラアレンジセル関数再定義 | |||
singer = function(x) return '<td>' .. (x.singer or ' ') .. '</td>' end | |||
end | |||
if credits.extra then | if credits.extra then | ||
--extra列追加 | --extra列追加 | ||
| 240行目: | 275行目: | ||
if md then | if md then | ||
for k, v in ipairs(trackA) do | for k, v in ipairs(trackA) do | ||
local color = (v[1] % 2 == 0) and ' | local color = (v[1] % 2 == 0) and '' or '' --偶数/奇数で別色指定 | ||
result = result .. '<tr itemprop="track" itemscope itemtype="http://schema.org/MusicRecording" style="background-color:' .. color .. '; vertical-align:top;"><td style="padding-left:0.5em; text-align:right;"><span itemprop="position">' .. (v['#'] or v[1]) .. '</span>.</td><td>' .. (v.title and (' | result = result .. '<tr itemprop="track" itemscope itemtype="http://schema.org/MusicRecording" style="background-color:' .. color .. '; vertical-align:top;"><td style="padding-left:0.5em; text-align:right;"><span itemprop="position">' .. (v['#'] or v[1]) .. '</span>.</td><td>' .. (v.title and ('<span itemprop="name">' .. v.title .. '</span>') or 'タイトルなし') .. (v.note and ('<small>(' .. v.note .. ')</small>') or '') .. '</td>' .. writer(v) .. lyrics(v) .. music(v) .. arranger(v) .. strings_arrange(v) .. brass_arrange(v) .. horn_arrange(v) .. orchestra_arrange(v) .. remix(v) .. singer(v) .. extra(v) .. length(v) .. '</tr>' | ||
end | end | ||
else | else | ||
for k, v in ipairs(trackA) do | for k, v in ipairs(trackA) do | ||
local color = (v[1] % 2 == 0) and ' | local color = (v[1] % 2 == 0) and '' or '' | ||
result = result .. '<tr style="background-color:' .. color .. '; vertical-align:top;"><td style="padding-left:0.5em; text-align:right;">' .. (v['#'] or v[1]) .. '.</td><td>' .. (v.title and (' | result = result .. '<tr style="background-color:' .. color .. '; vertical-align:top;"><td style="padding-left:0.5em; text-align:right;">' .. (v['#'] or v[1]) .. '.</td><td>' .. (v.title and ('' .. v.title .. '') or 'タイトルなし') .. (v.note and ('<small>(' .. v.note .. ')</small>') or '') .. '</td>' .. writer(v) .. lyrics(v) .. music(v) .. arranger(v) .. strings_arrange(v) .. brass_arrange(v) .. horn_arrange(v) .. orchestra_arrange(v) .. remix(v) .. singer(v) .. extra(v) .. length(v) .. '</tr>' | ||
end | end | ||
end | end | ||
| 280行目: | 315行目: | ||
total = '<time datetime="PT' .. min .. 'M' .. sec .. 'S">'.. min .. ':' .. sec .. '</time>' | total = '<time datetime="PT' .. min .. 'M' .. sec .. 'S">'.. min .. ':' .. sec .. '</time>' | ||
--合計時間行追加 | --合計時間行追加 | ||
return '<tr style="text-align:right; font-size:111%;"><th colspan="' .. (col - 1) .. '"><div style="width:7.5em; text-align:left; margin:0 0 0 auto; padding-left:0.5em; white-space:nowrap; font-weight:bold; | return '<tr style="text-align:right; font-size:111%;"><th colspan="' .. (col - 1) .. '"><div style="width:7.5em; text-align:left; margin:0 0 0 auto; padding-left:0.5em; white-space:nowrap; font-weight:bold;>合計時間:</div></th><td style="padding-right:0.5em;">'.. total .. '</td></tr>' | ||
else | else | ||
return '' | return '' | ||
| 297行目: | 332行目: | ||
:wikitext(header() .. body() .. footer()) --tableタグ内 | :wikitext(header() .. body() .. footer()) --tableタグ内 | ||
:attr({class = 'tracklist', id = args.id or ''}) | :attr({class = 'tracklist', id = args.id or ''}) | ||
:cssText('display:block; max-width:100%; width:auto; border-spacing:0px; border-collapse:collapse; padding:0.2em; font-size:90%; text-align:left;') | :cssText('display:block; max-width:100%; width:auto; border-spacing:0px; border-collapse:collapse; padding:0.2em; font-size:90%; text-align:left; vertical-align: middle;') | ||
if collapsed then | if collapsed then | ||
--折りたたみ表示追加指定 | --折りたたみ表示追加指定 | ||
| 308行目: | 343行目: | ||
end | end | ||
return tostring(table) | return tostring(table) | ||
end | |||
-- calc_columns 関数に新しい変数に関する表示可否判定のロジックを追加 | |||
local function calc_columns() | |||
local col = 2 -- #, タイトル | |||
-- ... | |||
if credits.strings_arrange then col = col + 1 end | |||
if credits.brass_arrange then col = col + 1 end | |||
if credits.horn_arrange then col = col + 1 end | |||
if credits.orchestra_arrange then col = col + 1 end | |||
if credits.remix then col = col + 1 end | |||
if credits.singer then col = col + 1 end | |||
return col | |||
end | |||
-- ... | |||
-- calc_width 関数に新しい変数に関する列幅の計算ロジックを追加 | |||
local function calc_width() | |||
local width = {} | |||
-- ... | |||
if not credits.strings_arrange then col = col + 1 end | |||
if not credits.brass_arrange then col = col + 1 end | |||
if not credits.horn_arrange then col = col + 1 end | |||
if not credits.orchestra_arrange then col = col + 1 end | |||
if not credits.singer then col = col + 1 end | |||
if not credits.remix then col = col + 1 end | |||
return width | |||
end | end | ||
return p | return p | ||