Bu modul müzakirələrdə müxtəlif emojiləri göstərmək üçün istifadə edilə bilər. Təqdim olunan emojilərin siyahısı data səhifəsindədir. Bütün emojilər bütün dəstlər tərəfindən eyni dərəcədə dəstəklənmir.

Emojiləri istifadə etmək üçün {{-:}} şablonundan istifadə edin, modulun özünün funksionallığı burada nümayiş etdirilir.

Parametrlər redaktə

Çağırış mexanizmi: {{#invoke:Emoji|render}}. Modulu çağırarkən aşağıdakı parametrlərdən istifadə edilə bilər ({{#invoke}} əlavə olunur; defolt parametlər kursivlə göstərilib):

Defolt emoji görünüşü:: 🙂

İstifadə redaktə

İstifadə nümunələri:

  • Emojinin adı ilə:
    😎
    {{#invoke:Emoji|render|name=sunglasses}}
  • Emojinin özü ilə:
    👍
    {{#invoke:Emoji|render|name=👍}}
  • Ölçüsünü dəyişmək:
    😡
    {{#invoke:Emoji|render|name=rage|size=24}}
  • Dəsti dəyişmək:
    😢
    {{#invoke:Emoji|render|name=cry|size=32|theme=twitter}}
  • Şəkilsiz:
    😂
    {{#invoke:Emoji|render|name=joy|size=48|theme=none}}

Xətalar redaktə

Emoji dəstində seçilmiş emoji üçün uyğun fayl yoxdursa, "şəkil yoxdur" seçimi emojinin dəstdə olmadığına işarə ilə göstərilir:

  • 🇳🇴{{#invoke:Emoji|render|name=flag-no|theme=noto}};
  • 😡👍{{#invoke:Emoji|render|name=😡👍}}

-- Модуль для показа эмодзи в различных конфигурациях

-- Данные эмодзи-кодов 8-)
local emoji = mw.loadData('Module:Emoji/data');
local p = {};

-- Проверка пустоты параметра :-O
local function isEmpty(s)
	return s == nil or s == ''
end

-- Вывод названия файла для показа эмодзи :-3
local function fileName(code, theme)
	-- Стиль Noto требует другого форматирования двойных эмодзи >:-(
	if theme == 'noto' then
		code = code:gsub('%-',' ')
	end

	-- Темы и их сокращения <3
	local themes = {
		['firefox'] = 'Fxemoji u' .. string.upper(code),
		['noto'] = 'Noto Emoji Pie' .. string.lower(code),
		['one'] = 'Emojione ' .. string.upper(code),
		['twitter'] = 'Twemoji12 ' .. string.lower(code),
	}
	themes['fx'] = themes['firefox'];
	themes['tw'] = themes['twitter'];

	return themes[theme]
end

-- Вывод HTML-кода соответствующих эмодзи D-:
local function toHTML(code)
	local r = ''
	if string.match(code,'-') then
		local spl = mw.text.split(code,'-',true)
		r = '&#x' .. spl[1] .. ';' .. '&#x' .. spl[2] .. ';'
	else
		r = '&#x' .. code .. ';'
	end

	return r
end

-- Получение ключей по значениям {-:
local function getKey(t, value)
	for k, v in pairs(t) do
		if v == value then return k end
	end
	return nil
end

-- Получение HTML-мнемоники из эмодзи :=|
local function getCode(str)
	local r = '';
	for i = 1, mw.ustring.len(str) do
		r = r .. string.format('%04x', mw.ustring.codepoint(str, i, (i+1))) .. '-';
	end
	return r:sub(1,-2)
end

-- Вывод названия файла ;-1
function p.fileName(frame)
	local f = frame.args
	local name = f.name
	local theme = f.theme
	local code = emoji[name]
	
	if isEmpty(code) then
		if getKey(emoji,name) ~= nil then
			code = name
		else
			code = getCode(name)
		end
	end
	
	return fileName(code, theme)
end

-- Вывод шаблона с эмодзи ;-)
function p.render(frame)
	local f = frame.args
	local name = f.name
	local size = f.size
	local theme = f.theme
	
	-- Выбор стандартного эмодзи :-)
	if isEmpty(name) then
		name = 'slightly_smiling_face'
	end

	-- Выбор стандартного размера c-:
	if isEmpty(size) then
		size = '16'
	end

	-- Выбор темы по умолчанию :->
	if isEmpty(theme) then
		theme = 'one'
	end
	
	local code = emoji[name]
	if isEmpty(code) then
		if getKey(emoji,name) ~= nil then
			code = name
		else
			code = getCode(name)
		end
	end
	local span = mw.html.create():tag('span')

	span:addClass('emoji')
	span:cssText('font-size:' .. size .. 'px; font-family:"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol",sans-serif; line-height:' .. size .. 'px;')

	-- Названия тем :-D
	local themes = {
		['firefox'] = 'Firefox Emoji',
		['noto'] = 'Noto Color Emoji',
		['one'] = 'EmojiOne',
		['twitter'] = 'Twitter Emoji',
	}
	themes['fx'] = themes['firefox'];
	themes['tw'] = themes['twitter'];

	-- Вывод символа или символов или файла в зависимости от темы :-*
	if theme == 'none' then
		span:attr('title',name)
		span:wikitext(toHTML(code))
	else
		local file = fileName(code, theme)
		if not isEmpty(file) then
			file = string.format('Fayl:%s.svg', file)
		end
		
		if not isEmpty(file) and mw.title.new(file).fileExists then
			span:wikitext(string.format('[[%s|%spx|%s|alt=%s]]', file, size, name, toHTML(code)))
		else
			span:attr('title',string.format('Seçilmiş %s emojisi dəstdə mövcud deyil',name,themes[theme]))
			span:wikitext(toHTML(code))
		end
	end

	return tostring(span:done())
end

return p