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

Commit 9379c52

Browse files
committed
adding some basic jsdoc header
refs #135
1 parent 46879cb commit 9379c52

2 files changed

Lines changed: 156 additions & 2 deletions

File tree

src/mods/observer.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
idrinth.observer = {
2+
/**
3+
*
4+
* @type MutationObserver[]
5+
*/
26
list: { },
7+
/**
8+
*
9+
* @param {MutationRecord[]} mutations
10+
* @param {boolean} isPrivate
11+
* @returns {undefined}
12+
*/
313
handle: function ( mutations, isPrivate ) {
14+
/**
15+
*
16+
* @param {HTMLElement} element
17+
* @returns {undefined}
18+
*/
419
var handleLink = function ( element ) {
520
var href = element.getAttribute ( 'href' );
621
if ( href && href.match ( /action_type=raidhelp/ ) ) {
@@ -15,7 +30,7 @@ idrinth.observer = {
1530
hash = parts[count].split ( '=' )[1];
1631
} else if ( parts[count].match ( 'serverid=2' ) && !idrinth.settings.get ( "world" ) ) {
1732
return;
18-
} else if ( parts[count].match ( 'server_id=2' ) && !idrinth.settings.get ( "world" ) ) {
33+
} else if ( !parts[count].match ( 'server_id=2' ) && idrinth.settings.get ( "world" ) ) {
1934
return;
2035
}
2136
}
@@ -40,6 +55,10 @@ idrinth.observer = {
4055
} );
4156
} );
4257
},
58+
/**
59+
*
60+
* @returns {undefined}
61+
*/
4362
start: function () {
4463
if ( idrinth.platform !== 'kongregate' ) {
4564
return;

src/mods/raids.js

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,44 @@
11
idrinth.raids = {
2-
script: null,
2+
/**
3+
* @type Object
4+
*/
35
list: { },
6+
/**
7+
* @type Object
8+
*/
49
private: {},
10+
/**
11+
* @type Object
12+
*/
513
joined: { },
14+
/**
15+
* @type Number
16+
*/
617
requested: 0,
18+
/**
19+
*
20+
* @param {Number} id
21+
* @returns {undefined}
22+
*/
723
import: function ( id ) {
824
if ( !idrinth.platform ) {
925
return;
1026
}
27+
/**
28+
*
29+
* @param {String} toImport
30+
* @returns {String}
31+
*/
1132
var getImportLink = function ( toImport ) {
1233
return 'raid-service/' + ( toImport === '' ? '_' : toImport ) + '/';
1334
};
1435
idrinth.core.ajax.runHome (
1536
getImportLink ( id ),
37+
/**
38+
*
39+
* @param {string} responseText
40+
* @returns {undefined}
41+
*/
1642
function ( responseText ) {
1743
var delHandler = function ( key ) {
1844
if ( key in idrinth.raids.list ) {
@@ -42,9 +68,17 @@ idrinth.raids = {
4268
idrinth.raids.knowRaids ()
4369
);
4470
},
71+
/**
72+
*
73+
* @returns {String}
74+
*/
4575
knowRaids: function () {
4676
return ( ( Object.keys ( idrinth.raids.joined ) ).concat ( Object.keys ( idrinth.raids.list ) ) ).join ();
4777
},
78+
/**
79+
*
80+
* @returns {undefined}
81+
*/
4882
clearAll: function () {
4983
idrinth.core.timeouts.remove ( 'raids' );
5084
while ( document.getElementById ( "idrinth-raid-link-list" ).firstChild ) {
@@ -55,11 +89,33 @@ idrinth.raids = {
5589
idrinth.raids.start ();
5690
},
5791
join: {
92+
/**
93+
*
94+
*/
5895
data: {
96+
/**
97+
* @type String
98+
*/
5999
prefix: null,
100+
/**
101+
* @type String
102+
*/
60103
tag: null
61104
},
105+
/**
106+
*
107+
* @param {String} key
108+
* @returns {String}
109+
*/
62110
getServerLink: function ( key ) {
111+
/**
112+
*
113+
* @param {Object} list
114+
* @param {String} key
115+
* @param {String} prefix
116+
* @param {String} tag
117+
* @returns {String|Boolean}
118+
*/
63119
var getLink = function ( list, key, prefix, tag ) {
64120
var build = function ( data, tag, prefix ) {
65121
try {
@@ -80,6 +136,10 @@ idrinth.raids = {
80136
}
81137
}
82138
};
139+
/**
140+
*
141+
* @returns {String}
142+
*/
83143
var makePrefix = function () {
84144
if ( idrinth.raids.join.data.prefix === null ) {
85145
var sites = {
@@ -99,6 +159,10 @@ idrinth.raids = {
99159
}
100160
return idrinth.raids.join.data.prefix;
101161
};
162+
/**
163+
*
164+
* @returns {String}
165+
*/
102166
var makeTag = function () {
103167
if ( idrinth.raids.join.data.tag === null ) {
104168
var sites = {
@@ -124,7 +188,16 @@ idrinth.raids = {
124188
}
125189
return prefix;
126190
},
191+
/**
192+
*
193+
*/
127194
messages: {
195+
/**
196+
*
197+
* @param {String} string
198+
* @param {String} key
199+
* @returns {undefined}
200+
*/
128201
log: function ( string, key ) {
129202
var message = ( string.replace ( '#name#', idrinth.raids.list[key].name ) ).replace ( '#raid#', idrinth.raids.list[key].raid );
130203
idrinth.core.log ( message );
@@ -140,20 +213,40 @@ idrinth.raids = {
140213
ul.insertBefore ( li, ul.firstChild );
141214
}
142215
},
216+
/**
217+
*
218+
* @param {String} key
219+
* @returns {undefined}
220+
*/
143221
addToJoined: function ( key ) {
144222
if ( key && idrinth.raids.list.hasOwnProperty ( key ) ) {
145223
idrinth.raids.joined[key] = idrinth.raids.list[key];
146224
delete idrinth.raids.list[key];
147225
}
148226
},
227+
/**
228+
*
229+
* @param {String} key
230+
* @returns {undefined}
231+
*/
149232
success: function ( key ) {
150233
idrinth.raids.join.messages.log ( 'Joined #name#\'s #raid#.', key );
151234
idrinth.ui.removeElement ( 'idrinth-raid-link-' + key );
152235
this.addToJoined ( key );
153236
},
237+
/**
238+
*
239+
* @param {String} key
240+
* @returns {undefined}
241+
*/
154242
failed: function ( key ) {
155243
idrinth.raids.join.messages.log ( 'Could not join #name#\'s #raid#', key );
156244
},
245+
/**
246+
*
247+
* @param {String} key
248+
* @returns {undefined}
249+
*/
157250
trying: function ( key ) {
158251
( ( function ( key ) {
159252
idrinth.core.timeouts.add ( 'raid.join.' + key, function () {
@@ -169,8 +262,20 @@ idrinth.raids = {
169262
this.addToJoined ( key );
170263
}
171264
},
265+
/**
266+
*
267+
* @returns {undefined}
268+
*/
172269
process: function () {
270+
/**
271+
*
272+
* @returns {Boolean}
273+
*/
173274
var join = function () {
275+
/**
276+
*
277+
* @returns {function[]}
278+
*/
174279
var getServerMethods = function () {
175280
var byAjax = function ( key ) {
176281
idrinth.core.ajax.run (
@@ -187,6 +292,11 @@ idrinth.raids = {
187292
}
188293
);
189294
};
295+
/**
296+
*
297+
* @param {String} key
298+
* @returns {undefined}
299+
*/
190300
var byFrame = function ( key ) {
191301
var exist = document.getElementsByClassName ( 'idrinth-join-frame' ).length;
192302
if ( exist >= idrinth.settings.get ( "windows" ) ) {
@@ -228,6 +338,11 @@ idrinth.raids = {
228338
idrinth.ui.base.appendChild ( frame );
229339
idrinth.raids.join.messages.trying ( key );
230340
};
341+
/**
342+
*
343+
* @param {String} key
344+
* @returns {undefined}
345+
*/
231346
var postLink = function ( key ) {
232347
if ( !document.getElementById ( 'idrinth-raid-link-' + key ) ) {
233348
document.getElementById ( 'idrinth-raid-link-list' ).appendChild (
@@ -260,9 +375,21 @@ idrinth.raids = {
260375
}
261376
return options;
262377
};
378+
/**
379+
*
380+
* @param {Number} amount
381+
* @returns {Boolean}
382+
*/
263383
var reachedMax = function ( amount ) {
264384
return amount > 99 || ( ( idrinth.platform === 'facebook' || idrinth.platform === 'dawnofthedragons' ) && amount >= idrinth.settings.get ( "windows" ) );
265385
};
386+
/**
387+
*
388+
* @param {Number} added
389+
* @param {String} key
390+
* @param {function[]} options
391+
* @returns {Number}
392+
*/
266393
var handleKey = function ( added, key, options ) {
267394
var raid = idrinth.raids.list[key];
268395
if ( !raid.joined ) {
@@ -288,6 +415,10 @@ idrinth.raids = {
288415
}
289416
return false;
290417
};
418+
/**
419+
* requests information for raids caught from a third party(chat for example)
420+
* @returns {undefined}
421+
*/
291422
var handlePrivates = function() {
292423
for(var raidId in idrinth.raids.private) {
293424
idrinth.core.ajax.runHome (
@@ -319,6 +450,10 @@ idrinth.raids = {
319450
handlePrivates();
320451
}
321452
},
453+
/**
454+
*
455+
* @returns {undefined}
456+
*/
322457
start: function () {
323458
idrinth.core.timeouts.remove ( 'raids' );
324459
idrinth.core.timeouts.add ( 'raids', idrinth.raids.join.process, 1500, -1 );

0 commit comments

Comments
 (0)