If you can't read please download the document
Upload
hasan-ibrahim-kozan
View
214
Download
2
Embed Size (px)
DESCRIPTION
denemeee
Citation preview
/*Author: Author Name*Name: LA Enhancer*Version: 1.00*Client script: javascript:$.getScript('https://dl.dropboxusercontent.com/u/26362756/laEnhancer/test.js');void(0);*//***********************************************************************Global variables*/var version = "1.10";var scriptName = "LA Enhancer"var scriptURL = "https://dl.dropboxusercontent.com/u/26362756/laEnhancer/";var updateNotesURL = "http://forum.tribalwars.net/showthread.php?266604-ntoombs19-s-FA-Filter&p=6785655&viewfull=1#post6785655";var working = true;var resourcesLoaded = false;var scriptLoaded = false;var pagesLoaded = false;var filtersApplied = false;var cansend = true;var keySetMode = false;var hideRow = false;var editingKey = false;var troubleshoot = true;var clearProfiles = false;var reason = [];var keyToEdit;var current_units;var currentGameTime = getCurrentGameTime();var sitter = "";if (window.game_data.player.sitter != "0") {sitter = "t=" + window.game_data.player.id + "&";}var link = ["https://" + window.location.host + "/game.php?" + sitter + "village=", "&screen=am_farm"];var userset;var s = {start_page: 0,end_page: 1,order_by: 2,direction: 3,all_none: 4,blue: 5,green: 6,yellow: 7,red_yellow: 8,red_blue: 9,red: 10,hide_recent_farms: 11,sent_time_filter: 12,hide_recent_time: 13,enable_hauls: 14,full: 15,partial: 16,enable_attacks: 17,attack_operator: 18,attack_value: 19,enable_walls: 20,wall_operator: 21,
wall_value: 22,enable_distances: 23,distance_operator: 24,distance_value: 25,enable_scout: 26,scout_report_operator: 27,haul_value: 28,continent_display: 29,continents_list: 30,enable_time: 31,attack_time_filter: 32,time_value: 33,enable_auto_run: 34,next_village_no_farms: 35,next_village_scouts: 36,scouts_left: 37,next_village_farming_troops: 38,farming_troops_left: 39,next_village_units: 40};var keycodes = {"a": 65,"b": 66,"c": 67,"skip": 83,"right": 39,"left": 37,"master": 77};var keyPressSettings = {"a_code": 65,"a_char": "A","b_code": 66,"b_char": "B","c_code": 67,"c_char": "C","master_code": 77,"master_char": "M","skip_code": 83,"skip_char": "S","left_code": 37,"left_char": "","right_code": 39,"right_char": "","priorityOneEnabled": true,"priorityOneProfile": "Default","priorityOneButton": "Skip","priorityTwoEnabled": true,"priorityTwoProfile": "Default","priorityTwoButton": "Skip","priorityThreeEnabled": true,"priorityThreeProfile": "Default","priorityThreeButton": "Skip","defaultButton": "Skip"};var availableLangs = ["en", "es", "el", "ar"];/***********************************************************************Init script*/
// Enables caching of loaded javascript before loading
resources$.getScript(scriptURL + "resources.js", function() {if
($.jStorage.get("language") == null)
{setDefaultLanguage();}$.getScript(scriptURL + "lang/" +
$.jStorage.get("language") + '.js', function()
{checkPage();});});function
run(){checkVersion();checkWorking();setVersion();makeItPretty();///setTWFilters();showSettings();turnOnHotkeys();hotkeysOnOff();if(userset[s.enable_auto_run]
!= false){applySettings();}}function checkVersion(){if
(getVersion() != version) {buttons = [{text: 'OK',callback:
null,confirm: true}];if(clearProfiles){var profileList =
$.jStorage.get("profileList");$.each(profileList, function(i, val)
{$.jStorage.deleteKey("profile:" +
val);});$.jStorage.set("keyPressSettings",keyPressSettings);Dialog.show("update_dialog",
"This script has recently been updated to version " + version + "
and in order for the new version to work, all profiles and settings
must be reset.Sorry for any inconvenience.
See what's new");}else{Dialog.show("update_dialog", "This script
has recently been updated to version " + version + "
See what's new");}} else {//UI.SuccessMessage("Welcome to LA
Enhancer", 1000);}}function checkWorking(){var acknowledged =
$.jStorage.get("working");if(acknowledged ==
null){$.jStorage.set("working", false);}
if (getVersion() != version) {$.jStorage.set("working", false);}if (working == false && acknowledged == false) {buttons = [{text: 'OK',callback: null,confirm: true}];UI.ConfirmationBox("An error has been discovered in this version. You may continue testing the script if you haven't noticed the error.", buttons, false, []);$.jStorage.set("working", true);}}function setVersion(){$.jStorage.set("version", version);}function getVersion(){var ver = $.jStorage.get("version");if(ver == undefined){setVersion();return version;}return ver;}function setTWFilters(){if($('#all_village_checkbox').prop('checked') == true){$('#all_village_checkbox').click();doTime(100);}if($('#attacked_checkbox').prop('checked') == false){$('#attacked_checkbox').click();doTime(100);}if($('#full_hauls_checkbox').prop('checked') == true){$('#full_hauls_checkbox').click();doTime(100);}if($('#full_losses_checkbox').prop('checked') == false){$('#full_losses_checkbox').click();doTime(100);}if($('#partial_losses_checkbox').prop('checked') == false){$('#partial_losses_checkbox').click();doTime(100);}}/***********************************************************************Auto page loading and settings creation*/function showAllRows() {var pages = $.trim($('#plunder_list_nav tr:first td:last').children().last().html().replace(/\D+/g, ''));if ($('#end_page').val() == "max") {$('#end_page').text(pages);
}$('#am_widget_Farm tr:last').remove();if (pages > parseInt($('#end_page').val(), 10)) {pages = parseInt($('#end_page').val(), 10);}setTimeout(function() {getPage((parseInt($('#start_page').val(), 10) - 1), pages);}, 1);}function getPage(i, pages) {if (i < pages) {changeHeader(filter_41 + " " + (i + 1) + "/" + pages + " ");$.get(link[0] + window.game_data.village.id + "&order=" + userset[s.order_by] + "&dir" + userset[s.direction] + "&Farm_page=" + i + "&screen=am_farm", function(data) {$('#plunder_list tr', data).slice(1).each(function() {$('#plunder_list tr:last').after("" + $(this).html() + "");});setTimeout(function(){getPage(i + 1, pages);}, 1);});} else {setTimeout(function() {addTableInfo();applyFilters();changeHeader(filter_40);highlightRows();}, 1);$('#plunder_list').show();Accountmanager.initTooltips();pagesLoaded = true;cansend = true;}}function changeHeader(string) {$("h3:first").html(string);}function highlightRows() {$('#am_widget_Farm table').each(function() {$('tr:even:gt(0) td', this).not("table:first").css("backgroundColor", "#FFF5DA");$('tr:odd:gt(0) td', this).not("table:first").css("backgroundColor", "#F0E2BE");});}function getNewVillage(way) {if(way == "n")UI.InfoMessage('Switching to next village...', 500);elseUI.InfoMessage('Switching to previous village...', 500);window.onkeydown = function(){};cansend = false;filtersApplied = false;
Timing.pause();fadeThanksToCheese();openLoader();var vlink =
link[0] + way + window.game_data.village.id + link[1];$.ajax({type:
"GET",url: vlink,error: function(xhr, statusText) {alert("Error: "
+
statusText);$('#fader').remove();$('#loaders').remove();},success:
function(data) {var v = $(data);var title =
data.split('')[1].split('')[0];window.game_data =
$.parseJSON(data.split("var game_data= ")[1].split("};")[0] +
"}");$('#header_info').html($('#header_info',
v).html());$('#topContainer').html($('#topContainer',
v).html());$('#contentContainer').html($('#contentContainer',
v).html());$('#quickbar_inner').html($('#quickbar_inner',
v).html());$('head').find('title').html(title);$('#fader').remove();$('#loaders').remove();Timing.resetTickHandlers();Timing.pause();pagesLoaded
= false;cansend = false;run();}});}/*function
getNewVillage(way){if(way == "n")UI.InfoMessage('Switching to next
village...', 500);elseUI.InfoMessage('Switching to previous
village...', 500);window.onkeydown = function(){};cansend =
false;filtersApplied = false;Timing.pause();var vlink = link[0] +
way + window.game_data.village.id + link[1];window.location =
vlink;}*/function
showSettings(){//$('#plunder_list').hide();//$('#plunder_list_nav').hide();$('head').append("");$("#contentContainer
h3").eq(0).after($("" + filter_01 + " " + version + " - " +
filter_02+ " - " + filter_42 + ": " + filter_03 + " ntoombs19-" +
filter_04 + "" + filter_05 + "" + filter_06 + "" + filter_07 +
"
" + filter_08 + "
" + filter_09 + "
" + filter_10 + "
" + filter_11 + "
" + filter_12 + "
" + filter_13 + "" + filter_14 + ":" + filter_15 + "" + filter_16 +
"
" + filter_17 + ":" + filter_18 + "" + filter_19 + "" + filter_20 +
"" + filter_21 + "" + filter_22 + "" + filter_23 + "" + filter_24 +
"" + filter_25 + "" + filter_26 + ""+filter_43+"" + filter_30 + ""
+ filter_24 + "" + filter_25 + "" + filter_26 + "" + filter_39 + ""
+ filter_31 + "" + filter_24 + "" +filter_25 + "" + filter_26 +
""+filter_44+"" + filter_32 + "" + filter_33 + "" +filter_34 + "
"+filter_45+"" + filter_35 + "" + filter_24 + "" + filter_25 + "" +
filter_26 + " "+filter_46+"" + filter_32 + ""+ filter_33 + "" +
filter_36 +"" + filter_37 + "" + filter_38 + "" + filter_32 + "" +
filter_33 + ""+filter_47+"
"+filter_48+""+filter_49+""+filter_50+""+filter_54+" "+filter_55+"
"+filter_56+""+filter_57+""+filter_58+""+filter_59+""+filter_54+"
"+filter_55+"
"+filter_56+""+filter_57+""+filter_58+""+filter_59+""+filter_54+"
"+filter_55+"
"+filter_56+""+filter_57+""+filter_58+""+filter_59+""+filter_60+"
"+filter_56+""+filter_57+""+filter_58+""+filter_59+"" + profile_01+
":"));formatSettings();addLanguages();$("#language option[value='"
+ $.jStorage.get("language") + "']").attr("selected",
"selected");}function formatSettings()
{$("#all_none").bind("click", function()
{$(this).closest('form').find(':checkbox').prop('checked',
this.checked);});// report instructionsvar reportHelp =
$('#report_help');reportHelp.attr('title',
instructions_01);UI.ToolTip(reportHelp);// enable instrunctionsvar
enableHelp = $('#enable_help');enableHelp.attr('title',
instructions_02);UI.ToolTip(enableHelp);// continent
instrunctionsvar continentHelp =
$('#continent_help');continentHelp.attr('title',
instructions_03);UI.ToolTip(continentHelp);// recent
instrunctionsvar recentHelp =
$('#recent_help');recentHelp.attr('title',
instructions_04);UI.ToolTip(recentHelp);// profile instrunctionsvar
profileHelp = $('#profile_help');profileHelp.attr('title',
instructions_05);UI.ToolTip(profileHelp);loadDefaultProfile();fillProfileList();fillMasterSettings();fillKeypressSettings();}function
removeFirstPage() {$('#plunder_list
tr:gt(0)').remove();$('#plunder_list_nav').hide();}/***********************************************************************Table
formatting*/function customSendUnits(link, target_village,
template_id, button)
{if(!checkIfNextVillage()){button.closest("tr").hide();link =
$(link);if (link.hasClass('farm_icon_disabled')) return false;var
data = {target: target_village,template_id: template_id,source:
game_data.village.id};$.post(Accountmanager.send_units_link, data,
function (data) {if (data.error) {if(userset[s.next_village_units]
&& data.error === "Notenough units available"){if(cansend
&& filtersApplied)getNewVillage("n");return false;} else
{UI.ErrorMessage(data.error);button.closest("tr").show();}} else
{setLocalStorageRow(target_village);//$('.farm_village_' +
target_village).addClass('farm_icon_disabled');if (typeof
$(button).prop('tooltipText') != 'undefined') {var buttext =
$(button).prop('tooltipText');}var yolo =
$('').append($(buttext));var bolo =
$(yolo).find('img[src*="res.png"]').eq(0).attr('src');var sep1 =
buttext.split("
");sep1.splice(sep1.length - 2, 1);UI.SuccessMessage(sep1.join("
"),
100);Accountmanager.farm.updateOwnUnitsAvailable(data.current_units);}},
'json');return false}}function customSendUnitsFromReport(link,
target_village, report_id, button)
{if(!checkIfNextVillage()){button.closest("tr").hide();link =
$(link);if (link.hasClass('farm_icon_disabled')) return false;var
data = {report_id:
report_id};$.post(Accountmanager.send_units_link_from_report, data,
function (data) {if (data.error) {if(userset[s.next_village_units]
&& data.error === "Notenough units available"){if(cansend
&& filtersApplied)getNewVillage("n");return false;} else
{UI.ErrorMessage(data.error);button.closest("tr").show();}} else
{setLocalStorageRow(target_village);if (typeof data.success ===
'string') {if (typeof $(button).prop('tooltipText')!= 'undefined')
{var buttext = $(button).prop('tooltipText');}var yolo =
$('').append($(buttext));var bolo =
$(yolo).find('img[src*="res.png"]').eq(0).attr('src');var sep1 =
buttext.split("
");sep1.splice(sep1.length - 2, 1);UI.SuccessMessage(sep1.join("
"),
100);Accountmanager.farm.updateOwnUnitsAvailable(data.current_units);};//$('.report_'
+ target_village + ' .farm_icon').addClass('farm_icon_disabled')}},
'json');return false}}function setOnclick(button){var clickFunction
= button.find('a').attr('onclick');if(typeof clickFunction !=
'undefined'){var parameters =
clickFunction.slice(clickFunction.indexOf("(")+1,clickFunction.indexOf(")"));var
eachParameter =
parameters.split(",");if(clickFunction.indexOf("FromReport") ==
-1){button.find('a').attr('onclick', 'return
customSendUnits('+parameters+',
$(this))');}else{button.find('a').attr('onclick', 'return
customSendUnitsFromReport('+parameters+'))');}button.closest('tr').attr('name',
$.trim(eachParameter[1]));}}function
addTableInfo(){$('#am_widget_Farm tr
th').slice(0,1).after("");$('#am_widget_Farm
tr:not(:first-child)').each(function(i){$(this).children("td").each(function(j)
{switch(j){case
1:$(this).filter(":first").before(""+(i+1)+"")break;case 3:var
attackImg = $(this).find('img');var tooltip=
$(this).find('img').prop('tooltipText');if(typeof tooltip !=
'undefined'){var numAttacks = tooltip.replace(/\D/g,
'');attackImg.after(" ("+numAttacks+")");}break;case
8:setOnclick($(this));break;case 9:setOnclick($(this));break;case
10:setOnclick($(this));break;}});});}function
checkIfNextVillage(){current_units =
Accountmanager.farm.current_units;if(userset[s.next_village_scouts]){var
scouts = current_units.spy;if(scouts = 0 &&
profileArray[s.green]){reason.push("Report is green");hideRow =
true;return;}if (cell.html().indexOf("yellow") >= 0 &&
profileArray[s.yellow]){reason.push("Report is yellow");hideRow =
true;return;}if (cell.html().indexOf("red_yellow") >= 0
&& profileArray[s.red_yellow]){reason.push("Report is
red_yellow");hideRow = true;return;}if
(cell.html().indexOf("red_blue") >= 0 &&
profileArray[s.red_blue]){reason.push("Report is red_blue");hideRow
= true;return;}if (cell.html().indexOf("red") >= 0 &&
profileArray[s.red]){reason.push("Report is red");hideRow =
true;return;}}function haulSettings(cell,
profileArray){if(profileArray[s.enable_hauls]){// Hides full
haulsif (cell.html().indexOf("max_loot/1") >= 0 &&
profileArray[s.full]){reason.push("Haul is full");hideRow =
true;return;}// Hides partial haulsif
(cell.html().indexOf("max_loot/0") >= 0 &&
profileArray[s.partial]){reason.push("Haul is partial");hideRow =
true;return;}// Hides scout reportsif
(cell.html().indexOf("max_loot") == -1 &&
(profileArray[s.full])){reason.push("No haul graphic");hideRow =
true;return;}}}function hideRecentlyFarmed(cell,
profileArray){if(profileArray[s.hide_recent_farms]){var village =
cell.closest('tr').attr('name');localTitle = "sitter:"+sitter+",
village:"+village+", world:"+getURL()[0];var sentTime = new
Date($.jStorage.get(localTitle));var t1 = currentGameTime;var t2 =
sentTime;var dif = t1.getTime() - t2.getTime();console.log("Sent
Time: "+t2);var minutesBetween =
Math.abs(parseInt(dif/1000/60));switch(profileArray[s.sent_time_filter]){case
"hide":if(minutesBetween <
parseInt(profileArray[s.hide_recent_time])){reason.push("Village
was sent to " + minutesBetween + " minutes ago");hideRow =
true;return;}break;case "show":if(minutesBetween >
parseInt(profileArray[s.hide_recent_time])){reason.push("Village
was not sent to");hideRow = true;return;}break;}}}function
attackSettings(cell, profileArray){var numAttacks;var attackImg =
cell.find('img');if(typeof attackImg.prop('tooltipText') !=
'undefined'){numAttacks =
parseInt(attackImg.prop('tooltipText').replace(/\D/g,
''));}else{numAttacks =
0;}if(profileArray[s.enable_attacks]){console.log(numAttacks);switch
(profileArray[s.attack_operator]) {case
"greater_than":if(numAttacks >
parseInt(profileArray[s.attack_value])){reason.push("Outgoing
attacks is too many");hideRow = true;return;}break;case
"less_than":if(numAttacks <
parseInt(profileArray[s.attack_value])){reason.push("Outgoing
attacks is too few");hideRow = true;return;}break;case
"equal_to":if(numAttacks ==
parseInt(profileArray[s.attack_value])){reason.push("Outgoing
attacks is equal");hideRow = true;return;}break;}}}function
continentSettings(cell, profileArray){var continent =
cell.find('a').html();if(typeof continent != 'undefined'){continent
= continent.substr(continent.length - 2);var filteredContinents =
profileArray[s.continents_list].split('.');if($.inArray(continent,
filteredContinents) >= 0 &&
profileArray[s.continent_display] == "hide"){reason.push("Continent
is set to hide");hideRow = true;return;}if($.inArray(continent,
filteredContinents) == -1 &&
profileArray[s.continent_display] == "show"){reason.push("Continent
is not set to show");hideRow = true;return;}}}function
hideTime(cell, profileArray){if(profileArray[s.enable_time]){var t1
= currentGameTime;var t2 = getVillageAttackedTime(cell);var dif =
t1.getTime() - t2.getTime();console.log("Plunder Time: "+t2);var
minutesBetween = Math.abs(parseInt(dif/1000/60));switch
(profileArray[s.attack_time_filter]) {case "hide":if(minutesBetween
< parseInt(profileArray[s.time_value])){reason.push("Village
attacked "+ minutesBetween +" minutes ago.");hideRow =
true;return;}break;case "show":if(minutesBetween >
parseInt(profileArray[s.time_value])){reason.push("Village attacked
"+ minutesBetween +" minutes ago.");hideRow =
true;return;}break;}}}function scoutReportSettings(cell,
profileArray){var
total;if(profileArray[s.enable_scout]){if($.trim(cell.find('span').html())
== "?"){total = 0;}else{var wood =
parseInt(cell.children('span').eq(0).html().replace(/\D+/g,
''));var clay =
parseInt(cell.children('span').eq(1).html().replace(/\D+/g,
''));var iron =
parseInt(cell.children('span').eq(2).html().replace(/\D+/g,
''));total = wood+clay+iron;}switch
(profileArray[s.scout_report_operator]) {case
"greater_than":if(total >
parseInt(profileArray[s.haul_value])){reason.push("Too many
resources");hideRow = true;return;}break;case "less_than":if(total
< parseInt(profileArray[s.haul_value])){reason.push("Not enough
resources");hideRow = true;return;}break;case "equal_to":if(total
== parseInt(profileArray[s.haul_value])){reason.push("Exact
resources");hideRow = true;return;}break;}}}function
wallSettings(cell,
profileArray){if(profileArray[s.enable_walls]){var wallLvl =
parseInt(cell.html());if(wallLvl == '?'){wallLvl = 0;}switch
($.trim(profileArray[s.wall_operator])) {case
"greater_than":if(wallLvl >
parseInt(profileArray[s.wall_value])){reason.push("Wall too
high");hideRow = true;return;}break;case "less_than":if(wallLvl
< parseInt(profileArray[s.wall_value])){reason.push("Wall too
low");hideRow = true;return;}break;case "equal_to":if(wallLvl ==
parseInt(profileArray[s.wall_value])){reason.push("Wall is
exact");hideRow = true;return;}break;}}}function
distanceSettings(cell,
profileArray){if(profileArray[s.enable_distances]){var distanceLvl
= cell.html();switch ($.trim(profileArray[s.distance_operator]))
{case "greater_than":if(parseFloat(distanceLvl) >
parseFloat(profileArray[s.distance_value])){reason.push("Village
too far");hideRow = true;return;}break;case
"less_than":if(parseFloat(distanceLvl) <
parseFloat(profileArray[s.distance_value])){reason.push("Village
too close");hideRow = true;return;}break;case
"equal_to":if(parseFloat(distanceLvl) ==
parseFloat(profileArray[s.distance_value])){reason.push("Village
exact distance");hideRow = true;return;}break;}}}//deletes local
storage for recently farmed rowsfunction
deleteRecentlyFarmed(){$('#am_widget_Farm
tr:gt(0)').each(function(i)
{$(this).children("td").each(function(j){if(j == 4){reportLinkText
= $.trim($(this).children("a").html());localTitle =
"sitter:"+sitter+", village:"+reportLinkText+",
world:"+getURL()[0];if($.jStorage.get(localTitle) !=
null){$.jStorage.deleteKey(localTitle);}}});});}//gets game time to
compare to reportsfunction getCurrentGameTime(){var serverTime =
$('#serverTime').html().split(':');var serverDate =
$('#serverDate').html().split('/');return new Date(serverDate[2],
serverDate[1]-1, serverDate[0], serverTime[0], serverTime[1],
serverTime[2], 0);}//helper function for time filtersfunction
getVillageAttackedTime(cell){var time = cell.html();var cellTime =
time.split(' ');var attackDay;var attackTime;var cell;for (var i =
0; i < cellTime.length; i++){cell =
$.trim(cellTime[i]);if(cell.indexOf('.') > -1){attackDay =
cell;} else if (cell == filter_61){attackDay = filter_61;} else if
(cell == filter_62){attackDay = filter_62;}if(cell.indexOf(':')
> -1){attackTime = cell;}}if(attackDay == filter_61 || attackDay
== filter_62){var day = currentGameTime.getDate();if(attackDay ==
filter_62)day--;var month = currentGameTime.getMonth();var year =
currentGameTime.getFullYear();var time = attackTime.split(':');var
hours = time[0];var minutes = time[1];var seconds = time[2];return
new Date(year, month, day, hours, minutes, seconds, 0);}else{var
cellDay = attackDay.split('.');var day = cellDay[0];var month =
cellDay[1]-1;if(currentGameTime.getMonth() == 0 && month ==
11)var year = currentGameTime.getFullYear()-1;elsevar year =
currentGameTime.getFullYear();var time = attackTime.split(':');var
hours = time[0];var minutes = time[1];var seconds = time[2];return
new Date(year, month, day, hours, minutes, seconds,
0);}}/***********************************************************************Settings
profiles functionality*/function loadDefaultProfile() {if
($.jStorage.get("profile:" + profile_10) == null)
{$.jStorage.set("profile:" + profile_10, ["1", "1", "distance",
"asc", false, false, false, false, false, false, false, false,
"hide", "", false,false, false, false, "greater_than", "", false,
"greater_than", "", false, "greater_than", "", false,
"greater_than", "", "hide", "", false, "hide", "", false,false,
false, "", false, "",
false]);$.jStorage.deleteKey("profileList");$.jStorage.set("profileList",
[profile_10]);}userset = $.jStorage.get("profile:" +
profile_10);loadProfile(profile_10);$('#settingsProfile').val(profile_10);}function
setDefaultProfile() {if ($('#settingsProfile').val() == profile_10)
{var newProfile = confirm(dialog_02);if (newProfile)
{createProfile();setDefaultProfile();} else {return false;}} else
{var profile = $.jStorage.get("profile:" +
$('#settingsProfile').val());$.jStorage.set("profile:" +
profile_10, profile);}}function fillProfileList() {var profileList
= $.jStorage.get("profileList");$.each(profileList, function(i,
val) {$('#settingsProfile').append("" + val +
"")});$('#settingsProfile').val($.jStorage.get("DefaultProfile"));}function
createProfile() {var profileName = prompt(dialog_03 + ":");if
($.inArray(profileName, $.jStorage.get("profileList")) != -1)
{alert(dialog_04);createProfile();return false;}if (profileName ==
"") {alert(dialog_05);createProfile();return false;}var profiles;if
(profileName != null && profileName != "") {var settings =
[];settings.push($('#start_page').val());
//0settings.push($('#end_page').val());
//1settings.push($('#order_by').val());
//2settings.push($('#direction').val());
//3settings.push($('#all_none').prop('checked'));
//4settings.push($('#blue').prop('checked'));
//5settings.push($('#green').prop('checked'));
//6settings.push($('#yellow').prop('checked'));
//7settings.push($('#red_yellow').prop('checked'));
//8settings.push($('#red_blue').prop('checked'));
//9settings.push($('#red').prop('checked'));
//10settings.push($('#hide_recent_farms').prop('checked'));
//11settings.push($('#sent_time_filter').val());
//12settings.push($('#hide_recent_time').val());
//13settings.push($('#enable_hauls').prop('checked'));
//14settings.push($('#full').prop('checked'));
//15settings.push($('#partial').prop('checked'));
//16settings.push($('#enable_attacks').prop('checked'));
//17settings.push($('#attack_operator').val());settings.push($('#attack_value').val());settings.push($('#enable_walls').prop('checked'));settings.push($('#wall_operator').val());settings.push($('#wall_value').val());settings.push($('#enable_distances').prop('checked'));settings.push($('#distance_operator').val());settings.push($('#distance_value').val());settings.push($('#enable_scout').prop('checked'));settings.push($('#scout_report_operator').val());settings.push($('#haul_value').val());settings.push($('#continent_display').val());settings.push($('#continents_list').val());settings.push($('#enable_time').prop('checked'));settings.push($('#attack_time_filter').val());settings.push($('#time_value').val());settings.push($('#enable_auto_run').prop('checked'));settings.push($('#next_village_no_farms').prop('checked'));settings.push($('#next_village_scouts').prop('checked'));settings.push($('#scouts_left').val());settings.push($('#next_village_farming_troops').prop('checked'));settings.push($('#farming_troops_left').val());settings.push($('#next_village_units').prop('checked'));$.jStorage.set("profile:"
+ profileName, settings);var profileList =
$.jStorage.get("profileList");profileList.push(profileName);$.jStorage.set("profileList",
profileList)$('#settingsProfile').append("" + profileName +
"");$('#priorityOneProfile').append("" + profileName +
"");$('#priorityTwoProfile').append("" + profileName +
"");$('#priorityThreeProfile').append("" + profileName +
"");$('#settingsProfile').val(profileName);}}function
loadProfile(profile) {var settings = $.jStorage.get("profile:" +
profile);userset =
settings;$('#start_page').val(settings[0]);$('#end_page').val(settings[1]);$('#order_by').val(settings[2]);$('#direction').val(settings[3]);$('#all_none').prop('checked',
settings[4]);$('#blue').prop('checked',
settings[5]);$('#green').prop('checked',
settings[6]);$('#yellow').prop('checked',
settings[7]);$('#red_yellow').prop('checked',
settings[8]);$('#red_blue').prop('checked',
settings[9]);$('#red').prop('checked',
settings[10]);$('#hide_recent_farms').prop('checked',
settings[11]);$('#sent_time_filter').val(settings[12]);$('#hide_recent_time').val(settings[13]);$('#enable_hauls').prop('checked',
settings[14]);$('#full').prop('checked',
settings[15]);$('#partial').prop('checked',
settings[16]);$('#enable_attacks').prop('checked',
settings[17]);$('#attack_operator').val(settings[18]);$('#attack_value').val(settings[19]);$('#enable_walls').prop('checked',
settings[20]);$('#wall_operator').val(settings[21]);$('#wall_value').val(settings[22]);$('#enable_distances').prop('checked',
settings[23]);$('#distance_operator').val(settings[24]);$('#distance_value').val(settings[25]);$('#enable_scout').prop('checked',
settings[26]);$('#scout_report_operator').val(settings[27]);$('#haul_value').val(settings[28]);$('#continent_display').val(settings[29]);$('#continents_list').val(settings[30]);$('#enable_time').prop('checked',
settings[31]);$('#attack_time_filter').val(settings[32]);$('#time_value').val(settings[33]);$('#enable_auto_run').prop('checked',
settings[34]);$('#next_village_no_farms').prop('checked',
settings[35]);$('#next_village_scouts').prop('checked',
settings[36]);$('#scouts_left').val(settings[37]);$('#next_village_farming_troops').prop('checked',
settings[38]);$('#farming_troops_left').val(settings[39]);$('#next_village_units').prop('checked',
settings[40]);}function changeProfile(profile)
{loadProfile(profile);resetTable();applyFilters();}function
deleteProfile() {var profileName = $('#settingsProfile').val();if
(profileName == profile_10) {alert(dialog_06);} else {var
profilesList =
$.jStorage.get("profileList");profilesList.splice(profilesList.indexOf(profileName),
1);$.jStorage.set("profileList",
profilesList);$.jStorage.deleteKey("profile:" +
profileName);$("#settingsProfile option[value='" + profileName +
"']").remove();$("#priorityOneProfile option[value='" + profileName
+ "']").remove();$("#priorityTwoProfile option[value='" +
profileName + "']").remove();$("#priorityThreeProfile
option[value='" + profileName +
"']").remove();loadDefaultProfile(profile_10);}}function
updateProfile() {var profileName = $('#settingsProfile').val();var
settings =
[];settings.push($('#start_page').val());settings.push($('#end_page').val());settings.push($('#order_by').val());settings.push($('#direction').val());settings.push($('#all_none').prop('checked'));settings.push($('#blue').prop('checked'));settings.push($('#green').prop('checked'));settings.push($('#yellow').prop('checked'));settings.push($('#red_yellow').prop('checked'));settings.push($('#red_blue').prop('checked'));settings.push($('#red').prop('checked'));settings.push($('#hide_recent_farms').prop('checked'));settings.push($('#sent_time_filter').val());settings.push($('#hide_recent_time').val());settings.push($('#enable_hauls').prop('checked'));settings.push($('#full').prop('checked'));settings.push($('#partial').prop('checked'));settings.push($('#enable_attacks').prop('checked'));settings.push($('#attack_operator').val());settings.push($('#attack_value').val());settings.push($('#enable_walls').prop('checked'));settings.push($('#wall_operator').val());settings.push($('#wall_value').val());settings.push($('#enable_distances').prop('checked'));settings.push($('#distance_operator').val());settings.push($('#distance_value').val());settings.push($('#enable_scout').prop('checked'));settings.push($('#scout_report_operator').val());settings.push($('#haul_value').val());settings.push($('#continent_display').val());settings.push($('#continents_list').val());settings.push($('#enable_time').prop('checked'));settings.push($('#attack_time_filter').val());settings.push($('#time_value').val());settings.push($('#enable_auto_run').prop('checked'));settings.push($('#next_village_no_farms').prop('checked'));settings.push($('#next_village_scouts').prop('checked'));settings.push($('#scouts_left').val());settings.push($('#next_village_farming_troops').prop('checked'));settings.push($('#farming_troops_left').val());settings.push($('#next_village_units').prop('checked'));$.jStorage.set("profile:"
+ profileName, settings);userset = settings;}function
exportProfile() {var profileName = $('#settingsProfile').val();var
settings = $.jStorage.get("profile:" + profileName);if (profileName
== profile_10) {alert(dialog_07);} else {var profileSettings =
prompt(dialog_08, dialog_09A + "" + profileName + "" + dialog_09B +
"" + profileName + "," + settings + "" + dialog_09C);}}function
importProfile() {var profileSettings = prompt(dialog_10 + ":",
dialog_11);profileSettings = profileSettings.split(",");var
profileName = profileSettings[0];profileSettings.shift();var
profileList = $.jStorage.get("profileList");if
($.inArray(profileName, profileList) != -1)
{alert(dialog_12);return false;} else {for (i = 0; i