6369
редагувань
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
| Рядок 973: | Рядок 973: | ||
$('.content .mw-parser-output .wikitable').each(function () { | $('.content .mw-parser-output .wikitable').each(function () { | ||
processRatingTable($(this)); | processRatingTable($(this)); | ||
}); | |||
}); | |||
// ============================================================ | |||
// ПЕРІОД TABLE — medals for top 3 (has №, PLAYERS/Гравець, Σ cols) | |||
// ============================================================ | |||
$(function () { | |||
// Detect Період-style table: № | name | Σ | many season cols | |||
// Headers[0]='№', headers[1]='PLAYERS' or 'Гравець', headers[2]='Σ' or 'І' | |||
$('.content .mw-parser-output .wikitable').each(function () { | |||
var $t = $(this); | |||
if ($t.hasClass('mcc-rating-table')) return; // already processed | |||
var $headerRow = $t.find('tr').first(); | |||
var $ths = $headerRow.find('th'); | |||
if (!$ths.length) return; | |||
var h0 = $ths.eq(0).text().trim(); | |||
var h1 = $ths.eq(1).text().trim(); | |||
// Період / Статистика / Фіналіст pattern: № + name + many cols | |||
var isWideRank = h0 === '№' && $ths.length > 5; | |||
if (!isWideRank) return; | |||
var $rows = $t.find('tbody tr').filter(function () { | |||
return $(this).find('td').length >= 2; | |||
}); | |||
if (!$rows.length) return; | |||
// Add medals for top 3 | |||
$rows.each(function () { | |||
var $tds = $(this).find('td'); | |||
var raw = $tds.eq(0).text().trim(); | |||
var n = parseInt(raw); | |||
if (isNaN(n) || n < 1 || n > 3) return; | |||
$tds.eq(0).html('<span class="mcc-rank-' + n + '">' + n + '</span>'); | |||
}); | |||
}); | |||
}); | |||
// ============================================================ | |||
// SEASON FINAL TABLE — add .mcc-final-table + row numbering | |||
// Detects: Пан/Пані | І | П | ДБ | Дія | Σ (no № column) | |||
// ============================================================ | |||
$(function () { | |||
$('.content .mw-parser-output .wikitable').each(function () { | |||
var $t = $(this); | |||
if ($t.hasClass('mcc-rating-table')) return; | |||
var $ths = $t.find('tr').first().find('th'); | |||
if (!$ths.length) return; | |||
var h0 = $ths.eq(0).text().trim(); | |||
var h1 = $ths.eq(1).text().trim(); | |||
var h_last = $ths.last().text().trim(); | |||
// Final table: Пан/Пані | І | П | ДБ | Дія | Σ | |||
var isFinal = (h0 === 'Пан/Пані' || h0 === 'Пан' || h0 === 'Гравець') | |||
&& (h1 === 'І' || h1 === 'Ігри') | |||
&& (h_last === 'Σ'); | |||
if (!isFinal) return; | |||
$t.addClass('mcc-final-table'); | |||
// Prepend № header | |||
$t.find('tr').first().prepend('<th style="width:36px;text-align:center">#</th>'); | |||
// Number each data row | |||
var n = 1; | |||
$t.find('tbody tr').each(function () { | |||
var $tds = $(this).find('td'); | |||
if (!$tds.length) return; | |||
var prefix = ''; | |||
if (n === 1) prefix = '<span class="mcc-rank-1">1</span>'; | |||
else if (n === 2) prefix = '<span class="mcc-rank-2">2</span>'; | |||
else if (n === 3) prefix = '<span class="mcc-rank-3">3</span>'; | |||
else prefix = n; | |||
$(this).prepend('<td style="text-align:center;padding:10px 8px">' + prefix + '</td>'); | |||
n++; | |||
}); | |||
}); | }); | ||
}); | }); | ||