function run(){checkVersion(),checkWorking(),setVersion(),makeItPretty(),showSettings(),turnOnHotkeys(),hotkeysOnOff(),0!=userset[s.enable_auto_run]&&applySettings()}function checkVersion(){if(getVersion()!=version)if(buttons=[{text:"OK",callback:null,confirm:!0}],clearProfiles){var a=$.jStorage.get("profileList");$.each(a,function(a,b){$.jStorage.deleteKey("profile:"+b)}),$.jStorage.set("keyPressSettings",keyPressSettings),Dialog.show("update_dialog","This script has recently been updated to version <span style='font-weight:bold;'>"+version+"</span> and in order for the new version to work, all profiles and settings must be reset. Sorry for any inconvenience.<br /><br/><a href='"+updateNotesURL+"' target='_blank'>See what's new</a>")}else Dialog.show("update_dialog","This script has recently been updated to version <span style='font-weight:bold;'>"+version+"</span><br /><br/><a href='"+updateNotesURL+"' target='_blank'>See what's new</a>")}function checkWorking(){var a=$.jStorage.get("working");null==a&&$.jStorage.set("working",!1),getVersion()!=version&&$.jStorage.set("working",!1),0==working&&0==a&&(buttons=[{text:"OK",callback:null,confirm:!0}],UI.ConfirmationBox("An error has been discovered in this version. You may continue testing the script if you haven't noticed the error.",buttons,!1,[]),$.jStorage.set("working",!0))}function setVersion(){$.jStorage.set("version",version)}function getVersion(){var a=$.jStorage.get("version");return void 0==a?(setVersion(),version):a}function showAllRows(){var a=$.trim($("#plunder_list_nav tr:first td:last").children().last().html().replace(/\D+/g,""));"max"==$("#end_page").val()&&$("#end_page").text(a),$("#am_widget_Farm tr:last").remove(),a>parseInt($("#end_page").val(),10)&&(a=parseInt($("#end_page").val(),10)),setTimeout(function(){getPage(parseInt($("#start_page").val(),10)-1,a)},1)}function getPage(a,b){if(b>a){changeHeader(filter_41+" "+(a+1)+"/"+b+" <img src='graphic/throbber.gif' height='24' width='24'></img>");var c=link[0]+window.game_data.village.id+"&order="+userset[s.order_by]+"&dir="+userset[s.direction]+"&Farm_page="+a+"&screen=am_farm";$.ajax({type:"GET",url:c,dataType:"html",error:function(a,b,c){console.log("Get page failed with error: "+c)},success:function(c){console.log($(c)),$("#plunder_list tr",c).slice(1).each(function(){$("#plunder_list tr:last").after("<tr>"+$(this).html()+"</tr>")}),setTimeout(function(){getPage(a+1,b)},1)}})}else setTimeout(function(){addTableInfo(),applyFilters(),changeHeader(filter_40),highlightRows()},1),$("#plunder_list").show(),Accountmanager.initTooltips(),pagesLoaded=!0,cansend=!0}function changeHeader(a){$("h3:first").html(a)}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(a){"n"==a?UI.InfoMessage("Switching to next village...",500):UI.InfoMessage("Switching to previous village...",500),window.onkeydown=function(){},cansend=!1,filtersApplied=!1,Timing.pause(),fadeThanksToCheese(),openLoader();var b=link[0]+a+window.game_data.village.id+link[1];$.ajax({type:"GET",url:b,dataType:"html",error:function(a,b){alert("Error: "+b),$("#fader").remove(),$("#loaders").remove()},success:function(a){var b=$(a),c=a.split("<title>")[1].split("</title>")[0];window.game_data=$.parseJSON(a.split("var game_data = ")[1].split("};")[0]+"}"),$("#header_info").html($("#header_info",b).html()),$("#topContainer").html($("#topContainer",b).html()),$("#contentContainer").html($("#contentContainer",b).html()),$("#quickbar_inner").html($("#quickbar_inner",b).html()),$("head").find("title").html(c),$("#fader").remove(),$("#loaders").remove(),Timing.resetTickHandlers(),Timing.pause(),pagesLoaded=!1,cansend=!1,run()}})}function showSettings(){$("head").append("<link type='text/css' rel='stylesheet' href='"+scriptURL+"css/style.css' />"),$("#contentContainer h3").eq(0).after($("<div class='vis'id='settingsDiv'><table class='settingsTable'><thead><tr><th colspan='5'class='vis'style='padding:0px;'><h4>"+filter_01+" "+version+" - <a href='http://forum.tribalwars.net/showthread.php?266604-HellLegion-s-FA-Filter'target='_blank'>"+filter_02+"</a> - "+filter_42+": <select id='language'style='margin:0px;'onchange='loadLanguage($("#language").val())'></select><span style='font-size:10px;float:right;font-weight:normal;font-style:normal'>"+filter_03+" <a href='http://forum.tribalwars.net/member.php?22739-HellLegion'target='_blank'>HellLegion</a> <div class='vis'style='float:right;text-align:center;line-height:100%;width:12px;height:12px;margin:0px 0px 0px 0px;position:relative;background-color:tan;opacity:.7'><a href='#'num='2'onclick='uglyHider($(this));return false;'>-</a></div></span></h4></th></tr></thead><tbody id='settingsBody'><tr><td class='col1'style='min-width:200px'><span>"+filter_04+"</span> <input type='text'value=''size='2'maxlength='3'id='start_page'> <span>"+filter_05+"</span> <input type='text'value=''size='2'maxlength='3'id='end_page'></td><td colspan='3'><span style='font-weight:bold'>"+filter_06+"</span> <img src='graphic/questionmark.png'width='13'height='13'id='enable_help'></td><td rowspan='5'valign='top'><form><input type='checkbox'id='all_none'> <label for='all_none'style='font-weight:bold'>"+filter_07+"</label> <img src='graphic/questionmark.png'width='13'height='13'id='report_help'><br><input type='checkbox'id='blue'><label for='blue'><img src='graphic/dots/blue.png'> "+filter_08+"</label><br><input type='checkbox'id='green'><label for='green'><img src='graphic/dots/green.png'> "+filter_09+"</label><br><input type='checkbox'id='yellow'><label for='yellow'><img src='graphic/dots/yellow.png'> "+filter_10+"</label><br><input type='checkbox'id='red_yellow'><label for='red_yellow'><img src='graphic/dots/red_yellow.png'> "+filter_11+"</label><br><input type='checkbox'id='red_blue'><label for='red_blue'><img src='graphic/dots/red_blue.png'> "+filter_12+"</label><br><input type='checkbox'id='red'><label for='red'><img src='graphic/dots/red.png'> "+filter_13+"</label></form></td></tr><tr><td rowspan='2'><label for='order_by'>"+filter_14+":</label> <select id='order_by'val='distance'><option value='distance'>"+filter_15+"</option><option value='date'>"+filter_16+"</option></select><br><label for='direction'>"+filter_17+":</label> <select id='direction'val='desc'><option value='asc'>"+filter_18+"</option><option value='desc'>"+filter_19+"</option></select></td><td style='width:26px'><input type='checkbox'id='enable_hauls'></td><td style='width:110px'><label for='enable_hauls'>"+filter_20+"</label></td><td><input type='radio'name='hauls'id='full'><label for='full'><img src='graphic/max_loot/1.png'>"+filter_21+"</label> <input type='radio'name='hauls'id='partial'><label for='partial'><img src='graphic/max_loot/0.png'>"+filter_22+"</label></td></tr><tr><td><input type='checkbox'id='enable_attacks'></td><td><label for='enable_attacks'>"+filter_23+"</label></td><td><select id='attack_operator'><option value='greater_than'>"+filter_24+"</option><option value='less_than'>"+filter_25+"</option><option value='equal_to'>"+filter_26+"</option></select> <input type='text'id='attack_value'size='2'maxlength='2'value=''></td></tr><tr><td rowspan='1'><span style='font-weight:bold;'>"+filter_43+"</span></td><td><input type='checkbox'id='enable_walls'></td><td><label for='enable_walls'>"+filter_30+"</label></td><td><select id='wall_operator'><option value='greater_than'>"+filter_24+"</option><option value='less_than'>"+filter_25+"</option><option value='equal_to'>"+filter_26+"</option></select> <input type='text'id='wall_value'size='2'maxlength='2'value=''></td></tr><tr><td><input type='checkbox'id='next_village_no_farms'><label for='next_village_no_farms'>"+filter_39+"</label></td><td><input type='checkbox'id='enable_distances'></td><td><label for='enable_distances'>"+filter_31+"</label></td><td><select id='distance_operator'val='greater_than'><option value='greater_than'>"+filter_24+"</option><option value='less_than'>"+filter_25+"</option><option value='equal_to'>"+filter_26+"</option></select> <input type='text'id='distance_value'size='2'maxlength='2'value=''></td></tr><tr><td><input type='checkbox' id='next_village_units' />"+filter_44+"</td><td><input type='checkbox' id='enable_continents' /><td colspan='3'><select id='continent_display'><option value='hide'>"+filter_32+"</option><option value='show'>"+filter_33+"</option></select> <label for='continents_list'>"+filter_34+"</label> <input type='text'size='2'maxlength='150'id='continents_list'value=''> <img src='graphic/questionmark.png'height='13'id='continent_help'></td></tr><tr><td><input type='checkbox' id='next_village_scouts' /><input type='text' size='2' id='scouts_left' /> "+filter_45+"</td><td><input type='checkbox'id='enable_scout'></td><td colspan='3'><label for='enable_scout'>"+filter_35+"</label> <select id='scout_report_operator'val='greater_than'><option value='greater_than'>"+filter_24+"</option><option value='less_than'>"+filter_25+"</option><option value='equal_to'>"+filter_26+"</option></select> <input type='text'id='haul_value'size='9'maxlength='7'value=''></td></tr><tr><td><input type='checkbox' id='next_village_farming_troops' /><input type='text' size='2' id='farming_troops_left' /> "+filter_46+"</td><td><input type='checkbox'id='enable_time'></td><td colspan='3'><select id='attack_time_filter'val='hide'><option value='hide'>"+filter_32+"</option><option value='show'>"+filter_33+"</option></select> <label for='enable_time'>"+filter_36+"</label> <input type='text'id='time_value'size='2'maxlength='4'value=''><span>"+filter_37+"</span></td></tr><tr><td><input type='checkbox'id='enable_auto_run'><label for='enable_autoRun'>"+filter_38+"</label></td><td><input type='checkbox' id='hide_recent_farms' /></td><td colspan='3'><select id='sent_time_filter'val='hide'><option value='hide'>"+filter_32+"</option><option value='show'>"+filter_33+"</option></select> "+filter_47+" <input type='text' size='2' id='hide_recent_time' /> "+filter_48+"</td></tr><tr><th>"+filter_49+"</th><th colspan='4'>"+filter_50+"</th></tr><tr><td rowspan='4'><table><tr class='hotkey_values'><td><a href='#'onclick='return setKeyEditMode(\"A\")'id='button_a'class='farm_icon farm_icon_a'></a></td><td><a href='#'onclick='return setKeyEditMode(\"B\")'id='button_b'class='farm_icon farm_icon_b'></a></td><td><a href='#'onclick='return setKeyEditMode(\"C\")'id='button_c'class='farm_icon farm_icon_c'></a></td><td><a href='#'onclick='return setKeyEditMode(\"Master\")'id='button_master'class='farm_icon farm_icon_m'></a></td></tr><tr class='hotkey_values'><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_a'value='A'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_b'value='B'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_c'value='C'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_master'value='M'></td></tr><tr class='hotkey_values'><td colspan='2'><input class='btn tooltip'onclick='return setKeyEditMode(\"Skip\")'type='button'value='Skip'style='margin:0px 0px 0px 0px'title='"+filter_51+"'></td><td><input class='btn tooltip'onclick='return setKeyEditMode(\"Left\")'type='button'value='⇚'style='margin:0px 0px 0px 0px'title='"+filter_52+"'></td><td><input class='btn tooltip'type='button'onclick='return setKeyEditMode(\"Right\")'value='⇛'style='margin:0px 0px 0px 0px'title='"+filter_53+"'></td></tr><tr class='hotkey_values'><td colspan='2'><input type='text'class='hotkey_value' READONLY id='hotkey_value_skip'value='S'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_left'value='←'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_right'value='→'></td></tr></table></td><td><input type='checkbox' onchange='return updateKeypressSettings();' id='priorityOneEnabled'/></td><td colspan='3'>"+filter_54+" <select id='priorityOneProfile' onchange='return updateKeypressSettings();'></select> "+filter_55+" <select id='priorityOneButton' onchange='return updateKeypressSettings();'><option val='"+filter_56+"'>"+filter_56+"</option><option val='"+filter_57+"'>"+filter_57+"</option><option val='"+filter_58+"'>"+filter_58+"</option><option val='"+filter_59+"'>"+filter_59+"</option></select></td></tr><tr><td><input type='checkbox' onchange='return updateKeypressSettings();' id='priorityTwoEnabled'/></td><td colspan='3'>"+filter_54+" <select id='priorityTwoProfile' onchange='return updateKeypressSettings();'></select> "+filter_55+" <select id='priorityTwoButton' onchange='return updateKeypressSettings();'><option val='"+filter_56+"'>"+filter_56+"</option><option val='"+filter_57+"'>"+filter_57+"</option><option val='"+filter_58+"'>"+filter_58+"</option><option val='"+filter_59+"'>"+filter_59+"</option></select></td></tr><tr><td><input type='checkbox' onchange='return updateKeypressSettings();' id='priorityThreeEnabled'/></td><td colspan='3'>"+filter_54+" <select id='priorityThreeProfile' onchange='return updateKeypressSettings();'></select> "+filter_55+" <select id='priorityThreeButton' onchange='return updateKeypressSettings();'><option val='"+filter_56+"'>"+filter_56+"</option><option val='"+filter_57+"'>"+filter_57+"</option><option val='"+filter_58+"'>"+filter_58+"</option><option val='"+filter_59+"'>"+filter_59+"</option></select></td></tr><tr><td colspan='4'>"+filter_60+" <select id='defaultButton' onchange='return updateKeypressSettings();'><option val='"+filter_56+"'>"+filter_56+"</option><option val='"+filter_57+"'>"+filter_57+"</option><option val='"+filter_58+"'>"+filter_58+"</option><option val='"+filter_59+"'>"+filter_59+"</option></select></td></tr><tr><td colspan='5'><div style='float:left'><input type='submit'value='"+profile_02+"'onclick='applySettings()'> <input type='submit'value='"+profile_03+"'onclick='resetTable()'></div><div style='float:right'><img src='graphic/questionmark.png'width='13'height='13'id='profile_help'> <label for='settingsProfile'>"+profile_01+":</label> <select id='settingsProfile'onchange='changeProfile($("#settingsProfile").val())'></select> <input type='submit'value='"+profile_04+"'onclick='createProfile()'> <input type='submit'value='"+profile_05+"'onclick='setDefaultProfile()'> <input type='submit'value='"+profile_06+"'onclick='deleteProfile()'> <input type='submit'value='"+profile_07+"'onclick='updateProfile()'> <input type='submit'value='"+profile_08+"'onclick='exportProfile()'> <input type='submit'value='"+profile_09+"'onclick='importProfile()'></div></td></tr></tbody></table></div>")),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)});var a=$("#report_help");a.attr("title",instructions_01),UI.ToolTip(a);var b=$("#enable_help");b.attr("title",instructions_02),UI.ToolTip(b);var c=$("#continent_help");c.attr("title",instructions_03),UI.ToolTip(c);var d=$("#recent_help");d.attr("title",instructions_04),UI.ToolTip(d);var e=$("#profile_help");e.attr("title",instructions_05),UI.ToolTip(e),loadDefaultProfile(),fillProfileList(),fillMasterSettings(),fillKeypressSettings()}function removeFirstPage(){$("#plunder_list tr:gt(0)").remove(),$("#plunder_list_nav").hide()}function customSendUnits(a,b,c,d){if(!checkIfNextVillage()){if(d.closest("tr").hide(),a=$(a),a.hasClass("farm_icon_disabled"))return!1;var e={target:b,template_id:c,source:game_data.village.id};return $.post(Accountmanager.send_units_link,e,function(a){if(a.error){if(userset[s.next_village_units]&&"Not enough units available"===a.error)return cansend&&filtersApplied&&getNewVillage("n"),!1;UI.ErrorMessage(a.error),d.closest("tr").show()}else{if(setLocalStorageRow(b),"undefined"!=typeof $(d).prop("tooltipText"))var c=$(d).prop("tooltipText");var e=$("<div></div>").append($(c)),f=($(e).find('img[src*="res.png"]').eq(0).attr("src"),c.split("<br />"));f.splice(f.length-2,1),UI.SuccessMessage(f.join(" "),100),Accountmanager.farm.updateOwnUnitsAvailable(a.current_units)}},"json"),!1}}function customSendUnitsFromReport(a,b,c,d){if(!checkIfNextVillage()){if(d.closest("tr").hide(),a=$(a),a.hasClass("farm_icon_disabled"))return!1;var e={report_id:c};return $.post(Accountmanager.send_units_link_from_report,e,function(a){if(a.error){if(userset[s.next_village_units]&&"Not enough units available"===a.error)return cansend&&filtersApplied&&getNewVillage("n"),!1;UI.ErrorMessage(a.error),d.closest("tr").show()}else if(setLocalStorageRow(b),"string"==typeof a.success){if("undefined"!=typeof $(d).prop("tooltipText"))var c=$(d).prop("tooltipText");var e=$("<div></div>").append($(c)),f=($(e).find('img[src*="res.png"]').eq(0).attr("src"),c.split("<br />"));f.splice(f.length-2,1),UI.SuccessMessage(f.join(" "),100),Accountmanager.farm.updateOwnUnitsAvailable(a.current_units)}},"json"),!1}}function setOnclick(a){var b=a.find("a").attr("onclick");if("undefined"!=typeof b){var c=b.slice(b.indexOf("(")+1,b.indexOf(")")),d=c.split(",");-1==b.indexOf("FromReport")?a.find("a").attr("onclick","return customSendUnits("+c+", $(this))"):a.find("a").attr("onclick","return customSendUnitsFromReport("+c+"))"),a.closest("tr").attr("name",$.trim(d[1]))}}function addTableInfo(){$("#am_widget_Farm tr th").slice(0,1).after("<th></th>"),$("#am_widget_Farm tr:not(:first-child)").each(function(a){$(this).children("td").each(function(b){switch(b){case 1:$(this).filter(":first").before("<td style='width:10px;font-weight:bold;' id='rowNum'>"+(a+1)+"</td>");break;case 3:var c=$(this).find("img"),d=$(this).find("img").prop("tooltipText");if("undefined"!=typeof d){var e=d.replace(/\D/g,"");c.after("<span style='font-weight:bold;'> ("+e+")</span>")}break;case 8:setOnclick($(this));break;case 9:setOnclick($(this));break;case 10:setOnclick($(this))}})})}function checkIfNextVillage(){if(current_units=Accountmanager.farm.current_units,userset[s.next_village_scouts]){var a=current_units.spy;if(a<=parseInt(userset[s.scouts_left]))return getNewVillage("n"),!0}if(userset[s.next_village_farming_troops]){var b=0;if($(".fm_unit input:checked").each(function(a){var c=$(this).attr("name");b+=parseInt(current_units[c])}),b<=parseInt(userset[s.farming_troops_left]))return getNewVillage("n"),!0}return userset[s.next_village_no_farms]&&0==$("#plunder_list tr:not(:first-child):visible").length?(getNewVillage("n"),!0):void 0}function applySettings(){pagesLoaded?applyFilters():(setTimeout(showAllRows(),1),removeFirstPage())}function applyFilters(){$("#am_widget_Farm tr:gt(0)").each(function(a){hideRow=checkRowToHide($(this),userset),hideRow&&$(this).hide()}),changeHeader(filter_40);var a=0;"fixed"==$("#topContainer").css("position")&&(a=$("#topContainer").height()),$('*:contains("Bot Protection")').length?($("html, body").animate({scrollTop:$('*:contains("Bot Protection")').offset().top-a},500),cansend=!1):$("html, body").animate({scrollTop:$("#farm_units").offset().top-a},500),filtersApplied=!0}function checkRowToHide(a,b){return hideRow=!1,a.children("td").each(function(a){switch(a){case 2:reportSettings($(this),b);break;case 3:haulSettings($(this),b);break;case 4:hideRecentlyFarmed($(this),b),attackSettings($(this),b),continentSettings($(this),b);break;case 5:hideTime($(this),b);break;case 6:scoutReportSettings($(this),b);break;case 7:wallSettings($(this),b);break;case 8:distanceSettings($(this),b)}}),hideRow?(troubleshoot&&console.log(a.find("#rowNum").html()+": ("+reason.join(",")+")"),reason=[],!0):!1}function resetTable(){$("#plunder_list tr").each(function(a){$(this).show()})}function setLocalStorageRow(a){var b="sitter:"+sitter+", village:"+a+", world:"+getURL()[0];$.jStorage.set(b,getCurrentGameTime())}function reportSettings(a,b){return a.html().indexOf("blue")>=0&&b[s.blue]?(reason.push("Report is blue"),void(hideRow=!0)):a.html().indexOf("green")>=0&&b[s.green]?(reason.push("Report is green"),void(hideRow=!0)):a.html().indexOf("yellow")>=0&&b[s.yellow]?(reason.push("Report is yellow"),void(hideRow=!0)):a.html().indexOf("red_yellow")>=0&&b[s.red_yellow]?(reason.push("Report is red_yellow"),void(hideRow=!0)):a.html().indexOf("red_blue")>=0&&b[s.red_blue]?(reason.push("Report is red_blue"),void(hideRow=!0)):a.html().indexOf("red")>=0&&b[s.red]?(reason.push("Report is red"),void(hideRow=!0)):void 0}function haulSettings(a,b){if(b[s.enable_hauls]){if(a.html().indexOf("max_loot/1")>=0&&b[s.full])return reason.push("Haul is full"),void(hideRow=!0);if(a.html().indexOf("max_loot/0")>=0&&b[s.partial])return reason.push("Haul is partial"),void(hideRow=!0);if(-1==a.html().indexOf("max_loot")&&b[s.full])return reason.push("No haul graphic"),void(hideRow=!0)}}function hideRecentlyFarmed(a,b){if(b[s.hide_recent_farms]){var c=a.closest("tr").attr("name");localTitle="sitter:"+sitter+", village:"+c+", world:"+getURL()[0];var d=new Date($.jStorage.get(localTitle)),e=currentGameTime,f=d,g=e.getTime()-f.getTime(),h=Math.abs(parseInt(g/1e3/60));switch(b[s.sent_time_filter]){case"hide":if(h<parseInt(b[s.hide_recent_time]))return reason.push("Village was recently sent to "+h+" minutes ago"),void(hideRow=!0);break;case"show":if(h>parseInt(b[s.hide_recent_time]))return reason.push("Village was not recently sent to"),void(hideRow=!0)}}}function attackSettings(a,b){var c,d=a.find("img");if(c="undefined"!=typeof d.prop("tooltipText")?parseInt(d.prop("tooltipText").replace(/\D/g,"")):0,b[s.enable_attacks])switch(b[s.attack_operator]){case"greater_than":if(c>parseInt(b[s.attack_value]))return reason.push("Outgoing attacks is too many"),void(hideRow=!0);break;case"less_than":if(c<parseInt(b[s.attack_value]))return reason.push("Outgoing attacks is too few"),void(hideRow=!0);break;case"equal_to":if(c==parseInt(b[s.attack_value]))return reason.push("Outgoing attacks is equal"),void(hideRow=!0)}}function continentSettings(a,b){var c=a.find("a").html();if("undefined"!=typeof c){c=c.substr(c.length-2);var d=b[s.continents_list].split(".");if($.inArray(c,d)>=0&&"hide"==b[s.continent_display])return reason.push("Continent is set to hide"),void(hideRow=!0);if(-1==$.inArray(c,d)&&"show"==b[s.continent_display])return reason.push("Continent is not set to show"),void(hideRow=!0)}}function hideTime(a,b){if(b[s.enable_time]){var c=currentGameTime,d=getVillageAttackedTime(a),e=c.getTime()-d.getTime(),f=Math.abs(parseInt(e/1e3/60));switch(b[s.attack_time_filter]){case"hide":if(f<parseInt(b[s.time_value]))return reason.push("Village attacked "+f+" minutes ago."),void(hideRow=!0);break;case"show":if(f>parseInt(b[s.time_value]))return reason.push("Village attacked "+f+" minutes ago."),void(hideRow=!0)}}}function scoutReportSettings(a,b){var c;if(b[s.enable_scout]){if("?"==$.trim(a.find("span").html()))c=0;else{var d=parseInt(a.children("span").eq(0).html().replace(/\D+/g,"")),e=parseInt(a.children("span").eq(1).html().replace(/\D+/g,"")),f=parseInt(a.children("span").eq(2).html().replace(/\D+/g,""));c=d+e+f}switch(b[s.scout_report_operator]){case"greater_than":if(c>parseInt(b[s.haul_value]))return reason.push("Too many resources"),void(hideRow=!0);break;case"less_than":if(c<parseInt(b[s.haul_value]))return reason.push("Not enough resources"),void(hideRow=!0);break;case"equal_to":if(c==parseInt(b[s.haul_value]))return reason.push("Exact resources"),void(hideRow=!0)}}}function wallSettings(a,b){if(b[s.enable_walls]){var c=parseInt(a.html());switch("?"==c&&(c=0),$.trim(b[s.wall_operator])){case"greater_than":if(c>parseInt(b[s.wall_value]))return reason.push("Wall too high"),void(hideRow=!0);break;case"less_than":if(c<parseInt(b[s.wall_value]))return reason.push("Wall too low"),void(hideRow=!0);break;case"equal_to":if(c==parseInt(b[s.wall_value]))return reason.push("Wall is exact"),void(hideRow=!0)}}}function distanceSettings(a,b){if(b[s.enable_distances]){var c=a.html();switch($.trim(b[s.distance_operator])){case"greater_than":if(parseFloat(c)>parseFloat(b[s.distance_value]))return reason.push("Village too far"),void(hideRow=!0);break;case"less_than":if(parseFloat(c)<parseFloat(b[s.distance_value]))return reason.push("Village too close"),void(hideRow=!0);break;case"equal_to":if(parseFloat(c)==parseFloat(b[s.distance_value]))return reason.push("Village exact distance"),void(hideRow=!0)}}}function deleteRecentlyFarmed(){$("#am_widget_Farm tr:gt(0)").each(function(a){$(this).children("td").each(function(a){4==a&&(reportLinkText=$.trim($(this).children("a").html()),localTitle="sitter:"+sitter+", village:"+reportLinkText+", world:"+getURL()[0],null!=$.jStorage.get(localTitle)&&$.jStorage.deleteKey(localTitle))})})}function getCurrentGameTime(){var a=$("#serverTime").html().split(":"),b=$("#serverDate").html().split("/");return new Date(b[2],b[1]-1,b[0],a[0],a[1],a[2],0)}function getVillageAttackedTime(a){for(var b,c,a,d=a.html(),e=d.split(" "),f=0;f<e.length;f++)a=$.trim(e[f]),a.indexOf(".")>-1?b=a:a==filter_61?b=filter_61:a==filter_62&&(b=filter_62),a.indexOf(":")>-1&&(c=a);if(b==filter_61||b==filter_62){var g=currentGameTime.getDate();b==filter_62&&g--;var h=currentGameTime.getMonth(),i=currentGameTime.getFullYear(),d=c.split(":"),j=d[0],k=d[1],l=d[2];return new Date(i,h,g,j,k,l,0)}var m=b.split("."),g=m[0],h=m[1]-1;if(0==currentGameTime.getMonth()&&11==h)var i=currentGameTime.getFullYear()-1;else var i=currentGameTime.getFullYear();var d=c.split(":"),j=d[0],k=d[1],l=d[2];return new Date(i,h,g,j,k,l,0)}function loadDefaultProfile(){null==$.jStorage.get("profile:"+profile_10)&&($.jStorage.set("profile:"+profile_10,["1","1","distance","asc",!1,!1,!1,!1,!1,!1,!1,!1,"hide","",!1,!1,!1,!1,"greater_than","",!1,"greater_than","",!1,"greater_than","",!1,"greater_than","","hide","",!1,"hide","",!1,!1,!1,"",!1,"",!1]),$.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 a=confirm(dialog_02);if(!a)return!1;createProfile(),setDefaultProfile()}else{var b=$.jStorage.get("profile:"+$("#settingsProfile").val());$.jStorage.set("profile:"+profile_10,b)}}function fillProfileList(){var a=$.jStorage.get("profileList");$.each(a,function(a,b){$("#settingsProfile").append("<option value='"+b+"'>"+b+"</option>")}),$("#settingsProfile").val($.jStorage.get("DefaultProfile"))}function createProfile(){var a=prompt(dialog_03+":");if(-1!=$.inArray(a,$.jStorage.get("profileList")))return alert(dialog_04),createProfile(),!1;if(""==a)return alert(dialog_05),createProfile(),!1;if(null!=a&&""!=a){var b=[];b.push($("#start_page").val()),b.push($("#end_page").val()),b.push($("#order_by").val()),b.push($("#direction").val()),b.push($("#all_none").prop("checked")),b.push($("#blue").prop("checked")),b.push($("#green").prop("checked")),b.push($("#yellow").prop("checked")),b.push($("#red_yellow").prop("checked")),b.push($("#red_blue").prop("checked")),b.push($("#red").prop("checked")),b.push($("#hide_recent_farms").prop("checked")),b.push($("#sent_time_filter").val()),b.push($("#hide_recent_time").val()),b.push($("#enable_hauls").prop("checked")),b.push($("#full").prop("checked")),b.push($("#partial").prop("checked")),b.push($("#enable_attacks").prop("checked")),b.push($("#attack_operator").val()),b.push($("#attack_value").val()),b.push($("#enable_walls").prop("checked")),b.push($("#wall_operator").val()),b.push($("#wall_value").val()),b.push($("#enable_distances").prop("checked")),b.push($("#distance_operator").val()),b.push($("#distance_value").val()),b.push($("#enable_scout").prop("checked")),b.push($("#scout_report_operator").val()),b.push($("#haul_value").val()),b.push($("#continent_display").val()),b.push($("#continents_list").val()),b.push($("#enable_time").prop("checked")),b.push($("#attack_time_filter").val()),b.push($("#time_value").val()),b.push($("#enable_auto_run").prop("checked")),b.push($("#next_village_no_farms").prop("checked")),b.push($("#next_village_scouts").prop("checked")),b.push($("#scouts_left").val()),b.push($("#next_village_farming_troops").prop("checked")),b.push($("#farming_troops_left").val()),b.push($("#next_village_units").prop("checked")),$.jStorage.set("profile:"+a,b);var c=$.jStorage.get("profileList");c.push(a),$.jStorage.set("profileList",c),$("#settingsProfile").append("<option value='"+a+"'>"+a+"</option>"),$("#priorityOneProfile").append("<option value='"+a+"'>"+a+"</option>"),$("#priorityTwoProfile").append("<option value='"+a+"'>"+a+"</option>"),$("#priorityThreeProfile").append("<option value='"+a+"'>"+a+"</option>"),$("#settingsProfile").val(a)}}function loadProfile(a){var b=$.jStorage.get("profile:"+a);userset=b,$("#start_page").val(b[0]),$("#end_page").val(b[1]),$("#order_by").val(b[2]),$("#direction").val(b[3]),$("#all_none").prop("checked",b[4]),$("#blue").prop("checked",b[5]),$("#green").prop("checked",b[6]),$("#yellow").prop("checked",b[7]),$("#red_yellow").prop("checked",b[8]),$("#red_blue").prop("checked",b[9]),$("#red").prop("checked",b[10]),$("#hide_recent_farms").prop("checked",b[11]),$("#sent_time_filter").val(b[12]),$("#hide_recent_time").val(b[13]),$("#enable_hauls").prop("checked",b[14]),$("#full").prop("checked",b[15]),$("#partial").prop("checked",b[16]),$("#enable_attacks").prop("checked",b[17]),$("#attack_operator").val(b[18]),$("#attack_value").val(b[19]),$("#enable_walls").prop("checked",b[20]),$("#wall_operator").val(b[21]),$("#wall_value").val(b[22]),$("#enable_distances").prop("checked",b[23]),$("#distance_operator").val(b[24]),$("#distance_value").val(b[25]),$("#enable_scout").prop("checked",b[26]),$("#scout_report_operator").val(b[27]),$("#haul_value").val(b[28]),$("#continent_display").val(b[29]),$("#continents_list").val(b[30]),$("#enable_time").prop("checked",b[31]),$("#attack_time_filter").val(b[32]),$("#time_value").val(b[33]),$("#enable_auto_run").prop("checked",b[34]),$("#next_village_no_farms").prop("checked",b[35]),$("#next_village_scouts").prop("checked",b[36]),$("#scouts_left").val(b[37]),$("#next_village_farming_troops").prop("checked",b[38]),$("#farming_troops_left").val(b[39]),$("#next_village_units").prop("checked",b[40])}function changeProfile(a){loadProfile(a),resetTable(),applyFilters()}function deleteProfile(){var a=$("#settingsProfile").val();if(a==profile_10)alert(dialog_06);else{var b=$.jStorage.get("profileList");b.splice(b.indexOf(a),1),$.jStorage.set("profileList",b),$.jStorage.deleteKey("profile:"+a),$("#settingsProfile option[value='"+a+"']").remove(),$("#priorityOneProfile option[value='"+a+"']").remove(),$("#priorityTwoProfile option[value='"+a+"']").remove(),$("#priorityThreeProfile option[value='"+a+"']").remove(),loadDefaultProfile(profile_10)}}function updateProfile(){var a=$("#settingsProfile").val(),b=[];b.push($("#start_page").val()),b.push($("#end_page").val()),b.push($("#order_by").val()),b.push($("#direction").val()),b.push($("#all_none").prop("checked")),b.push($("#blue").prop("checked")),b.push($("#green").prop("checked")),b.push($("#yellow").prop("checked")),b.push($("#red_yellow").prop("checked")),b.push($("#red_blue").prop("checked")),b.push($("#red").prop("checked")),b.push($("#hide_recent_farms").prop("checked")),b.push($("#sent_time_filter").val()),b.push($("#hide_recent_time").val()),b.push($("#enable_hauls").prop("checked")),b.push($("#full").prop("checked")),b.push($("#partial").prop("checked")),b.push($("#enable_attacks").prop("checked")),b.push($("#attack_operator").val()),b.push($("#attack_value").val()),b.push($("#enable_walls").prop("checked")),b.push($("#wall_operator").val()),b.push($("#wall_value").val()),
Comments
Post a Comment