Jump to content

User:Alexis Jazz/Factotum/modules/Emoji-inator.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the โ‡ง Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
if ( typeof window.FTTModules == 'undefined' ) { window.FTTModules=[]; }
/*globals $:false,mw:false,OO:false*/
window.FTTModules.push({'load':['afterOpenForm','processComment'],'afterOpenFormFunc':function(emoInt){
	FTT.MD.emoji = {};
	FTT.MD.emoji.div = document.createElement('div');
	FTT.MD.emoji.div.id = 'FTTEmojiContainer';
	FTT.MD.emoji.divAll = document.createElement('div');
	FTT.MD.emoji.divAll.id = 'FTTEmojiButtons';
	FTT.MD.emoji.emojis = [ //descriptions copied from [[:Emoticons (Unicode block)]] (CC BY-SA 3.0) which is partially based on https://unicode.org/Public/UNIDATA/emoji/emoji-data.txt (https://www.unicode.org/license.txt)
		['๐Ÿ˜€',new RegExp(':\\-D','g'),'grinning face'],
		['๐Ÿ˜',null,'grinning face with smiling eyes'],
		['๐Ÿ˜‚',null,'face with tears of joy'],
		['๐Ÿ˜ƒ',new RegExp(':-\\)','g'),'smiling face with open mouth (c.f. โ˜บ)'],
		['๐Ÿ˜„',null,'smiling face with open mouth and smiling eyes'],
		['๐Ÿ˜…',null,'smiling face with open mouth and cold sweat'],
		['๐Ÿ˜†',null,'smiling face with open mouth and tightly-closed eyes'],
		['๐Ÿ˜‡',null,'smiling face with halo '],
		['๐Ÿ˜ˆ',null,'smiling face with horns (c.f. ๐Ÿ‘ฟ "imp")'],
		['๐Ÿ˜‰',new RegExp(';-\\)','g'),'winking face'],
		['๐Ÿ˜Š',null,'smiling face with smiling eyes'],
		['๐Ÿ˜‹',null,'face savouring delicious food'],
		['๐Ÿ˜Œ',null,'relieved face'],
		['๐Ÿ˜',null,'smiling face with heart-shaped eyes'],
		['๐Ÿ˜Ž',null,'smiling face with sunglasses'],
		['๐Ÿ˜',null,'smirking face'],
		['๐Ÿ˜',null,'neutral face (also used for "west wind" ่ฅฟ in some Mahjong annotation)'],
		['๐Ÿ˜‘',null,'expressionless face'],
		['๐Ÿ˜’',null,'unamused face'],
		['๐Ÿ˜“',null,'face with cold sweat'],
		['๐Ÿ˜”',null,'pensive face'],
		['๐Ÿ˜•',null,'confused face'],
		['๐Ÿ˜–',null,'confounded face'],
		['๐Ÿ˜—',null,'kissing face'],
		['๐Ÿ˜˜',null,'face throwing a kiss'],
		['๐Ÿ˜™',null,'kissing face with smiling eyes'],
		['๐Ÿ˜š',null,'kissing face with closed eyes'],
		['๐Ÿ˜›',null,'face with stuck-out tongue'],
		['๐Ÿ˜œ',null,'face with stuck-out tongue and winking eye'],
		['๐Ÿ˜',null,'face with stuck-out tongue and tightly-closed eyes'],
		['๐Ÿ˜ž',null,'disappointed face'],
		['๐Ÿ˜Ÿ',null,'worried face'],
		['๐Ÿ˜ ',null,'angry face'],
		['๐Ÿ˜ก',null,'pouting face'],
		['๐Ÿ˜ข',null,'crying face'],
		['๐Ÿ˜ฃ',null,'persevering face'],
		['๐Ÿ˜ค',null,'Unicode: face with look of triumph, Apple: huffing with anger face'],
		['๐Ÿ˜ฅ',null,'disappointed but relieved face'],
		['๐Ÿ˜ฆ',null,'frowning face with open mouth'],
		['๐Ÿ˜ง',null,'anguished face'],
		['๐Ÿ˜จ',null,'fearful face'],
		['๐Ÿ˜ฉ',null,'weary face'],
		['๐Ÿ˜ช',null,'sleepy face'],
		['๐Ÿ˜ซ',null,'tired face'],
		['๐Ÿ˜ฌ',null,'grimacing face'],
		['๐Ÿ˜ญ',null,'loudly crying face'],
		['๐Ÿ˜ฎ',null,'face with open mouth'],
		['๐Ÿ˜ฏ',null,'hushed face'],
		['๐Ÿ˜ฐ',null,'face with open mouth and cold sweat'],
		['๐Ÿ˜ฑ',null,'face screaming in fear'],
		['๐Ÿ˜ฒ',null,'astonished face'],
		['๐Ÿ˜ณ',null,'flushed face'],
		['๐Ÿ˜ด',null,'sleeping face'],
		['๐Ÿ˜ต',null,'dizzy face'],
		['๐Ÿ˜ถ',null,'face without mouth (c.f. โš‡ "white circle with two dots")'],
		['๐Ÿ˜ท',null,'face with medical mask'],
		['๐Ÿ˜ธ',null,'grinning cat face with smiling eyes'],
		['๐Ÿ˜น',null,'cat face with tears of joy'],
		['๐Ÿ˜บ',null,'smiling cat face with open mouth'],
		['๐Ÿ˜ป',null,'smiling cat face with heart-shape eyes'],
		['๐Ÿ˜ผ',null,'cat face with wry smile'],
		['๐Ÿ˜ฝ',null,'kissing cat face with closed eyes'],
		['๐Ÿ˜พ',null,'pouting cat face'],
		['๐Ÿ˜ฟ',null,'crying cat face '],
		['๐Ÿ™€',null,'weary cat face'],
		['๐Ÿ™',null,'slightly frowning face'],
		['๐Ÿ™‚',null,'slightly smiling face'],
		['๐Ÿ™ƒ',null,'upside-down face'],
		['๐Ÿ™„',null,'face with rolling eyes'],
		['๐Ÿ™…',null,'face with "no good" gesture, with lower arms crossed, derived from the japanese gesture for "no". Intended as gender-neutral but represented as a woman on most platforms (Apple name: "Woman Gesturing No").'],
		['๐Ÿ™†',null,'face with "ok" gesture, described as a person with arms raised above the head forming a "circle", interpreted as "OK sign" (derived from the japanese gesture for "OK"). Intended as gender-neutral but represented as a woman on most platforms (Apple name: "Woman Gesturing OK").'],
		['๐Ÿ™‡',null,'person bowing (dogeza), depicted as a man on most platforms (Apple name: "Man Bowing")'],
		['๐Ÿ™ˆ',null,'see-no-evil monkey'],
		['๐Ÿ™‰',null,'hear-no-evil monkey'],
		['๐Ÿ™Š',null,'speak-no-evil monkey'],
		['๐Ÿ™‹',null,'happy person raising one hand, a person raising one hand as if to answer a question, intended as gender-neutral but represented as a woman on most platforms (Apple name: "Happy Woman Raising One Hand")'],
		['๐Ÿ™Œ',null,'person raising both hands in celebration, on many platforms depicted as just the raised hands (Apple name: "Hands Raised in Celebration")'],
		['๐Ÿ™',null,'person frowning'],
		['๐Ÿ™Ž',null,'person with pouting face'],
		['๐Ÿ™',null,'person with folded hands (to indicate variously sorrow, regret, pleading, praying, bowing, thanking). In most platforms depicted as just the hand, pressed together but not folded (Apple name: "Hands Pressed Together").']
	];
	FTT.MD.emoji.buttons = [];
	FTT.MD.emoji.makeButton = function(int,emoji,desc){
		FTT.MD.emoji.buttons[int] = new OO.ui.ButtonWidget({label:emoji,title:desc,framed:false});
		FTT.MD.emoji.buttons[int].$button.attr('aria-label',desc);
		FTT.MD.emoji.buttons[int].on('click',function(){ console.log(this);FTT.insertMarkup('cI','',emoji+' ','',FTT.focusNode,FTT.focusOffset,FTT.anchorNode,FTT.anchorOffset);});
	};
	for(emoInt=0;emoInt<FTT.MD.emoji.emojis.length;emoInt++) {
		FTT.MD.emoji.makeButton(emoInt,FTT.MD.emoji.emojis[emoInt][0],FTT.MD.emoji.emojis[emoInt][1]);
	}
	FTT.MD.emoji.horizontalLayout = new OO.ui.HorizontalLayout({items:FTT.MD.emoji.buttons});
	FTT.MD.emoji.divAll.append(FTT.MD.emoji.horizontalLayout.$element[0]);
	FTT.insertAfter($('#FTTCustomInserts')[0],FTT.MD.emoji.divAll);
	if ( ! FTT.MD.emoji.addedCSS ) {
		mw.util.addCSS('#FTTEmojiButtons .oo-ui-buttonElement-frameless.oo-ui-labelElement:first-child{margin-left:unset !important} #FTTEmojiButtons .oo-ui-buttonElement-button:active{border:none !important} #FTTEmojiButtons .oo-ui-buttonElement-frameless.oo-ui-labelElement > .oo-ui-buttonElement-button{border-width:0 !important}');
		FTT.MD.emoji.addedCSS = 1;
	}
	},processCommentFunc:function(text1,emoInt2){
		if ( ! text1 || ! FTT.MD.emoji ) {
			return text1;
		}
		for(emoInt2=0;emoInt2<FTT.MD.emoji.emojis.length;emoInt2++) {
			if ( FTT.MD.emoji.emojis[emoInt2][1] ) {
				text1 = text1.replace(FTT.MD.emoji.emojis[emoInt2][1],FTT.MD.emoji.emojis[emoInt2][0]);
			}
		}
		return text1;
	}
});