User:Alexis Jazz/Factotum/modules/Emoji-inator.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Alexis Jazz/Factotum/modules/Emoji-inator. |
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;
}
});