11.314
suntingan
(←Membuat halaman berisi 'local p = {} local default_color = '#F8F9FA' local categories = { party_not_in_list = 'Category:Pages using Political party with unknown party', shortname_not_in_list = 'Category:Pages using Political party with missing shortname', color_not_in_list = 'Category:Pages using Political party with missing color', } local function create_error(error_message) return string.format('<strong class="error">%s</strong>', error_message) end local func...') |
Tidak ada ringkasan suntingan |
||
| (6 revisi perantara oleh pengguna yang sama tidak ditampilkan) | |||
| Baris 4: | Baris 4: | ||
local categories = { | local categories = { | ||
party_not_in_list = '[[Category: | party_not_in_list = '[[Category:Halaman menggunakan Partai politik dengan partai tak dikenal]]', | ||
shortname_not_in_list = '[[Category: | shortname_not_in_list = '[[Category:Halaman menggunakan Partai politik yang tak punya nama penyebutan]]', | ||
color_not_in_list = '[[Category: | color_not_in_list = '[[Category:Halaman menggunakan Partai politik dengan warna yang tak dikenal]]', | ||
} | } | ||
| Baris 45: | Baris 45: | ||
local party = stripToNil(args[1]) | local party = stripToNil(args[1]) | ||
local out_type = stripToNil(args[2]) | local out_type = stripToNil(args[2]) | ||
-- if out_type == 'colour' then | |||
-- out_type = 'warna' | |||
-- end | |||
if out_type == 'colour' then | if out_type == 'colour' then | ||
out_type = ' | out_type = 'warna' | ||
end | end | ||
local index = getFirstLetter(party) | local index = getFirstLetter(party) | ||
-- Load data from submodule | -- Load data from submodule | ||
local data = mw.loadData('Module: | local data = mw.loadData('Module:Partai politik/' .. index) | ||
local data_all = data.full | local data_all = data.full | ||
| Baris 61: | Baris 64: | ||
else | else | ||
index = getFirstLetter(party_alt) | index = getFirstLetter(party_alt) | ||
data = mw.loadData('Module: | data = mw.loadData('Module:Partai politik/' .. index) | ||
party_info = data.full[party_alt] | party_info = data.full[party_alt] | ||
end | end | ||
| Baris 73: | Baris 76: | ||
-- * No shortname/abbrev - return first non-blank of abbrev->shortname->input | -- * No shortname/abbrev - return first non-blank of abbrev->shortname->input | ||
if not party_info then | if not party_info then | ||
if out_type == ' | -- if out_type == 'color' then | ||
if out_type == 'warna' then | |||
return args.error or default_color | return args.error or default_color | ||
else | else | ||
| Baris 81: | Baris 85: | ||
local return_value = party_info[out_type] | local return_value = party_info[out_type] | ||
if return_value == "" then | if return_value == "" then | ||
if out_type == ' | -- if out_type == 'color' then | ||
if out_type == 'warna' then | |||
return args.error or create_error("Value not in template. Please request that it be added.") | return args.error or create_error("Value not in template. Please request that it be added.") | ||
elseif out_type == ' | elseif out_type == 'singkatan' then | ||
if party_info.shortname ~= "" then | if party_info.shortname ~= "" then | ||
return party_info.shortname | return party_info.shortname | ||
| Baris 90: | Baris 95: | ||
end | end | ||
elseif out_type == 'shortname' then | elseif out_type == 'shortname' then | ||
if party_info. | if party_info.singkatan ~= "" then | ||
return party_info. | return party_info.singkatan | ||
else | else | ||
return party | return party | ||
| Baris 100: | Baris 105: | ||
end | end | ||
if out_type == ' | -- if out_type == 'color' and string.find(return_value, '#') then | ||
if out_type == 'warna' and string.find(return_value, '#') then | |||
return_value = string.gsub(return_value, '#', '#') | return_value = string.gsub(return_value, '#', '#') | ||
end | end | ||