Меню
Главная
Случайная статья
Настройки
|
Содержание
Функции
NameByNum
Возвращает название линии Московского метрополитена (без слова "линия", если таковое присутствует). Параметр - номер линии или сокращение её названия (см. ниже).
ColorByNum
Возвращает цвет линии (наиболее близкий к официальной схеме). Параметр - номер линии или сокращение её названия (см. ниже).
interchange
Возвращает иконку с номером линии и, в зависимости от параметров, название линии или станции пересадки. Подробнее см. {{MOSMETRO icon}}.
Параметры:
line — номер или сокращение названия линии
size — размер иконки
station_dabbed — название статьи о станции пересадки
station — станция пересадки без уточнения
CPIC — непустое значение для кроссплатформенной пересадки
text , alt , small , style — так же, как в
Линия |
NameByNum |
ColorByNum |
|
1 |
Сокольническая |
ED1B35 |
@1
|
2 |
Замоскворецкая |
44B85C |
|
3 |
Арбатско-Покровская |
0078BF |
|
4 |
Филёвская |
19C1F3 |
|
4А |
|
bgcolor=# style="color:white" | |
|
5 |
Кольцевая |
894E35 |
|
6 |
Калужско-Рижская |
F58631 |
|
7 |
Таганско-Краснопресненская |
8E479C |
|
8 |
Калининско-Солнцевская |
FFCB31 |
|
8А |
|
bgcolor=# style="color:black" | |
|
9 |
Серпуховско-Тимирязевская |
A1A2A3 |
|
10 |
Люблинско-Дмитровская |
B3D445 |
|
11 |
Каховская |
79CDCD |
@11
|
11А |
|
bgcolor=# style="color:white" | |
|
12 |
Бутовская |
ACBFE1 |
@12
|
13 |
Кожуховская |
F09E36 |
13
|
14 |
|
bgcolor=# style="color:black" | |
@14
|
15 |
|
bgcolor=# style="color:white" | |
@15
|
16 |
|
bgcolor=# style="color:white" | |
@16
|
17 |
' |
bgcolor=# style="color:white" | |
@17
|
18 |
' |
bgcolor=# style="color:white" | |
@18
|
D1 |
|
bgcolor=# style="color:white" | |
@D1
|
D2 |
|
bgcolor=# style="color:white" | |
@D2
|
D3 |
|
bgcolor=# style="color:white" | |
@D3
|
D4 |
|
bgcolor=# style="color:white" | |
@D4
|
D4А |
|
bgcolor=# style="color:white" | |
@D4А
|
D5 |
' |
bgcolor=# style="color:white" | |
@D5
|
0 |
остальные линии |
bgcolor=# style="color:white" | |
—
|
В «8А», «11А» и «D4А» буква А — кириллическая.
Во избежание поломок страниц, использующих этот модуль, экспериментируйте в песочнице (создать) или песочнице для модулей. Пожалуйста, добавляйте категории на подстраницу /doc. Подстраницы этого модуля.
local i18n = {
NAMES = {
['1'] = 'Сокольническая',
['2'] = 'Замоскворецкая',
['3'] = 'Арбатско-Покровская',
['4'] = 'Филёвская',
['5'] = 'Кольцевая',
['6'] = 'Калужско-Рижская',
['7'] = 'Таганско-Краснопресненская',
['8'] = 'Калининско-Солнцевская',
['9'] = 'Серпуховско-Тимирязевская',
['10'] = 'Люблинско-Дмитровская',
['11'] = 'Каховская',
['12'] = 'Бутовская',
['ТПК']= 'Третий пересадочный контур',
['КожЛ']='Кожуховская',
['М1'] = 'Московский монорельс',
},
html = {
icon_fmt = '<span title="%s">[[File:Moskwa Metro Line %s.svg|%spx|%s|link=%s]]</span>', -- parameters: alt, linenum, icon size, alt, link
text_fmt = '[[%s|<span style="display:inline-block;line-height:%spx;height:%spx;font-size:%spx;font-weight:bold;background:#%s;color:white;text-align:center" title="%s"> %s </span>]]', --[[
parameters: link, icon size, icon size, icon size - 3, color, alt, linenum ]]
small = '<span style="font-size:85%%">%s</span>',
style = '<span style="%s">%s</span>',
sortkey = '<span style="display:none" class="sortkey">%s</span>',
},
text = {
transfer = 'Переход на станцию %s %s',
CPIC = 'Кросс-платформенная пересадка на станцию %s %s',
dab = ' (станция метро)',
},
default = {
icon_size = '15'
}
}
i18n.NAMES['СолЛ'] = i18n.NAMES['8']; i18n.NAMES['КСЛ'] = i18n.NAMES['8'];
i18n.NAMES['13'] = i18n.NAMES['КожЛ']; --по умолчанию пока КожЛ будет считаться тринадцатой линией, если что, поменяем.
i18n.NAMES['L1'], i18n.NAMES['Л1'] = i18n.NAMES['12'], i18n.NAMES['12']; --для совместимости с предыдущими версиями шаблонов
i18n.line = function(num) -- название линии в именительном падеже
if num == 'ТПК' then return i18n.NAMES[num]
elseif num == 'М1' then return 'Московская монорельсовая транспортная система'
else return i18n.NAMES[num] .. ' линия'
end
end
i18n.link = function(num) -- ссылка на страницу линии
if num == '5' then return i18n.NAMES[num] .. ' линия (Москва)'
else return i18n.line(num)
end
end
i18n.ofLine = function(num) -- название линии в родительном падеже ("пересадка на станцию ... ... линии")
if num == 'ТПК' or num =='13' then return 'Третьего пересадочного контура'
elseif num == 'М1' then return 'Московского монорельса'
else return mw.ustring.sub(i18n.NAMES[num], 1, -3) .. 'ой линии'
end
end
local COLORS = { -- МЕНЯЙТЕ ЗНАЧЕНИЯ ЦВЕТОВ ТОЛЬКО В СООТВЕТСТВИИ С ОФИЦИАЛЬНОЙ СХЕМОЙ
['1'] = 'ED1B35', -- Сокольническая
['2'] = '44B85C', -- Замоскворецкая
['3'] = '0078BF', -- Арбатско-Покровская
['4'] = '19C1F3', -- Филёвская
['5'] = '894E35', -- Кольцевая
['6'] = 'F58631', -- Калужско-Рижская
['7'] = '8E479C', -- Таганско-Краснопресненская
['8'] = 'FFCB31', -- Калининско-Солнцевская
['9'] = 'A1A2A3', -- Серпуховско-Тимирязевская
['10'] = 'B3D445', -- Люблинско-Дмитровская
['11'] = '79CDCD', -- Каховская
['12'] = 'ACBFE1', -- Бутовская
['13'] = 'F09E36', -- временно
['КожЛ'] = 'CC0066', -- Кожуховская
['М1'] = '2C87C5', -- Московский монорельс
}
COLORS['ТПК'] = COLORS['11'] -- Третий пересадочный контур = Каховская
COLORS['Кожуховская'] = COLORS['КожЛ']
COLORS['СолЛ'] = COLORS['8'] ; COLORS['Солнцевская'] = COLORS['8'] ; COLORS['КСЛ'] = COLORS['8']
COLORS['L1'], COLORS['Л1'] = COLORS['12'], COLORS['12'];
function IconByNum(num)
if num == 'ТПК' or num == 'КожЛ' then return nil
elseif num == 'М1' then return 'M1'
elseif num == 'КСЛ' or num == 'СолЛ' then return '8'
else return num
end
end
local p = {}
function p.ColorByNum(frame)
return COLORS[mw.text.trim(frame.args[1] or '')] or '[[Категория:Википедия:Статьи с неверно заданными параметрами модуля MoscowMetro]]'
end
function p.NameByNum(frame)
return i18n.NAMES[mw.text.trim(frame.args[1] or '')] or '[[Категория:Википедия:Статьи с неверно заданными параметрами модуля MoscowMetro]]'
end
function p.interchange(frame)
local num, station, station_dabbed, CPIC = frame.args['line'] or '', frame.args['station'] or '', frame.args['station_dabbed'] or '', frame.args['CPIC'] or '' ~= ''
local icon_size, alt, text, small, style = frame.args['size'] or '', frame.args['alt'] or '', frame.args['text'] or '', frame.args['small'] or '', frame.args['style'] or ''
local icon, station_stripped
if not i18n.NAMES[num] then return '[[Категория:Википедия:Статьи с неверно заданными параметрами модуля MoscowMetro]]' end
local iconN = IconByNum(num)
if icon_size == '' then
icon_size = i18n.default.icon_size
elseif mw.ustring.sub(icon_size, -2 ) == 'px' then
icon_size = mw.ustring.sub(icon_size, 1, -3 )
end
if alt == '' then
if station ~= '' then
alt = mw.ustring.format(i18n.text[CPIC ~= '' and 'CPIC' or 'transfer'], station, i18n.ofLine(num))
elseif station_dabbed ~= '' then
station_stripped = mw.ustring.match(station_dabbed, '(.-) %(') or station_dabbed
alt = mw.ustring.format(i18n.text[CPIC ~= '' and 'CPIC' or 'transfer'], station_stripped, i18n.ofLine(num))
else
alt = i18n.line(num)
end
elseif station_dabbed ~= '' then
station_stripped = mw.ustring.match(station_dabbed, '(.-) %(') or station_dabbed
end
local link = text == '' and (station_dabbed ~= '' and station_dabbed or (station ~= '' and station .. i18n.text.dab or i18n.link(num))) or i18n.link(num)
if iconN then
icon = mw.ustring.format(i18n.html.sortkey, mw.ustring.len(iconN) == 2 and iconN or '0' .. iconN) .. mw.ustring.format(i18n.html.icon_fmt, alt, iconN, icon_size, alt, link)
else
icon = mw.ustring.format(i18n.html.text_fmt, link, icon_size, icon_size, tonumber(icon_size) - 3, COLORS[num], alt, num)
end
if text == '' then return icon end
local result = ''
if station_dabbed ~= '' then
result = '[[' .. station_dabbed .. '|' .. (station ~= '' and station or station_stripped) .. ']]'
elseif station ~= '' then
result = '[[' .. station .. i18n.text.dab .. '|' .. station .. ']]'
elseif link == mw.title.getCurrentTitle().text then
result = style ~= '' and mw.ustring.format(i18n.html.style, style, text == '2' and i18n.NAMES[num] or i18n.line(num)) or (text == '2' and i18n.NAMES[num] or i18n.line(num))
elseif text == '2' and num ~= 'ТПК' or style ~= '' or num == '5' then
result = '[[' .. link .. '|' .. (style ~= '' and mw.ustring.format(i18n.html.style, style, text == '2' and i18n.NAMES[num] or i18n.line(num)) or (text == '2' and i18n.NAMES[num] or i18n.line(num))) .. ']]'
else
result = '[[' .. link .. ']]'
end
if small ~= '' then result = mw.ustring.format(i18n.html.small, result) end
return (not iconN and station == '' and station_dabbed == '' and '' or icon .. ' ') .. result
end
return p
|
|