@@ -27,7 +27,7 @@ let Emotes = {
2727 string . html ( html ) ;
2828 } ,
2929 buildRegex : function ( ) {
30- let emoteKeyList = Array . from ( this . emoteList . keys ( ) ) . sort ( function ( a , b ) {
30+ let emoteKeyList = Array . from ( this . emoteList . keys ( ) ) . sort ( function ( a , b ) {
3131 return b . length - a . length ;
3232 } ) ;
3333 var stringlist = Emotes . escapeRegExp ( emoteKeyList . join ( '|' ) ) ;
@@ -40,10 +40,17 @@ let Emotes = {
4040 Emotes . emote_list_element . empty ( ) ;
4141 } ,
4242 load : function ( ) {
43- $ . getJSON ( this . emoteset_json , function ( setlist ) {
44- setlist . forEach ( function ( set ) {
45- $ . getJSON ( "Emotes/" + set ) . then ( function ( json ) {
46- Emotes . parseJson ( json ) ;
43+ $ . getJSON ( this . emoteset_json , function ( setlist ) {
44+ setlist . forEach ( function ( set ) {
45+ $ . getJSON ( "Emotes/" + set ) . then ( function ( json ) {
46+ if ( Array . isArray ( json ) ) {
47+ json . forEach ( function ( item ) {
48+ Emotes . parseJson ( item ) ;
49+ } ) ;
50+ }
51+ else {
52+ Emotes . parseJson ( json ) ;
53+ }
4754 } ) ;
4855 } ) ;
4956 } ) ;
@@ -52,9 +59,17 @@ let Emotes = {
5259 }
5360 } ,
5461 addRemoteEmote : function ( jsonString ) {
55- Emotes . parseJson ( JSON . parse ( jsonString ) ) ;
62+ let json = JSON . parseJson ( jsonString ) ;
63+ if ( Array . isArray ( json ) ) {
64+ json . forEach ( function ( item ) {
65+ Emotes . parseJson ( item ) ;
66+ } ) ;
67+ }
68+ else {
69+ Emotes . parseJson ( json ) ;
70+ }
5671 } ,
57- parseJson : function ( json ) {
72+ parseJson : function ( json ) {
5873 let set_element = $ ( '<div>' , {
5974 class : 'emoteset' ,
6075 'data-name' : json . setname
@@ -64,7 +79,7 @@ let Emotes = {
6479 class : 'emote-container'
6580 } ) ;
6681 set_element . append ( emote_container ) ;
67- json . emoticons . forEach ( function ( emote ) {
82+ json . emoticons . forEach ( function ( emote ) {
6883 let e = {
6984 name : `${ json . pathbase } ${ emote . name } ${ json . pathappend } ` ,
7085 code : emote . code ,
@@ -77,7 +92,7 @@ let Emotes = {
7792 alt : emote . code ,
7893 'data-key' : emote . code
7994 } )
80- . click ( function ( e ) {
95+ . click ( function ( e ) {
8196 emoteClicked ( $ ( this ) . data ( 'key' ) , e . shiftKey ) ;
8297 } ) ;
8398 emote_container . append ( emote_img ) ;
@@ -87,7 +102,7 @@ let Emotes = {
87102 Emotes . buildRegex ( ) ;
88103 this . emote_list_element . append ( set_element ) ;
89104 } ,
90- escapeRegExp : function ( str ) {
105+ escapeRegExp : function ( str ) {
91106 return str . replace ( / [ \- \[ \] \/ \{ \} \( \) \* \+ \? \. \\ \^ \$ ] / g, "\\$&" ) ;
92107 }
93108} ;
0 commit comments