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

Commit

Permalink
Merge pull request #112 from Idrinth/idrinth
Browse files Browse the repository at this point in the history
Fixes #110
  • Loading branch information
Idrinth authored Sep 5, 2016
2 parents 7481919 + 0ae1dd8 commit 52b9439
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion mods/war.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ idrinth.war = {
idrinth.war.element.childNodes[1].childNodes[1].removeChild ( idrinth.war.element.childNodes[1].firstChild.firstChild );
}
}
idrinth.war.element.setAttribute ( 'class', idrinth.ui.getClassesList ( idrinth.war.element.getAttribute ( 'class' ), addClasses, removeClasses ) );
idrinth.ui.updateClassesList ( idrinth.war.element, addClasses, removeClasses );
};
var processJson = function ( data ) {
var magicIgmSrv = 'https://dotd.idrinth.de/static/magic-image-service/';
Expand Down
47 changes: 25 additions & 22 deletions stable.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,10 @@ var idrinth = {
function tooltip ( set, element, pos, guilds, platform ) {
idrinth.names.isHovering = false;
if ( !set ) {
idrinth.ui.tooltip.setAttribute ( "class", idrinth.ui.getClassesList ( idrinth.ui.tooltip.getAttribute ( 'class' ), [ 'idrinth-hide' ], [ ] ) );
idrinth.ui.updateClassesList ( idrinth.ui.tooltip, [ 'idrinth-hide' ], [ ] );
return;
}
idrinth.ui.tooltip.setAttribute ( "class", idrinth.ui.getClassesList ( idrinth.ui.tooltip.getAttribute ( 'class' ), [ ], [ 'idrinth-hide' ] ) );
idrinth.ui.updateClassesList ( idrinth.ui.tooltip, [ ], [ 'idrinth-hide' ] );
element.childNodes[0].setAttribute ( 'href', 'https://dotd.idrinth.de/' + platform + '/summoner/' + set.id + '/' );
element.childNodes[0].innerHTML = set.name;
element.childNodes[1].childNodes[1].innerHTML = set.level + ' (' + set['7day'] + '/week, ' + set['30day'] + '/month)';
Expand Down Expand Up @@ -512,7 +512,7 @@ var idrinth = {
idrinth.ui.tooltipTO = window.setTimeout ( idrinth.ui.hideTooltip, delay );
return;
}
idrinth.ui.tooltip.setAttribute ( 'class', idrinth.ui.tooltip.getAttribute ( 'class' ), [ 'idrinth-hide' ], [ ] );
idrinth.ui.updateClassesList ( idrinth.ui.tooltip, [ 'idrinth-hide' ], [ ] );
},
openCloseSettings: function ( ) {
'use strict';
Expand Down Expand Up @@ -569,35 +569,38 @@ var idrinth = {
idrinth.alert ( 'The game couldn\'t be reloaded' );
}
},
getClassesList: function ( classString, add, remove ) {
var forceToArray = function ( value ) {
return value && typeof value === 'object' && Array.isArray ( value ) ? value : [ ];
};
var original = classString.split ( ' ' ).concat ( forceToArray ( add ) );
var list = [ ];
remove = forceToArray ( remove );
var addUnique = function ( list, element, forbidden ) {
if ( list.indexOf ( element ) === -1 && forbidden.indexOf ( element ) === -1 ) {
list.push ( element );
updateClassesList: function ( element, add, remove ) {
var getClassesList = function ( classString, add, remove ) {
var forceToArray = function ( value ) {
return value && typeof value === 'object' && Array.isArray ( value ) ? value : [ ];
};
var original = classString.split ( ' ' ).concat ( forceToArray ( add ) );
var list = [ ];
remove = forceToArray ( remove );
var addUnique = function ( list, element, forbidden ) {
if ( list.indexOf ( element ) === -1 && forbidden.indexOf ( element ) === -1 ) {
list.push ( element );
}
return list;
};
for (var counter = 0; counter < original.length; counter++) {
list = addUnique ( list, original[counter], remove );
}
return list;
return list.join ( ' ' );
};
for (var counter = 0; counter < original.length; counter++) {
list = addUnique ( list, original[counter], remove );
}
return list.join ( ' ' );
element.setAttribute ( 'class', getClassesList ( element.getAttribute ( 'class' ), add, remove ) );
},
activateTab: function ( name ) {
var head = document.getElementById ( 'tab-activator-' + name ).parentNode.childNodes;
var body = document.getElementById ( 'tab-element-' + name ).parentNode.childNodes;
var setClasses = function ( head, body, name ) {
if ( head === document.getElementById ( 'tab-activator-' + name ) ) {
head.setAttribute ( 'class', idrinth.ui.getClassesList ( head.getAttribute ( 'class' ), [ 'active' ], [ ] ) );
body.setAttribute ( 'class', idrinth.ui.getClassesList ( body.getAttribute ( 'class' ), [ ], [ 'idrinth-hide' ] ) );
idrinth.ui.updateClassesList ( head, [ 'active' ], [ ] );
idrinth.ui.updateClassesList ( body, [ ], [ 'idrinth-hide' ] );
return;
}
head.setAttribute ( 'class', idrinth.ui.getClassesList ( head.getAttribute ( 'class' ), [ ], [ 'active' ] ) );
body.setAttribute ( 'class', idrinth.ui.getClassesList ( body.getAttribute ( 'class' ), [ 'idrinth-hide' ], [ ] ) );
idrinth.ui.updateClassesList ( head, [ ], [ 'active' ] );
idrinth.ui.updateClassesList ( body, [ 'idrinth-hide' ], [ ] );
};
for (var count = 0; count < head.length; count++) {
setClasses ( head[count], body[count], name );
Expand Down

0 comments on commit 52b9439

Please sign in to comment.