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

Commit 0ec836a

Browse files
committed
fixes #313
1 parent 3433daa commit 0ec836a

2 files changed

Lines changed: 57 additions & 26 deletions

File tree

src/mods/observer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ idrinth.observer = {
3030
* @param {string} prefix
3131
* @returns {null|string}
3232
*/
33-
var getData = function(parts,prefix) {
33+
var getData = function ( parts, prefix ) {
3434
for (var count = 0; count < parts.length; count++) {
35-
if ( parts[count].match ( prefix+'=' ) ) {
35+
if ( parts[count].match ( prefix + '=' ) ) {
3636
return parts[count].split ( '=' )[1];
3737
}
3838
}
@@ -44,22 +44,22 @@ idrinth.observer = {
4444
* @param {Boolean} isWorld
4545
* @returns {Boolean}
4646
*/
47-
var correctServer = function(href, isWorld) {
48-
if (href.match ( 'serverid=2' )) {
47+
var correctServer = function ( href, isWorld ) {
48+
if ( href.match ( 'serverid=2' ) ) {
4949
return isWorld;
5050
}
5151
return !isWorld;
5252
};
53-
if(!href || !href.match ( /action_type=raidhelp/ )) {
53+
if ( !href || !href.match ( /action_type=raidhelp/ ) ) {
5454
return;
5555
}
5656
href = href.replace ( /^.*\?/, '' );
57-
if ( !correctServer(href, idrinth.settings.get ( "world" )) ) {
57+
if ( !correctServer ( href, idrinth.settings.get ( "world" ) ) ) {
5858
return;
5959
}
6060
var parts = href.split ( "&" );
61-
var id = getData(parts, 'raid_id');
62-
var hash = getData(parts, 'hash');
61+
var id = getData ( parts, 'raid_id' );
62+
var hash = getData ( parts, 'hash' );
6363
if ( !id || !hash ) {
6464
return;
6565
}

src/mods/tier.js

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,55 @@ idrinth.tier = {
187187
var ln = {
188188
type: 'td'
189189
};
190-
if (
191-
idrinth.tier.list[listKey].hasOwnProperty ( 'loot' ) &&
192-
idrinth.tier.list[listKey].loot.hasOwnProperty ( difficulty ) &&
193-
idrinth.tier.list[listKey].loot[difficulty].hasOwnProperty ( ic ) &&
194-
idrinth.tier.list[listKey].loot[difficulty][ic]
195-
) {
196-
ln.attributes = ln.attributes?ln.attributes:[];
190+
/**
191+
*
192+
* @param {object} ln
193+
* @param {string} listKey
194+
* @param {string} difficulty
195+
* @param {string} ic
196+
* @returns {object} for the buildElement wrapper
197+
*/
198+
var addTitle = function ( ln, listKey, difficulty, ic ) {
199+
if ( !idrinth.tier.list[listKey].hasOwnProperty ( 'loot' ) ) {
200+
return ln;
201+
}
202+
if ( !idrinth.tier.list[listKey].loot.hasOwnProperty ( difficulty ) ) {
203+
return ln;
204+
}
205+
if ( !idrinth.tier.list[listKey].loot[difficulty].hasOwnProperty ( ic ) ) {
206+
return ln;
207+
}
208+
if ( !idrinth.tier.list[listKey].loot[difficulty][ic] ) {
209+
return ln;
210+
}
211+
ln.attributes = ln.attributes ? ln.attributes : [ ];
197212
var title = "";
198-
for(var key in idrinth.tier.list[listKey].loot[difficulty][ic]) {
199-
if(idrinth.tier.list[listKey].loot[difficulty][ic].hasOwnProperty (key)) {
200-
title += idrinth.tier.list[listKey].loot[difficulty][ic][key]+" "+idrinth.text.get ('tier.loot.'+key)+"\n";
213+
for (var key in idrinth.tier.list[listKey].loot[difficulty][ic]) {
214+
if ( idrinth.tier.list[listKey].loot[difficulty][ic].hasOwnProperty ( key ) ) {
215+
title += idrinth.tier.list[listKey].loot[difficulty][ic][key] + " " + idrinth.text.get ( 'tier.loot.' + key ) + "\n";
201216
}
202217
}
203-
ln.attributes.push({name:'title',value:title});
204-
}
205-
if (
206-
idrinth.tier.list[listKey].hasOwnProperty ( difficulty ) &&
207-
idrinth.tier.list[listKey][difficulty].hasOwnProperty ( ic )
208-
) {
218+
ln.attributes.push ( {
219+
name: 'title',
220+
value: title
221+
} );
222+
return ln;
223+
};
224+
/**
225+
*
226+
* @param {object} ln
227+
* @param {string} listKey
228+
* @param {string} difficulty
229+
* @param {string} ic
230+
* @returns {object} for the buildElement wrapper
231+
*/
232+
var addContent = function ( ln, listKey, difficulty, ic ) {
233+
if (
234+
!idrinth.tier.list[listKey].hasOwnProperty ( difficulty ) ||
235+
!idrinth.tier.list[listKey][difficulty].hasOwnProperty ( ic )
236+
) {
237+
return ln;
238+
}
209239
ln.styles = idrinth.tier.list[listKey].os[difficulty] === idrinth.tier.list[listKey][difficulty][ic] ? 'is-os' : '';
210240
ln.content = idrinth.ui.formatNumber ( idrinth.tier.list[listKey][difficulty][ic] );
211241
if (
@@ -215,8 +245,9 @@ idrinth.tier = {
215245
) {
216246
ln.content += ' ' + idrinth.tier.list[listKey].epics[difficulty][ic] + 'E';
217247
}
218-
}
219-
return ln;
248+
return ln;
249+
};
250+
return addContent ( addTitle ( ln, listKey, difficulty, ic ), listKey, difficulty, ic );
220251
};
221252
/**
222253
*

0 commit comments

Comments
 (0)