Skip to content
This repository was archived by the owner on Mar 29, 2021. It is now read-only.

Commit 52b9439

Browse files
authored
Merge pull request #112 from Idrinth/idrinth
Fixes #110
2 parents 7481919 + 0ae1dd8 commit 52b9439

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

mods/war.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ idrinth.war = {
4545
idrinth.war.element.childNodes[1].childNodes[1].removeChild ( idrinth.war.element.childNodes[1].firstChild.firstChild );
4646
}
4747
}
48-
idrinth.war.element.setAttribute ( 'class', idrinth.ui.getClassesList ( idrinth.war.element.getAttribute ( 'class' ), addClasses, removeClasses ) );
48+
idrinth.ui.updateClassesList ( idrinth.war.element, addClasses, removeClasses );
4949
};
5050
var processJson = function ( data ) {
5151
var magicIgmSrv = 'https://dotd.idrinth.de/static/magic-image-service/';

stable.js

+25-22
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,10 @@ var idrinth = {
481481
function tooltip ( set, element, pos, guilds, platform ) {
482482
idrinth.names.isHovering = false;
483483
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' ], [ ] );
485485
return;
486486
}
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' ] );
488488
element.childNodes[0].setAttribute ( 'href', 'https://dotd.idrinth.de/' + platform + '/summoner/' + set.id + '/' );
489489
element.childNodes[0].innerHTML = set.name;
490490
element.childNodes[1].childNodes[1].innerHTML = set.level + ' (' + set['7day'] + '/week, ' + set['30day'] + '/month)';
@@ -512,7 +512,7 @@ var idrinth = {
512512
idrinth.ui.tooltipTO = window.setTimeout ( idrinth.ui.hideTooltip, delay );
513513
return;
514514
}
515-
idrinth.ui.tooltip.setAttribute ( 'class', idrinth.ui.tooltip.getAttribute ( 'class' ), [ 'idrinth-hide' ], [ ] );
515+
idrinth.ui.updateClassesList ( idrinth.ui.tooltip, [ 'idrinth-hide' ], [ ] );
516516
},
517517
openCloseSettings: function ( ) {
518518
'use strict';
@@ -569,35 +569,38 @@ var idrinth = {
569569
idrinth.alert ( 'The game couldn\'t be reloaded' );
570570
}
571571
},
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 );
582588
}
583-
return list;
589+
return list.join ( ' ' );
584590
};
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 ) );
589592
},
590593
activateTab: function ( name ) {
591594
var head = document.getElementById ( 'tab-activator-' + name ).parentNode.childNodes;
592595
var body = document.getElementById ( 'tab-element-' + name ).parentNode.childNodes;
593596
var setClasses = function ( head, body, name ) {
594597
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' ] );
597600
return;
598601
}
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' ], [ ] );
601604
};
602605
for (var count = 0; count < head.length; count++) {
603606
setClasses ( head[count], body[count], name );

0 commit comments

Comments
 (0)