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 #292 from IDotD/idrinth
Browse files Browse the repository at this point in the history
Idrinth
  • Loading branch information
Idrinth authored Mar 22, 2017
2 parents 13d31c2 + 7c30176 commit 955e2a7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 111 deletions.
34 changes: 0 additions & 34 deletions src/mods/facebook.js

This file was deleted.

17 changes: 17 additions & 0 deletions src/mods/inframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ idrinth.inframe = {
}
}
};
/**
* @returns {undefined}
*/
var joinRaid = function(data) {
var requestHandler = new XMLHttpRequest ( );
requestHandler.timeout = 30000;
var error = function ( event ) {
console.log ( 'Request to ' + ( event || window.event ).target._url + ' failed.' );
};
requestHandler.ontimeout = error;
requestHandler.onerror = error;
requestHandler.onabort = error;
requestHandler.open ( "GET", data, true );
requestHandler.withCredentials = true;
requestHandler.send ( );
};
/**
* @param {HTMLElement} parent
*/
Expand All @@ -65,6 +81,7 @@ idrinth.inframe = {
handleFrame ( document.getElementById ( 'gamefilearea' ) );
}
idrinth.inframe.send ( 'add', 'window.idrinth.reload=' + reload.toString () + ';' );
idrinth.inframe.send ( 'add', 'window.idrinth.joinRaid=' + joinRaid.toString () + ';' );
} catch ( e ) {
idrinth.core.log ( 'failed to find frame' );
}
Expand Down
69 changes: 9 additions & 60 deletions src/mods/raids.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,65 +277,16 @@ idrinth.raids = {
* @returns {function[]}
*/
var getServerMethods = function () {
var byAjax = function ( key ) {
idrinth.core.ajax.run (
idrinth.raids.join.getServerLink ( key ),
function () {
idrinth.raids.join.messages.success ( key );
},
function () {
idrinth.raids.join.messages.failed ( key );
},
function () {
idrinth.raids[key].joined = false;
idrinth.raids.join.messages.failed ( key );
}
);
};
/**
*
* @param {String} key
* @returns {undefined}
* @returns {Function}
*/
var byFrame = function ( key ) {
var exist = document.getElementsByClassName ( 'idrinth-join-frame' ).length;
if ( exist >= idrinth.settings.get ( "windows" ) ) {
idrinth.raids.list[key].joined = false;
return;
}
var frame = idrinth.ui.buildElement ( {
type: 'iframe',
css: 'idrinth-join-frame',
id: 'join-' + key,
attributes: [
{
name: 'src',
value: idrinth.raids.join.getServerLink ( key )
},
{
name: 'sandbox',
value: 'allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts'
},
{
name: 'style',
value: 'top:' + exist + 'px;'
},
{
name: 'onload',
value: 'try{event.stopPropagation();}catch(e){}idrinth.core.timeouts.add(\'raids.join.cleanup.' + key + '\',{function(){idrinth.ui.removeElement(\'' + key + '\');},1234);'
},
{
name: 'onunload',
value: 'try{event.stopPropagation();}catch(e){}'
}
]
} );
( ( function ( key ) {
return idrinth.core.timeouts.add ( 'raids.join.remove.' + key, function () {
idrinth.ui.removeElement ( 'join-' + key );
}, 30000 );
} ) ( key ) );
idrinth.ui.base.appendChild ( frame );
var byMessage = function(key) {
idrinth.inframe.send (
'joinRaid',
(idrinth.raids.join.getServerLink ( key )).replace(/^.*raidjoin\.php/,'raidjoin.php')
);
idrinth.raids.join.messages.trying ( key );
};
/**
Expand Down Expand Up @@ -368,10 +319,8 @@ idrinth.raids = {
}
};
var options = [ postLink ];
if ( idrinth.platform === 'armorgames' || idrinth.platform === 'kongregate' ) {
options.push ( byAjax );
} else if ( idrinth.platform === 'facebook' || idrinth.platform === 'dawnofthedragons' ) {
options.push ( byFrame );
if ( idrinth.platform === 'armorgames' || idrinth.platform === 'kongregate') {
options.push ( byMessage );
}
return options;
};
Expand All @@ -381,7 +330,7 @@ idrinth.raids = {
* @returns {Boolean}
*/
var reachedMax = function ( amount ) {
return amount > 99 || ( ( idrinth.platform === 'facebook' || idrinth.platform === 'dawnofthedragons' ) && amount >= idrinth.settings.get ( "windows" ) );
return amount > 99;
};
/**
*
Expand Down
10 changes: 0 additions & 10 deletions src/mods/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ idrinth.settings = {
* @type Number
*/
timeout: 5000,
/**
*
* @type Number
*/
loadtime: 5000,
/**
*
* @type Number
*/
windows: 3,
/**
*
* @type Boolean
Expand Down
7 changes: 0 additions & 7 deletions src/mods/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ idrinth.ui = {
buttonMaker ( idrinth.text.get ( "raids.clear" ), 'idrinth.raids.clearAll();' ),
buttonMaker ( idrinth.text.get ( "button.reloadScript" ), 'idrinth.reload();' ),
buttonMaker ( idrinth.text.get ( "raids.imports.restart" ), 'idrinth.raids.start();' ),
buttonMaker ( idrinth.text.get ( "button.refreshFBGameLogin" ), 'idrinth.facebook.rejoin()', 'facebook' ),
buttonMaker ( idrinth.text.get ( "button.ngRaidJoin" ), 'idrinth.newgrounds.joinRaids()', 'newgrounds' ),
buttonMaker ( idrinth.settings.get ( "alarmActive" ) ? idrinth.text.get ( "button.disableTimedAutoJoin" ) : idrinth.text.get ( "button.enableTimedAutoJoin" ),
'idrinth.settings.change(\'alarmActive\',!idrinth.settings.get("alarmActive"));this.innerHTML=idrinth.settings.get("alarmActive") ? idrinth.text.get ( "button.disableTimedAutoJoin" ):"button.enableTimedAutoJoin"', 'newgrounds' )
Expand Down Expand Up @@ -714,12 +713,6 @@ idrinth.ui = {
type: 'text',
platforms: [ 'newgrounds' ],
label: "ui.timeAutoJoin"
}, {
name: 'windows',
rType: '#input',
type: 'number',
platforms: [ 'dawnofthedragons', 'facebook' ],
label: "ui.maxPopupsFrame"
} ], 'raidjoining' ),
wrap ( [ {
name: 'chatting',
Expand Down

0 comments on commit 955e2a7

Please sign in to comment.