@@ -481,10 +481,10 @@ var idrinth = {
481
481
function tooltip ( set , element , pos , guilds , platform ) {
482
482
idrinth . names . isHovering = false ;
483
483
if ( ! set ) {
484
- idrinth . ui . tooltip . setAttribute ( "class" , idrinth . ui . getClassesList ( idrinth . ui . tooltip . getAttribute ( 'class' ) , [ 'idrinth-hide' ] , [ ] ) ) ;
484
+ idrinth . ui . updateClassesList ( idrinth . ui . tooltip , [ 'idrinth-hide' ] , [ ] ) ;
485
485
return ;
486
486
}
487
- idrinth . ui . tooltip . setAttribute ( "class" , idrinth . ui . getClassesList ( idrinth . ui . tooltip . getAttribute ( 'class' ) , [ ] , [ 'idrinth-hide' ] ) ) ;
487
+ idrinth . ui . updateClassesList ( idrinth . ui . tooltip , [ ] , [ 'idrinth-hide' ] ) ;
488
488
element . childNodes [ 0 ] . setAttribute ( 'href' , 'https://dotd.idrinth.de/' + platform + '/summoner/' + set . id + '/' ) ;
489
489
element . childNodes [ 0 ] . innerHTML = set . name ;
490
490
element . childNodes [ 1 ] . childNodes [ 1 ] . innerHTML = set . level + ' (' + set [ '7day' ] + '/week, ' + set [ '30day' ] + '/month)' ;
@@ -512,7 +512,7 @@ var idrinth = {
512
512
idrinth . ui . tooltipTO = window . setTimeout ( idrinth . ui . hideTooltip , delay ) ;
513
513
return ;
514
514
}
515
- idrinth . ui . tooltip . setAttribute ( 'class' , idrinth . ui . tooltip . getAttribute ( 'class' ) , [ 'idrinth-hide' ] , [ ] ) ;
515
+ idrinth . ui . updateClassesList ( idrinth . ui . tooltip , [ 'idrinth-hide' ] , [ ] ) ;
516
516
} ,
517
517
openCloseSettings : function ( ) {
518
518
'use strict' ;
@@ -569,35 +569,38 @@ var idrinth = {
569
569
idrinth . alert ( 'The game couldn\'t be reloaded' ) ;
570
570
}
571
571
} ,
572
- getClassesList : function ( classString , add , remove ) {
573
- var forceToArray = function ( value ) {
574
- return value && typeof value === 'object' && Array . isArray ( value ) ? value : [ ] ;
575
- } ;
576
- var original = classString . split ( ' ' ) . concat ( forceToArray ( add ) ) ;
577
- var list = [ ] ;
578
- remove = forceToArray ( remove ) ;
579
- var addUnique = function ( list , element , forbidden ) {
580
- if ( list . indexOf ( element ) === - 1 && forbidden . indexOf ( element ) === - 1 ) {
581
- list . push ( element ) ;
572
+ updateClassesList : function ( element , add , remove ) {
573
+ var getClassesList = function ( classString , add , remove ) {
574
+ var forceToArray = function ( value ) {
575
+ return value && typeof value === 'object' && Array . isArray ( value ) ? value : [ ] ;
576
+ } ;
577
+ var original = classString . split ( ' ' ) . concat ( forceToArray ( add ) ) ;
578
+ var list = [ ] ;
579
+ remove = forceToArray ( remove ) ;
580
+ var addUnique = function ( list , element , forbidden ) {
581
+ if ( list . indexOf ( element ) === - 1 && forbidden . indexOf ( element ) === - 1 ) {
582
+ list . push ( element ) ;
583
+ }
584
+ return list ;
585
+ } ;
586
+ for ( var counter = 0 ; counter < original . length ; counter ++ ) {
587
+ list = addUnique ( list , original [ counter ] , remove ) ;
582
588
}
583
- return list ;
589
+ return list . join ( ' ' ) ;
584
590
} ;
585
- for ( var counter = 0 ; counter < original . length ; counter ++ ) {
586
- list = addUnique ( list , original [ counter ] , remove ) ;
587
- }
588
- return list . join ( ' ' ) ;
591
+ element . setAttribute ( 'class' , getClassesList ( element . getAttribute ( 'class' ) , add , remove ) ) ;
589
592
} ,
590
593
activateTab : function ( name ) {
591
594
var head = document . getElementById ( 'tab-activator-' + name ) . parentNode . childNodes ;
592
595
var body = document . getElementById ( 'tab-element-' + name ) . parentNode . childNodes ;
593
596
var setClasses = function ( head , body , name ) {
594
597
if ( head === document . getElementById ( 'tab-activator-' + name ) ) {
595
- head . setAttribute ( 'class' , idrinth . ui . getClassesList ( head . getAttribute ( 'class' ) , [ 'active' ] , [ ] ) ) ;
596
- body . setAttribute ( 'class' , idrinth . ui . getClassesList ( body . getAttribute ( 'class' ) , [ ] , [ 'idrinth-hide' ] ) ) ;
598
+ idrinth . ui . updateClassesList ( head , [ 'active' ] , [ ] ) ;
599
+ idrinth . ui . updateClassesList ( body , [ ] , [ 'idrinth-hide' ] ) ;
597
600
return ;
598
601
}
599
- head . setAttribute ( 'class' , idrinth . ui . getClassesList ( head . getAttribute ( 'class' ) , [ ] , [ 'active' ] ) ) ;
600
- body . setAttribute ( 'class' , idrinth . ui . getClassesList ( body . getAttribute ( 'class' ) , [ 'idrinth-hide' ] , [ ] ) ) ;
602
+ idrinth . ui . updateClassesList ( head , [ ] , [ 'active' ] ) ;
603
+ idrinth . ui . updateClassesList ( body , [ 'idrinth-hide' ] , [ ] ) ;
601
604
} ;
602
605
for ( var count = 0 ; count < head . length ; count ++ ) {
603
606
setClasses ( head [ count ] , body [ count ] , name ) ;
0 commit comments