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 #205 from Idrinth/ardenian
Browse files Browse the repository at this point in the history
Ardenian
  • Loading branch information
w20k authored Oct 12, 2016
2 parents 6b16ad2 + c1958f4 commit 999587a
Show file tree
Hide file tree
Showing 23 changed files with 454 additions and 146 deletions.
30 changes: 15 additions & 15 deletions src/mods/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ idrinth.chat = {
};
var messageAllowed = function ( text ) {
try {
return ( idrinth.settings.notification.message && text.match ( /\{[A-Z]{2}-Raid / ) === null ) ||
( idrinth.settings.notification.mention && text.match ( new RegExp ( '(\s|^)' + idrinth.core.escapeRegExp ( idrinth.chat.users[idrinth.chat.self].name ) + '(\s|$)', 'i' ) ) !== null ) ||
( idrinth.settings.notification.raid && text.match ( /\{[A-Z]{2}-Raid / ) !== null );
return ( idrinth.settings.get ( "notification#message" ) && text.match ( /\{[A-Z]{2}-Raid / ) === null ) ||
( idrinth.settings.get ( "notification#mention" ) && text.match ( new RegExp ( '(\s|^)' + idrinth.core.escapeRegExp ( idrinth.chat.users[idrinth.chat.self].name ) + '(\s|$)', 'i' ) ) !== null ) ||
( idrinth.settings.get ( "notification#raid" ) && text.match ( /\{[A-Z]{2}-Raid / ) !== null );
} catch ( e ) {
idrinth.core.log ( e.getMessage () );
return false;
Expand Down Expand Up @@ -544,11 +544,11 @@ idrinth.chat = {
};
return idrinth.ui.buildElement ( {
id: 'idrinth-chat',
css: 'idrinth-hovering-box' + ( !idrinth.settings.chatHiddenOnStart ? ' active' : '' ) + ( idrinth.settings.moveLeft ? ' left-sided' : '' ),
css: 'idrinth-hovering-box' + ( !idrinth.settings.get ( "chatHiddenOnStart" ) ? ' active' : '' ) + ( idrinth.settings.get ( "moveLeft" ) ? ' left-sided' : '' ),
children: [
{
type: 'button',
content: ( idrinth.settings.chatHiddenOnStart ? '<<' : '>>' ),
content: ( idrinth.settings.get ( "chatHiddenOnStart" ) ? '<<' : '>>' ),
attributes: [ {
name: 'onclick',
value: 'idrinth.chat.openCloseChat(this);'
Expand Down Expand Up @@ -706,7 +706,7 @@ idrinth.chat = {
]
} );
};
if ( !idrinth.settings.chatting ) {
if ( !idrinth.settings.get ( "chatting" ) ) {
return;
}
if ( !document.getElementById ( 'idrinth-chat' ) ) {
Expand All @@ -724,8 +724,8 @@ idrinth.chat = {
window.setTimeout ( idrinth.chat.login, 1 );
},
JSON.stringify ( {
user: idrinth.settings.chatuser,
pass: idrinth.settings.chatpass
user: idrinth.settings.get ( "chatuser" ),
pass: idrinth.settings.get ( "chatpass" )
} )
);
}, 2500 );
Expand Down Expand Up @@ -847,9 +847,9 @@ idrinth.chat = {
return;
}
if ( data.success ) {
idrinth.settings.chatuser = document.getElementById ( 'idrinth-chat-login' ).getElementsByTagName ( 'input' )[0].value;
idrinth.settings.chatpass = document.getElementById ( 'idrinth-chat-login' ).getElementsByTagName ( 'input' )[1].value;
idrinth.settings.save ();
var login = document.getElementById ( 'idrinth-chat-login' ).getElementsByTagName ( 'input' );
idrinth.settings.change ( "chatuser", login[0].value );
idrinth.settings.change ( "chatpass", login[1].value );
idrinth.ui.removeElement ( 'idrinth-chat-login' );
idrinth.chat.join ( data.data );
return;
Expand Down Expand Up @@ -927,11 +927,11 @@ idrinth.chat = {
openCloseChat: function ( element ) {
var chat = element.parentNode;
if ( chat.getAttribute ( 'class' ) === 'idrinth-hovering-box active' || chat.getAttribute ( 'class' ) === 'idrinth-hovering-box active left-sided' ) {
chat.setAttribute ( 'class', 'idrinth-hovering-box' + ( idrinth.settings.moveLeft ? ' left-sided' : '' ) +
chat.setAttribute ( 'class', 'idrinth-hovering-box' + ( idrinth.settings.get ( "moveLeft" ) ? ' left-sided' : '' ) +
( chat.getElementsByClassName ( 'new-message' ) && chat.getElementsByClassName ( 'new-message' ).length ? ' new-message' : '' ) );
element.innerHTML = '&lt;&lt;';
} else {
chat.setAttribute ( 'class', 'idrinth-hovering-box active' + ( idrinth.settings.moveLeft ? ' left-sided' : '' ) );
chat.setAttribute ( 'class', 'idrinth-hovering-box active' + ( idrinth.settings.get ( "moveLeft" ) ? ' left-sided' : '' ) );
element.innerHTML = '&gt;&gt;';
}
},
Expand Down Expand Up @@ -962,8 +962,8 @@ idrinth.chat = {
success = function () {
idrinth.chat.updateTimeout = window.setTimeout ( idrinth.chat.refreshChats, 1500 );
};
headers.user = idrinth.settings.chatuser;
headers.pass = idrinth.settings.chatpass;
headers.user = idrinth.settings.get ( "chatuser" );
headers.pass = idrinth.settings.get ( "chatpass" );
} else {
chatLogin = document.getElementById ( 'idrinth-chat-login' ).getElementsByTagName ( 'input' );
headers.user = chatLogin[0].value;
Expand Down
2 changes: 1 addition & 1 deletion src/mods/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ idrinth.core = {
},
ajax: {
runHome: function ( url, success, failure, timeout, additionalHeader, isStatic ) {
var server = isStatic ? 'static' : ( idrinth.settings.isWorldServer ? 'world-' : '' ) + idrinth.platform;
var server = isStatic ? 'static' : ( idrinth.settings.get ( "isWorldServer" ) ? 'world-' : '' ) + idrinth.platform;
var homeUrl = 'https://dotd.idrinth.de/' + server + ( '/' + url ).replace ( /\/\//, '/' );
idrinth.core.ajax.run ( homeUrl, success, failure, timeout, additionalHeader );
},
Expand Down
24 changes: 11 additions & 13 deletions src/mods/land.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
idrinth.land = {
calculate: function () {
var baseCalculator = function ( checkElementFunc ) {
var factor = idrinth.settings.factor ? 10 : 1;
var factor = idrinth.settings.get ( "factor" ) ? 10 : 1;
var nextPrice = function ( building ) {
return ( 10 + idrinth.settings.land[building] ) * idrinth.land.data[building].base;
return ( 10 + idrinth.settings.get ( "land#" + building ) ) * idrinth.land.data[building].base;
};
var results = { };
var applyResult = function ( results, res, factor, nextPrice ) {
idrinth.settings.land.gold = idrinth.settings.land.gold - nextPrice ( res.key ) * factor / 10;
idrinth.settings.change ( "land#gold", idrinth.settings.get ( "land#gold" ) - nextPrice ( res.key ) * factor / 10 );
results[res.key] = ( results[res.key] === undefined ? 0 : results[res.key] ) + factor;
idrinth.settings.land[res.key] = idrinth.settings.land[res.key] + factor;
idrinth.settings.change ( "land#" + res.key, idrinth.settings.get ( "land#" + res.key ) + factor );
return results;
};
var processBuildings = function ( checkElementFunc, factor, nextPrice ) {
Expand All @@ -35,41 +35,39 @@ idrinth.land = {
}
return res;
};
while ( idrinth.settings.land.gold >= 0 ) {
while ( idrinth.settings.get ( "land#gold" ) >= 0 ) {
var res = processBuildings ( checkElementFunc, factor, nextPrice );
if ( res.key === null ) {
return results;
}
results = applyResult ( results, res, factor, nextPrice );
}
idrinth.settings.save ();
return results;
};
var getRequirements = function () {
var bestPrice = function ( building, factor, res, nextPrice ) {
return res.min === null || nextPrice ( building ) / idrinth.land.data[building].perHour < res.min;
};
var useUp = function ( building, factor, res, nextPrice ) {
return nextPrice ( building ) * factor / 10 <= idrinth.settings.land.gold;
return nextPrice ( building ) * factor / 10 <= idrinth.settings.get ( "land#gold" );
};
var funcs = [ useUp ];
if ( idrinth.settings.landMax ) {
if ( idrinth.settings.get ( "landMax" ) ) {
funcs.push ( bestPrice );
}
return funcs;
};
var putResults = function ( results ) {
for (var key in results) {
if ( results.hasOwnProperty ( key ) ) {
document.getElementById ( 'idrinth-land-' + key ).value = idrinth.settings.land[key];
document.getElementById ( 'idrinth-land-' + key ).value = idrinth.settings.get ( "land#" + key );
document.getElementById ( 'idrinth-land-' + key ).parentNode.nextSibling.innerHTML = '+' + results[key];
}
}
document.getElementById ( 'idrinth-land-gold' ).value = idrinth.settings.land.gold;
idrinth.settings.save ();
document.getElementById ( 'idrinth-land-gold' ).value = idrinth.settings.get ( "land#gold" );
};
for (var key in idrinth.settings.land) {
if ( idrinth.settings.land.hasOwnProperty ( key ) ) {
for (var key in idrinth.settings.get ( "land#" )) {
if ( idrinth.settings.get ( "land#" + hasOwnProperty ( key ) ) ) {
idrinth.settings.change ( 'land#' + key, parseInt ( document.getElementById ( 'idrinth-land-' + key ).value, 10 ) );
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/mods/raids.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ idrinth.raids = {
tag + 'raid_id=' + data.raidId + '&' +
tag + 'difficulty=' + data.difficulty + '&' +
tag + 'hash=' + data.hash +
( idrinth.settings.isWorldServer ? '&' + tag + 'serverid=' + 2 : '' );
( idrinth.settings.get ( "isWorldServer" ) ? '&' + tag + 'serverid=' + 2 : '' );
} catch ( e1 ) {
return false;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ idrinth.raids = {
var byFrame = function ( key ) {
'use strict';
var exist = document.getElementsByClassName ( 'idrinth-join-frame' ).length;
if ( exist >= idrinth.settings.windows ) {
if ( exist >= idrinth.settings.get ( "windows" ) ) {
idrinth.raids.list[key].joined = false;
return;
}
Expand Down Expand Up @@ -281,14 +281,14 @@ idrinth.raids = {
return options;
};
var reachedMax = function ( amount ) {
return amount > 99 || ( ( idrinth.platform === 'facebook' || idrinth.platform === 'dawnofthedragons' ) && amount >= idrinth.settings.windows );
return amount > 99 || ( ( idrinth.platform === 'facebook' || idrinth.platform === 'dawnofthedragons' ) && amount >= idrinth.settings.get ( "windows" ) );
};
var handleKey = function ( added, key, options ) {
var raid = idrinth.raids.list[key];
if ( !raid.joined ) {
added++;
options[0] ( key );//post link
if ( !idrinth.settings.bannedRaids[raid.raid] ) {
if ( !idrinth.settings.get ( "bannedRaids#" + raid.raid ) ) {
for (var count = 1; count < options.length; count++) {
options[count] ( key );
}
Expand All @@ -310,7 +310,7 @@ idrinth.raids = {
};
if ( !join ( ) && Date.now ( ) - 60000 > idrinth.raids.requested ) {
idrinth.raids.requested = Date.now ( );
idrinth.raids.import ( idrinth.settings.raids ? idrinth.settings.favs : '-1' );
idrinth.raids.import ( idrinth.settings.get ( "raids" ) ? idrinth.settings.get ( "favs" ) : '-1' );
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/mods/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ idrinth.text = {
* @returns {undefined}
*/
start: function ( ) {
var language = idrinth.settings.language || window.navigator.userLanguage || window.navigator.language;
var language = idrinth.settings.get ( "language" ) || window.navigator.userLanguage || window.navigator.language;
if ( language === 'en' ) {
idrinth.text.initialized = true;
return;
Expand Down
6 changes: 4 additions & 2 deletions src/mods/tier.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ idrinth.tier = {
if ( data ) {
idrinth.tier.list = data;
for (var key in data) {
if ( data[key].name && idrinth.settings.bannedRaids[data[key].name] === undefined ) {
idrinth.settings.bannedRaids[data[key].name] = false;
if ( data[key].name ) {
if ( idrinth.settings.get ( "bannedRaids#" + data[key].name ) === undefined ) {
idrinth.settings.change ( "bannedRaids#" + data[key].name, false );
}
document.getElementById ( 'idrinth-raid-may-join-list' ).appendChild ( idrinth.ui.buildElement ( {
name: 'bannedRaids#' + data[key].name,
rType: '#input',
Expand Down
20 changes: 10 additions & 10 deletions src/mods/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ idrinth.ui = {
}
idrinth.names.isHovering = false;
var name = idrinth.names.parse ( element ).toLowerCase ( );
if ( idrinth.settings.names && idrinth.ui.tooltip && idrinth.names.users[name] ) {
if ( idrinth.settings.get ( "names" ) && idrinth.ui.tooltip && idrinth.names.users[name] ) {
window.clearTimeout ( idrinth.ui.tooltipTO );
idrinth.ui.tooltip.setAttribute ( 'style', idrinth.ui.getElementPositioning ( element, -200, -100 ) );
tooltip ( idrinth.names.users[name].kongregate, idrinth.ui.tooltip.firstChild, false );
Expand All @@ -294,7 +294,7 @@ idrinth.ui = {
}
},
setTooltipTimeout: function () {
idrinth.ui.tooltipTO = window.setTimeout ( idrinth.ui.hideTooltip, idrinth.settings.timeout ? idrinth.settings.timeout : 5000 );
idrinth.ui.tooltipTO = window.setTimeout ( idrinth.ui.hideTooltip, idrinth.settings.get ( "timeout" ) ? idrinth.settings.get ( "timeout" ) : 5000 );
},
hideTooltip: function () {
if ( idrinth.names.isHovering ) {
Expand All @@ -305,10 +305,10 @@ idrinth.ui = {
openCloseSettings: function ( ) {
'use strict';
var toRemove = [ ( idrinth.ui.controls.getAttribute ( 'class' ) ).match ( /(^|\s)inactive($|\s)/ ) ? 'inactive' : 'active' ];
if ( !idrinth.settings.moveLeft ) {
if ( !idrinth.settings.get ( "moveLeft" ) ) {
toRemove.push ( 'left-sided' );
}
if ( !idrinth.settings.minimalist ) {
if ( !idrinth.settings.get ( "minimalist" ) ) {
toRemove.push ( 'small' );
}
idrinth.ui.updateClassesList ( idrinth.ui.controls, [ 'active', 'inactive', 'left-sided', 'small' ], toRemove );
Expand Down Expand Up @@ -414,15 +414,15 @@ idrinth.ui = {
return [ {
children: [
buttonMaker ( idrinth.text.get ( "raids.imports.manually" ), 'idrinth.raids.import(\'\');' ),
buttonMaker ( idrinth.text.get ( "raids.imports.favs" ), 'idrinth.raids.import(idrinth.settings.favs);' ),
buttonMaker ( idrinth.text.get ( "raids.imports.favs" ), 'idrinth.raids.import(idrinth.settings.get("favs"));' ),
buttonMaker ( idrinth.text.get ( "button.reloadGame" ), 'idrinth.ui.reloadGame();' ),
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.restartInterval();' ),
buttonMaker ( idrinth.text.get ( "button.refreshFBGameLogin" ), 'idrinth.facebook.rejoin()', 'facebook' ),
buttonMaker ( idrinth.text.get ( "button.ngRaidJoin" ), 'idrinth.newgrounds.joinRaids()', 'newgrounds' ),
buttonMaker ( idrinth.settings.alarmActive ? idrinth.text.get ( "button.disableTimedAutoJoin" ) : idrinth.text.get ( "button.enableTimedAutoJoin" ),
'idrinth.settings.change(\'alarmActive\',!idrinth.settings.alarmActive);this.innerHTML=idrinth.settings.alarmActive?idrinth.text.get ( "button.disableTimedAutoJoin" ):"button.enableTimedAutoJoin"', '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' )
]
}, {
css: 'idrinth-line',
Expand Down Expand Up @@ -594,7 +594,7 @@ idrinth.ui = {
attributes: [
{
name: 'value',
value: idrinth.settings.land[label.toLowerCase ()]
value: idrinth.settings.get ( "land#" + label.toLowerCase () )
},
{
name: 'type',
Expand Down Expand Up @@ -650,7 +650,7 @@ idrinth.ui = {
attributes: [
{
name: 'value',
value: idrinth.settings.land.gold
value: idrinth.settings.get ( "land#gold" )
},
{
name: 'type',
Expand Down Expand Up @@ -781,7 +781,7 @@ idrinth.ui = {
} ]
} );
idrinth.ui.controls = idrinth.ui.buildElement ( {
css: 'idrinth-hovering-box idrinth-controls-overwrite inactive' + ( idrinth.settings.moveLeft ? ' left-sided' : '' ) + ( idrinth.settings.minimalist ? ' small' : '' ),
css: 'idrinth-hovering-box idrinth-controls-overwrite inactive' + ( idrinth.settings.get ( "moveLeft" ) ? ' left-sided' : '' ) + ( idrinth.settings.get ( "minimalist" ) ? ' small' : '' ),
id: 'idrinth-controls',
children: children
} );
Expand Down
2 changes: 1 addition & 1 deletion src/mods/war.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ idrinth.war = {
if ( toggle === true ) {
removeClasses.push ( 'idrinth-hide' );
addClasses.push ( "bottom" );
if ( !idrinth.settings.warBottom ) {
if ( !idrinth.settings.get ( "warBottom" ) ) {
removeClasses.push ( "bottom" );
}
} else {
Expand Down
Loading

0 comments on commit 999587a

Please sign in to comment.