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 #305 from IDotD/idrinth
Browse files Browse the repository at this point in the history
Idrinth
  • Loading branch information
w20k authored Mar 28, 2017
2 parents be67aab + a7aa751 commit a8d527e
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 53 deletions.
116 changes: 64 additions & 52 deletions src/mods/raids.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ idrinth.raids = {
/**
* @type Object
*/
private: {},
private: { },
/**
* @type Object
*/
Expand Down Expand Up @@ -39,35 +39,36 @@ idrinth.raids = {
* @param {string} responseText
* @returns {undefined}
*/
function ( responseText ) {
var delHandler = function ( key ) {
if ( key in idrinth.raids.list ) {
delete idrinth.raids.list[key];
}
if ( key in idrinth.raids.joined ) {
delete idrinth.raids.joined[key];
}
if ( document.getElementById ( 'idrinth-raid-link-' + key ) ) {
idrinth.ui.removeElement ( 'idrinth-raid-link-' + key );
}
};
var list = JSON.parse ( responseText );
for (var key in list) {
if ( list[key].delete ) {
delHandler ( key );
} else {
//worst case: overwriting itself
idrinth.raids.list[key] = list[key];
}
}
},
function () {
},
function () {
},
idrinth.raids.knowRaids ()
);
},
function ( responseText ) {
var delHandler = function ( key ) {
if ( key in idrinth.raids.list ) {
delete idrinth.raids.list[key];
}
if ( key in idrinth.raids.joined ) {
delete idrinth.raids.joined[key];
}
if ( document.getElementById ( 'idrinth-raid-link-' + key ) ) {
idrinth.ui.removeElement ( 'idrinth-raid-link-' + key );
}
};
var list = JSON.parse ( responseText );
for (var key in list) {
if ( list[key].delete ) {
delHandler ( key );
} else {
//worst case: overwriting itself
list[key].private = idrinth.raids.list[key] && idrinth.raids.list[key].private;
idrinth.raids.list[key] = list[key];
}
}
},
function () {
},
function () {
},
idrinth.raids.knowRaids ()
);
},
/**
*
* @returns {String}
Expand Down Expand Up @@ -282,11 +283,11 @@ idrinth.raids = {
* @param {String} key
* @returns {Function}
*/
var byMessage = function(key) {
var byMessage = function ( key ) {
idrinth.inframe.send (
'joinRaid',
(idrinth.raids.join.getServerLink ( key )).replace(/^.*raidjoin\.php/,'raidjoin.php')
);
( idrinth.raids.join.getServerLink ( key ) ).replace ( /^.*raidjoin\.php/, 'raidjoin.php' )
);
idrinth.raids.join.messages.trying ( key );
};
/**
Expand Down Expand Up @@ -319,7 +320,7 @@ idrinth.raids = {
}
};
var options = [ postLink ];
if ( idrinth.platform === 'armorgames' || idrinth.platform === 'kongregate') {
if ( idrinth.platform === 'armorgames' || idrinth.platform === 'kongregate' ) {
options.push ( byMessage );
}
return options;
Expand All @@ -345,9 +346,14 @@ idrinth.raids = {
added++;
options[0] ( key );//post link
if (
(!idrinth.settings.get ( "bannedRaids#" + raid.raid ) && !idrinth.settings.get("raidWhitelist")) ||
(idrinth.settings.get ( "bannedRaids#" + raid.raid ) && idrinth.settings.get("raidWhitelist"))
) {
(
( !idrinth.settings.get ( "bannedRaids#" + raid.raid ) && !idrinth.settings.get ( "raidWhitelist" ) ) ||
( idrinth.settings.get ( "bannedRaids#" + raid.raid ) && idrinth.settings.get ( "raidWhitelist" ) )
) && (
!raid.private ||
idrinth.settings.get ( 'raid#joinPrivate' )
)
) {
for (var count = 1; count < options.length; count++) {
options[count] ( key );
}
Expand All @@ -371,41 +377,47 @@ idrinth.raids = {
* requests information for raids caught from a third party(chat for example)
* @returns {undefined}
*/
var handlePrivates = function() {
var handlePrivates = function () {
/**
*
* @param {String} reply
* @returns {undefined}
*/
var handle = function(reply){
if(!reply) {
var handle = function ( reply ) {
if ( !reply ) {
return;
}
reply=JSON.parse(reply);
if(!reply) {
reply = JSON.parse ( reply );
if ( !reply ) {
return;
}
if(!reply.hasOwnProperty ('delete')) {
if ( !reply.hasOwnProperty ( 'delete' ) ) {
idrinth.raids.list[reply.aid] = reply;
idrinth.raids.list[reply.aid].private = true;
}
try{
try {
delete idrinth.raids.private[reply.raidId];
}catch(e) {
idrinth.core.log (e.getMessage?e.getMessage():e.message);
} catch ( e ) {
idrinth.core.log ( e.getMessage ? e.getMessage () : e.message );
}
};
for(var raidId in idrinth.raids.private) {
idrinth.core.ajax.runHome (
'get-raid-service/'+raidId+'/'+idrinth.raids.private[raidId]+'/',
handle
);
if ( !idrinth.settings.get ( 'raid#requestPrivate' ) ) {
return;
}
for (var raidId in idrinth.raids.private) {
if(idrinth.raids.private.hasOwnProperty (raidId)) {
idrinth.core.ajax.runHome (
'get-raid-service/' + raidId + '/' + idrinth.raids.private[raidId] + '/',
handle
);
}
}
};
if ( !join () && Date.now () - 60000 > idrinth.raids.requested ) {
idrinth.raids.requested = Date.now ();
idrinth.raids.import ( idrinth.settings.get ( "raids" ) ? idrinth.settings.get ( "favs" ) : '-1' );
}
handlePrivates();
handlePrivates ();
}
},
/**
Expand Down
15 changes: 15 additions & 0 deletions src/mods/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ idrinth.settings = {
* @type String
*/
lang: null,
/**
* @type Object
*/
raid: {
/**
*
* @type Boolean
*/
requestPrivate: true,
/**
*
* @type Boolean
*/
joinPrivate: true
},
/**
*
* @type {Object}
Expand Down
2 changes: 1 addition & 1 deletion src/mods/tier.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ idrinth.tier = {
return true;
}
}
return false;
return regExp.toString () === '/(?:)/i';
};
if ( ( !data.name || data.name.length === 0 ) && ( !data.type || data.type.length === 0 ) ) {
return [ ];
Expand Down
10 changes: 10 additions & 0 deletions src/mods/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,16 @@ idrinth.ui = {
rType: '#input',
type: 'checkbox',
label: "setting.worldserver"
}, {
name: 'raid#requestPrivate',
rType: '#input',
type: 'checkbox',
label: "setting.raid.requestPrivate"
}, {
name: 'raid#joinPrivate',
rType: '#input',
type: 'checkbox',
label: "setting.raid.joinPrivate"
}, {
name: 'newgroundLoad',
rType: '#input',
Expand Down

0 comments on commit a8d527e

Please sign in to comment.