Large diffs are not rendered by default.

@@ -93,7 +93,7 @@ tools.cage.clearSavedData = function() {
tools.Settings.start();
};
tools.cage.loadData = function(_data) {
var _data = JSON.parse(_data);
_data = JSON.parse(_data);
Object.keys(_data).forEach(function(key) {
console.log(key, _data[key]);
localStorage[key] = _data[key];
@@ -131,4 +131,4 @@ tools.cage.toggleFx = function() {
};
tools.cage.init = function() {
tools.cage.runtimeUpdate();
}
};
@@ -31,7 +31,7 @@ tools.castleage.settings = function() {
};

tools.castleage.runtimeUpdate = function() {
if(!tools.castleage.runtime) {
if (!tools.castleage.runtime) {
tools.castleage.runtime = {};
}
tools.castleage.runtime.battleResults = item.get('castleageBattleResults', false);
@@ -69,27 +69,28 @@ tools.castleage.init = function() {
item.set('sidebarGuildChat', tools.castleage.runtime.sidebarGuildChat);
tools.castleage.sidebarGuildChat();
});
}
};
tools.castleage.macBGFix = function() {
if(tools.castleage.runtime.macBGFix) {
if (tools.castleage.runtime.macBGFix) {
tools.Page.runtime.addOn['tools.castleage.macBGFix'] = function() {
setTimeout(function() {
$('#app_body div').each(function(_i, _e) {
if($(this).css('backgroundImage') !== "none") {
$(this).css('backgroundImage', $(this).css('backgroundImage'))
};
if ($(this).css('backgroundImage') !== "none") {
$(this).css('backgroundImage', $(this).css('backgroundImage'));
}
;
});
}, 100);
}
};
} else {
if(tools.Page.runtime.addOn['tools.castleage.macBGFix']) {
if (tools.Page.runtime.addOn['tools.castleage.macBGFix']) {
tools.Page.runtime.addOn['tools.castleage.macBGFix'] = null;
}
}

}
};
tools.castleage.sidebarGuildChat = function() {
if(tools.castleage.runtime.sidebarGuildChat === true) {
if (tools.castleage.runtime.sidebarGuildChat === true) {
$('#cageSidebarChat').append($('#chatGuildChat').detach()).append($('#chatGuildChatTextBox').detach()).show();
$('#chatGuildChat').addClass('chatGuildChatSidebar').css('height', '100%');
$('#chatGuildChatContainer').addClass('chatGuildChatContainerSidebar');
@@ -105,44 +106,44 @@ tools.castleage.sidebarGuildChat = function() {
$('#chatGuildChatSizeHandle').hide();
}
$('#chatGuildChat').scrollTop($('#chatGuildChat div').length * 20);
}
};
tools.castleage.scrollGuildChat = function() {
if(tools.castleage.runtime.scrollGuildChat === true) {
if (tools.castleage.runtime.scrollGuildChat === true) {
$('#chatGuildChat').bind('DOMNodeInserted', function() {
$('#chatGuildChat').scrollTop($('#chatGuildChat div').length * 20);
});
} else {
$('#chatGuildChat').unbind('DOMNodeInserted');
}
}
};
tools.castleage.results = function() {
if(tools.castleage.runtime.battleResults || tools.castleage.runtime.hourly) {
if (tools.castleage.runtime.battleResults || tools.castleage.runtime.hourly) {
tools.Page.runtime.addOn['tools.castleage.results'] = function() {
var _re = [];
if(tools.castleage.runtime.battleResults) {
if (tools.castleage.runtime.battleResults) {
_re.push('You have now won a total');
}
if(tools.castleage.runtime.hourly) {
if (tools.castleage.runtime.hourly) {
_re.push('Dwarven Miner - |Your treasury is flourishing in Castle Age|Your potion is not ready yet');
}
if(tools.castleage.runtime.upgrade) {
if (tools.castleage.runtime.upgrade) {
_re.push('You just upgraded your');
}

var _reg = new RegExp(_re.join('|'), "g");
$('#results_main_wrapper div.results').each(function() {
if($(this).text().match(_reg) !== null) {
if ($(this).text().match(_reg) !== null) {
console.log('REMOVED BR');
$(this).remove();
}
});
if($('#results_main_wrapper div.results').length == 0) {
if ($('#results_main_wrapper div.results').length == 0) {
$('#results_main_wrapper div.results').hide();
}
}
};
} else {
if(tools.Page.runtime.addOn['tools.castleage.results']) {
tools.Page.runtime.addOn['tools.castleage.results'] = null
if (tools.Page.runtime.addOn['tools.castleage.results']) {
tools.Page.runtime.addOn['tools.castleage.results'] = null;
}
}
};
@@ -42,7 +42,7 @@ tools.COPTER.request = function() {
tools.COPTER.receiver = function(_data) {
_copter = JSON.parse(_data);
if(_copter && _copter.status === 'connected') {
var _lvl = parseInt($('#st_5').children().eq(1).text().match(/\d+/), 10)
var _lvl = parseInt($('#st_5').children().eq(1).text().match(/\d+/), 10);
if(!isNaN(_lvl) && _lvl !== _copter.level) {
tools.COPTER.addDisplay();
} else {
@@ -16,39 +16,38 @@ tools.Facebook.runtimeUpdate = function() {
idWait : false,
idCallbacks : [],
id : [],
friendlistId : {
},
friendlistId : {},
listMembersWait : false,
listMembersNext : [],
hideBluebar : item.get('cage.Facebook.Bluebar', false)
};
$('#cageHideFBBluebar').data('hidden', tools.Facebook.runtime.hideBluebar);
if(tools.Facebook.runtime.hideBluebar === true) {
if (tools.Facebook.runtime.hideBluebar === true) {
$('#cageHideFBBluebar').data('hidden', !tools.Facebook.runtime.hideBluebar).click();
}
}
};
/*
* Get friendlist members
*/
tools.Facebook.GetListMembers = function(_friendlist, _callback) {

if(tools.Facebook.runtime.listMembersWait == false) {
if (tools.Facebook.runtime.listMembersWait == false) {
console.log('tools.Facebook.GetListMembers: Reading members of ', _friendlist);
tools.Facebook.runtime.listMembersWait = true;
var _listmembers = [];
customEvent('GetFLMembers', function() {
var _members = JSON.parse($('#GetFLMembers').val());
if(_members !== 'false') {
//_members = JSON.parse(_members);
if (_members !== 'false') {
// _members = JSON.parse(_members);
$.each(_members, function(_i, _e) {
_listmembers.push(_e.id);
});
}
tools.Facebook.runtime.listMembersWait = false
if(_callback) {
tools.Facebook.runtime.listMembersWait = false;
if (_callback) {
_callback(_listmembers);
}
while( _call = tools.Facebook.runtime.listMembersNext.shift()) {
while (_call = tools.Facebook.runtime.listMembersNext.shift()) {
console.log('unparked...');
_call();
}
@@ -57,7 +56,7 @@ tools.Facebook.GetListMembers = function(_friendlist, _callback) {
addFunction(function(_list) {
function cageGetFLM() {
FB.api(_list.flid + '/members', function(_members) {
if(_members.error) {
if (_members.error) {
window.setTimeout(function() {
cageGetFLM(_list);
}, 100);
@@ -76,33 +75,33 @@ tools.Facebook.GetListMembers = function(_friendlist, _callback) {
console.log('parked...');
tools.Facebook.runtime.listMembersNext.push(function() {
tools.Facebook.GetListMembers(_friendlist, _callback);
})
});
}
};
/*
* Get Friend list names from FB
*/
tools.Facebook.getFriendlists = function(_callback) {

if(tools.Facebook.runtime.friendListWait == false) {
if(tools.Facebook.runtime.friendlists.length !== 0) {
if (tools.Facebook.runtime.friendListWait == false) {
if (tools.Facebook.runtime.friendlists.length !== 0) {
_callback(tools.Facebook.runtime.friendlists);
} else {
console.log('tools.Facebook.getFriendlists: Get FB friend lists...');
tools.Facebook.runtime.friendListWait = true;
customEvent('GetFriendLists', function() {
var _fl = $('#GetFriendLists').val();
if(_fl !== 'false') {
if (_fl !== 'false') {
$.each(JSON.parse(_fl), function(_i, _e) {
tools.Facebook.runtime.friendlistId[_e.name] = _e.id;
tools.Facebook.runtime.friendlists.push(_e.name);
})
});
}
tools.Facebook.runtime.friendListWait = false;
if(_callback) {
if (_callback) {
_callback(tools.Facebook.runtime.friendlists.sort());
}
while( _call = tools.Facebook.runtime.friendListCallbacks.shift()) {
while (_call = tools.Facebook.runtime.friendListCallbacks.shift()) {
_call(tools.Facebook.runtime.friendlists);
}
$('#GetFriendLists').val('');
@@ -112,20 +111,21 @@ tools.Facebook.getFriendlists = function(_callback) {
FB.api('me/friendlists', {
'list_type' : 'user_created'
}, function(responseFriendlist) {
if(responseFriendlist.error) {
if (responseFriendlist.error) {
window.setTimeout(getFriendlists, 100);
} else {
var _lists = [];
$.each(responseFriendlist.data, function(_i, _e) {
if(_e.name) {
if (_e.name) {
_lists.push(_e);
}
});
$('#GetFriendLists').val(JSON.stringify(_lists));
fireGetFriendLists();
}
});
};
}
;

getFriendlists();
}, null, true, true);
@@ -139,36 +139,36 @@ tools.Facebook.getFriendlists = function(_callback) {
*/
tools.Facebook.CAPlayers = function(_callback) {

if(tools.Facebook.runtime.idWait == false) {
if(tools.Facebook.runtime.id.length > 0) {
if (tools.Facebook.runtime.idWait == false) {
if (tools.Facebook.runtime.id.length > 0) {
_callback(tools.Facebook.runtime.id);
} else {
console.log('tools.Facebook.CAPlayers: Reading CA players...');
tools.Facebook.runtime.idWait = true;
tools.Facebook.runtime.id = [];
customEvent('GetArmy', function() {
var _army = $('#GetArmy').val();
if(_army !== 'false') {
if (_army !== 'false') {
_army = JSON.parse(_army);
$.each(_army, function(_i, _e) {
if(_e.installed == true) {
if (_e.installed == true) {
tools.Facebook.runtime.id.push(_e.id);
}
});
}
tools.Facebook.runtime.idWait = false
if(_callback) {
tools.Facebook.runtime.idWait = false;
if (_callback) {
_callback(tools.Facebook.runtime.id);
}
while( _call = tools.Facebook.runtime.idCallbacks.shift()) {
while (_call = tools.Facebook.runtime.idCallbacks.shift()) {
_call(tools.Facebook.runtime.id);
}
$('#GetArmy').val('');
});
addFunction(function() {
FB.api('/me/friends?fields=installed', function(_response) {
console.log('tools.Facebook.CAPlayers: got army...');
if(_response.data.length > 0) {
if (_response.data.length > 0) {
$('#GetArmy').val(JSON.stringify(_response.data));
} else {
$('#GetArmy').val('false');
@@ -184,7 +184,7 @@ tools.Facebook.CAPlayers = function(_callback) {

tools.Facebook.init = function() {
$(document.body).append($('<img id="cageHideFBBluebar" src="http://www.facebook.com/favicon.ico" class="cageFBBluebar">').data('hidden', false).click(function() {
if($(this).data('hidden') === false) {
if ($(this).data('hidden') === false) {
$(this).data('hidden', true).removeClass('cageFBBluebar').addClass('cageFBBluebarHidden');
com.send(com.task.hideBluebar, com.port.facebook);
} else {
@@ -7,7 +7,7 @@ tools.Functions.runtime = {};
tools.Functions.init = function() {
// add global cageStat
addFunction(function() {
cageStat = {}
cageStat = {};
}, null, true, true);
// replace CA funtions
addFunction(tools.Functions.stat_increase_ticker, null, true, true);
@@ -32,7 +32,7 @@ tools.Functions.cageRePos = function() {
window['cageRePos'] = function(fb_js_var, top) {
$('#single_popup_background').css('opacity', 0).removeClass('connect_castlepb_bg').fadeTo('slow', 0.75);
var _sp = $('#single_popup');
if(fb_js_var.indexOf('<div') !== -1) {
if (fb_js_var.indexOf('<div') !== -1) {
_sp.html(fb_js_var);
} else {
_sp.html($('#' + fb_js_var).html());
@@ -42,8 +42,8 @@ tools.Functions.cageRePos = function() {
'padding' : 0
});
var _width = _sp.width() == 0 ? _sp.find('>div:first').width() : _sp.width(), _margin = (770 - _width) / 2;
if(top) {
if(_sp.height() + (top - $(window).scrollTop() - $(window).height()) > 0) {
if (top) {
if (_sp.height() + (top - $(window).scrollTop() - $(window).height()) > 0) {
top -= _sp.height() + (top - $(window).scrollTop() - $(window).height());
}
_sp.css('top', top);
@@ -55,14 +55,14 @@ tools.Functions.cageRePos = function() {
}).fadeTo('slow', 1);
$(document).keypress(function(_key) {
console.log(_key.charCode);
if(_key.charCode == 120) {
if (_key.charCode == 120) {
$(document).unbind('keypress');
hidePositionBox();
}
});
_sp = _width = _margin = null;
};
}
};
tools.Functions.centerPopups = function() {
window['centerPopups'] = function() {
$('div.result_popup_message').each(function() {
@@ -73,14 +73,14 @@ tools.Functions.centerPopups = function() {
'opacity' : 0
}).fadeTo('fast', 1);
$(document).keypress(function(_key) {
if(_key.charCode == 120) {
if (_key.charCode == 120) {
$(document).unbind('keypress');
hideFeedbackPositionBox();
}
});
_popup = null;
});
}
};
};

tools.Functions.generateAtPageTop = function() {
@@ -126,49 +126,49 @@ tools.Functions.PositionAndDisplayPopupAtTop = function() {

tools.Functions.PopupAtMousePosition = function() {
window['PopupAtMousePosition'] = function(event, fb_js_var) {
//cageRePos(fb_js_var, Math.max(event.pageY + document.body.scrollTop - 326, 90 + document.body.scrollTop));
// cageRePos(fb_js_var, Math.max(event.pageY + document.body.scrollTop - 326, 90 + document.body.scrollTop));
cageRePos(fb_js_var, 90 + document.body.scrollTop);
};
};
tools.Functions.PositionAndDisplayPopupAutoCenter = function() {
window['PositionAndDisplayPopupAutoCenter'] = function(event, fb_js_var) {
cageRePos(fb_js_var, window.pageYOffset + 150);
}
};
};
// Stats Ticker + CAGE calls
tools.Functions.stat_increase_ticker = function() {
// set new value via cageStat
window['stat_increase_ticker'] = function(ticks_left, stat_current, stat_max, tick_time, increase_value, stat_type, first_call) {
if(cageStat[stat_type] && cageStat[stat_type] !== null) {
if (cageStat[stat_type] && cageStat[stat_type] !== null) {
stat_current = cageStat[stat_type];
$('#' + stat_type + '_current_value').text(stat_current);
cageStat[stat_type] = null;
}

if(!first_call && stopTimers) {
if (!first_call && stopTimers) {
return;
}

if(timedStats[stat_type] && first_call) {
if (timedStats[stat_type] && first_call) {
clearTimeout(timedStats[stat_type]);
}

if(ticks_left < 0) {
if (ticks_left < 0) {
ticks_left = 0;
}

var time_container = $('#' + stat_type + '_time_container'), time_value = $('#' + stat_type + '_time_value'), current_val = $('#' + stat_type + '_current_value');

if(!time_container || !time_value || !current_val) {
if (!time_container || !time_value || !current_val) {
time_container = time_value = current_val = null;
return;
}

if(ticks_left == 0) {
if (ticks_left == 0) {
stat_current = parseInt(stat_current);
increase_value = parseInt(increase_value);
stat_current += increase_value;
if(stat_current > stat_max) {
if (stat_current > stat_max) {
stat_current = stat_max;
}
current_val.html(stat_current);
@@ -177,14 +177,14 @@ tools.Functions.stat_increase_ticker = function() {
ticks_left -= 1;
}

if(stat_max == stat_current) {
if (stat_max == stat_current) {
time_container.empty();
time_container = time_value = current_val = null;
return;
}

var mins = parseInt(ticks_left / 60), secs = ticks_left % 60;
time_value.text(mins + ':' + ((secs > 9) ? secs : '0' + secs ));
time_value.text(mins + ':' + ((secs > 9) ? secs : '0' + secs));
timedStats[stat_type] = setTimeout(function() {
stat_increase_ticker(ticks_left, stat_current, stat_max, tick_time, increase_value, stat_type, false);
}, 1000);
@@ -1,29 +1,25 @@
// news
function cageNews(_full) {
var _hed = 'CAGE - Castle Age Game Enhancer - V ' + version.string(), _sub = 'You\'re now running CAGE and making your Castle Age life a bit easier ;)';
if(!item.get('permissions', false)) {
if (!item.get('permissions', false)) {
_sub += '<br><span style="color:red;font-weight:bold">It\'s possible you need some extra permissons for CAGE, please check Settings > CAGE</span>';
}
$('#results_main_wrapper').prepend('<div class="results"><div class="result"><span class="result_body"></div></span></div></div>');
$('#results_main_wrapper span.result_body:first').append('<div id="cageNews"><center id="cageNewsHead">' + _hed + '</center><center id="cageNewsSubHead">' + _sub + '</center><div id="cageNewsBody"><br><b>Changelog:</b><ul id="cageNewsChanges"></ul></div><div id="cageNewsFoot"><br><a href="http://cagenhancer.blogspot.com/" target="_blank">Blog</a> <a href="http://cagenhancer.blogspot.com/p/manual.html" target="_blank">Manual</a> <form action="https://www.paypal.com/cgi-bin/webscr" target="_blank" method="post" style="display:inline-block;bottom:-8px;position:relative"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="PC84GRGBLQ2J8"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1"></form> <a href="http://caaplayer.freeforums.org/c-a-g-e-f29.html" target="_blank">Forum</a> <a href="https://github.com/unknowner/CAGE" target="_blank">GitHub</a><br><br><span style="font-size:12px;text-align:center;">You want to say thank you? Just visit the Blog, click an Ad or donate via PayPal.</span></div></div>');
$('#results_main_wrapper span.result_body:first')
.append('<div id="cageNews"><center id="cageNewsHead">' + _hed + '</center><center id="cageNewsSubHead">' + _sub + '</center><div id="cageNewsBody"><br><b>Changelog:</b><ul id="cageNewsChanges"></ul></div><div id="cageNewsFoot"><br><a href="http://cagenhancer.blogspot.com/" target="_blank">Blog</a> <a href="http://cagenhancer.blogspot.com/p/manual.html" target="_blank">Manual</a> <form action="https://www.paypal.com/cgi-bin/webscr" target="_blank" method="post" style="display:inline-block;bottom:-8px;position:relative"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="PC84GRGBLQ2J8"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1"></form> <a href="http://caaplayer.freeforums.org/c-a-g-e-f29.html" target="_blank">Forum</a> <a href="https://github.com/unknowner/CAGE" target="_blank">GitHub</a><br><br><span style="font-size:12px;text-align:center;">You want to say thank you? Just visit the Blog, click an Ad or donate via PayPal.</span></div></div>');
$('#cageNewsFoot').prepend('<center>If you find bugs, just go to the blog and post them there (no signup required).<br>Logs (CTRL+SHIFT+J) are always welcome!</center>');
$.each([
'ADD: Select gift on RTF',
'FIX: Battle summary on home page',
'FIX: Assisting friendlists',
'FIX: Update function (Firefox only)',
'FIX: Remove generals from favorites',
'FIX: Monster stats overlapping',
'FIX: Consumables in keep only shows energy'
'ADD: Hide incomplete at alchemy page',
'ADD: Pin alchemy to top of list'
], function(_i, _e) {
$('#cageNewsChanges').append('<li><span>' + _e.split(':')[0] + '</span>' + _e.split(':')[1] + '</li>');
});
$('#cageNewsFoot a').button().css('color', '#FFF');
if(version.string() !== item.get('cageLocalVersion', '')) {
if (version.string() !== item.get('cageLocalVersion', '')) {
item.set('cageLocalVersion', version.string());
_full = true;
}
if(_full === false) {
if (_full === false) {
$('#results_main_wrapper div.result:first').css({
'height' : 75,
'overflow' : 'hidden'
@@ -39,12 +35,12 @@ function cageNews(_full) {
$(this).remove();
}));
}
if($('#results_main_wrapper div.results').length > 1) {
if ($('#results_main_wrapper div.results').length > 1) {
$('#results_main_wrapper div.result:first').css({
'borderBottom' : '1px solid #701919',
'paddingBottom' : 10
});
} else {
$('#results_main_wrapper').css('marginBottom', 10)
$('#results_main_wrapper').css('marginBottom', 10);
}
}
}
@@ -5,7 +5,7 @@ tools.Settings.runtime = {};
tools.Settings.start = function() {
$('body').animate({
scrollTop : 0
}, 'slow')
}, 'slow');
$('#app_body > table > tbody > tr > td').empty().html('<div id="results_main_wrapper" class="resultsmainwrapper" style="height:0;"><div class="results"><div class="result"><span class="result_body"></div></span></div></div></div><div id="cageSettingsTop"><span style="cursor:pointer;" id="cageShowNews">CAGE Settings<span></div><div id="cageSettingsMiddle"></div><div id="cageSettingsBottom"><a href="http://cagenhancer.blogspot.com/" target="_blank">Blog</a> <a href="http://cagenhancer.blogspot.com/p/manual.html" target="_blank">Manual</a> <a href="http://caaplayer.freeforums.org/c-a-g-e-f29.html" target="_blank">Forum</a> <a href="https://github.com/unknowner/CAGE" target="_blank">GitHub</a><br><br><span style="text-align:center;">You want to say thank you? Just visit the Blog, click an Ad or donate via PayPal.</span></div>');
$.each(tools, function(_index, _tool) {
if(_tool.settings) {
@@ -20,7 +20,7 @@ tools.Sidebar.hideSection = function(_section, _child, _text) {
_sec.data('inOut', _inOut);
_sec.children('.cageSidebarSectionHider').stop().animate({
opacity : _sec.data('inOut')
})
});
}


@@ -1,122 +1,53 @@
// Alchemy
tools.Page.pages['alchemy.php'] = function() {

// CSS stuff
$('div.statsT2 div.statsTTitle_inc').text($('div.statsT2 div.statsTTitle_inc').text().toLowerCase());
$('div.ingredientUnit').children('div').attr('style', '');
$('div.recipeImgContainer').parent().css('height', 80);
$('div.statsTTitle_inc').css({
'font-family' : 'sans-serif',
'text-transform' : 'capitalize',
'padding' : '6px 0 0 37px',
'text-decoration' : 'none',
'text-shadow' : '1px 1px 1px white'
console.log('Page: alchemy.php');

// pinned items
$('div[style*="/graphics/alchfb_top.jpg"]').after($('<div id="cagePinnedItems">'));
$('div[style *= "graphics/alchfb_midrepeat.jpg"]').addClass('cageAlchemyContainer').attr('style', '').append('<button class="cagePinItem ui-icon ui-icon-unlocked">');
$('div[style *= "graphics/alchfb_midrepeat_blank.jpg"]').addClass('cageAlchemyContainerBlank').attr('style', '').append('<button class="cagePinItem ui-icon ui-icon-unlocked">');
$('button.cagePinItem').click(function() {
var _topin = $(this).parent(), _pinned = _topin.clone(), _id = Math.floor(Math.random() * Math.random() * 100000000), _stored = item.get('cagePageAlchemyPinned', []);
_topin.data('name', _topin.find('div > div:eq(2) > div:eq(0) > div').text().trim());
if (_stored.indexOf(_topin.data('name')) === -1) {
_stored.push(_topin.data('name'));
}
item.set('cagePageAlchemyPinned', _stored);
_pinned.attr('id', _id + 'pinned').find('button.cagePinItem').unbind('click').click(function() {
var _storedPinned = item.get('cagePageAlchemyPinned', []), _hiddenPin = $('#' + _id + 'list'), _index = _stored.indexOf(_hiddenPin.data('name'));
if (_index !== -1) {
_storedPinned.splice(_index, 1);
item.set('cagePageAlchemyPinned', _storedPinned);
}
$(this).parent().remove();
_hiddenPin.removeClass('cagePinItemForceHidden');
}).removeClass('ui-icon-unlocked').addClass('ui-icon-locked').css('background-color', '#633').end().appendTo('#cagePinnedItems');
_topin.addClass('cagePinItemForceHidden').attr('id', _id + 'list');
});
var _stored = item.get('cagePageAlchemyPinned', []);
$('#cagePinnedItems').nextAll('div.cageAlchemyContainer, div.cageAlchemyContainerBlank').each(function() {
if (_stored.indexOf($(this).find('div > div:eq(2) > div:eq(0) > div').text().trim()) >= 0) {
$(this).find('button.cagePinItem').click();
}
});
$('div.statsTMain').css('display', 'none');
// Add hide & pin
$('div.statsT2 div.statsTTitle_inc').prepend($('<img src="http://image4.castleagegame.com/graphics/class_button_plus.jpg">').css({
'borderRadius' : 4,
'position' : 'absolute',
'marginLeft' : -31,
'marginTop' : -2
})).append($('<div id="cageHideRecipe"><img src="http://image4.castleagegame.com/graphics/boss_lotus_help2.gif"><span></span><span>Hide incomplete recipes</span></div>').toggle(function() {
$('#recipe_list').find('div.alchemyRecipeBackMonster:has(div.missing), div.alchemyQuestBack:has(div.missing), div.alchemyRecipeBackClass:has(div.missing), div.alchemyRecipeBack:has(div.missing)').addClass('cageHideIncomplete');

// hide incomplete button
$('#alchemy_sort_pulldown, #alchemy_filter_pulldown').parent().parent().height(40);
$('#alchemy_filter_pulldown').parent().parent().after($('<div id="cageHideRecipe"><img src="http://image4.castleagegame.com/graphics/boss_lotus_help2.gif"><span></span><span>HIDE INCOMPLETE</span></div>').toggle(function() {
$('#cagePinnedItems').nextAll('div.cageAlchemyContainer, div.cageAlchemyContainerBlank').filter(function() {
return $(this).find('input[value = "perform_alchemy"]').length == 0;
}).hide();
$('#cageHideRecipe').find('span:first').html('&#10003').end().children('img').attr('src', 'http://image4.castleagegame.com/graphics/boss_lotus_help3.gif');
item.set('cagePageAlchemyHideIncomplete', true);
}, function() {
$('#recipe_list').find('div.alchemyRecipeBackMonster:has(div.missing), div.alchemyQuestBack:has(div.missing), div.alchemyRecipeBackClass:has(div.missing), div.alchemyRecipeBack:has(div.missing)').removeClass('cageHideIncomplete');
$('#cagePinnedItems').nextAll('div.cageAlchemyContainer, div.cageAlchemyContainerBlank').show();
$('#cageHideRecipe').find('span:first').html('').end().children('img').attr('src', 'http://image4.castleagegame.com/graphics/boss_lotus_help2.gif');
item.set('cagePageAlchemyHideIncomplete', false);
}));
$('div.statsTTitle').css({
'cursor' : 'pointer'
}).toggle(function() {
$('div.statsTTitle_inc > img:first').attr('src', 'http://image4.castleagegame.com/graphics/class_button_minus.jpg');
$('div.statsTMain').css('display', 'block');
}, function() {
$('div.statsTTitle_inc > img:first').attr('src', 'http://image4.castleagegame.com/graphics/class_button_plus.jpg');
$('div.statsTMain').css('display', 'none');
});

setTimeout(function() {
var _ingredients = {}, $ingredientUnit = $('div.ingredientUnit');
$ingredientUnit.each(function(_i, _e) {
_e = $(_e);
var _count = _e.find('div:eq(1)');
_count.text(_count.text().replace('x', ''));
_ingredients[_e.find('img').attr('src')] = parseInt(_count.text(), 10);
_count = null;
});
//Recipes
$('td.statsTMainback').width(686);
$('div.recipeImgContainer').each(function(_i, _e) {
_e = $(_e);
var _count = _e.parent().find('> div:contains(x)');
_count.addClass('alchemyItemNum2');
if(_count.length === 0) {
_e.parent().find('> strong:contains(" of ")').addClass('alchemyItemNum2');
} else {
var _need = parseInt(_count.text().replace('x', ''), 10), _have = 0;
if(_ingredients[_e.children('img:first').attr('src')]) {
_have = _ingredients[_e.children('img:first').attr('src')];
_have = _have > _need ? _need : _have;
}
_count.text(_have + '/' + _need);
}
});
_ingredients = $ingredientUnit = null;
}, 50);
// pinned
$('#recipe_list td.statsTMainback').children('div:not(:last)').prepend('<div class="cagePinItem"><img src="http://image4.castleagegame.com/graphics/boss_lotus_help2.gif"><span></span><span>Pin item</span></div>');
$('div.cagePinItem').click(function() {
var $this = $(this), _storedPinned = item.get('cagePageAlchemyPinned', []), _alch = $this.parent().find('.recipeTitle').contents().first().text().trim(), _index = _storedPinned.indexOf(_alch);
console.log(_alch);
if(_index === -1) {
_storedPinned.push(_alch);
item.set('cagePageAlchemyPinned', _storedPinned);
var _c = $this.parent().clone(true);
console.log(_c);
_c.removeClass('cageHideIncomplete').addClass('cagePinedItemContainer').find('img[src="http://image4.castleagegame.com/graphics/boss_lotus_help2.gif"]').attr('src', 'http://image4.castleagegame.com/graphics/boss_lotus_help3.gif');
_c.find('span:first').html('&#10003').end().find('span:last').text('Unpin item');
$('#cagePinnedItems').append(_c);
$this.parent().addClass('cageHidePinnedItem');
} else {
_storedPinned.splice(_index, 1);
item.set('cagePageAlchemyPinned', _storedPinned);
$this.parent().remove();
$('#recipe_list td.statsTMainback').children('div').find('.recipeTitle:contains(' + _alch + ')').parent().parent().removeClass('cageHidePinnedItem');
}
});
$('#recipe_list').before($('<div id="cagePinnedItems" style="margin: 10px 16px -16px 10px;"></div>').css({
'max-height' : 375,
'overflowY' : 'auto',
'overflowX' : 'hidden',
'background' : 'rgba(0,0,0,0.5)',
'padding' : 12,
'margin' : '10px 0 0 0',
'width' : 693,
'boxShadow' : '0 0 10px #000, 0 0 10px #000 inset',
'borderRadius' : 15,
'position' : 'relative'
}));
var _storedPinned = item.get('cagePageAlchemyPinned', []), _storedNew = [];
$('#recipe_list td.statsTMainback').children('div').each(function(_i, _e) {
var $this = $(this), $title = $this.find('.recipeTitle');
if(_storedPinned.indexOf($title.contents().first().text().trim()) >= 0) {
_storedNew.push(_storedPinned[_storedPinned.indexOf($title.contents().first().text().trim())]);
var _c = $this.clone(true);
_c.removeClass('cageHideIncomplete').addClass('cagePinedItemContainer').find('img[src="http://image4.castleagegame.com/graphics/boss_lotus_help2.gif"]').attr('src', 'http://image4.castleagegame.com/graphics/boss_lotus_help3.gif');
$('#cagePinnedItems').append(_c);
$this.addClass('cageHidePinnedItem');
}
});
item.set('cagePageAlchemyPinned', _storedNew);
_storedPinned = _storedNew = null;

// remove some stuff
$('div.alchemySpaceRecipe, div.alchemySpaceClass, div.alchemySpaceMonster, div.alchemySpaceQuest').remove();

if(item.get('cagePageAlchemyHideIncomplete', true) === true) {
if (item.get('cagePageAlchemyHideIncomplete', false) === true) {
$('#cageHideRecipe').click();
}

};
@@ -8,7 +8,7 @@ tools.Page.pages['army_member.php'] = function() {
'marginLeft' : 515,
'width' : 250,
'textAlign' : 'left'
})
});
$('div:contains("Current Army Size"):last').css('width', 175).before($('<button style="width:85px;" class="cageArmyEdit">F<span>ill </span>A<span>rmy</button>').click(function() {
$('button.cageGifterButton').fadeOut('slow');
addFunction(function() {
@@ -18,7 +18,7 @@ tools.Page.pages['army_news_feed.php'] = function() {
$.each(tools['Assister'].runtime.Assisted, function(_i, _e) {
_alogs.append($('<div class="cageAssisterList imgButton"><img class="cageAssisterListImage" src="' + _e.image + '"><div class="cageAssisterListName">Assisted for: ' + _e.name + '<br>Time left: ' + _e.timer + '</div><div class="cageAssisterListValues">' + _e.values.join('<br>') + '</div></div>').click(function() {
tools.Page.loadPage(_e.link);
}))
}));
});
}));
}
@@ -36,7 +36,7 @@ tools.Page.pages['battle.php'] = function() {
item.set('cagePageBattleSortOrder', $('#cageBattleListSort span:last').text());
_battlesSorted.sort();
if($('#cageBattleListSort span:last').text() == 'descending') {
_battlesSorted.reverse()
_battlesSorted.reverse();
}
renderBattles();
}
@@ -50,7 +50,7 @@ tools.Page.pages['battle.php'] = function() {
if(_sortOrder == 'ascending') {
_battlesSorted.sort();
} else {
_battlesSorted.sort().reverse()
_battlesSorted.sort().reverse();
}
renderBattles();
}
@@ -69,7 +69,7 @@ tools.Page.pages['battle.php'] = function() {
_sortOrder = _sortOrder == 'ascending' ? 'descending' : 'ascending';
item.set('cagePageBattleOrder', _sortOrder);
$(this).text(_sortOrder);
chooseRank()
chooseRank();
});
chooseRank();

@@ -14,7 +14,7 @@ tools.Page.pages['conquest_duel.php'] = function() {
});
_battleSorted.sort();
if(_sortOrder == 'descending') {
_battleSorted.reverse()
_battleSorted.reverse();
}
_divs.remove();
$.each(_battleSorted, function(_i, _e) {
@@ -14,7 +14,7 @@ tools.Page.pages['festival_duel_battle.php'] = function() {
});
_battleSorted.sort();
if(_sortOrder == 'descending') {
_battleSorted.reverse()
_battleSorted.reverse();
}
_divs.remove();
$.each(_battleSorted, function(_i, _e) {
@@ -36,14 +36,12 @@ tools.Page.pages['festival_guild_battle.php'] = function() {
//reduce gate size and add number
if($('#enemy_guild_member_list:contains("No Soldiers Posted In This Position!")').length == 0) {
$('#enemy_guild_member_list > div > div, #your_guild_member_list > div > div').each(function(_i, _e) {
$(_e).append('<span class="GuildNum">' + (_i + 1) + '<span>')
$(_e).append('<span class="GuildNum">' + (_i + 1) + '<span>');
});
}

//Saved filter settings
var _storedClass = item.get('cagePageFestGuildBattleClass', 'All');
var _storedActivity = item.get('cagePageFestGuildBattleActivity', 'All');
var _storedStatus = item.get('cagePageFestGuildBattleStatus', 'All')
var _storedClass = item.get('cagePageFestGuildBattleClass', 'All'),_storedActivity = item.get('cagePageFestGuildBattleActivity', 'All'),_storedStatus = item.get('cagePageFestGuildBattleStatus', 'All');

//gate filter
function filterGate() {
@@ -8,9 +8,9 @@ tools.Page.pages['generals.php'] = function() {
$.each(tools.General.runtime.favLists, function(_i, _e) {
var _attr = {
value : _i
}
};
if(_e === tools.General.runtime.favList) {
_attr.selected = "selected"
_attr.selected = "selected";
}
_list.append($('<option>', _attr).text(_e));
});
@@ -121,5 +121,5 @@ tools.Page.pages['generals.php'] = function() {
tolerance : 'pointer'
});
//Update generals data
tools['General'].parsePage()
tools['General'].parsePage();
};
@@ -13,7 +13,7 @@ tools.Page.pages['gift.php'] = function() {
$('#giftContainer').attr({
'CAGEGiftNum' : _num,
'CAGEGiftName' : _nam.replace('!', '')
})
});
}
_this.click(function() {
$('#giftContainer').attr({
@@ -45,7 +45,7 @@ tools.Page.pages['guild_battle.php'] = function() {
//$('#your_guild_member_list, #enemy_guild_member_list').css('backgroundSize', '641px 110px');
if($('#your_guild_member_list:contains("No Soldiers Posted In This Position!"), #enemy_guild_member_list:contains("No Soldiers Posted In This Position!")').length === 0) {
$('#enemy_guild_member_list > div > div, #your_guild_member_list > div > div').each(function(_i, _e) {
$(_e).append('<span class="GuildNum">' + (_i + 1) + '<span>')
$(_e).append('<span class="GuildNum">' + (_i + 1) + '<span>');
});
}

@@ -27,7 +27,7 @@ tools.Page.pages['index.php'] = function() {
uid : _uid,
win : 0,
lose : 0
}
};
}
if(txt.match(/Victory!|VICTORIOUS/i)) {
win++;
@@ -42,7 +42,7 @@ tools.Page.pages['index.php'] = function() {
user : _uid,
win : users[_uid].win,
lose : users[_uid].lose
}
};
}
my_xp = txt.match(/(\d+) experience/i);
my_bp = txt.match(/(\d+) Battle Points!/i);
@@ -77,7 +77,7 @@ tools.Page.pages['index.php'] = function() {
if(nemesis.user !== null) {
$('#cageBattleNews').append($('<div id="cagePageKeepNemesisImg"><div style="background-image:url(\'http://graph.facebook.com/' + nemesis.user + '/picture?type=large\');"></div><div><strong style="width:150px;padding:0 0 3px 0;">Your Nemesis</strong><br><strong>Won</strong>' + nemesis.win + '<br><strong>Lost</strong>' + nemesis.lose + '<br></div></div>').click(function() {
tools.Page.loadPage('keep.php?user=' + nemesis.user);
}))
}));
}
}

@@ -23,7 +23,7 @@ tools.Page.pages['keep.php'] = function() {
'overflow' : 'hidden'
});
});
// Calulate devine power
// Calculate devine power
var _data = {}, _divPow = 0, _divItems = [], _divine = {
'general' : {
'Aegea' : 45,
@@ -94,7 +94,7 @@ tools.Page.pages['keep.php'] = function() {
_temp = _temp > _val ? _temp : _val;
}
});
_divPow += _temp
_divPow += _temp;
});
}

@@ -118,13 +118,7 @@ tools.Page.pages['keep.php'] = function() {
_data.bsi = Math.round((_data.att + _data.def) / _data.lvl * 100) / 100;
_data.lsi = Math.round((_data.eng + _data.sta * 2) / _data.lvl * 100) / 100;
_data.tsi = _data.bsi + _data.lsi;
$('div.keep_healer_section').prepend(
$('<div id="cageKeepStats">').append('<div>eAtt: ' + _data.eAt.toFixed(2) + '</div><div style="font-size:9px;">Effective Attack</div>').append(
'<div>eDef: ' + _data.eDe.toFixed(2) + '</div><div style="font-size:9px;">Effective Defense</div>').append(
'<div>BSI: ' + _data.bsi.toFixed(2) + '</div><div style="font-size:9px;">Battle Strength Index</div>').append(
'<div>LSI: ' + _data.lsi.toFixed(2) + '</div><div style="font-size:9px;">Levelling Speed Index</div>').append(
'<div>TSI: ' + _data.tsi.toFixed(2) + '</div><div style="font-size:9px;">Total Skillpoints per Level</div>').append(
'<div>Divine: ' + _divPow + '</div><div style="font-size:9px;">Calculated Divine Power</div>'));
$('div.keep_healer_section').prepend($('<div id="cageKeepStats">').append('<div>eAtt: ' + _data.eAt.toFixed(2) + '</div><div style="font-size:9px;">Effective Attack</div>').append('<div>eDef: ' + _data.eDe.toFixed(2) + '</div><div style="font-size:9px;">Effective Defense</div>').append('<div>BSI: ' + _data.bsi.toFixed(2) + '</div><div style="font-size:9px;">Battle Strength Index</div>').append('<div>LSI: ' + _data.lsi.toFixed(2) + '</div><div style="font-size:9px;">Levelling Speed Index</div>').append('<div>TSI: ' + _data.tsi.toFixed(2) + '</div><div style="font-size:9px;">Total Skillpoints per Level</div>').append('<div>Divine: ' + _divPow + '</div><div style="font-size:9px;">Calculated Divine Power</div>'));
}
// rearrange Items
setTimeout(function() {
@@ -151,7 +145,7 @@ tools.Page.pages['keep.php'] = function() {
}, function() {
$this.css('zIndex', '').children('div.cageUnitStats').remove();
}).attr('title', '').unwrap().unwrap();
})
});
}, 50);

// Add stuff on others keep
@@ -10,15 +10,15 @@ tools.Page.pages['raid.php'] = function() {
setRaidLst = function(diff, max_raid_lst) {
console.log(diff, max_raid_lst, cur_raid_lst);
var next_lst = cur_raid_lst + diff;
if(next_lst < 0)
if (next_lst < 0)
next_lst = 0;
else if(next_lst > max_raid_lst)
else if (next_lst > max_raid_lst)
next_lst = max_raid_lst;
if(next_lst !== cur_raid_lst && $('#raid_atk_lst' + next_lst).text().length !== 0) {
if (next_lst !== cur_raid_lst && $('#raid_atk_lst' + next_lst).text().length !== 0) {
$('#raid_atk_lst' + cur_raid_lst).stop().fadeOut('fast');
$('#raid_atk_lst' + next_lst).stop().fadeIn('fast');
cur_raid_lst = next_lst;
}
}
};
}, null, true, false);
};
@@ -51,7 +51,7 @@ tools.ArmyCleaner.readCAArmy = function(_page) {
'marginLeft' : 515,
'width' : 250,
'textAlign' : 'left'
})
});
var _last = /\d+/.exec($('a[href*="army_member.php?page="]:last', _armydata).text());
if(_last == null) {
tools.ArmyCleaner.readCAArmy(_page);
@@ -39,7 +39,7 @@ tools.ArmyFiller.readCAArmy = function(_page) {
'marginLeft' : 515,
'width' : 250,
'textAlign' : 'left'
})
});
var _last = /\d+/.exec($('a[href*="army_member.php?page="]:last', _armydata).text());
if(_last == null) {
tools.ArmyFiller.readCAArmy(_page);
@@ -37,7 +37,7 @@ tools.Assister.runtimeUpdate = function() {
assisterCommentMonster : item.get('assisterCommentMonster', true),
assisterCommentFBPost : item.get('assisterCommentFBPost', true),
assisterLikeFBPost : item.get('assisterLikeFBPost', true)
}
};
tools.Facebook.getFriendlists(function(_names) {
$.each(_names, function(_i, _e) {
tools.Assister.runtime.assisterLists[_e] = _e;
@@ -56,7 +56,7 @@ tools.Assister.start = function() {
} else {
tools.Facebook.GetListMembers(tools.Assister.runtime.assisterList, function(_ids) {
tools.Assister.getCTA(_ids);
})
});
}
};

@@ -175,7 +175,7 @@ tools.Assister.assist = function(_ids) {
tools.Assister.assist();
}
} else {
console.log('Assister - No assist, maybe already assisted')
console.log('Assister - No assist, maybe already assisted');
tools.Assister.assist();
}
}, 'text');
@@ -11,7 +11,7 @@ tools.Class.runtimeUpdate = function() {
4 : 'cleric'
},
classSet : null
}
};
};
tools.Class.start = function() {
signedGet('guild_class_power_equipment.php', function(_data) {
@@ -26,7 +26,6 @@ tools.Class.showClass = function(_data) {
//Get current class and setup class selector
tools.Class.runtime.classId = parseInt(_data.find('input[name="class_id"]').val(), 10);
tools.Class.runtime.classSet = tools.Class.runtime.classes[tools.Class.runtime.classId];
var _classes = ['cleric', 'mage', 'rogue', 'warrior'];
$.each(tools.Class.runtime.classes, function() {
var _set = this.toString(), _img = $('<img id="cageClassImg' + _set + '" src="http://image4.castleagegame.com/graphics/g_char_select' + _set + '.jpg">');
if(_set === tools.Class.runtime.classSet) {
@@ -62,7 +61,7 @@ tools.Class.showClass = function(_data) {
// available powers
tools.Class.runtime.powersOwn = {};
_data.find('input[id^="slot_image_"]').each(function() {
var _key = /\d+_\d+_\d+/.exec($(this).attr('id'))[0]
var _key = /\d+_\d+_\d+/.exec($(this).attr('id'))[0];
tools.Class.runtime.powersOwn[_key] = {
small : 'http://image4.castleagegame.com/graphics/' + $(this).val(),
big : $(this).next('div.imgButton').find('img').attr('nosrc')
@@ -145,7 +144,7 @@ tools.Class.showClass = function(_data) {
$('#cageClassContainer').animate({
'top' : 99
}, 'slow');
}
};
tools.Class.changeClass = function(_class) {
$('#cageClassLogo').css({
'cursor' : 'wait',
@@ -163,7 +162,7 @@ tools.Class.done = function() {
$('#cageClassContainer').animate({
'top' : -500
}, 'slow', function() {
$(this).hide
$(this).hide();
});
$('#cageClassLogo').css({
'cursor' : 'pointer',
@@ -9,7 +9,7 @@ tools.Demi.runtimeUpdate = function() {
5 : 25
},
bgSet : 1
}
};
};
tools.Demi.start = function() {

@@ -20,7 +20,7 @@ tools.Demi.start = function() {
$('div[id^="symbol_displaysymbols"]', _demipage).each(function(_i, _e) {
var _text = $(_e).text(), _deity = /\+1 max (\w+)/.exec(_text)[1], _points = /You have (\d+)/.exec(_text)[1];
_demi.append('<div><div id="cageDemi' + _deity + '" class="cageDemiImage" style="background-image:url(http://image4.castleagegame.com/graphics/deity_' + _deity + '.jpg);" symbol="' + (_i + 1) + '"><span>' + _points + '<br>' + _deity.substr(0, 1).toUpperCase() + _deity.substr(1) + '</span></div></div>');
})
});
_demi.append($('<img style="position: absolute;right: 1px;cursor: pointer;margin-top: 8px;height: 18px;" src="http://image4.castleagegame.com/graphics/popup_close_button.png">').click(function() {
_demi.animate({
'top' : -100
@@ -42,7 +42,9 @@ tools.Demi.start = function() {
zIndex : 3999,
width : 440,
minHeight : 0,
position : ['center', 50],
position : [
'center', 50
],
draggable : false,
buttons : {
"Ok" : function() {
@@ -59,20 +61,20 @@ tools.Demi.start = function() {
_demi.hide().empty();
});
tools.Demi.done();
})
})
});
});
};
tools.Demi.timer = function() {
var _last = item.get('cageDemiLast', null);
if(_last !== null) {
if (_last !== null) {
var _date = new Date(_last);
var _wait = item.get('cageDemiTime', 24);
_date.setHours(_date.getHours() + _wait);
var _ms = Date.parse(_date) - Date.parse((new Date()));
var _sec = _ms / 1000;
var _min = Math.floor(_sec % 3600 / 60);
var _hr = Math.floor(_sec / 3600);
if(_hr < 0 || _min < 0) {
if (_hr < 0 || _min < 0) {
$('#cageNextDemi span:last').text('Now');
$('#cageNextDemi > div:eq(1) > div').css({
'width' : '100%',
@@ -93,13 +95,13 @@ tools.Demi.timer = function() {
};
tools.Demi.parse = function(_pagedata) {
// Set/check demi timer
var _pagedata = $(_pagedata).text();
if(_pagedata.indexOf('You cannot pay another tribute so soon') !== -1 || _pagedata.indexOf('You have paid tribute to') !== -1) {
_pagedata = $(_pagedata).text();
if (_pagedata.indexOf('You cannot pay another tribute so soon') !== -1 || _pagedata.indexOf('You have paid tribute to') !== -1) {
var _wait = _pagedata.indexOf('Azeron') > 0 ? 48 : 24;
var _hour = _wait;
var _minute = 0;
var _demi = new Date();
if(_pagedata.indexOf('You cannot pay another tribute so soon') !== -1) {
if (_pagedata.indexOf('You cannot pay another tribute so soon') !== -1) {
_hour = parseInt(/(\d+)(?= hours)/.exec(_pagedata)[0], 10);
_minute = parseInt(/(\d+)(?= minutes)/.exec(_pagedata)[0], 10);
_demi.setHours(_demi.getHours() + _hour - _wait, _demi.getMinutes() + _minute);
@@ -116,7 +118,7 @@ tools.Demi.done = function() {
'backgroundPosition' : tools.Demi.runtime.bgDemi[tools.Demi.runtime.bgSet] + 'px 0',
'backgroundImage' : 'url(\'http://image4.castleagegame.com/graphics/choose_demi.jpg\')'
}).removeAttr('disabled');
//tools.Demi.fbButton.enable();
// tools.Demi.fbButton.enable();
};
tools.Demi.init = function() {
tools.Demi.runtimeUpdate();
@@ -85,7 +85,7 @@ tools.Favor.init = function() {
'marginLeft' : 3
}, 'fast');
}).appendTo('#cageStatsFavor span');
}
};
tools.Favor.runtimeUpdate = function() {
tools.Favor.runtime = {};
};
@@ -11,7 +11,7 @@ tools.General.settings = function() {
tools.Settings.onoff(language.generalsSetFixHeight, tools.General.runtime.generalsSetFixHeight, 'generalsSetFixHeight', tools.General.runtimeUpdate);
};
tools.General.generalsSetFixHeight = function() {
if(tools.General.runtime.generalsSetFixHeight) {
if (tools.General.runtime.generalsSetFixHeight) {
$('#cageAllGenerals').css({
'overflow' : 'auto',
'maxHeight' : 208,
@@ -26,7 +26,7 @@ tools.General.generalsSetFixHeight = function() {
}
};
tools.General.runtimeUpdate = function() {
if(!tools.General.runtime) {
if (!tools.General.runtime) {
tools.General.runtime = {};
}
tools.General.runtime.generalsSetFixHeight = item.get('generalsSetFixHeight', false);
@@ -39,31 +39,35 @@ tools.General.runtimeUpdate = function() {
tools.General.runtime.favorites = item.get('favFavorites', {
'Favorites' : []
});
if(!tools.General.runtime.general) {
if (!tools.General.runtime.general) {
tools.General.runtime.general = {};
}
if(tools.General.runtime.favLists == false) {
tools.General.runtime.favLists = ['Favorites'];
if(item.get('favouriteGenerals', false) !== false) {
if (tools.General.runtime.favLists == false) {
tools.General.runtime.favLists = [
'Favorites'
];
if (item.get('favouriteGenerals', false) !== false) {
tools.General.runtime.favorites.Favorites = item.get('favouriteGenerals', []);
}
item.set('favList', 'Favorites');
item.set('favLists', ['Favorites']);
item.set('favLists', [
'Favorites'
]);
item.set('favFavorites', tools.General.runtime.favorites);
}

};
//get current general from CA
// get current general from CA
tools.General.get = function() {
if($('div[style*="graphics/hot_container.gif"]').length > 0) {
if ($('div[style*="graphics/hot_container.gif"]').length > 0) {
var _old = tools.General.current, _i = $('#main_bn div > img[style="width:24px;height:24px;"]');
tools.General.current = $('div[style*="graphics/hot_container.gif"] > div:first').text().trim();
setTimeout(function() {
if(_i.length > 0) {
if (_i.length > 0) {
$('#cageGeneralEquipment').empty().append(_i);
}
}, 100);
if(_old !== tools.General.current) {
if (_old !== tools.General.current) {
$('#cageGeneralImageCharge').remove();
$('#cageGeneralImage, #cagegeneralname, #cageGeneralDefense').fadeOut('slow');
$('#cageGeneralAttack').fadeOut('slow', function() {
@@ -80,39 +84,39 @@ tools.General.set = function() {
$('#cageGeneralDefense').text(_values[1]);
$('#cageGeneralText').text(_g.text);
$('#cageGeneralImageCharge').remove();
if(_g.charge) {
if (_g.charge) {
var _cool = _g.cooldown * 60 - (_g.cooldown * _g.charge / 10 * 6);
$('#cageGeneralImageContainer').append('<div id="cageGeneralImageCharge"><div style="width:' + _g.charge + '%;"></div><span>' + (_g.charge == 100 ? 'Charge!' : Math.floor((_cool - (_cool % 60)) / 60) + ':' + Math.floor((_cool % 60)) + '</span></div>'))
$('#cageGeneralImageContainer').append('<div id="cageGeneralImageCharge"><div style="width:' + _g.charge + '%;"></div><span>' + (_g.charge == 100 ? 'Charge!' : Math.floor((_cool - (_cool % 60)) / 60) + ':' + Math.floor((_cool % 60)) + '</span></div>'));
}
$('#cageGeneralImage').attr('src', _g.image);
$('#cageGeneralImage, #cageGeneralName, #cageGeneralDefense, #cageGeneralAttack').fadeIn('slow');
};
// Set General by name
tools.General.setByName = function(_name, _callback) {
if(_name !== tools.General.current) {
if (_name !== tools.General.current) {
$('#cageGeneralImageCharge').remove();
var _g = tools.General.runtime.general[_name];
if(_g !== null) {
if (_g !== null) {
$('#cageGeneralImage, #cagegeneralname, #cageGeneralDefense, #cageGeneralAttack').fadeOut('slow');
signedGet('generals.php?item=' + _g.item + '&itype=' + _g.itype + '&bqh=' + CastleAge.bqh, function(_data) {
$data = $(noSrc(_data));
$('#main_bn').html($data.find('#main_bn').html());
var _i = $('#main_bn').find('div > img[style="width:24px;height:24px;"]');
if($('div.generalContainerBox:first').length == 1) {
$('div.generalContainerBox:first').next('div').replaceWith($data.find('div.generalContainerBox:first').next('div'))
if ($('div.generalContainerBox:first').length == 1) {
$('div.generalContainerBox:first').next('div').replaceWith($data.find('div.generalContainerBox:first').next('div'));
}
setTimeout(function() {
if(_i.length > 0) {
if (_i.length > 0) {
_i.each(function() {
$(this).attr('src', $(this).attr('nosrc')).attr('nosrc', '');
})
});
$('#cageGeneralEquipment').empty().append(_i);
}
}, 100);
tools.Stats.update($('#main_sts', _data));
tools.General.parsePage(_data);
tools.General.current = _name;
if(_callback !== undefined) {
if (_callback !== undefined) {
_callback();
}
});
@@ -121,8 +125,8 @@ tools.General.setByName = function(_name, _callback) {
};
// update generals object
tools.General.update = function() {
if(CastleAge.signed_request !== null) {
if($('div.generalContainerBox:first').length == 1) {
if (CastleAge.signed_request !== null) {
if ($('div.generalContainerBox:first').length == 1) {
tools.General.parsePage();
} else {
signedGet('generals.php', function(_data) {
@@ -138,9 +142,9 @@ tools.General.lists = function() {
$.each(tools.General.runtime.favLists, function(_i, _e) {
var _attr = {
value : _i
}
if(_e === tools.General.runtime.favList) {
_attr.selected = "selected"
};
if (_e === tools.General.runtime.favList) {
_attr.selected = 'selected';
}
_list.append($('<option>', _attr).text(_e));
});
@@ -155,7 +159,7 @@ tools.General.parsePage = function(_data) {
var _names = [], _src = _data ? 'nosrc' : 'src';
_data = _data ? $(noSrc(_data)) : $('#app_body');
_data.find('table.layout div.general_pic_div3').each(function(i, e) {
var $_this = $(this), $_image = $('form:has(input[name="item"]) input.imgButton', e), $_general = $_this.parent(), _name = $_general.children('div.general_name_div3:first').text().trim(), _stats = $_general.find('div.generals_indv_stats_padding'), _charge = $_this.find('div[style*="gen_chargebarsmall.gif"]:last'), _gtext = $_general.children('div:last').children('div');
var $_this = $(this), $_image = $('form:has(input[name="item"]) input.imgButton', e), $_general = $_this.parent(), _name = $_general.children('div.general_name_div3:first').text().trim(), _charge = $_this.find('div[style*="gen_chargebarsmall.gif"]:last'), _gtext = $_general.children('div:last').children('div');
_names.push(_name);
tools.General.runtime.general[_name] = {
name : _name,
@@ -167,7 +171,7 @@ tools.General.parsePage = function(_data) {
text : _gtext.html(_gtext.html().replace(/<br>/g, ' ')).text().trim(),
level : $_general.find('div:contains("Level"):last').text().trim()
};
if(_charge.length > 0) {
if (_charge.length > 0) {
tools.General.runtime.general[_name].charge = Math.round(parseInt(_charge.css('width').replace('px', ''), 10) / (_charge.parent().css('width') == '0px' ? 1 : 1.12), 2);
tools.General.runtime.general[_name].cooldown = /\d+(?= Hour cooldown)/ig.exec(tools.General.runtime.general[_name].text)[0];
}
@@ -176,7 +180,7 @@ tools.General.parsePage = function(_data) {
$('#cageGeneralSelector').html('<span id="cageSelectorInfo" class="ui-state-active ui-corner-left"></span><select id="cageSelectorList"></select><div id="cageFavoriteGenerals"></div><div id="cageAllGenerals"></div>');

console.log(tools.General.runtime.general);
for(var i = 0, len = _names.length; i < len; i++) {
for ( var i = 0, len = _names.length; i < len; i++) {
var _e = tools.General.runtime.general[_names[i]];
$('#cageAllGenerals').append($('<div>').append($('<img src="' + _e.image + '" alt="' + _e.name + '" />').click(function() {
tools.General.setByName($(this).attr('alt'));
@@ -187,7 +191,7 @@ tools.General.parsePage = function(_data) {
}, function() {
$('#cageSelectorInfo').html('');
})).append($('<img src="' + getPath('img/fav.png') + '" alt="' + _e.name + '" />').hover(tools.General.hoverAddIn, tools.General.hoverAddOut).click(tools.General.clickAdd)));
if(_e.charge) {
if (_e.charge) {
$('#cageAllGenerals div:last').append('<div class="cageCharge" style="height:' + Math.max(10, _e.charge) + '%;' + (_e.charge < 100 ? '' : 'background-color:#4F4;') + '"></div>');
}
}
@@ -199,17 +203,17 @@ tools.General.parsePage = function(_data) {
};
tools.General.renderFavs = function() {
$('#cageAllGenerals > div').show();
$('#cageSelectorList').val()
if(tools.General.runtime.favorites[tools.General.runtime.favList] && tools.General.runtime.favorites[tools.General.runtime.favList].length > 0) {
// $('#cageSelectorList').val()
if (tools.General.runtime.favorites[tools.General.runtime.favList] && tools.General.runtime.favorites[tools.General.runtime.favList].length > 0) {
var _tempFav = tools.General.runtime.favorites[tools.General.runtime.favList];
$('#cageFavoriteGenerals').html('');
for(var i = 0, len = _tempFav.length; i < len; i++) {
for ( var i = 0, len = _tempFav.length; i < len; i++) {
$('#cageAllGenerals > div > img[alt="' + _tempFav[i] + '"]').parent().hide().clone(true, true).appendTo('#cageFavoriteGenerals').show().find('img:last').unbind().click(tools.General.clickRemove).hover(tools.General.hoverRemoveIn, tools.General.hoverRemoveOut);
}
} else {
$('#cageFavoriteGenerals').html('');
}
}
};
tools.General.clickAdd = function() {
tools.General.runtime.favorites[tools.General.runtime.favList].push($(this).attr('alt'));
console.log('clickAdd:', tools.General.runtime.favorites);
@@ -244,14 +248,14 @@ tools.General.hoverRemoveOut = function() {
// show/hide generals
tools.General.showAll = function() {
var _speed = 'slow';
if(tools.General.runtime.onlyFavourites == true) {
if (tools.General.runtime.onlyFavourites == true) {
$('#cageAllGenerals').hide();
_speed = 'fast';
} else {
$('#cageAllGenerals').show();
}
$('#cageGeneralSelector').slideToggle(_speed);
}
};
// init general tool
tools.General.init = function() {
tools.General.runtimeUpdate();
@@ -264,11 +268,11 @@ tools.General.init = function() {
generalValues : '<div id="cageGeneralEquipment"></div><div id="cageGeneralAttDiv"><img src="http://image4.castleagegame.com/graphics/icon_atk.gif" id="cageGeneralAttImg" /><span id="cageGeneralAttack"></span></div><div id="cageGeneralDefDiv"><img src="http://image4.castleagegame.com/graphics/icon_def.gif" id="cageGeneralDefImg" /><span id="cageGeneralDefense"></span></div>',
generalText : '<div id="cageGeneralText"></div>',
generalSelector : '<div id="cageGeneralSelector" class="ui-widget-content ui-corner-bottom">',
}
};
$('#cageContainer').append(_elm.general).prepend(_elm.generalSelector);
$('#cageSidebarHeader').append($(_elm.generalImageContainer).append(_elm.generalName).append(_elm.generalValues).append(_elm.generalImage)).append($(_elm.generalStatsDiv).append(_elm.generalText));
$('#cageGeneralImage').click(function() {
if(tools.General.runtime.onlyFavourites == true) {
if (tools.General.runtime.onlyFavourites == true) {
$('#cageAllGenerals').hide();
} else {
$('#cageAllGenerals').show();
@@ -284,11 +288,11 @@ tools.General.init = function() {
'opacity' : 0,
'top' : 5,
}, 'slow', function() {
$(this).hide()
$(this).hide();
});
});
$('#cageGeneralEquipment').click(function() {
tools.Page.loadPage('guild_class_item_equipment.php')
tools.Page.loadPage('guild_class_item_equipment.php');
});
tools.General.update();
_elm = null;
@@ -14,23 +14,23 @@ tools.Gifter.init = function() {
tools.Gifter.runtime.returnGift = true;
tools.Gifter.start();
});
//prepare update event to receive userids and request ids
// prepare update event to receive userids and request ids
customEvent('GiftRequests', function() {
console.log('EVENT: GiftRequests');
_gifts = JSON.parse(JSON.parse($('#GiftRequests').val()));
console.log(_gifts);
var _received = 0;
if(_gifts) {
if (_gifts) {
$.each(_gifts.data, function(_i, _e) {
if(_e.from !== null) {
if($.inArray(_e.from.id, tools.Gifter.runtime.sendGiftTo) === -1) {
if (_e.from !== null) {
if ($.inArray(_e.from.id, tools.Gifter.runtime.sendGiftTo) === -1) {
tools.Gifter.runtime.sendGiftTo.push(_e.from.id);
_received++;
}
tools.Gifter.runtime.requests.push(_e.id);
}
});
if(_received === 0) {
if (_received === 0) {
note('Gifter', 'No gifts to accept.');
} else {
note('Gifter', 'You accepted ' + _received + ' gift(s).');
@@ -58,8 +58,8 @@ tools.Gifter.runtimeUpdate = function() {
returnGift : false,
returnGiftNum : 1,
returnGiftName : null
}
if(tools.Gifter.runtime.sendGiftTo == null) {
};
if (tools.Gifter.runtime.sendGiftTo == null) {
tools.Gifter.runtime.sendGiftTo = [];
}
tools.Facebook.getFriendlists(function(_names) {
@@ -68,7 +68,7 @@ tools.Gifter.runtimeUpdate = function() {
});
});
console.log('tools.Gifter.runtime', tools.Gifter.runtime);
}; 7
};
tools.Gifter.start = function() {
addFunction(function() {
FB.api('/me/apprequests/', function(_response) {
@@ -78,7 +78,7 @@ tools.Gifter.start = function() {
}, null, true, true);
};
tools.Gifter.work = function() {
if(tools.Gifter.runtime.requests.length > 0) {
if (tools.Gifter.runtime.requests.length > 0) {
signedGet('index.php?request_ids=' + tools.Gifter.runtime.requests.join(','), function(_data) {
_data = $(noSrc(_data));
$('#results_container').after(noNoSrc(_data.find('div[style*="graphics/newrequest_background.jpg"]:first')));
@@ -90,12 +90,12 @@ tools.Gifter.work = function() {
}
};
tools.Gifter.done = function() {
if(tools.Gifter.runtime.returnGift === true) {
if(tools.Gifter.runtime.returnGiftName === null) {
if (tools.Gifter.runtime.returnGift === true) {
if (tools.Gifter.runtime.returnGiftName === null) {
get('gift.php?request_ids=' + tools.Gifter.runtime.requests.join(','), function(_data) {
$('body').append('<div id="cageLevelUp"><div></div><div><div id="cageLevelUpTop" style="padding:15px 0 0 50px !important;width:448px !important;"></div><div id="cageLevelUpMiddle"></div><div id="cageLevelUpBottom"></div></div></div>');
var _cLU = $('#cageLevelUpMiddle');
_cLU.append('<div id="cageRTFGift"></div>')
_cLU.append('<div id="cageRTFGift"></div>');
console.log(tools.Gifter.runtime.returnGiftNum);
$(_data).find('#giftContainer div[id^="gift"]').each(function() {
var $this = $(this), _num = $this.attr('id').match(/\d+/)[0], _name = $this.text().trim().replace('!', '');
@@ -109,7 +109,7 @@ tools.Gifter.done = function() {
$('#cageRTFGift > img').removeClass('cageRTFGiftSelected');
$(this).addClass('cageRTFGiftSelected');
}));
if(tools.Gifter.runtime.returnGiftNum == _num) {
if (tools.Gifter.runtime.returnGiftNum == _num) {
$('#cageRTFGift').children('img:last').addClass('cageRTFGiftSelected');
tools.Gifter.runtime.returnGiftNum = _num;
tools.Gifter.runtime.returnGiftName = _name;
@@ -121,19 +121,20 @@ tools.Gifter.done = function() {
$('#cageLevelUp').fadeOut('fast', function() {
$(this).remove();
tools.Gifter.done();
})
});
}));
//cancel gifting
// cancel gifting
_cLU.append($('<img id="cageLevelUpCancel" src="http://image4.castleagegame.com/graphics/war_select_button_cancel.gif">').click(function() {
$('#cageLevelUp').fadeOut('fast', function() {
$(this).remove();
tools.Gifter.runtime.returnGift = false;
tools.Gifter.done();
})
});
}));
$('#cageLevelUp').show();
//tools.Gifter.runtime.returnGiftName = $(_data).find('div[id="gift' + tools.Gifter.runtime.returnGiftNum + '"]:first').text().trim().replace('!', '');
//tools.Gifter.done();
// tools.Gifter.runtime.returnGiftName = $(_data).find('div[id="gift' + tools.Gifter.runtime.returnGiftNum +
// '"]:first').text().trim().replace('!', '');
// tools.Gifter.done();
});
} else {
console.log('RTF!');
@@ -163,7 +164,7 @@ tools.Gifter.newRequestForm = function() {

function getCageFriendList() {
FB.api(_giftData.flid + '/members', function(_members) {
if(_members.error) {
if (_members.error) {
window.setTimeout(getCageFriendList, 100);
} else {
console.log('GIFTER - friendlists:', _members);
@@ -175,7 +176,7 @@ tools.Gifter.newRequestForm = function() {
});
}

if(_giftData.flid) {
if (_giftData.flid) {
getCageFriendList();
}

@@ -192,19 +193,21 @@ tools.Gifter.newRequestForm = function() {
message : msg,
data : track,
title : tit,
filters : ['app_users', 'all', 'app_non_users'],
filters : [
'app_users', 'all', 'app_non_users'
],
};
console.log('_uid1', cageGifterVars.userId);
console.log('localStorage[cageGifterVars.userId CAGEsendGiftTo]', cageGifterVars.sendTo);
if(cageGiftUserList.length > 0) {
if (cageGiftUserList.length > 0) {
_ui.filters.unshift({
name : _giftData.userList,
user_ids : cageGiftUserList
});
}
if(cageGifterVars.sendTo !== undefined && cageGifterVars.sendTo !== null && JSON.parse(cageGifterVars.sendTo).length > 0) {
if (cageGifterVars.sendTo !== undefined && cageGifterVars.sendTo !== null && JSON.parse(cageGifterVars.sendTo).length > 0) {
console.log('GIFTER - RTF list: ', JSON.parse(cageGifterVars.sendTo));
if(rtf === true) {
if (rtf === true) {
_ui.to = cageGifterVars.sendTo;
} else {
_ui.filters.unshift({
@@ -223,7 +226,7 @@ tools.Gifter.newRequestForm = function() {
$('.fb_dialog_iframe').each(function() {
$(this).remove();
});
if(cageGifterVars.result === null || cageGifterVars.result === undefined) {
if (cageGifterVars.result === null || cageGifterVars.result === undefined) {
fireGifterDone();
} else {
getFriendsName(giftReturning);
@@ -234,7 +237,7 @@ tools.Gifter.newRequestForm = function() {
FB.api('/me/friends', {
fields : 'name'
}, function(response) {
if(response.error) {
if (response.error) {
console.log('getFriendsName error:', response);
getFriendsName(_callback);
} else {
@@ -244,13 +247,13 @@ tools.Gifter.newRequestForm = function() {
}

function giftReturning(_friendsnames) {
var _friends = {}, _requestids = [], _store = null, _resultContainer = $('#results_container'), params = 'ajax=1&signed_request=' + $('#signed_request').val();
var _friends = {}, _store = null, _resultContainer = $('#results_container'), params = 'ajax=1&signed_request=' + $('#signed_request').val();
// get all ids from sent gifts and remove them from the list
console.log('_friendsnames', _friendsnames);
console.log('GIFTER - check for RTFs');
_resultContainer.html('Sending gifts...<br>').show();
_resultContainer.css('borderRadius', 5).html('Sending to: ...<br>').show();
if(cageGifterVars.sendTo !== undefined) {
if (cageGifterVars.sendTo !== undefined) {
console.log('GIFTER - found open RTF');
_store = JSON.parse(cageGifterVars.sendTo);
console.log('store:', _store, 'cageGifterVars', cageGifterVars);
@@ -262,10 +265,10 @@ tools.Gifter.newRequestForm = function() {
$.each(cageGifterVars.result.to, function(_i, _e) {
var _fr = '';
console.log(_i, _e);
if(_store !== null && _store.indexOf(_e) > -1) {
if (_store !== null && _store.indexOf(_e) > -1) {
_store.splice(_store.indexOf(_e), 1);
_fr = ' - <b>Favor returned</b>';
if(_store.length > 0) {
if (_store.length > 0) {
localStorage[cageGifterVars.userId + '_' + 'CAGEsendGiftTo'] = JSON.stringify(_store);
} else {
console.log('GIFTER - clear RTF list');

Large diffs are not rendered by default.

@@ -1,6 +1,6 @@
tool('Page');
tools.Page.runtime = {};
tools.Page.runtime.addOn = {}
tools.Page.runtime.addOn = {};
tools.Page.pages = {};
tools.Page.init = function() {
addFunction(tools.Page.get_cached_ajax, null, true, true);
@@ -14,21 +14,21 @@ tools.Page.init = function() {
var _re = new RegExp('src=', 'gi');
_t = _t.replace(_re, 'nosrc=');
return _t;
}
};
noNoSrc = function(_jqo) {
_jqo.find('input[nosrc], img[nosrc]').each(function() {
var $t = $(this);
$t.attr('src', $t.attr('nosrc')).removeAttr('nosrc');
});
return _jqo;
}
};
}, null, true, true);

// Do stuff after page loaded
customEvent('PageURL', function(_evt) {
var _page = $('#PageURL').val();
tools.Page.allPages();
if(tools.Page.pages[_page]) {
if (tools.Page.pages[_page]) {
var start = new Date();
tools.Page.pages[_page]();
console.log('Time to mod', _page, ':', (new Date() - start));
@@ -42,17 +42,17 @@ tools.Page.settings = function() {
// All Pages
tools.Page.allPages = function() {

//Execute add ons from tools
// Execute add ons from tools
$.each(tools.Page.runtime.addOn, function(_i, _e) {
_e();
})
//delayed stuff
});
// delayed stuff
setTimeout(function() {
// chat pos
$('#collapsedGuildChat').css('left', '');
$('#expandedGuildChat').css('left', '');
}, 250);
//repos CA menu & add stuff
// repos CA menu & add stuff
tools.Functions.addToCANav('mainMenu_home', 'index.php', 'specialmembership.php', 'Crusaders');
tools.Functions.addToCANav('mainMenu_keep', 'alchemy.php', 'goblin_emp.php', 'Goblin');
tools.Functions.addToCANav('mainMenu_monster', 'public_monster_list.php?monster_tier=3', 'army_news_feed.php', 'Live feed');
@@ -61,14 +61,14 @@ tools.Page.allPages = function() {
$(this).attr('cage', $(this).height()).css('height', 0);
});
// If found update bqh
if($('form').find('input[name="bqh"]:first').length > 0) {
if ($('form').find('input[name="bqh"]:first').length > 0) {
CastleAge.bqh = $('form input[name="bqh"]:first').val();
}

// Favour points
$('#cageFavorPoints').text($('#main_bn div[style*="persistent_bar_oracle.gif"]').text().trim());

//Stats
// Stats
$('#main_sts').css('background', $('#main_bn').css('backgroundImage'));
window.setTimeout(function() {
$('#main_sts_container').css('background', $('#main_sts').css('backgroundImage'));
@@ -77,21 +77,21 @@ tools.Page.allPages = function() {
// remove CA:HOD ad, etc...
$('div > a > img.imgButton[src*="/graphics/iphone_cross_promo.jpg"]').parent().parent().remove();
$('a[href*="apps.facebook.com/castle_hod/?xprom=cax"]').parents('div:first').remove();
if($('#globalContainer > div:first').height() == 80) {
if ($('#globalContainer > div:first').height() == 80) {
$('#globalContainer > div:first').hide();
}

// xp to next lvl and lvl bar fix
var _xpwidth = /\d+/.exec($('#st_5 > div:first > div > div')[0].style.width)[0];
if(_xpwidth !== null) {
if (_xpwidth !== null) {
$('#st_5').find('div:first > div > div').css('width', parseInt(_xpwidth, 10) / 126 * 100 + '%');
}
if($('#st_2_5').find('strong:contains("to")').length == 0 && /\d+\/(\d+)/.exec($('#st_2_5 strong').text()) !== null) {
if ($('#st_2_5').find('strong:contains("to")').length == 0 && /\d+\/(\d+)/.exec($('#st_2_5 strong').text()) !== null) {
$('#st_2_5').find('strong').text(/\d+/.exec($('#st_5').attr('title'))[0] + ' to ' + /\d+\/(\d+)/.exec($('#st_2_5').find('strong').text())[1]);
}
_xpwidth = null;
// reworkin results
if($('div.results').length > 0) {
if ($('div.results').length > 0) {
$('div.results').attr('style', '');
$('#results_main_wrapper').addClass('resultsmainwrapper').prepend('<img id="cageCloseResult" src="http://image4.castleagegame.com/graphics/popup_close_button.png">').children('br').remove();
$('#cageCloseResult').click(function() {
@@ -106,7 +106,7 @@ tools.Page.allPages = function() {
});
// remove some stuff
$('#hinvite_help, #nvbar_table').empty();
//fix some results eg out of stamina general image
// fix some results eg out of stamina general image
$('span.result_body:contains("Allocate skill points to Max")').find('img:first').css('width', 160);
// closing results
$('div.results:has(img[src$="help_close_x.gif"])').each(function(_index, _element) {
@@ -155,13 +155,13 @@ tools.Page.get_cached_ajax = function() {
}, 'slow');
// just_body_cache
var url_key = url, _oldurl = $('#PageURL').val();
if(url.indexOf('?') !== -1) {
if (url.indexOf('?') !== -1) {
url_key = url.substring(0, url.indexOf('?'));
}
console.log(url_key + '-' + _oldurl);
setPageURL(url_key);
if(get_type === 'cache_body' && pageCache[url_key]) {
if(pageCache[url_key].lastIndexOf('<fb:') === -1) {
if (get_type === 'cache_body' && pageCache[url_key]) {
if (pageCache[url_key].lastIndexOf('<fb:') === -1) {
$('#app_body_container').html(pageCache[url_key]);
} else {
$('#app_body_container').html(data);
@@ -170,21 +170,21 @@ tools.Page.get_cached_ajax = function() {
FB.XFBML.parse();
}
firePageURL();
if(url_key !== _oldurl) {
if (url_key !== _oldurl) {
$('body').animate({
scrollTop : 0
}, 'slow');
}
} else {
if(get_type === 'get_page') {
if (get_type === 'get_page') {
stopTimers = true;
pageCache[url_key] = null;
} else if(get_type === 'destroy_all_get_page') {
} else if (get_type === 'destroy_all_get_page') {
stopTimers = true;
pageCache = {};
}
var params = 'ajax=1&signed_request=' + $('#signed_request').attr('value');
if((get_type === 'cache_body') || (get_type === 'get_body')) {
if ((get_type === 'cache_body') || (get_type === 'get_body')) {
params += '&get_type=body';
}
ajaxPerforming = true;
@@ -198,12 +198,14 @@ tools.Page.get_cached_ajax = function() {
stopTimers = false;
ajaxPerforming = false;
$('#AjaxLoadIcon').hide();
if((get_type === 'cache_body') || (get_type === 'get_body')) {
if ((get_type === 'cache_body') || (get_type === 'get_body')) {
$('#app_body_container').html(data);
} else {
$('#globalContainer').html(data);
}
setTimeout(FB.XFBML.parse, 1, [document.getElementById('globalContainer')]);
setTimeout(FB.XFBML.parse, 1, [
document.getElementById('globalContainer')
]);
startAllTimers();
firePageURL();
centerPopups();
@@ -214,19 +216,17 @@ tools.Page.get_cached_ajax = function() {
};
tools.Page.ajaxPageDone = function() {
ajaxPageDone = function(data, div, anchor) {
var start1 = new Date();
stopTimers = false;
ajaxPerforming = false;
if(/<script type="text\/javascript">\stop.location.href = "http:\/\/apps.facebook.com\/castle_age\/.*.php";\s<\/script>/.test(data.substr(data.length < 200 ? 0 : data.length - 300)) === false) {
if (/<script type="text\/javascript">\stop.location.href = "http:\/\/apps.facebook.com\/castle_age\/.*.php";\s<\/script>/.test(data.substr(data.length < 200 ? 0 : data.length - 300)) === false) {
$data = $(noSrc(data));
data = null;
console.log('ajaxPageDone:', div);
if(div === 'globalContainer') {
var _abc = $('#app_body_container'), start1 = new Date(), _sts = $data.find('#main_sts');
if (div === 'globalContainer') {
var _abc = $('#app_body_container'), _sts = $data.find('#main_sts');
_sts.html(_sts.html().replace(/more/g, ''));
$('#main_sts').replaceWith(noNoSrc(_sts));
$('#main_bntp').replaceWith(noNoSrc($data.find('#main_bntp')));
var start2 = new Date();
$('#app_body_container').hide().empty().append(noNoSrc($data.find('#app_body_container')).html()).append(noNoSrc($data.filter('div[id]:not(.game)'))).show();
// update stats
var _stats = $('#main_sts'), _stam = $('#stamina_current_value'), _ener = $('#energy_current_value'), _heal = $('#health_current_value');
@@ -246,7 +246,7 @@ tools.Page.ajaxPageDone = function() {
$('#' + div).html(noNoSrc($data).html());
}
centerPopups();
if(anchor) {
if (anchor) {
$('#' + anchor).animate({
scrollTop : 0
}, 'slow');
@@ -276,11 +276,11 @@ tools.Page.ajaxLinkSend = function() {
pageCache = {};
ajaxPerforming = true;
$('#AjaxLoadIcon').fadeIn();
if(!url) {
if (!url) {
url = 'index.php?adkx=2';
}
var params = 'ajax=1&signed_request=' + $('#signed_request').attr('value'), url_key = url, _oldurl = $('#PageURL').val();
if(url.indexOf('?') !== -1) {
var params = 'ajax=1&signed_request=' + $('#signed_request').attr('value'), url_key = url;
if (url.indexOf('?') !== -1) {
url_key = url.substring(0, url.indexOf('?'));
}
setPageURL(url_key);
@@ -303,7 +303,7 @@ tools.Page.ajaxLinkSend = function() {
tools.Page.ajaxFormSend = function() {
ajaxFormSend = function(div, url, formElement, anchor) {
friend_browse_offset = 0;
if(!anchor) {
if (!anchor) {
$('body').animate({
scrollTop : 0
}, 'slow');
@@ -313,11 +313,11 @@ tools.Page.ajaxFormSend = function() {
params += '&ajax=1';
params += '&signed_request=' + $('#signed_request').attr('value');
pageCache = {};
if(!url) {
if (!url) {
url = 'index.php?adkx=7';
}
var url_key = url, _oldurl = $('#PageURL').val();
if(url.indexOf('?') !== -1) {
if (url.indexOf('?') !== -1) {
url_key = url.substring(0, url.indexOf('?'));
}
console.log(url_key + '-' + _oldurl);
@@ -1,7 +1,7 @@
tool('StatPoints');

tools.StatPoints.update = function() {
if($('#main_bntp a:contains("My Stats")').text().match(/\d+/g) !== null) {
if ($('#main_bntp a:contains("My Stats")').text().match(/\d+/g) !== null) {
$('#cageStatPoints > span').text($('#main_bntp a:contains("My Stats")').text().match(/\d+/g)[0]);
$('#cageStatPoints').css('backgroundImage', 'url(\'http://image4.castleagegame.com/graphics/keep_upgrade_orange.gif\')');
} else {
@@ -11,7 +11,7 @@ tools.StatPoints.update = function() {
};

tools.StatPoints.start = function() {
if($('#cageStatPoints').text() === '') {
if ($('#cageStatPoints').text() === '') {
return false;
}
$('#cageStatPoints').css({
@@ -62,18 +62,17 @@ tools.StatPoints.start = function() {
val : parseInt(_stats.eq(4).text(), 10),
lup : 0,
url : 'health_max'
};
}, _cLU = $('#cageLevelUpMiddle'), _points = [], _max;
$('body').append('<div id="cageLevelUp"><div></div><div><div id="cageLevelUpTop">Upgrade your stats!</div><div id="cageLevelUpMiddle"></div><div id="cageLevelUpBottom"></div></div></div>');
var _cLU = $('#cageLevelUpMiddle');

$.each(_stat, function(_i, _e) {
_cLU.append('<div class="cageLevelUpStat"><img src="http://image4.castleagegame.com/graphics/' + _e.im + '"><span class="cageLevelUpStatName">' + _i + '</span><span class="cageLevelUpStatVal">' + _e.val + '</span><img class="cageLevelUpPlus" src="http://image4.castleagegame.com/graphics/festival_achievement_plus.jpg"><img class="cageLevelUpMinus" src="http://image4.castleagegame.com/graphics/festival_achievement_minus.jpg"></div>')
_cLU.append('<div class="cageLevelUpStat"><img src="http://image4.castleagegame.com/graphics/' + _e.im + '"><span class="cageLevelUpStatName">' + _i + '</span><span class="cageLevelUpStatVal">' + _e.val + '</span><img class="cageLevelUpPlus" src="http://image4.castleagegame.com/graphics/festival_achievement_plus.jpg"><img class="cageLevelUpMinus" src="http://image4.castleagegame.com/graphics/festival_achievement_minus.jpg"></div>');
});
_cLU.append($('<img id="cageLevelUpSave" src="http://image4.castleagegame.com/graphics/war_select_button_accept_2.gif">').click(function() {
$('#cageLevelUpCancel, #cageLevelUpSave').fadeOut();
$('#main_bntp a:contains("My Stats")').text(_sp.have - _sp.used);
function setStat(_up) {
console.log('setStat');
if(_up.length > 0) {
if (_up.length > 0) {
signedGet('keep.php?' + _up.pop(), function(_data) {
console.log('setStat...loaded');
$('#cageLevelUpBar > div ').css('width', ((_max - _up.length) / _max * 100).toString() + '%');
@@ -83,16 +82,15 @@ tools.StatPoints.start = function() {
tools.StatPoints.update();
$('#cageLevelUp').fadeOut('slow', function() {
$(this).remove();
})
});
}
}

var _points = [], _max;
$.each(_stat, function(_i, _e) {
if(_e.lup > 0) {
for(var i = 0; i < _e.lup; i++) {
if (_e.lup > 0) {
for ( var i = 0; i < _e.lup; i++) {
_points.push('upgrade=' + _e.url);
};
}
}
});
_max = _points.length;
@@ -102,14 +100,14 @@ tools.StatPoints.start = function() {
tools.StatPoints.update();
$('#cageLevelUp').fadeOut('slow', function() {
$(this).remove();
})
});
}));
_cLU.append('<div id="cageLevelUpSP">Stat Points<br>' + _sp.have + '</div><div id="cageLevelUpBar"><div></div></div>');
_cLU.find('div.cageLevelUpStat').each(function() {
var _this = $(this);
$('img.cageLevelUpPlus', _this).click(function() {
var _s = $('span.cageLevelUpStatName', _this).text().toLowerCase();
if(_sp.used + (_s == 'stamina' ? 2 : 1) <= _sp.have) {
if (_sp.used + (_s == 'stamina' ? 2 : 1) <= _sp.have) {
_sp.used += _s == 'stamina' ? 2 : 1;
_stat[_s].lup += 1;
$('#cageLevelUpSP').html('Stat Points<br>' + (_sp.have - _sp.used));
@@ -118,7 +116,7 @@ tools.StatPoints.start = function() {
});
$('img.cageLevelUpMinus', _this).click(function() {
var _s = $('span.cageLevelUpStatName', _this).text().toLowerCase();
if(_sp.used > 0 && _stat[_s].lup > 0) {
if (_sp.used > 0 && _stat[_s].lup > 0) {
_sp.used -= _s == 'stamina' ? 2 : 1;
_stat[_s].lup -= 1;
$('#cageLevelUpSP').html('Stat Points<br>' + (_sp.have - _sp.used));
@@ -1,9 +1,9 @@
// Add function to content site
function addFunction(_func, _arg, _run, _once) {
var script = document.createElement('script');
script.textContent = ( _run ? '(' : '') + _func + ( _run ? ')(' + _arg + ');' : ';');
script.textContent = (_run ? '(' : '') + _func + (_run ? ')(' + _arg + ');' : ';');
document.body.appendChild(script);
if(_once) {
if (_once) {
document.body.removeChild(script);
}
}
@@ -28,15 +28,15 @@ $.extend($.expr[':'], {
// Return Array with unique values
function unique(_array, _tostring) {
var o = {}, i, l = _array.length, r = [];
for( i = 0; i < l; i += 1) {
for (i = 0; i < l; i += 1) {
o[_array[i]] = _array[i];
}
if(_tostring) {
for(i in o) {
if (_tostring) {
for (i in o) {
r.push(o[i].toString());
}
} else {
for(i in o) {
for (i in o) {
r.push(o[i]);
}
}
@@ -45,11 +45,11 @@ function unique(_array, _tostring) {

// removes all items that are listed more than once
function removeDuplicates(_array) {
var _uniques = [], _dupl = [], _i = 0;
for(i; i <= _array.length; i++) {
var _uniques = [], _dupl = [], i = 0;
for (i; i <= _array.length; i++) {
var v = _array[i];
console.log(i + '-' + v);
if(_array.lastIndexOf(v) > i || _dupl.indexOf(v) > -1) {
if (_array.lastIndexOf(v) > i || _dupl.indexOf(v) > -1) {
_dupl.push(v);
} else {
_uniques[_uniques.length] = v;
@@ -61,18 +61,18 @@ function removeDuplicates(_array) {
});
}

//shortcut to jQuery get with signed request
// shortcut to jQuery get with signed request
function get(_url, _callback) {
$.get(_url + (_url.indexOf('?') > -1 ? '&' : '?') + 'signed_request=' + CastleAge.signed_request, _callback);
}

//shortcut to jQuery get with signed request reworked
// shortcut to jQuery get with signed request reworked
function signedGet() {
arguments[0] = arguments[0] + (arguments[0].indexOf('?') > -1 ? '&' : '?') + 'signed_request=' + CastleAge.signed_request;
$.get.apply(this, arguments);
}

//shortcut to jQuery get with signed request reworked
// shortcut to jQuery get with signed request reworked
function signedPost() {
arguments[0] = arguments[0] + (arguments[0].indexOf('?') > -1 ? '&' : '?') + 'signed_request=' + CastleAge.signed_request;
$.post.apply(this, arguments);
@@ -94,16 +94,16 @@ function noNoSrc(_jqo) {
return _jqo;
}

//shortcut to jQuery post with signed request
// shortcut to jQuery post with signed request
function post(_url, _callback) {
$.post(_url + (_url.indexOf('?') > -1 ? '&' : '?') + 'signed_request=' + CastleAge.signed_request, _callback);
}

//http://note19.com/2007/05/27/javascript-guid-generator/
// http://note19.com/2007/05/27/javascript-guid-generator/
function S4() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}

function guid() {
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}
}
@@ -1,6 +1,6 @@
{
"name": "CAGE - Castle Age Game Enhancer [β]",
"version": "1.2.7.2",
"version": "1.2.8.0",
"description": "CAGE makes playing Castle Age on Facebook a bit easier and a lot more fun ;)",
"background_page": "background.html",
"browser_action": {