@@ -185,28 +185,71 @@ idrinth.tier = {
185185 */
186186 var makeField = function ( listKey , difficulty , ic ) {
187187 var ln = {
188- type : 'td'
188+ type : 'td' ,
189+ attributes : [ ]
189190 } ;
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 :[ ] ;
191+ /**
192+ *
193+ * @param {object } ln
194+ * @param {string } listKey
195+ * @param {string } difficulty
196+ * @param {string } ic
197+ * @returns {object } for the buildElement wrapper
198+ */
199+ var addTitle = function ( ln , listKey , difficulty , ic ) {
200+ /**
201+ *
202+ * @param {string } listKey
203+ * @param {string } difficulty
204+ * @param {string } ic
205+ * @returns {Boolean }
206+ */
207+ var isUseable = function ( listKey , difficulty , ic ) {
208+ return idrinth . tier . list [ listKey ] . hasOwnProperty ( 'loot' ) &&
209+ idrinth . tier . list [ listKey ] . loot . hasOwnProperty ( difficulty ) &&
210+ idrinth . tier . list [ listKey ] . loot [ difficulty ] . hasOwnProperty ( ic ) &&
211+ idrinth . tier . list [ listKey ] . loot [ difficulty ] [ ic ] ;
212+ } ;
213+ if ( ! isUseable ( listKey , difficulty , ic ) ) {
214+ return ln ;
215+ }
197216 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" ;
217+ for ( var key in idrinth . tier . list [ listKey ] . loot [ difficulty ] [ ic ] ) {
218+ if ( idrinth . tier . list [ listKey ] . loot [ difficulty ] [ ic ] . hasOwnProperty ( key ) ) {
219+ title += idrinth . tier . list [ listKey ] . loot [ difficulty ] [ ic ] [ key ] + " " + idrinth . text . get ( 'tier.loot.' + key ) + "\n" ;
201220 }
202221 }
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- ) {
209- ln . styles = idrinth . tier . list [ listKey ] . os [ difficulty ] === idrinth . tier . list [ listKey ] [ difficulty ] [ ic ] ? 'is-os' : '' ;
222+ ln . attributes . push ( {
223+ name : 'title' ,
224+ value : title
225+ } ) ;
226+ return ln ;
227+ } ;
228+ /**
229+ *
230+ * @param {object } ln
231+ * @param {string } listKey
232+ * @param {string } difficulty
233+ * @param {string } ic
234+ * @returns {object } for the buildElement wrapper
235+ */
236+ var addContent = function ( ln , listKey , difficulty , ic ) {
237+ /**
238+ *
239+ * @param {string } os numeric string
240+ * @param {string } current numeric string
241+ * @returns {Boolean }
242+ */
243+ var isOs = function ( os , current ) {
244+ return Number . parseInt ( os , 10 ) === Number . parseInt ( current , 10 ) ;
245+ } ;
246+ if (
247+ ! idrinth . tier . list [ listKey ] . hasOwnProperty ( difficulty ) ||
248+ ! idrinth . tier . list [ listKey ] [ difficulty ] . hasOwnProperty ( ic )
249+ ) {
250+ return ln ;
251+ }
252+ ln . css = isOs ( idrinth . tier . list [ listKey ] . os [ difficulty ] , idrinth . tier . list [ listKey ] [ difficulty ] [ ic ] ) ? 'is-os' : '' ;
210253 ln . content = idrinth . ui . formatNumber ( idrinth . tier . list [ listKey ] [ difficulty ] [ ic ] ) ;
211254 if (
212255 idrinth . tier . list [ listKey ] . epics &&
@@ -215,8 +258,9 @@ idrinth.tier = {
215258 ) {
216259 ln . content += ' ' + idrinth . tier . list [ listKey ] . epics [ difficulty ] [ ic ] + 'E' ;
217260 }
218- }
219- return ln ;
261+ return ln ;
262+ } ;
263+ return addContent ( addTitle ( ln , listKey , difficulty , ic ) , listKey , difficulty , ic ) ;
220264 } ;
221265 /**
222266 *
0 commit comments