// ==UserScript==
// @name MyFreeFarm Automat
// @namespace https://github.com/BastianKanaan/GMscripts_MyFreeFarm
// @author BastianKanaan
// @description Extends MyFreeFarm
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB94BGgo6NO+u5q4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAS0ElEQVRo3t2aeYxl11ngf+fub3+172t3V1cv7sVuJ3bs7jh2QtoMDoHEwRlCbMJEATRiSaKBQTNBCKGwBwSDNAyTQVGCYJIMEINjxrFix3E73mO7TW/V1VXVtS+v6i13v+ee+aNvQSXDaCTS7W7nSE/v3veuzrm/8y3nO9934Dq08cE+APv9E/1//tDN+16/9+hNJ/l+bXv3jAHw4zf1P/sLdx5TRqXyc++fHPvsGzW+/kbC5vMOyyvrfOSDJz99eM/gj+09fkK9Na/fW8sVzr86NfOl7ydgB+iK46TnVz75wJNtHZX3rcuUI8dvFS9cnuHQ7YcOWprTfvb8pUe/H4BzwH7g0H/59INfq3Z09++ZHBPHbn8LpVKF3WNdWPlOdeIdd962MDf/8vSl+XPX8mW0awxrAiPAgd/4xXf+wdaG74yP7BL9w/vp7x2h1WrRM3SYwf5+8cLz31Yf/w8f/fK1nn3tGkt2D3AE6J7o6xoc7Cjyq//pt3ntm88wMzvDhfMX+dmP/AJJnDKxe0j09HQZDzzwns+9GVW6CBwGjgIdhbz91vfdffjg6soWrhcwf+p5Cu7L3DwhWTkdYvVWCeOEQsFm//5dY1/4wld+880kYQeYBG4CqoD23uMTk0mcQJTQF9R4/48PM3mwDU2HDz5Y5dk/+VPc5YuErZpKooZ9LSVsXOX+BNAB7AUK2X1yx97C7oXpNQb7Nrn5pw5hOA6FthLFYh4hdD7+B8NceHGKi2eqYmTfmAGwb3I3Z85O3fAS1oHubckC6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w1NbCIFj64gWTFaUfA37kken6oyA/HHUMfwqWuV6tANwJ/BrwF9le+W7gs6OVwnYq4k9vGuy8cP/+8jPQb/4L6/0w8BPAFxHi+I7//puZyx/YMc5f2MXKEa5z07Ii2k8AN2c7KwG8e8czd+Rs+wN2tTM33Nv9L/XRA9wP3PVdGpf7rue6rsYL/x8HbwtumjbAVwAAAABJRU5ErkJggg==
// @date 13.02.2015
// @version 2.4.1
// @include /^http:\/\/(|www\.|s\d+\.)au\.myfreefarm\.com\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)veselaferma\.com\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.com\.br\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.de\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.cz\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.dk\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.gr\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)migranjalinda\.es\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)mabelleferme\.fr\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.com\.hr\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.ae\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.ir\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.it\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)enkicsitanyam\.hu\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.nl\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.co\.nz\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.no\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)wolnifarmerzy\.pl\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)pt\.myfreefarm\.com\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)fermavesela\.ro\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)mojaderewnja\.ru\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.se\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)th\.myfreefarm\.com\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)tr\.myfreefarm\.com\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.co\.uk\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.com\/.*$/
// @include /^http:\/\/(|www\.|s\d+\.)myfreefarm\.com\.vn\/.*$/
// @exclude http://*/dyn_bubbles.php*
// @exclude http://*/login_inc.php*
// @exclude http://*/stadt/*
// @exclude http://*/nachrichten/*
// @exclude http://*/vertraege/*
// @exclude http://*/nutzer/*
// @exclude http://*/payment/*
// @grant GM_addStyle
// @grant GM_deleteValue
// @grant GM_getValue
// @grant GM_listValues
// @grant GM_log
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @require https://raw.githubusercontent.com/BastianKanaan/GMscripts_MyFreeFarm/master/MyFreeFarm_Common_functions.user.js
// ==/UserScript==
const VERSION=GM_info["script"]["version"];
const neededVersionBerater="2.4.1";
const neededVersionFunctionFile="2.1.3";
const GM_Home =GM_info["script"]["namespace"];
const GM_Source=GM_info["script"]["namespace"];
// [version,date,[[de,en],[de,en],...]]
const CHANGELOG=[["2.0","29.05.2014",[["Migration nach openuserjs.org","Migration to openuserjs.org"],["Script wird jetzt auf GitHub entwickelt","Script now developed on GitHub"]]]
,["2.1","11.07.2014",[["Neu: Changelog","New: Changelog"],["Refaktorierung der Zonen-Daten","Refactoring of zones data"]]]
,["2.1.1","12.07.2014",[["Bugfix","Bugfix"]]]
,["2.1.2","22.08.2014",[["Bugfix: S"+a_dots+"gewerk und Schreinerei durch Patch 18.08.2014","Bugfix: Sawmill and carpentry by patch 18.08.2014"]]]
,["2.1.3","02.09.2014",[["Neu: Doppelte Sicherung des Bots gegen Ausf"+a_dots+"lle. Entsprechende Optionen.","New: Double protection against failing of the bot. Corresponding options."],["Refaktorierung der Optionen","Refactoring of settings"]]]
,["2.1.4","09.09.2014",[["Bugfix","Bugfix"]]]
,["2.1.5","09.12.2014",[["Bugfix","Bugfix"]]]
,["2.1.6","18.12.2014",[["Neu: Bot f"+u_dots+"r Waltraud kann jetzt in den Optionen aktiviert werden","New: Bot for donkey can be activated in options"]]]
,["2.2.0","01.02.2015",[["Neu: Ernte-Bot f"+u_dots+"r G"+u_dots+"terhof","New: Cropping bot for megafield"]]]
,["2.4.0","12.02.2015",[["Anpassung an Firefox 35","Fix for Firefox 35"]]]
,["2.4.1","13.02.2015",[["Bugfix: Optionen","Bugfix: Settings"]]]
];
if(!VERSIONfunctionFile){
alert("Hi, I am the Automaton-Script.\nThe function-file is missing.\nPlease install me again.");
location.href=GM_Source;
}else if(compareVersions(neededVersionFunctionFile,VERSIONfunctionFile)>0){
alert("Hi, I am the Automaton-Script.\nThe function-file is too old.\nPlease install me again.");
location.href=GM_Source;
}
var DEVMODE=GM_getValue("devmode",false);
var DEVMODE_FUNCTION=GM_getValue("devmode_function",false);
var DEVMODE_LOG_WARNING=GM_getValue("devmode_log_warning",false);
var DEVMODE_LOG_ERROR=GM_getValue("devmode_log_error",false);
const LOGGING_ARBITER=false;
const PRODSTOP=-1;
const PRODSTOPold=66; // TODO remove
const MILLSTOPold=0; // TODO remove
const ExtendedListCHAR="l";
var extendedListReg=/^l(\d+)$/;
const REPEAT_NO_LIMIT=-1;
const REPEAT_RESTART=0;
const OPTION_ITEM_REPEAT=false; // should be OPTION_LIST_REPEAT=!OPTION_ITEM_REPEAT, But is not needed
const OPTION_LIST_REPEAT=true; // should be OPTION_LIST_REPEAT=!OPTION_ITEM_REPEAT, But is not needed
const DEFAULT_ZONELIST_ITEM=[PRODSTOP,0,0,false,false,REPEAT_NO_LIMIT];// ["prodId","AmntToDo","AmntToGo","rackMode","mode","AmntToRepeat"] //mode=Field,Rack,Time,Repeat
const DEFAULT_ZONELIST_ITEM_ARRAY=[DEFAULT_ZONELIST_ITEM];
const DEFAULT_ZONELIST_ITEM_ARRAY2=[DEFAULT_ZONELIST_ITEM,DEFAULT_ZONELIST_ITEM];
const DEFAULT_ZONELIST_MILL=[PRODSTOP,0,0,0,[]]; // {"pId":PRODSTOP,"AmntTodo":0,"AmntMax":0,"AmntItem":[]}
const DEFAULT_ZONELIST_MILL_ARRAY=[DEFAULT_ZONELIST_MILL];
const _TEXTE_STOP="----";
const row1=2;const row2=21;const row3=38;const row4=55;const row5=72;const row6=89;const row7=108;
const col1=2;const col2=21;const col3=40;const col4=55;
//Icon images
const IMAGES={"repeat_off":'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAACXBIWXMAAAsSAAALEgHS3X78AAABoUlEQVR4nK2TQW7aQBRAfZ54wKEhEaA48djYhDiqMQdooKRpthjqdgHYSjcp66B0GYsDhB273IJUjdQcoVd4XUApVqqWViye%2Fnz90dOfmT8KoGyCjUj%2BS1T363x7evr%2BR9F0OmU0Gq1wPY%2FX8%2FzzzQ2WaWIcGiRJwjPRl4cHfK%2FGoX6AKeUSS0osaWIucKwybvWY46Mq0pD0%2B72lTHl8%2FIpjO1jSpFKpcHF%2BQdAO6LTbBCkCukGHE9flxHXxfT%2Fd0eXHS0xDYts269xRxbZ5%2B%2BYcQJlM7u6T24TZbGYoZ60zTEMSR9Faok9XV8t9Yfcde%2FldBv0BSqv1mgNd50P4fi3RKmEYUioUaTQaKNEgolQo0gmCpajb7awl7QQBpUKR01enz4vVoypCFX8VjcdjXuRy7OV36fV66WJ%2BZwctm0XTNOr1OjXPo%2Ba9xPO8JTXPw7EdhKqS286h7%2B%2BTGshms4nYUtnWNLSshhAqQl2wNUf9masCLZOlXC7%2FmqPVjobDIdmMICMEcRwTx9EirqyjOZPJXeqb%2FPb8uq7%2F8wtu7Pf%2FAH%2Fz8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Qpy2mXtZQBhfZr5XQkuWGk8AKu0cXGveO8QJd2lec2gKdoSIS1JEIOGK2F8%2FUMhI2kRsVZKhEZ6iI4%2Fo3JAISMlAGv6zt0aSBRKoNonDwcbNIb7KOEgOJYtdMGvY5CnLPxB3LI%2F6ZMuczFc6la%2FQ%2Br20pNv66gj%2B9iueZicRB4tD%2Fotp6j9pl56M2x%2F%2Bv%2FAYjnimH96%2FpaAAAAABJRU5ErkJggg%3D%3D',
"rotate":'data:image/gif;base64,R0lGODlhEAAPAKEAAICAgAAAAP%2F%2F%2F%2F%2F%2F%2FyH5BAEKAAIALAAAAAAQAA8AAAIrlI%2BpAOGgTnM0xAmlTS9yF21CRSGlQZrVcaKkKKqxNylBZmDhiy8U4wkiCgA7',
"minus":'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABGdBTUEAAK%2FINwWK6QAAAClJREFUKFNj%2FA8EDKQAkAZSAAMpisGuGcQagAEFCi28eLD7gdjgJTkeAMUo9xhLWaTjAAAAAElFTkSuQmCC',
"plus":'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABGdBTUEAAK%2FINwWK6QAAAChJREFUKFNj%2FA8EDKQAkAZSAAMuxUBLsUoNZg0gNxPC4BAdTp4mNrYBvNHfMGxUbs8AAAAASUVORK5CYII%3D',
"reload_all":'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAARCAYAAAAougcOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAeBJREFUeNq0lEsoRGEYhg%2FjmksZcivkspIslGwoFohcSixkx2Kk7Ni5bIaNhWthocbIzlIoSaFYkIQikdhKNBkZl%2FH%2B03vq6%2FTPSPLVc%2Br83%2Ftfzve%2F37EZoSMF%2BMGH8Yew%2FZDvB7VgH%2FiCaKJAAojnep882I%2BRA4rAKiccggqLJhl0gXXwQN0tWAJ1IDLY4gVgBlyBd0408QAndVlgy5KXvIEp3Ual4FoIP8Wn%2B5lrYWn2xPgKaANloBsciNyk3CANXDLxCEZAKpjn2CywU%2BsUi%2FRoqhED3Mx7eaeBGOPgK09rhgO0ivdocE%2FtTIg7zQSn1M0rN2SAYX6NmjghxEegBpQw3wwa6KI1EA6ywQtPbYaH4%2BWsjNEB7mjRRs2pjjUX%2B2W5rzHNvE7mDiLwSKILVKmeNeITNqWN5bKLu%2FOxNHFBnGp%2BlVFFy%2Frpe91Fqgm5wEXdBagEhaCaZZGRwcP5aZ5AmJ7fYZPpIg%2BcU7doMYObNjbfXTp3tYj6LoB0ywb5YEM0pXnyJtFbg6Dd0ifTcpEwMCeSZ2Ac9HH8RuTU%2FyyRh%2Fn4bcdHs9F8QSY%2BgV5qY2l7r0WjXLoM6kP9u1QUg1Gwy1JsggHhFhnqJ7rNDRwcizD%2BIVQFhug2bXwLMABxaqOs9lkr9wAAAABJRU5ErkJggg%3D%3D',
"singleArrowUp":'data:image/gif;base64,R0lGODlhBQAJAIAAAP%2F%2F%2FwAAACH5BAEAAAAALAAAAAAFAAkAAAIMhBEXibz2FIOzHVQAADs%3D',
"singleArrowDown":'data:image/gif;base64,R0lGODlhBQAJAIAAAP%2F%2F%2FwAAACH5BAEAAAAALAAAAAAFAAkAAAIMDA5hqJh72otLJlcAADs%3D',
"timlinebutton":'data:image/gif;base64,R0lGODlhFwAXAKIBAG1MG%2F%2F%2F%2F3FoUpiLZYhzTm1SNHthPF1BGSH5BAEAAAEALAAAAAAXABcAAAOIGLrc%2FjBCAoAhpBQj1dgLwIhRFgyCUgTCGoAOxwzLwRjyQnAC0Rgk36thgxQZO8YqtzAcA5gA6SV0PJW1k4NgczJzlkNVcSgzNS5pbwahBXI4qLYzVHADR%2FfDN8Uv9HpWSjZCgToqVjKAWBoOAwcyF2%2BIb31EaXhVB5ZWB5hvByl0eGWln6OjCQA7',
"gear":'data:image/gif;base64,R0lGODlhMAAwAPcAADQCBGSCZJzWnDQqZGSCnMzW/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KO2J8w%2FPgYMOHADZw3elhgsANnrKZQcewYgM%2BHjgc3sMbSICHWjaNfbxAgsIOAWDVDXzwYcDVCgwFmxxJgO6Au3LFodbxgpWNEAwsYMDDQQViGDAAydCQmXFWHgBcAYpyQwKByB8SoZKACENkwDyEyDOiIIWNBjUU1UC1SRIUHa0BCFtBYsKDOoEF16Awy5AmAAASSECD4jcAAAMJE9wpY%2FmKUkxsGaPhAQMNADQMIUgtYvEqHcRl7X8iAwQOLjxaiYxggXSN1%2B%2FY8EKA%2BHb9AbBKmhujfz19IEAA7',
"functionR":'data:image/gif;base64,R0lGODlhDwAPAIABAAAAAP%2F%2F%2FyH5BAEAAAEALAAAAAAPAA8AAAIcjI%2BpixAOn2R0SmdwXbHbnXgeqGhRRpbXqqVuAQA7',
"functionF":'data:image/gif;base64,R0lGODlhDwAPAIABAAAAAP%2F%2F%2FyH5BAEAAAEALAAAAAAPAA8AAAIdjI%2Bpy20AAwQynlkpvhFvB4ZiRn5lZz2olo6uWwAAOw%3D%3D',
"functionT":'data:image/gif;base64,R0lGODlhDQANAIABAAAAAP%2F%2F%2FyH5BAEAAAEALAAAAAANAA0AAAIYjI9pEMz5oFozNmRPphrPK4Xbx4WeQ34FADs%3D',
"mode_repeat":'data:image/gif;base64,R0lGODlhDQANALMCABiI%2BqvI%2BQAAAIit902Q9ypz8gNN8Ory%2FgZ6%2B2yX79Xh%2Bkqn%2FEh26X%2B5%2BypX1v%2F%2F%2FyH5BAEAAAIALAAAAAANAA0AAARFUMhJa3XBisSKM85QMQZYGgRFGMUQBOg7FUgmpUGRSLQ9BYiCJFHIpCRAITJAqAUGAESDskAgotdFpQEALL5TDUBDrkQAADs%3D',
"mode_1time":'data:image/gif;base64,R0lGODlhDQANALMPAEtJSkJBQmVkZZWVlXNxciwrKz49PlFQUYqJiX5%2BfYCAgE9PT4CAf6GgoDAvLwAAACH5BAEAAA8ALAAAAAANAA0AAAQv8MlJq33n1hAm%2Fx8AdA9hnoQALIsmAYIrEbJUANPB6jrg%2FLaCcFj4FWTCmqFWiQAAOw%3D%3D',
"arrowright":'data:image/gif;base64,R0lGODlhGQARALMPAGAzHPvNoK5tTcWQZva%2FknZMMLN%2FWMBzTc%2BrfuuvfoJYP8eCXJtlRP%2Foudmabf%2F%2F%2FyH5BAEAAA8ALAAAAAAZABEAAATZ8L2iCrj26g2Kl5NBNA0RnGVCrAGRBORQPNWwJo6T7HmfDwhYw6NQGAYDw2K5ODifAsZhORoUjUjDQTB9Tj0UgWCEqBgRjoVBqWU6MIw4olH2GNBRgYERZQwCHRcMBQN0RH8KDFeLDAYVGQUCdFc2HJYARRmSCIcBOQsDDqGgCWUKGgJznEUMKjw8Cy8NGGJAhol%2BaUsDTU46F0drDpNFerxNvFxTDn4GXAYJDVasSrwHony%2BaVJTL4ODBXwLYs5ceXlSA6UUNESKi5lgRJkKIFfyFh4YGvMSEQA7',
"arrowleft":'data:image/gif;base64,R0lGODlhGQARALMPAGAzHPvNoK5tTcWQZva%2FknZMMLN%2FWMBzTc%2BrfuuvfoJYP8eCXJtlRP%2Foudmabf%2F%2F%2FyH5BAEAAA8ALAAAAAAZABEAAATa8L2iCrj26g2Kl5NBNA0RnGVCrAGRBORQPNWwJo6T7HmfDwhYw6NQiAYLAUNwaDoPi2h00BgUjQkmw1NYOKMHpgHYQFSMCMY24wAfDAsD3IEoVwrwwvoSGCgNS0oCdGVEfhlEgBRXRQwKMGZFCAIYRRyXACMIhpMakglIDgMDbTmQiwwIfgIZDQEJCwM8Oy6FCmoOcgMGFggOX79RonaNsAICcgxtYVADULEGVVcMY0gHosdNogsMTQsvW2tLSchLYYHd3bKbCjREjoxFXFy3RCBn8xYeGBuLEhEAOw%3D%3D',
"windmill":'data:image/gif;base64,R0lGODlhEAAUALMPAN%2Ff3%2FX19fz8%2FPb29u%2Fv7%2Fn5%2BfLy8u3t7fr6%2BvPz8%2Bjo6NfX19nZ2fHx8f%2F%2F%2F%2F%2F%2F%2FyH5BAEAAA8ALAAAAAAQABQAAAR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8Cw9Ac/6cUhSi7v5xQeCqWZYIynPV4VhH0TPINLvzWRoAAaUtiGjrZTMa5fsIS7q3RtSzTIiWUls10fi66rjlDGbpBQCqkHUqICQUWNWx9+8zTL7xMqDhC+ew5nDt7mvLycl6vrqJkxn0A9uRhQqGp+P0BRkeG+eNyH7qmUYQPYWgYXolyDUMBbuYHFgKnuAcenr+YS9FfAV4B2oAxRyAn5AMKcxFw1/8/CjCBNJD9F+Hva8TmTxPaAAAAAElFTkSuQmCC"
}
const BUILDING2FEED=[,,[1,2],[3,4],[5,6],[7,8],,[9,21],[10,110],[11,151],[12],[92,93],[108,109],,,[153,154]]; // task_new_product
const FEEDBONUSTIME={"1":600,"2":1200,"3":900,"4":1800,"5":2400,"6":4800,"7":4800,"8":9600,"92":14400,"93":28800,"108":3600,"109":1800,"153":1560,"154":3120};//in sek // task_new_product
const CROPCOST={"13":2.5,"14":180,"15":30,"16":500};
var linecount=0;
var handled=new Object();
handled.set=function(zoneNrS){
try{
handled.zoneNrS=zoneNrS.toString();
handled.slot=(handled.zoneNrS.match(/\.(\d+)$/)?parseInt(/\.(\d+)$/.exec(handled.zoneNrS)[1],10):null);
handled.zoneNrF=handled.zoneNrS.replace(/\.\d+$/,"");
handled.farmNr=Math.floor((handled.zoneNrF-1)/6)+1;
handled.zoneNr=getGarden(handled.zoneNrF);
handled.zoneNrL=getZoneListId(handled.zoneNrF);
handled.zoneBuildingTyp=getBuildingTyp(handled.zoneNrF);
}catch(err){GM_logError("handled.set zoneNrS="+zoneNrS+"\n"+err);}
}
const queueItemBoxWidth=58;
const queueItemBoxTimeHeight=28;
const STEPPINGRACK=100;
const STEPPINGFIELD=1;
var zoneList=new Object(); // zoneList[zoneNrL][queueNum]=DEFAULT_ZONELIST_ITEM
var zoneToList=new Object();
var emergencyPlants=new Array();
var zoneWaiting=new Object();
var zoneSettings=new Object();
var autoMillStorage=new Object();
var modeOverViewFarms=null;
/* quest-bot needs review
var valQuestActivate=null;
var valQuestActivateUntilNr=null;
var valQuestSolving= null;
var valQuestSolvingUntilNr=null;
var valLodgeQuestSolving=null;
*/
var automatStarted=unsafeData.automatStarted=false;
var zoneTimeline=new Object();
const CLOSETIME=180;
const RAISETIME=2000; //milliseconds
const OpenWindow={"all":["multiframe","divQueueBox","divChooseBox","infoPanel","friendscontainer","guildmaincontainer","createguildbox","reallocateBuildingContainer"],"farm":["farmhousecontainer"],"city1":["cart","shop","shopframe","animaldealer","wbwcontainer","adcolumn"],"city2":["lotterycontainer","fishpoolinner","formuladealer","windmillinner","collectorscontainer"]};
const MenuCommand=["_currRack","autoMillStorage","buildinginfos","city","cityzones","currentslot","farm","farmamount","farmisinfo","farmisaway","forestry_action","forestry_area","forestry_area_name","forestry_area_pid","forestry_area_run","forestry_area_time","forestry_area_watertime","forestry_cache_area","forestry_farmis","forestry_production_products","forestry_production_run","forestry_production_time","forestry_questdelay_run","forestry_questdelay_time","forestry_quests","forestry_quicknavi","forestry_remain","forestry_run","forestry_slotremain","forestry_slotrun","forestry_slots","forestry_stock","forestry_unlock","forestry_user_buildings","forestry_waterall_cost","formulas","fremains","ftimer","garten_kategorie","garten_prod","garten_zeit","GMberaterDone","GMberaterVersion","GMbotConfigData","GMcalcToLodgeCampaignNr","GMcalcToLodgeQuestNr","GMcalcToQuestNr","GMcurrentPowerup","GMguid","GMgut","GMlodgeCampaignNr","GMlodgeQuestData","GMlodgeQuestNr","GMlodgeTimeEnd","GMlotteryCollectForPrize","GMnpcSaison","GMpreisBeob","GMprodBlock","GMprodGrowTime","GMprodMinRack","GMprodMinRackInit","GMprodMinRackSettings","prodName","prodNameSort","GMprodPlantSize","GMprodRequire","prodStock","prodTyp","prodYield","GMquestNr","GMquestState","readyZone","reallocateBuildingSet","GMsetCalcToLodgeQuest","GMsetCalcToQuest","GMstatBotgutBeob","GMstatBotpreisBeob","GMstatBotVersion","GMusername","GMvalFarmiLimits","GMzoneAddToGlobalTime","guildquestlist_level","locationinfo","lotrack","lotteryprizes","now","poweruprack","produkt_category","produkt_ernte","produkt_level","produkt_name","produkt_x","produkt_y","punkte","QUESTS","rackElement","racksortinfo","unsolvedquests","userfarminfos","userquests","windmillinfo","zoneList","zoneSettings","zoneToList","zoneWaiting"];
var botArbiter=new function(){
var stack=new Object();
var interval=null;
var intervalBusy=false;
this.add=function(evt){
try{
if(LOGGING_ARBITER){ GM_log("botArbiter.add evt="+evt+" bot.isActive()="+bot.isActive()); }
var priority,fkt=null;
switch(evt){
case "sessionEnds": priority=999;fkt=doGameSessionEnds; break;
case "farm": priority= 30;fkt=autoFarm; break;
case "farmersmarket": priority= 25;fkt=autoFarmersmarket; break;
case "windmill": priority= 20;fkt=autoWindmill; break;
case "forestry": priority= 10;fkt=autoForestry; break;
case "foodworld": priority= 10;fkt=autoFoodworld; break;
case "donkey": priority= 5;fkt=autoDonkey; break;
case "lottery": priority= 5;fkt=autoLottery; break;
case "activatePowerUp":priority= 5;fkt=autoActivatePowerUp;break;
case "farmi": priority= 5;fkt=autoFarmi; break;
// case "quest": priority= 5;fkt=autoActivateQuest; break;
// case "lodgeQuest": priority= 5;fkt=autoActivateLodgeQuest;break;
case "otherAccReady": priority= 1;fkt=doGameOtherAccReady;break;
}
if(!bot.isActive()){
GM_logWarning("botArbiter.add evt="+evt+": Bot is off!");
}else if(fkt==null){
GM_logWarning("botArbiter.add evt="+evt+": No bot-function!");
}else{
if(intervalBusy){
window.setTimeout(botArbiter.add,100,evt);
}else{
stack[evt]=[priority,fkt];
window.setTimeout(botArbiter.start,100);
}
}
}catch(err){GM_logError("botArbiter.add evt="+evt+"\n"+err);}
}
this.clear=function(evt){
try{
if(LOGGING_ARBITER){ GM_log("BEGIN botArbiter.clear evt="+evt+" intervalBusy="+intervalBusy); }
if(stack[evt]){
if(intervalBusy){
window.setTimeout(botArbiter.clear,100,evt);
// window.setTimeout(function(){
// botArbiter.clear(evt);
// },100);
}else{
delete stack[evt];
}
}
if(LOGGING_ARBITER){ GM_log("END botArbiter.clear stack="+implode(stack)); }
}catch(err){GM_logError("botArbiter.clear evt="+evt+"\n"+err);}
}
this.run=function(){
try{
// GM_log("stack="+implode(stack));
intervalBusy=true;
// logBubble.add(""+"stack="+implode(stack));
//if(LOGGING_ARBITER){ GM_log("interval, busy:"+busy+" zoneWaiting:"+implode(zoneWaiting)+" stack:"+implode(stack)); }
//if(LOGGING_ARBITER){ GM_log("interval, busy:"+busy+" zoneWaiting:"+implode(zoneWaiting)+" stack:"+print_r(stack)); }
try{
if(LOGGING_ARBITER){ GM_log("interval stack="+implode(stack)+" readyZone="+implode(unsafeData.readyZone)); }
if(bot.isActive()&&(!bot.isBusy())&&checkOpenWindow()){
var found=null;
var count=0;
for(evt in stack){
if(!stack.hasOwnProperty(evt)){ continue; }
count++;
if((found==null)||(stack[found][0]<stack[evt][0])){
found=evt;
}
}
if(LOGGING_ARBITER){ GM_log("interval found="+found); }
if(found){
stack[found][1](bot.start()); // call bot function
delete stack[found];
count--;
}
if(count==0){
try{ window.clearInterval(interval); }catch(err){}
interval=null;
}
}
}catch(err){GM_logError("botArbiter.run\n"+err);}
intervalBusy=false;
}catch(err){GM_logError("botArbiter.run\n"+err);}
}
this.start=function(){
try{
// GM_log("botArbiter.start "+interval+":"+bot.isActive());
if(bot.isActive()&&(!interval)){
interval=window.setInterval(botArbiter.run,RAISETIME);
}
}catch(err){GM_logError("botArbiter.start\n"+err);}
}
this.stop=function(){ //TODO the bot is not deactivated until the timer is runS out .. after that the buttoN should change.. inbetween it should have a inbetween state.
try{
if(LOGGING_ARBITER){ GM_log("BEGIN botArbiter.stop bot.isActive():"+bot.isActive()); }
if(intervalBusy){
window.setTimeout(botArbiter.stop,100);
// window.setTimeout(function(){
// botArbiter.stop();
// },100);
}else{
stack=new Object();
try{ window.clearInterval(interval); }catch(err){}
interval=null;
}
}catch(err){GM_logError("botArbiter.stop\n"+err);}
}
this.check=function(){
try{
if(LOGGING_ARBITER){GM_log("BEGIN botArbiter.check");}
// Testing for actions to do
botArbiter.stop();
if(bot.isActive()){
if($("divSessionEnd")){
botArbiter.add("sessionEnds");
}
checkReadyZone(); // farm, windmill, forestry
if(settings.get("account","botUseFarmi")&&unsafeWindow.farmisinfo && unsafeWindow.farmisinfo[0] && (settings.get("account","farmiReject") || settings.get("account","farmiAccept"))){
checkFarmi(1);
}
if(settings.get("account","botUseDonkey") && $("divGoToDonkey")) {
botArbiter.add("donkey");
}
if(settings.get("account","botUseLottery")&&settings.get("account","lotteryActivate")&&$("divGoToLottery")){
botArbiter.add("lottery");
}
var cell;
if(settings.get("account","botUseWindmill")){
if(checkPowerUp(1)){
botArbiter.add("activatePowerUp");
}
}
cell=null;
/* quest-bot needs review
if(settings.get("account","botUseQuest")&&unsafeData.questData["farm"]["1"]["state"]){
if(unsafeData.questData["farm"]["1"]["state"]==1 && valQuestActivate && valQuestActivateUntilNr>=unsafeData.questData["farm"]["1"]["nr"]){
botArbiter.add("quest");
}else if(unsafeData.questData["farm"]["1"]["state"]==2 && valQuestSolving && valQuestSolvingUntilNr>=unsafeData.questData["farm"]["1"]["nr"] && checkQuest()){
botArbiter.add("quest");
}
}
if(settings.get("account","botUseQuest")&&valLodgeQuestSolving&&checkLodgeQuest()){
botArbiter.add("lodgeQuest");
}
*/
if($("linkOtherAccReady")){
botArbiter.add("otherAccReady");
}
}
if(LOGGING_ARBITER){GM_log("End botArbiter.check");}
}catch(err){GM_logError("botArbiter.check\n"+err);}
}
}
var bot=new function(){
try{
var action,active,busy,interval,durationRun,durationStep,runId=0,divInfo;
this.isActive=function(){
try{
return !!active;
}catch(err){GM_logError("bot.isActive\n"+err);}
}
this.isBusy=function(){
try{
return !!busy;
}catch(err){GM_logError("bot.isBusy\n"+err);}
}
this.init=function(){
try{
divInfo=$("divBotInfo");
active=settings.get("server","botActive");;
if(active==undefined){active=false;}
if(active){
bot.activate();
}else{
bot.deactivate();
}
}catch(err){GM_logError("bot.init\n"+err);}
}
this.activate=function(){
try{
active=true;
settings.set("server","botActive",active);
busy=false;
var cell;
if(cell=$("divAutomatButtonBot")){
cell.style.backgroundColor="#f55";
cell.setAttribute("mouseOverText",getText("automat_botStop"));
cell.firstElementChild.classList.add("rotating");
}
if(cell=$("divBotInfo")){
cell.style.display="block";
cell.innerHTML="Busy:--";
}
cell=null;
botArbiter.check();
}catch(err){GM_logError("bot.activate\n"+err);}
}
this.deactivate=function(){
try{
active=false;
settings.set("server","botActive",active);
bot.end();
var cell
if(cell=$("divAutomatButtonBot")){
cell.style.backgroundColor="";
cell.setAttribute("mouseOverText",getText("automat_botStart"));
cell.firstElementChild.classList.remove("rotating");
}
if(cell=$("divBotInfo")){
cell.style.display="none";
}
cell=null;
botArbiter.stop();//TODO the bot is not deactivated until the timer is runS out .. after that the buttoN should change.. inbetween it should have a inbetween state.
stopCloseWindowTimer();
}catch(err){GM_logError("bot.deactivate\n"+err);}
}
this.start=function(){
try{
if(DEVMODE){ logBubble.add("bot.start"); }
try {window.clearInterval(interval);} catch (err){}
durationRun=settings.get("country","maxDurationBotRun");
durationStep=settings.get("country","maxDurationBotStep");
busy=true;
interval=window.setInterval(bot.run,1000);
runId++;
return runId;
}catch(err){GM_logError("bot.start\n"+err);}
}
this.end=function(){
try{
if(DEVMODE){ logBubble.add("bot.end"); }
top.unsafeData.autoAction=null;
runId++;
busy=false;
}catch(err){GM_logError("bot.end\n"+err);}
}
this.run=function(){
try{
if(DEVMODE){ logBubble.add("bot.run"); }
durationRun--;
durationStep--;
if(divInfo.style.display!="block"){ divInfo.style.display="block"; }
if(divInfo.innerHTML!="Busy: "+action){ divInfo.innerHTML="Busy: "+action; }
if(!busy){
try {window.clearInterval(interval);} catch (err){}
divInfo.innerHTML="Busy: --";
botArbiter.check();
}else if((durationRun>0)&&(durationStep>0)){
divInfo.innerHTML +="<br>Reset:"+getTimeStr(durationRun);
divInfo.innerHTML +="<br>Reset:"+getTimeStr(durationStep);
}else{
switch(settings.get("country","botErrorBehaviour")){
case "reload":
top.location.href=top.location.href;
break;
default:
try {window.clearInterval(interval);} catch (err){}
busy=false;
divInfo.innerHTML="Busy: --";
botArbiter.check();
}
}
}catch(err){GM_logError("bot.run\n"+err);}
}
this.setAction=function(str,showInLogBubble){
try{
durationStep=settings.get("country","maxDurationBotStep");
action=str;
top.unsafeData.autoAction="automat: "+action;
if(showInLogBubble){
logBubble.add(action);
}
}catch(err){GM_logError("bot.setAction\n"+err);}
}
this.checkRun=function(type,run,noBot){
try{
if((!noBot)&&(!active)){
GM_log("BOT INACTIVE: "+type);
return false;
}else if(!busy){
GM_log("BOT BUSY NOT SET: "+type);
return false;
}else if(run!=runId){
GM_log("BOT WRONG RUN ID: "+type+" ("+run+"!="+runId+")");
return false;
}else{
return true;
}
}catch(err){GM_logError("bot.checkRun "+type+"\n"+err);}
}
}catch(err){GM_logError("bot\n"+err);}
}
var settings=new function(){
var data={"global":{},"country":{},"server":{},"account":{}};
var dataDefault={"global":{},
"country":{"pauseShort":[300,700],"pause":[2000,4000],"maxDurationBotRun":300,"maxDurationBotStep":30,"botErrorBehaviour":"reload"},
"server":{"botActive":false},
"account":{"autoPlant":true,"autoWater":true,"autoFeed":true,"botUseFarmersmarket":false,"botUseFarmi":false,"botUseLottery":false,"botUseFoodworld":false,"botUseForestry":false,"botUseWindmill":false,"disableCropFields":false,"farmiAccept":false,"farmiAcceptAboveNr":100,"farmiAcceptBelowMinValue":false,"farmiReject":false,"farmiRejectUntilNr":90,"farmiRemoveMissing":false,"farmiRemoveMissingAboveNr":10,"lotteryActivate":false,"lotteryDailyLot":false,"powerUpActivate":false,"seedWaitForCrop":30,"showQueueTime":true,"useQueueList":false}
};
var require= {"global":{},
"country":{},
"server":{},
"account":{"farmiAccept":[["account","botUseFarmi"]],"farmiAcceptAboveNr":[["account","botUseFarmi"]],"farmiAcceptBelowMinValue":[["account","botUseFarmi"],["account","farmiAccept"]],"farmiReject":[["account","botUseFarmi"]],"farmiRejectUntilNr":[["account","botUseFarmi"]],"farmiRemoveMissing":[["account","botUseFarmi"]],"farmiRemoveMissingAboveNr":[["account","botUseFarmi"]],"lotteryActivate":[["account","botUseLottery"]],"lotteryDailyLot":[["account","botUseLottery"],["account","lotteryActivate"]],"powerUpActivate":[["account","botUseWindmill"]]}
};
this.init=function(){
try{
settings.load("global");
settings.load("country");
settings.load("server");
settings.load("account");
}catch(err){GM_logError("settings.init\n"+err);}
}
this.load=function(scope){
try{
var key;
switch(scope){
case "global": key="settings"; break;
case "country": if(COUNTRY){ key=COUNTRY+"_settings"; } break;
case "server": if(COUNTRY&&SERVER){ key=COUNTRY+"_"+SERVER+"_settings"; } break;
case "account": if(COUNTRY&&SERVER&&USERNAME){ key=COUNTRY+"_"+SERVER+"_"+USERNAME+"_settings"; } break;
}
if(key){
data[scope]=explode(GM_getValue(key,"{}"),"settings");
}
}catch(err){GM_logError("settings.load scope="+scope+"\n"+err);}
}
this.save=function(scope){
try{
var key;
switch(scope){
case "global": key="settings"; break;
case "country": if(COUNTRY){ key=COUNTRY+"_settings"; } break;
case "server": if(COUNTRY&&SERVER){ key=COUNTRY+"_"+SERVER+"_settings"; } break;
case "account": if(COUNTRY&&SERVER&&USERNAME){ key=COUNTRY+"_"+SERVER+"_"+USERNAME+"_settings"; } break;
}
if(key){
GM_setValue(key,implode(data[scope],"settings"));
}
}catch(err){GM_logError("settings.save scope="+scope+"\n"+err);}
}
this.get=function(scope,key){
try{
if((scope in data)&&(key in data[scope])){
return data[scope][key];
}else if((scope in dataDefault)&&(key in dataDefault[scope])){
return dataDefault[scope][key];
}else{
GM_logWarning("settings.get returns null\nscope="+scope+" key="+key);
return null;
}
}catch(err){GM_logError("settings.get scope="+scope+" key="+key+"\n"+err);}
}
this.set=function(scope,key,value){
try{
data[scope][key]=value;
settings.save(scope);
}catch(err){GM_logError("settings.set scope="+scope+" key="+key+"\n"+err);}
}
this.reset=function(scope,key){
try{
delete data[scope][key];
settings.save(scope);
return settings.get(scope,key);
}catch(err){GM_logError("settings.reset scope="+scope+" key="+key+"\n"+err);}
}
this.checkRequire=function(scope,key){
try{
if(require[scope][key]){
for(var j=require[scope][key].length-1;j>=0;j--){
if(!settings.get(require[scope][key][j][0],require[scope][key][j][1])){ return false; }
}
}
return true;
}catch(err){GM_logError("settings.checkRequire scope="+scope+" key="+key+"\n"+err);}
}
// Special functions
this.getPause=function(isShort){
try{
var val=settings.get("country",isShort?"pauseShort":"pause");
return getRandom(val[0],val[1]);
}catch(err){GM_logError("settings.set scope="+scope+" key="+key+"\n"+err);}
}
}
var closeWindowTimer=null;
var closeWindowTime=CLOSETIME;
var openWindows=null;
function startCloseWindowTimer(){
try{
var divCWL=$("divCloseWindowLayer");
if(divCWL.style.display!="block"){ divCWL.style.display="block"; }
var divCW=$("divCloseWindow");
if(divCW.style.display!="block"){ divCW.style.display="block"; }
var cell;
if(!bot.isBusy()){
// GM_log("startCloseWindowTimer ");
if(--closeWindowTime>0 && !checkOpenWindow(true)){
//-- GM_log("startCloseWindowTimer closeWindowTime:"+closeWindowTime);
divCW.innerHTML=getText("automat_CloseWindowTimer").replace("%1%", getTimeStr(closeWindowTime)) + "<br>" + getText("automat_CloseWindowTimerClick") + (DEVMODE?"<br>OpenWindows: "+openWindows:"");
if(!closeWindowTimer) closeWindowTimer=window.setInterval(startCloseWindowTimer,1000);
}else{
//-- GM_log("closingEventTimer closeWindowTime:"+closeWindowTime);
if((cell=$("multiframe"))&&(cell.style.display=="block")){
click($("multiframe").contentDocument.getElementsByClassName("link2")[0].firstElementChild);
}else if((cell=$("divQueueBox"))&&(cell.style.display=="block")){
click($("divQueueBoxClose"));
}else if((cell=$("divChooseBox"))&&(cell.style.display=="block")){
click($("divChooseBoxClose"));
}else if((cell=$("infoPanel"))&&(cell.style.display=="block")){
click($("infoPanelClose"));
}else if((cell=$("friendscontainer"))&&(cell.style.display=="block")){
click($("friendsclose").getElementsByClassName("link")[0]);
}else if((cell=$("guildmaincontainer"))&&(cell.style.display=="block")){
click($("cancelscreen2").getElementsByClassName("link")[0]);
}else if((cell=$("reallocateBuildingContainer"))&&(cell.style.display=="block")){
click($("reallocateBuildingContainerHeader").getElementsByClassName("link")[0]);
}else if((cell=$("farmhousecontainer"))&&(cell.style.display=="block")){
click($("fhclose").getElementsByClassName("link")[0]);
}else if((cell=$("cart"))&&(cell.style.display=="block")){
unsafeWindow.clearCart();
}else if((cell=$("shop"))&&(cell.style.display=="block")){
$('transp3').style.display='none';
$('shopframe').src='';
$('shop').style.display='none';
//click($("shopframe").contentDocument.getElementsByClassName("link2")[0].firstElementChild);
}else if((cell=$("shopframe"))&&(cell.style.display=="block")){
$('transp3').style.display='none';
$('shopframe').src='';
$('shop').style.display='none';
//click($("shopframe").contentDocument.getElementsByClassName("link2")[0].firstElementChild);
}else if((cell=$("animaldealer"))&&(cell.style.display=="block")){
click($("animaldealerheader").getElementsByClassName("link")[0]);
}else if((cell=$("wbwcontainer"))&&(cell.style.display=="block")){//competitie
click($("wbwhead").getElementsByClassName("link")[0]);
}else if((cell=$("adcolumn"))&&(cell.style.display=="block")){
click($("adcolumnheader").getElementsByClassName("link")[0]);
}else if((cell=$("lotterycontainer"))&&(cell.style.display=="block")){
click($("lotteryhead").getElementsByClassName("link")[0]);
}else if((cell=$("fishpoolinner"))&&(cell.style.display=="block")){
click($("fishpoolheader").getElementsByClassName("link")[0]);
}else if((cell=$("formuladealer"))&&(cell.style.display=="block")){
click($("formuladealerheader").getElementsByClassName("link")[0]);
}else if((cell=$("windmillinner"))&&(cell.style.display=="block")){
click($("windmillheader").getElementsByClassName("link")[0]);
}else if((cell=$("collectorscontainer"))&&(cell.style.display=="block")){
click($("collectorshead").getElementsByClassName("link")[0]);
}
botArbiter.start();
stopCloseWindowTimer();
}
}else{
stopCloseWindowTimer();
}
cell=null;
}catch(err){GM_logError("startCloseWindowTimer\n"+err);}
}
function stopCloseWindowTimer(){
try{
if(DEVMODE_FUNCTION){GM_log("Begin stopCloseWindowTimer "+ closeWindowTimer);}
try{ window.clearInterval(closeWindowTimer); }catch(err){}
closeWindowTimer=null;
closeWindowTime=CLOSETIME;
if($("divCloseWindowLayer")){ $("divCloseWindowLayer").style.display="none";}
if($("divCloseWindow")){ $("divCloseWindow").style.display="none";}
if(DEVMODE_FUNCTION){GM_log("End stopCloseWindowTimer "+ closeWindowTimer);}
}catch(err){GM_logError("stopCloseWindowTimer \n"+err);}
}
function checkOpenWindow(justcheck){
try{
var allWinClosed=true;
openWindows="";
if(DEVMODE_FUNCTION){GM_log("Begin checkOpenWindow automatStarted:"+automatStarted+" busy:"+bot.isBusy()+" closeWindowTimer:"+closeWindowTimer); }
if(automatStarted&&!bot.isBusy()){
for(var ctn in OpenWindow){
if(!OpenWindow.hasOwnProperty(ctn)){ ctn=null;continue; }
if(ctn=="all"||(ctn=="farm"&&unsafeWindow.farm!="")||(ctn=="city1"&&unsafeWindow.city==1)||(ctn=="city2"&&unsafeWindow.city==2)){
for(var wn in OpenWindow[ctn]){
// if(!OpenWindow[ctn].hasOwnProperty(wn)){ ctn=null;continue; }
if(typeof OpenWindow[ctn][wn]=="function"){ wn=null;continue; }
if($(OpenWindow[ctn][wn]) && $(OpenWindow[ctn][wn]).style.display=="block"){
openWindows +=(openWindows!=""?", ":"") + OpenWindow[ctn][wn];
//if(DEVMODE){ GM_log("Container:"+ctn+" Window:"+OpenWindow[ctn][wn]+" is open"+(justcheck?" (checking)":" (timer)")); }
allWinClosed=false;
}
}
}
}
if(justcheck===true){ return allWinClosed; }
if(allWinClosed){
if(closeWindowTimer&&!justcheck){
//-- GM_log("checkOpenWindow 1");
stopCloseWindowTimer();
}
return true;
}else if(!closeWindowTimer&&!justcheck){ //garden can be open for eve
//-- GM_log("checkOpenWindow 2");
startCloseWindowTimer();
}
}else if(bot.isBusy()&&closeWindowTimer&&!justcheck){
//-- GM_log("checkOpenWindow 3");
stopCloseWindowTimer();
}
return false;
}catch(err){GM_logError("checkOpenWindow ctn:"+ctn+" wn:"+wn+" \n"+err);}
}
function getFarmZoneBonus(zoneNr,product){
if(DEVMODE_FUNCTION){GM_log("Begin getFarmZoneBonus zoneNr:"+zoneNr+" product:"+product);}
try{
var bonus=1;
var zoneNrF=zoneNr.toString().replace(/\.\d+$/,"");
var currBonus=unsafeData.zones.getBonus(zoneNrF);
var currBonusSpecial=unsafeData.zones.getBonusSpecial(zoneNrF);
if(currBonusSpecial&&(currBonusSpecial[0]==product)){
bonus-=currBonusSpecial[1]/100;
}
if(currBonus){
bonus-=currBonus/100;
}
}catch(err){
GM_logError("getFarmZoneBonus \n"+err);
if(Math.ceil(zoneNrF/6)==parseInt(unsafeWindow.farm,10)){
if(unsafeWindow.userfarminfos[Math.ceil(zoneNrF/6)][getGarden(zoneNrF)]["specialwaterbonus"][0]==product){
bonus=1 - parseInt(unsafeWindow.userfarminfos[Math.ceil(zoneNrF/6)][getGarden(zoneNrF)]["specialwaterbonus"][1],10)/100;
}else if(unsafeWindow.userfarminfos[Math.ceil(zoneNrF/6)][getGarden(zoneNrF)]["waterbonus"]){
bonus=1 - parseInt(unsafeWindow.userfarminfos[Math.ceil(zoneNrF/6)][getGarden(zoneNrF)]["waterbonus"],10)/100;
}else if(unsafeWindow.userfarminfos[Math.ceil(zoneNrF/6)][getGarden(zoneNrF)]["time"]){
bonus=1 - parseInt(unsafeWindow.userfarminfos[Math.ceil(zoneNrF/6)][getGarden(zoneNrF)]["time"],10)/100;
}
}
}
if(DEVMODE_FUNCTION){GM_log("Begin getFarmZoneBonus zoneNrF:"+zoneNrF+" product:"+product+" bonus:"+bonus);}
return bonus;
}
function getLowestTimeFarmZone(timeTable){
if(DEVMODE_FUNCTION){GM_log("Begin getLowestTimeFarmZone:" + implode(timeTable,"getLowestTimeFarmZone/timeTable"));}
for(var i in timeTable){
if(!timeTable.hasOwnProperty(i)){ continue; }
if(zoneNrF==undefined) var zoneNrF=i;
if(timeTable[i] < timeTable[zoneNrF]){
zoneNrF=i;
}
}
if(DEVMODE_FUNCTION){GM_log("End getLowestTimeFarmZone:" + zoneNrF);}
return zoneNrF;
}
function getHighestTimeFarmZone(timeTable){
if(DEVMODE_FUNCTION){GM_log("Begin getHighestTimeFarmZone:" + zoneNrF);}
for(var i in timeTable){
if(!timeTable.hasOwnProperty(i)){ continue; }
if(zoneNrF==undefined) var zoneNrF=i;
if(timeTable[i] > timeTable[zoneNrF]){
zoneNrF=i;
}
}
if(DEVMODE_FUNCTION){GM_log("End getHighestTimeFarmZone:" + zoneNrF);}
return zoneNrF;
}
String.prototype.count=function(match){
var res=this.match(new RegExp(match,"g"));
if(res==null){ return 0; }
return res.length;
};
String.prototype.repeat=function(num){
return new Array(num+1).join(this);
};
String.prototype.leftPad=function(len, str){
return (new Array(len - this.length + 1)).join(str).concat(this);
};
String.prototype.replaceArray=function(arr){
if(typeof arr!="object") throw("Argument not a Object or Array :" + typeof arr +"<br>");
// if(!(arr instanceof Array)) throw("Argument not a Array :" + typeof arr +"<br>");
var val=this;
for(var key in arr){
if(!arr.hasOwnProperty(key)){ continue; }
// GM_log("replace :" + key + " with : " + arr[key] + " : " + val);
val=val.replace(new RegExp("%"+key+"%","gi"),arr[key]);
}
return val;
};
String.prototype.toTitleCase=function(){
return this.toLowerCase().replace(/^./, this.match(/^./)[0].toUpperCase());
};
Object.prototype.allEqual=function(){
var equal=true, num=null;
for(var key in this){
if(!this.hasOwnProperty(key)){ continue; }
// GM_log("prototype.average key: " + key + " num: " + this[key] + " tot: " + total + " len: " + len);
if( typeof this[key]=="number"){
if(num!=this[key] && num!=null){
equal=false;
break;
}
num=this[key];
}
}
return equal;
};
Object.prototype.average=function(){
var total=0, len=0;
for(var key in this){
if(!this.hasOwnProperty(key)){ continue; }
// GM_log("prototype.average key: " + key + " num: " + this[key] + " tot: " + total + " len: " + len);
if( typeof this[key]=="number"){
total +=this[key];
len++;
}
}
return total/len;
};
Object.prototype.averageFieldTime=function(amount){
var total=0, len=0;
for(var key in this){
if(!this.hasOwnProperty(key)){ continue; }
if( typeof this[key]=="number"){
// GM_log("prototype.averageFieldTime key: " + key + " num: " + this[key] + " tot: " + total + " len: " + len);
total +=this[key];
len++;
}
}
// GM_log("End prototype.averageFieldTime tot: " + total + " amount: " + amount + " len: " + len);
return (total*amount)/(len*len);
};
function calcDauer(dauer,bonus){ //dauer in sek, bonus zB 0.85
var gesamtdauer=0;
while(dauer>0){
dauer *=bonus;
help=Math.min(dauer,86400);
dauer -=help;
gesamtdauer +=help;
}
return gesamtdauer;
}
function calcProductScore(product, zoneNrF, amount, endtime){
if(DEVMODE_FUNCTION){GM_log("Begin calcScoreAmount: product:"+product+" zoneNrF:"+zoneNrF+" amount:"+amount);}
switch(getBuildingTyp(zoneNrF)){
case "windmill":
return unsafeData.prodPoints[3][product];
break;
case "sawmill":case "carpentry":
if(amount==null || amount==undefined){ amount=1; }
return unsafeData.prodPoints[1][product]*amount;
break;
case "forest":
if(amount==null || amount==undefined){ amount=calcProductPositions(product, zoneNrF); }
return unsafeData.prodPoints[1][product]*amount;
break;
case 1:
if(amount==null || amount==undefined) amount=calcProductPositions(product, zoneNrF);
if(unsafeData.currentPowerup && unsafeData.currentPowerup[product] && unsafeData.currentPowerup[product][0] > (endtime==null?now:endtime)){
return (unsafeData.prodPoints[0][product]+unsafeData.currentPowerup[product][2])*amount;
}else{
return unsafeData.prodPoints[0][product]*amount;
}
break;
case 2:
if(amount==null || amount==undefined){ amount=unsafeData.zones.getAnimals(zoneNrF); }
return unsafeData.prodPoints[0][product]*unsafeData.prodYield[0][product]*amount;
break;
case 3:case 4:
if(amount==null || amount==undefined){ amount=1; }
return unsafeData.prodPoints[0][product]*unsafeData.prodYield[0][product]*amount;
break;
default:
GM_logWarning("calcProductScore returns 0\nproduct="+product+" zoneNrF="+zoneNrF+" amount="+amount+" endtime="+endtime+"\ngetBuildingTyp="+getBuildingTyp(zoneNrF));
return 0;
}
}
function calcProductAmount(product, zoneNrF, amount, endtime, minPlanted){
if(DEVMODE_FUNCTION){GM_log("Begin calcProductAmount: product:"+product+" zoneNrF:"+zoneNrF+" amount:"+amount+" endtime:"+endtime+" minPlanted:"+minPlanted);}
switch(getBuildingTyp(zoneNrF)){
case "windmill":
return 1;
break;
case "sawmill":case "carpentry":
if(amount==null || amount==undefined){ amount=1; }
return unsafeData.prodYield[1][product]*amount;
break;
case "forest":
if(amount==null || amount==undefined){ amount=calcProductPositions(product, zoneNrF); }
return unsafeData.prodYield[1][product]*amount; //no minPlanted because planted is other product.
break;
case 1:case 4:
if(amount==null || amount==undefined){ amount=calcProductPositions(product, zoneNrF); }
if(unsafeData.currentPowerup && unsafeData.currentPowerup[product] && unsafeData.currentPowerup[product][0] > ((endtime==null||endtime==undefined)?now:endtime)){
return (unsafeData.prodYield[0][product]-(minPlanted?1:0)+unsafeData.currentPowerup[product][1])*amount;
}else{
return (unsafeData.prodYield[0][product]-(minPlanted?1:0))*amount;
}
break;
case 2:
return unsafeData.zones.getAnimals(zoneNrF) * unsafeData.prodYield[0][product];
break;
case 3:
return unsafeData.prodYield[0][product];
break;
default:
GM_logWarning("calcProductAmount returns 0\nproduct="+product+" zoneNrF="+zoneNrF+" amount="+amount+" endtime="+endtime+"\ngetBuildingTyp="+getBuildingTyp(zoneNrF));
return 0;
}
}
function calcEmptyProductPositions(product, zoneNrF){
var returnn=0;
if(getBuildingTyp(zoneNrF)==1){
var size=unsafeData.prodPlantSize[0][product];
var tempZoneProductionData=unsafeData.zones.getProduction(zoneNrF);
if(tempZoneProductionData){
if(tempZoneProductionData[1] && !isNaN(tempZoneProductionData[1][size])){
returnn=tempZoneProductionData[1][size];
}else{
returnn=120/size;
}
if(DEVMODE&&!tempZoneProductionData[3]){
GM_log("calcEmptyProductPositions OLD DATA: zoneNrF:"+zoneNrF+" product:"+product+" return:"+returnn);
}
}
}else if(isNaN(zoneNrF)){
var size=unsafeData.prodPlantSize[1][product];
var tempZoneProductionData=unsafeData.zones.getProduction(zoneNrF);
if(tempZoneProductionData){
if(tempZoneProductionData[1] && !isNaN(tempZoneProductionData[1][size])){
returnn=tempZoneProductionData[1][size];
}
if(DEVMODE&&!tempZoneProductionData[3]){
GM_log("calcEmptyProductPositions OLD DATA: zoneNrF:"+zoneNrF+" product:"+product+" return:"+returnn);
}
}
}
if(DEVMODE_FUNCTION){ GM_log("calcEmptyProductPositions: zoneNrF:"+zoneNrF+" product:"+product+" return:"+returnn);}
return returnn;
}
function calcProductPositions(product, zoneNrF){
try{
var returnn=1;
if(getBuildingTyp(zoneNrF)==1){
var size=unsafeData.prodPlantSize[0][product];
var tempZoneProductionData=unsafeData.zones.getProduction(zoneNrF);
if(tempZoneProductionData){
if(tempZoneProductionData[2] && !isNaN(tempZoneProductionData[2][size])){
returnn=tempZoneProductionData[2][size];
}else{
returnn=120/size;
}
if(DEVMODE&&!tempZoneProductionData[3]){
GM_log("calcProductPositions OLD DATA: zoneNrF:"+zoneNrF+" product:"+product+" return:"+returnn);
}
}
}else if(isNaN(zoneNrF)){
var tempZoneProductionData=unsafeData.zones.getProduction(zoneNrF);
if(tempZoneProductionData){
// var size=unsafeData.prodPlantSize[1][product];
if(tempZoneProductionData[2] && !isNaN(tempZoneProductionData[2])){
returnn=tempZoneProductionData[2];
}
if(DEVMODE&&!tempZoneProductionData[3]){
GM_log("calcProductPositions OLD DATA: zoneNrF:"+zoneNrF+" product:"+product+" return:"+returnn);
}
}
}
// GM_log("calcProductPositions: zoneNrF:"+zoneNrF+" product:"+product+" return:"+returnn);
return returnn;
}catch(err){ GM_logError("calcProductPositions product="+product+" zoneNrF="+zoneNrF+"\n"+err); }
}
function calcInGameProductAmountOnField(product, zoneNrF, endtime){
try{
var iBase=0;
var tempZoneProductionData=unsafeData.zones.getProduction(zoneNrF);
if(tempZoneProductionData){
if(tempZoneProductionData[0][0][product]){
for(var i in tempZoneProductionData[0][0][product]){
if(!tempZoneProductionData[0][0][product].hasOwnProperty(i)){ continue; }
if(endtime==undefined || endtime==null || tempZoneProductionData[0][0][product][i][1]<=endtime){
iBase +=calcProductAmount(product,zoneNrF,tempZoneProductionData[0][0][product][i][0],tempZoneProductionData[0][0][product][i][1],false);
}
}
}
if(DEVMODE&&!tempZoneProductionData[3]){
GM_log("calcInGameProductAmountOnField OLD DATA: zoneNrF:"+zoneNrF+" product:"+product+" endtime:"+endtime+" return:"+iBase);
}
}
return iBase;
}catch(err){ GM_logError("calcInGameProductAmountOnField product="+product+" zoneNrF="+zoneNrF+" endtime="+endtime+"\n"+err);return 0; }
}
function calcInGameProductAmount(product, zoneNrF, endtime, includeThisField){
try{
if(DEVMODE_FUNCTION){GM_log("Begin calcInGameProductAmount product:"+product); }
var type=getZoneStockType(zoneNrF);
var iBase=unsafeData.prodStock[type][product]?unsafeData.prodStock[type][product]:0;
var fzType=getBuildingTyp(zoneNrF);
if(includeThisField||(fzType=="sawmill")||(fzType=="carpentry")||(fzType=="forest")){
iBase +=calcInGameProductAmountOnField(product, zoneNrF, endtime);
}
for(var i=0;i<unsafeData.ALL_ZONES["farm"].length;i++){
var fz=unsafeData.ALL_ZONES["farm"][i];
if(includeThisField||(fz!=zoneNrF)){
iBase +=calcInGameProductAmountOnField(product, fz, endtime);
}
}
if(DEVMODE_FUNCTION){GM_log("End calcInGameProductAmount product:"+product+" endTotal:"+iBase,5,"red");}
return iBase;
}catch(err){ GM_logError("calcInGameProductAmount product="+product+" zoneNrF="+zoneNrF+" endtime="+endtime+" includeThisField="+includeThisField+"\n"+err);return 0; }
}
function calcProductionTime(product, zoneNrF){
try{
var bonus=getFarmZoneBonus(zoneNrF, product);
var time=(product==PRODSTOP?0:unsafeData.prodGrowTime[0][product]*60);
switch(getBuildingTyp(zoneNrF)){
case 1:
case 4:
time=calcDauer(time,bonus);
break;
case 2:
time *=bonus;
var zoneNrL=getZoneListId(zoneNrF);
if(zoneList[zoneNrL][0][0]!=PRODSTOP){
time -=zoneList[zoneNrL][0][1]*FEEDBONUSTIME[zoneList[zoneNrL][0][0]]/unsafeData.zones.getAnimals(zoneNrF);
if(zoneList[zoneNrL][1][1]>0){
time -=zoneList[zoneNrL][1][1]*FEEDBONUSTIME[zoneList[zoneNrL][1][0]]/unsafeData.zones.getAnimals(zoneNrF);
}
}
break;
case 3:
time*=bonus;
break;
case "windmill":
time=(product==PRODSTOP?0:parseInt(unsafeWindow.formulas[0][product][4],10));
//time*=bonus;
break;
case "forest":
time=(product==PRODSTOP?0:unsafeData.prodGrowTime[1][product]*60);
time=calcDauer(time,bonus);
break;
case "sawmill":
case "carpentry":
time=(product==PRODSTOP?0:unsafeData.prodGrowTime[1][product]*60);
time*=bonus;
break;
}
return time;
}catch(err){GM_logError("calcProductionTime product:"+product+" zoneNrF:"+zoneNrF+" \n"+err);return 0;}
}
function isVisibleZone(zoneNr){
if(extendedListReg.test(zoneNr)){
return false;
}else if(isNaN(zoneNr)){
zoneNr=zoneNr.toString().replace(/\.\d+$/,"");
switch(zoneNr){
case "windmill":
return((unsafeData.gameLocation[0]=="city")&&(unsafeData.gameLocation[1]==2));
break;
case "sawmill": case "carpentry": case "forest":
return(unsafeData.gameLocation[0]=="forestry");
break;
case "foodworld-1": case "foodworld-2":case "foodworld-3":case "foodworld-4":
return(unsafeData.gameLocation[0]=="foodworld");
break;
case "farmersmarket-0": case "farmersmarket-1": case "farmersmarket-2":case "farmersmarket-3":case "farmersmarket-4":case "farmersmarket-5":case "farmersmarket-6":
return(unsafeData.gameLocation[0]=="farmersmarket");
break;
default:
return false;
}
} else {
zoneNr=(parseInt(zoneNr,10));
return((unsafeData.gameLocation[0]=="farm")&&(unsafeData.gameLocation[1]==Math.floor((zoneNr-1)/6)));
}
}
function getZoneTimes(zoneNrL){
if(DEVMODE_FUNCTION){GM_log("Begin getZoneTimes " + zoneNrL);}
try{
var help;
if(!settings.get("account","showQueueTime")){
if(DEVMODE_FUNCTION){GM_log("End getZoneTimes DISABLED:" + zoneNrL);}
return new Object();
}
noTime=false;
var zoneTimes=new Object();
for(var fz in unsafeData.ALL_SLOTS){
if(!unsafeData.ALL_SLOTS.hasOwnProperty(fz)){ continue; }
help=unsafeData.zones.getEndtime(fz);
zoneTimes[fz]=((help==NEVER)?now:help);
}
if(zoneNrL==undefined){
if(DEVMODE_FUNCTION){GM_log("End getZoneTimes " + zoneNrL);}
return zoneTimes.clone();
}else{
var returnn=new Object();
var zones=getZonesFromList(zoneNrL);
for(var i=0;i<zones.length;i++){
returnn[zones[i]]=zoneTimes[zones[i]];
}
zoneTimes=null;
if(DEVMODE_FUNCTION){GM_log("End getZoneTimes " + zoneNrL);}
return returnn.clone();
}
}catch(err){GM_logError("getZoneTimes \n"+err);return new Object();}
}
function getFarmZonesTyp(zType){
var zoneT=new Array();
for(var fz=1;fz<=6*parseInt(unsafeWindow.farmamount,10);fz++){
if(getBuildingTyp(fz)==zType || zType==undefined){
zoneT.push(fz);
}
}
return zoneT;
}
function getZoneActiveList(){
if(DEVMODE_FUNCTION){ GM_log("Begin getZoneActiveList zoneNr:"+zoneNrL);}
var zones=new Object();
var returnn=new Array();
for(var zoneNrF in zoneList){
if(!zoneList.hasOwnProperty(zoneNrF)){continue;}
zones[zoneList[zoneNrF]]=1;
}
for(var zoneNrL in zones){
if(!zones.hasOwnProperty(zoneNrL)){continue;}
returnn.push(zoneNrL);
}
zones=null;
if(DEVMODE_FUNCTION){ GM_log("End getZoneActiveList zoneNr:"+zoneNrL+" return:"+implode(returnn,"getZoneActiveList/returnn"));}
return returnn;
}
function getZonesFromList(zoneNrL){
if(DEVMODE_FUNCTION){ GM_log("Begin getZonesFromList zoneNr:"+zoneNrL);}
var returnn=new Array(); // [[zoneNrF,slot],...]
// if(isNaN(zoneNrL)){
// returnn.push(zoneNrL);
// }else{
for(var i in zoneToList){
if(!zoneToList.hasOwnProperty(i)){continue;}
if(zoneToList[i]==zoneNrL){
//help=i.split(".");
//returnn.push([(isNaN(help[0])?help[0]:parseInt(help[0],10)),(help[1]?parseInt(help[1],10):null)]);
returnn.push(i);
}
}
if(DEVMODE_FUNCTION){ GM_log("End getZonesFromList zoneNr:"+zoneNrL+" return:"+implode(returnn,"getZonesFromList/returnn"));}
return returnn;
}
function createZoneList(zoneNrS){
switch(getZoneType(zoneNrS)){
case "windmill": zoneList[zoneNrS]=DEFAULT_ZONELIST_MILL_ARRAY.clone(); break;
case 2: zoneList[zoneNrS]=DEFAULT_ZONELIST_ITEM_ARRAY2.clone(); break;
default: zoneList[zoneNrS]=DEFAULT_ZONELIST_ITEM_ARRAY.clone();
}
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList,"createZoneList"),"createZoneList");
}
function getZoneListId(zoneNrF,slot){
try{
var zoneToListId = zoneNrF;
if(unsafeData.zones.isMultiSlot(zoneNrF)&&(!zoneNrF.match(/\.\d+$/))){
zoneToListId += "."+(slot?+slot:1);
}
// if(isNaN(zoneNrF)){
// var zoneToListId = zoneNrF+(unsafeData.zones.isMultiSlot(zoneNrF)?(slot?"."+slot:".1"):"");
// }else{
// var zoneToListId = zoneNrF.toString()+(unsafeData.zones.isMultiSlot(zoneNrF)?(slot?"."+slot:".1"):"");
// }
if(!zoneToList[zoneToListId]){ setZoneListId(zoneToListId,zoneToListId); }
if(!zoneList[zoneToList[zoneToListId]]){ createZoneList(zoneToList[zoneToListId]); }
return zoneToList[zoneToListId];
}catch(err){GM_logError("getZoneListId\n"+err);}
}
function setZoneListId(zoneNrF,zoneNrL){
if(!unsafeData.ALL_SLOTS[zoneNrF]){ return false; }
if((!extendedListReg.test(zoneNrL))&&(!unsafeData.ALL_SLOTS[zoneNrL])){ return false; }
zoneToList[zoneNrF]=zoneNrL;
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneToList",implode(zoneToList,"setZoneListId/zoneToList"));
logBubble.add("Change Queue: Zone "+getZoneName(0,zoneNrF,zoneNrF,null,false,true,false,true)+" paired to Queue "+getZoneName(0,zoneNrL,zoneNrL,null,false,true,false,true),5);
}
function deleteZoneInList(zoneNrL){
delete zoneList[zoneNrL];
delete zoneSettings[zoneNrL];
for(var fz in zoneToList){
if(!zoneToList.hasOwnProperty(fz)){ continue; }
if(zoneToList[fz]==zoneNrL){ setZoneListId(fz,fz); }
}
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneSettings",implode(zoneSettings,"deleteZoneInList/zoneSettings"));
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList,"deleteZoneInList/zoneList"));
logBubble.add("Remove General Queue:"+extendedListReg.exec(zoneNrL)[1],5);
}
function addZoneToList(){
var newZone=1;
for(var lz in zoneList){
if(!zoneList.hasOwnProperty(lz)){ continue; }
if(extendedListReg.test(lz)){
if(extendedListReg.exec(lz)[1]!=newZone) break;
newZone++;
}
}
zoneList[ExtendedListCHAR+newZone]=DEFAULT_ZONELIST_ITEM_ARRAY.clone();
// GM_log("zoneList "+ implode(zoneList,"addZoneToList/zoneList"));
zoneList.sortObj();
// GM_log("zoneList "+ implode(zoneList,"addZoneToList/zoneList"));
zoneSettings[ExtendedListCHAR+newZone]={"repeat":false,"shuffle":false};
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneToList",implode(zoneToList,"addZoneToList/zoneToList"));
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneSettings",implode(zoneSettings,"addZoneToList/zoneSettings"));
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList,"addZoneToList/zoneList"));
logBubble.add("Adding General Queue:"+newZone,5);
return ExtendedListCHAR+newZone;
}
function getFarmZone(gardenNr, farm){
if(farm==null || farm==undefined){ farm=unsafeWindow.farm; }
if(isNaN(gardenNr)){ return gardenNr; }
else { return parseInt(gardenNr,10) + 6*(parseInt(farm,10)-1); }
}
function getGarden(zoneNr){
var zoneNrF=zoneNr.toString().replace(/\.\d+$/g,"");
if(isNaN(zoneNrF)){
switch(zoneNrF){
case "windmill":
return "windmill";
break;
case "forest":case "sawmill":case "carpentry":
return "forestry";
break;
case "foodworld-1": case "foodworld-2":case "foodworld-3":case "foodworld-4":
return "foodworld";
break;
case "farmersmarket-0":case "farmersmarket-1":case "farmersmarket-2":case "farmersmarket-3":case "farmersmarket-4":case "farmersmarket-5":case "farmersmarket-6":
return "farmersmarket";
break;
default:
GM_logWarning("getGarden returns null\nzoneNr="+zoneNr);
return null;
}
}else{
return (((parseInt(zoneNrF,10)-1)%6)+1);
}
}
function getZoneStockType(zoneNrFL){//zoneNrFL=zoneNrF or zoneNrL
var fzType=getBuildingTyp(zoneNrFL);
if(extendedListReg.test(zoneNrFL)){//extended list is always a field of type 1
return 0;
}else if(fzType=="windmill"){
return 3;
}else if (fzType=="sawmill"||fzType=="carpentry"||fzType=="forest"){
return 1;
}else{
return 0;
}
}
function getZoneType(zoneNr){
try{
if(extendedListReg.test(zoneNr)){ //extended is always a field of type 1
return 1;
}else{
return unsafeData.zones.getBuilding(zoneNr);
}
}catch(err){GM_logError("getZoneType\n"+err);}
}
function getBuildingTyp(zoneNr){
try{
var zoneType=getZoneType(zoneNr);
if(unsafeData.BUILDINGTYPE[zoneType]==undefined){
return zoneType;
}else{
return unsafeData.BUILDINGTYPE[zoneType];
}
}catch(err){ GM_logError("getBuildingTyp zoneNr="+zoneNr+"\n"+err); }
}
function getZoneNameCorrected(zoneNrFL){
if(extendedListReg.test(zoneNrFL)){//extended is always a field
return zoneNrFL;
}else if(isNaN(zoneNrFL)){//all zones not fields
return zoneNrFL.match(/[^A-z]*([A-z]*)[^A-z]*/)[1];
}else{
return zoneNrFL;
}
}
function getOpenZoneNrF(){
var zoneNr=null;
if($("gardenmaincontainer").style.display=="block"){
zoneNr=parseInt($("gardenmaincontainer").getAttribute("zoneNr"),10);
}else if($("innermaincontainer").style.display=="block"){
zoneNr=parseInt($("innermaincontainer").getAttribute("zoneNr"),10);
}
return zoneNr;
}
function getZoneName(recursionCount,zoneNrS,zoneNrL,queueNum,showPaired,showLocation,showBonus,showName){
try{
if(recursionCount>100){throw("TOO MUCH RECURSION")}
if(DEVMODE_FUNCTION){ GM_log("Begin getZoneName zoneNrF="+zoneNrF+" zoneNrL="+zoneNrL);}
// GM_log("Begin getZoneName zoneNrS="+zoneNrS+" zoneNrL="+zoneNrL+" args="+implode([queueNum,showPaired,showLocation,showBonus,showName]));
if(showName==undefined){ showName=true; }
zoneNrS=zoneNrS.toString();
var zoneNrF=zoneNrS.replace(/\.\d+$/,"");
var zones=getZonesFromList(zoneNrL);
var txt="";
if((extendedList=extendedListReg.exec(zoneNrL))!=null){
txt=getText("automat_titleGeneral").replace(" "," ")+" "+extendedList[1];
if(zones.length==1){
// TODO rekursion ohne abbruch?
// txt +=" ("+ getZoneName(++recursionCount,zones[0],zoneNrL,null,false,false,showBonus,showName) + ")";
}
}else if(showPaired && (zones.length > 1 || zoneNrS!=zoneNrL)){
// if(showName) txt +=unsafeWindow.buildinginfos[0][unsafeData.zones.getBuilding(zoneNrF)][10].replace(" "," ")+" ";
if(showName){
txt +=(isNaN(zoneNrF)?getText(getZoneType(zoneNrF)):unsafeWindow.buildinginfos[0][getZoneType(zoneNrF)][10].replace(" "," "))+" ";
}
if(showLocation){
txt+='<span style="font-weight:bold;color:#505050;">';
for(var i=0;i<zones.length;i++){
zones[i]=[zones[i].toString().replace(/\..*$/,""),zones[i]];
if(i>0) txt +="|";
if(zones[i][0]==zoneNrF) txt+="</span>";
if(zones[i][0]==zoneNrL) txt+="<u>";
txt +=getZoneName(++recursionCount,zones[i][1],zoneNrL,null,false,true,false,(zones.length==1));
if(zones[i][0]==zoneNrL) txt+="</u>";
if(zones[i][0]==zoneNrF) txt+='<span style="font-weight:bold;color:#505050;">';
}
txt+="</span>";
if(settings.get("account","useQueueList") && queueNum!=null && queueNum>=0) txt+=" {" + queueNum + "}";
zones=null;lz=null;
}
}else{
switch(getBuildingTyp(zoneNrF)){
case 1:
if(settings.get("account","useQueueList") && showLocation && queueNum!=null && queueNum>=0){ // && showPaired
txt=" {" + queueNum + "}";
}
if(showBonus){
var currBonus=unsafeData.zones.getBonus(zoneNrF);
var currBonusSpecial=unsafeData.zones.getBonusSpecial(zoneNrF);
txt='<div style="position:relative;display:inline-block;">';
if(currBonus>0){
txt+='<span>'+currBonus+'%</span>';
}
if(currBonusSpecial){
txt+='<span>,</span><span><div class="kp'+currBonusSpecial[0]+'" style="display:inline-block;"></div>'+(currBonus+currBonusSpecial[1])+'%</span>';
}
txt+='</div>';
}
break;
case 2:
if(showBonus){
if(unsafeData.zones.getBonus(zoneNrF)>0){
txt+=unsafeData.zones.getBonus(zoneNrF)+"%";
}
if(txt!="") txt+=",";
txt+="#"+unsafeData.zones.getAnimals(zoneNrF);
}
break;
case 3:
if(showBonus && unsafeData.zones.getBonus(zoneNrF)>0){
txt=unsafeData.zones.getBonus(zoneNrF)+"%";
}
break;
default:
if(showBonus && unsafeData.zones.getBonus(zoneNrF)>0){
txt=unsafeData.zones.getBonus(zoneNrF)+"%";
}
}
if(showLocation){
txt=(zoneNrS.toString().match(/\./)?"["+zoneNrS.replace(/^.*\./,"")+"]":"")+(txt!=""?" ("+txt+")":"");
if(!isNaN(zoneNrF)){
txt=Math.ceil(zoneNrF/6)+"."+getGarden(zoneNrF)+txt;
}
}
if(showName){
txt=(isNaN(zoneNrF)?getText(getZoneType(zoneNrF)):unsafeWindow.buildinginfos[0][getZoneType(zoneNrF)][10].replace(" "," "))+" "+txt;
}
}
if(DEVMODE_FUNCTION){ GM_log("End getZoneName zoneNrL:"+zoneNrL);}
return txt;
}catch(err){GM_logError("getZoneName zoneNrF:"+zoneNrF+" zoneNrS:"+zoneNrS+" zoneNrL:"+zoneNrL+" \n"+err);return "Error. See console.";}
}
function drawAutomatIcon(name,zoneNrS,appendTo,style){
try {
if(DEVMODE_FUNCTION){ GM_log("Begin drawAutomatIcon name=" + name);}
// logBubble.add("drawAutomatIcon name="+name+" zoneNrS="+zoneNrS);
if(!$("divAutomatIcon_"+name)){
switch(getBuildingTyp(zoneNrS)){
case "windmill":
newdiv=createElement("div",{"id":"divAutomatIcon_"+name,"class":"link divWindmillIcon","product":PRODSTOP,"zoneNrS":zoneNrS,"style":style},appendTo);
createElement("div",{"class":"fmm"+PRODSTOP,"style":"position:relative;"},newdiv);
break;
case "forest":case "sawmill":case "carpentry":
newdiv=createElement("div",{"id":"divAutomatIcon_"+name,"class":"link divForestryIcon","product":PRODSTOP,"zoneNrS":zoneNrS,"style":style},appendTo);
createElement("div",{"class":"f_symbol"+PRODSTOP,"style":"position:relative;"},newdiv);
// newdiv=createElement("div",{"id":"divAutomatIcon_"+name,"class":"link divForestryIcon f_symbol"+PRODSTOP,"product":PRODSTOP,"zoneNrS":zoneNrS,"style":style},appendTo);
break;
case 4:
newdiv=createElement("div",{"id":"divAutomatIcon_"+name,"class":"link divFoodworldIcon","product":PRODSTOP,"zoneNrS":zoneNrS,"style":style},appendTo);
// createElement("div",{"class":"v"+PRODSTOP,"style":"position:relative;"},newdiv);
break;
default:
newdiv=createElement("div",{"id":"divAutomatIcon_"+name,"class":"link divZoneIcon v"+PRODSTOP,"product":PRODSTOP,"zoneNrS":zoneNrS,"style":style},appendTo);
}
newdiv.addEventListener("click", function(event){
event.stopPropagation();
var zoneNrF=getFarmZone(this.id.replace("divAutomatIcon_","").replace("global_",""));
var zoneNrS=this.getAttribute("zoneNrS");
var zoneNrL=getZoneListId(zoneNrS);
switch(getBuildingTyp(zoneNrS)){
case 1:
if(settings.get("account","useQueueList")){
redrawQueueBox(zoneNrS, zoneNrL, $("divQueueBoxInner"));
}else{
drawQueueChooseItemBox(zoneNrS, zoneNrL, 0, $("divChooseBoxInner"));
}
break;
case 2:
drawStableChooseFeedBox(zoneNrS, zoneNrL,$("divChooseBoxInner"));
break;
case 3:
if(settings.get("account","useQueueList")){
redrawQueueBox(zoneNrS, zoneNrL, $("divQueueBoxInner"));
}else{
drawFactoryChooseItemBox(zoneNrS, zoneNrL,$("divChooseBoxInner"));
}
break;
case "windmill":
case "forest":case "sawmill":case "carpentry":
redrawQueueBox(zoneNrS, zoneNrL, $("divQueueBoxInner"));
break;
case 4:
redrawQueueBox(zoneNrS, zoneNrL, $("divQueueBoxInner"));
break;
}
zoneNrF=null;zoneNrS=null;zoneNrL=null;
},false);
newdiv.addEventListener("mouseover", function(evt){
toolTip.show(evt, toolTipProductSmall(this.getAttribute("zoneNrS"),this.getAttribute("zoneNrL"),0,this));
},false);
newdiv=null;
updateQueueBox(zoneNrS);
}
if(DEVMODE_FUNCTION){ GM_log("End drawAutomatIcon:" + zoneNrS);}
}catch(err){GM_logError("drawAutomatIcon "+zoneNrS+"\n"+err);}
}
function drawQueueBox(zoneNrS, zoneNrL, appendTo){
try{
if(DEVMODE_FUNCTION){ GM_log("Begin drawQueueBox zoneNrS="+zoneNrS +" zoneNrL="+zoneNrL +" appendTo.id="+appendTo.id); }
if(zoneNrS==undefined){ return; }
if(zoneNrL==undefined || zoneNrL==null){ zoneNrL=getZoneListId(zoneNrS); }
var fzType=getBuildingTyp(zoneNrS);
appendTo.innerHTML="";
appendTo.style.display="none";
appendTo.setAttribute("zoneNrS",zoneNrS);
appendTo.setAttribute("zoneNrL",zoneNrL);
createElement("div",{id:"divAutoMatTitle_"+zoneNrL,"class":"queueTitle"},appendTo, getZoneName(0,zoneNrS, zoneNrL, null, true, true, true));
createElement("div",{id:"divAutoMatEndTime"+zoneNrL,"class":"queueTime"},appendTo);
createElement("div",{style:"clear:both;"},appendTo);
createElement("div",{id:"divAutoMatButton"+zoneNrL, "class":"queueBoxerButton"},appendTo);
// Repeat button
if(OPTION_LIST_REPEAT && zoneSettings[zoneNrL]["repeat"]!=undefined){
newelm=createElement("div",{id:"divAutoMatButtonRepeat"+zoneNrL,"class":"link queueButtonRepeat"},$("divAutoMatButton"+zoneNrL));
newelm.addEventListener("mouseover", function(evt){
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
toolTip.show(evt, zoneSettings[zoneNrL]["repeat"]?getText("automat_repeat_on"):getText("automat_repeat_off"));
},false);
newelm.style.backgroundImage=(zoneSettings[zoneNrL]["repeat"])?"url("+IMAGES["repeat_on"]+")":"url("+IMAGES["repeat_off"]+")";
newelm.addEventListener("click", function(){
var zoneNrS=this.parentNode.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
zoneSettings[zoneNrL]["repeat"]=!zoneSettings[zoneNrL]["repeat"];
this.style.backgroundImage=(zoneSettings[zoneNrL]["repeat"])?"url("+IMAGES["repeat_on"]+")":"url("+IMAGES["repeat_off"]+")";
if(!zoneSettings[zoneNrL]["repeat"]){ for(var i=0;i<zoneList[zoneNrL].length;i++) zoneList[zoneNrL][i][2]=0;} //reset when disabling
updateQueueBox(zoneNrS, zoneNrL);
toolTip.adjust(this);
},false);
}
// Shuffle button
newelm=createElement("div",{id:"divAutoMatButtonShuffle"+zoneNrL,"class":"link queueButtonShuffle"},$("divAutoMatButton"+zoneNrL));
newelm.addEventListener("mouseover", function(evt){
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
toolTip.show(evt, zoneSettings[zoneNrL]["shuffle"]?getText("automat_shuffle_on"):getText("automat_shuffle_off"));
},false);
newelm.style.backgroundImage=(zoneSettings[zoneNrL]["shuffle"])?"url("+IMAGES["shuffle_on"]+")":"url("+IMAGES["shuffle_off"]+")";
newelm.addEventListener("click",function(){
var zoneNrS=this.parentNode.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
zoneSettings[zoneNrL]["shuffle"]=!zoneSettings[zoneNrL]["shuffle"];
this.style.backgroundImage=(zoneSettings[zoneNrL]["shuffle"])?"url("+IMAGES["shuffle_on"]+")":"url("+IMAGES["shuffle_off"]+")";
updateQueueBox(zoneNrS, zoneNrL);
toolTip.adjust(this);
},false);
// Rotate button
newelm=createElement("div",{id:"divAutoMatButtonRotate"+zoneNrL,"class":"link queueButtonRotate"},$("divAutoMatButton"+zoneNrL));
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_rotate"));},false);
newelm.style.backgroundImage="url("+IMAGES["rotate"]+")";
newelm.addEventListener("click",function(){
var zoneNrS=this.parentNode.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
zoneList[zoneNrL].push(zoneList[zoneNrL].splice(0,1)[0]);
updateQueueBox(zoneNrS, zoneNrL);
},false);
// add button.
newelm=createElement("div",{id:"divAutoMatButtonAdd"+zoneNrL,"class":"link queueButtonAdd"},$("divAutoMatButton"+zoneNrL));
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_QueAddText"));},false);
newelm.addEventListener("click",function(){
var zoneNrS=this.parentNode.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
var lRepeat=(!OPTION_LIST_REPEAT || zoneNrS=="windmill")?false:!settings.get("account","useQueueList")?false:zoneSettings[zoneNrL]["repeat"]==undefined?false:zoneSettings[zoneNrL]["repeat"];
var lShuffle=!settings.get("account","useQueueList")?false:zoneSettings[zoneNrL]["shuffle"]==undefined?false:zoneSettings[zoneNrL]["shuffle"];
var product=(zoneNrS=="windmill"?(lShuffle?zoneList[zoneNrL][zoneList[zoneNrL].length-1][0]:PRODSTOP):(lRepeat||lShuffle?zoneList[zoneNrL][zoneList[zoneNrL].length-1][0]:PRODSTOP));
var queueNum=zoneList[zoneNrL].push(DEFAULT_ZONELIST_ITEM.clone())-1;
zoneList[zoneNrL][queueNum][0]=product;
reFillQueueBox(zoneNrS, zoneNrL, queueNum);
click($("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Item"));
product=null;
},false);
if(fzType=="windmill"){
// Clear mill-list then add all button
newelm=createElement("div",{id:"divAutoMatButtonAddAll"+zoneNrL,"class":"link queueButtonAddAll"},$("divAutoMatButton"+zoneNrL));
createElement("img",{id:"divAutoMatButtonAddAll",style:"width:21px;height:15px;top:1px;left:1px;",src:IMAGES["reload_all"]},newelm);
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_MillClearAddAll"));},false);
newelm.addEventListener("click",function(){
var zoneNrS=this.parentNode.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
zoneList[zoneNrL]=new Array();
for(var iProd in autoMillStorage){
if(!autoMillStorage.hasOwnProperty(iProd)){continue;}
if(autoMillStorage[iProd][0]){
zoneList[zoneNrL].push([iProd,autoMillStorage[iProd][0],0]);
}
}
if(zoneList[zoneNrL].length<=0) zoneList[zoneNrL]=DEFAULT_ZONELIST_MILL_ARRAY.clone();
reFillQueueBox(zoneNrS, zoneNrL, 0);
},false);
}
if(fzType=="sawmill"||fzType=="carpentry"||fzType=="forest"){
//TODO add button for sawmill/carpentry/forest
//TODO add button for needed in prodMinRack
}
if(!isNaN(zoneNrS)){
// copy button
newelm=createElement("div",{id:"divAutoMatButtonCopy"+zoneNrL,"class":"link queueButtonCopy"},$("divAutoMatButton"+zoneNrL));
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_QueCopyTextHeader"));},false);
newelm.addEventListener("click",function(){
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
var appendTo=this.parentNode.parentNode.id;
$("divQueueBoxInner").innerHTML="";
$("divQueueBoxInner").style.display="none";
$("divQueueBoxInner").setAttribute("zoneNrS","");
$("divQueueBoxInner").setAttribute("zoneNrL",zoneNrL);
$("divQueueBoxInner").setAttribute("reAppendTo",appendTo);
createElement("div",{"class":"headline divQueueItemListHeader"},$("divQueueBoxInner"),getText("automat_QueCopyTextHeaderFrom"));
createElement("div",{id:"farmZoneFrom","class":"divQueueItemListBox"},$("divQueueBoxInner"));
drawQueueListSmall(zoneNrL, zoneNrL, $("farmZoneFrom"));
createElement("div",{"class":"headline divQueueItemListHeader"},$("divQueueBoxInner"),getText("automat_QueCopyTextHeaderTo"));
var selectDiv=createElement("select",{id:"copyZone","class":"divQueueItemListSelect"},$("divQueueBoxInner"));
createElement("option",{value:"-"},selectDiv,"-");
for(var lz in zoneList){
if(!zoneList.hasOwnProperty(lz)){ continue; }
if(((!extendedListReg.test(lz) && getBuildingTyp(lz)==1)||(extendedListReg.test(lz)))&& lz!=zoneNrL){
createElement("option",{value:lz},selectDiv,getZoneName(0,lz,lz,null,false,true,false));
}
}
selectDiv.value="-";
selectDiv.addEventListener("change", function(evt){
if(this.value!="-"){
drawQueueListSmall(this.value, this.value, $("farmZoneTo"));
}else{
$("farmZoneTo").innerHTML="";
}
},false);
selectDiv=null;
createElement("div",{id:"farmZoneTo","class":"divQueueItemListBox"},$("divQueueBoxInner"));
createElement("div",{style:"clear:both;"},$("divQueueBoxInner"));
divfooter=createElement("div",{"class":"divQueueItemListFooter"},$("divQueueBoxInner"));
var newdiv=createElement("div",{style:"position:absolute;top:0px;left:100px;","class":"link"},divfooter);
createElement("img",{src:GFX + "button_ok.png"},newdiv);
newdiv.addEventListener("click", function(evt){
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
var toZone=$("copyZone").value;
// GM_log("Copy "+ zoneNrL+ " to " + toZone);
if(toZone!="-"){
zoneList[toZone]=zoneList[zoneNrL].clone();
zoneSettings[toZone]=zoneSettings[zoneNrL].clone();
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList", implode(zoneList,"drawQueueBox/zoneList"));
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneSettings",implode(zoneSettings,"drawQueueBox/zoneSettings"));
}
// reopen the correct queuelist. In general mode this can only be the general list.
var reAppendTo=this.parentNode.parentNode.getAttribute("reappendto");
toZone=(toZone=="-")?zoneNrL:toZone;
if(reAppendTo.indexOf("tdAutoMatOverview")==0){ //NOTE overview has the zoneNrL addend to it.
reAppendTo="tdAutoMatOverview"+toZone;
}
if($(reAppendTo)){
redrawQueueBox(toZone, toZone, $(reAppendTo));
}else{
click($("divQueueBoxClose"));
}
},false);
newdiv.addEventListener("mouseover", function(evt){
this.src=GFX + "button_ok_over.png";
toolTip.show(evt,unsafeWindow.commitbox_text_yes);
},false);
newdiv.addEventListener("mouseout", function(evt){
this.src=GFX + "button_ok.png";
},false);
var newdiv=createElement("div",{style:"position:relative;top:0px;left:200px;","class":"link"},divfooter);
createElement("img",{src:GFX + "button_no.png"},newdiv);
newdiv.addEventListener("click", function(evt){
var zoneNrS=this.parentNode.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
var reAppendTo=this.parentNode.parentNode.getAttribute("reappendto");
if(reAppendTo=="divQueueBoxInner"){
redrawQueueBox(zoneNrS, zoneNrL, $(reAppendTo));
}else if($("divQueueBox").style.display=="block"){
click($("divQueueBoxClose"));
}
},false);
newdiv.addEventListener("mouseover", function(evt){
this.src=GFX + "button_no_over.png";
toolTip.show(evt,unsafeWindow.commitbox_text_no);
},false);
newdiv.addEventListener("mouseout", function(evt){
this.src=GFX + "button_no.png";
},false);
newdiv=null;
//TODO this goes wrong needs appento==
$("divQueueBoxInner").style.display="block";
$("divQueueBox").style.display="block";
$("divQueueBox").style.top=Math.round(255 - $("divQueueBox").offsetHeight/2)+"px";
},false);
}
createElement("div",{id:"divAutoMatQueueBox"+zoneNrL,"class":"queueBoxerQueueBox"},appendTo);
for(queueNum=0;queueNum<zoneList[zoneNrL].length; queueNum++){
drawQueueItemBox(zoneNrS, zoneNrL, queueNum, $("divAutoMatQueueBox"+zoneNrL));
}
var newscrL=createElement("div",{id:"divAutoMatScrollLeft"+zoneNrL, "class":"link queueButtonScrollLeft"},settings.get("account","showQueueTime")?$("divAutoMatButton"+zoneNrL):appendTo);
var newscrR=createElement("div",{id:"divAutoMatScrollRight"+zoneNrL, "class":"link queueButtonScrollRight"},settings.get("account","showQueueTime")?$("divAutoMatButton"+zoneNrL):appendTo);
newscrL.addEventListener("click", function(){
var zoneNrL=this.id.replace("divAutoMatScrollLeft","");
// GM_log("click divAutoMatScrollLeft :" + zoneNrL);
var scrlelm=$("divAutoMatQueueBox"+zoneNrL);
if(scrlelm.scrollLeft > 0){
scrlelm.scrollLeft=Math.max(0,scrlelm.scrollLeft-queueItemBoxWidth);
}
this.style.visibility=(scrlelm.scrollLeft>0?"visible":"hidden");
$("divAutoMatScrollRight"+zoneNrL).style.visibility=((scrlelm.scrollLeft + scrlelm.clientWidth)<scrlelm.scrollWidth?"visible":"hidden");
scrlelm=null;
},false);
newscrR.addEventListener("click", function(){
var zoneNrL=this.id.replace("divAutoMatScrollRight","");
// GM_log("click divAutoMatScrollRight :" + zoneNrL);
var scrlelm=$("divAutoMatQueueBox"+zoneNrL);
if((scrlelm.scrollLeft + scrlelm.clientWidth)<scrlelm.scrollWidth){
scrlelm.scrollLeft=Math.min((scrlelm.scrollWidth-scrlelm.clientWidth),((scrlelm.scrollLeft+queueItemBoxWidth)-((scrlelm.scrollLeft+queueItemBoxWidth)%queueItemBoxWidth)));
}
$("divAutoMatScrollLeft"+zoneNrL).style.visibility=(scrlelm.scrollLeft>0?"visible":"hidden");
this.style.visibility=((scrlelm.scrollLeft + scrlelm.clientWidth)<scrlelm.scrollWidth?"visible":"hidden");
scrlelm=null;
},false);
createElement("div",{style:"clear:both;"},appendTo);
updateQueueBox(zoneNrS, zoneNrL);
appendTo.style.display="block";
if(appendTo==$("divQueueBoxInner")){
$("divQueueBox").style.display="block";
$("divQueueBox").style.top=Math.round(255 - $("divQueueBox").offsetHeight/2)+"px";
}
var scrlelm=$("divAutoMatQueueBox"+zoneNrL);
scrlelm.scrollLeft=0;
$("divAutoMatScrollLeft"+zoneNrL).style.display=((scrlelm.scrollWidth > scrlelm.clientWidth)?"block":"none");
$("divAutoMatScrollRight"+zoneNrL).style.display=((scrlelm.scrollWidth > scrlelm.clientWidth)?"block":"none");
$("divAutoMatScrollLeft"+zoneNrL).style.visibility=(scrlelm.scrollLeft>0?"visible":"hidden");
$("divAutoMatScrollRight"+zoneNrL).style.visibility=((scrlelm.scrollLeft + scrlelm.clientWidth)<scrlelm.scrollWidth?"visible":"hidden");
if(DEVMODE_FUNCTION){ GM_log("End drawQueueBox :" + zoneNrL); }
newlayer=null;newelm=null;newscrL=null;newscrR=null;scrlelm=null;appendTo=null;
}catch(err){GM_logError("drawQueueBox \n"+err);}
}
function drawQueueItemBox(zoneNrS, zoneNrL, queueNum, appendTo){
try{
if(DEVMODE_FUNCTION){ GM_log("Begin drawQueueItemBox zoneNrS:" + zoneNrS + " zoneNrL:" + zoneNrL + " queueNum:"+ queueNum); }
if(zoneNrL==undefined || zoneNrL==null){ zoneNrL=getZoneListId(zoneNrS); }
var fzType=getBuildingTyp(zoneNrS);
// begin adding new box
newlayer=createElement("span",{id:"divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum,"class":"queueItemBox","style":"cursor:default;"},appendTo);
newlayer.setAttribute("zoneNrS",zoneNrS);
newlayer.setAttribute("zoneNrL",zoneNrL);
newlayer.setAttribute("queueNum",queueNum);
/*
newelm=createElement("div",{id:newlayer.id+"test1",alt:"del","class":"link","style":"position:absolute;width:100%;height:10px;top:0px;left:0px;background:blue;opacity:0;z-index:250;cursor:default;"},newlayer);
newelm.addEventListener("mouseover", function(evt){
this.style.opacity = 0.5;
},false);
newelm.addEventListener("mouseout", function(evt){
this.style.opacity = 0;
},false);
newelm=createElement("div",{id:newlayer.id+"test2",alt:"del","class":"link","style":"position:absolute;width:20px;height:100%;top:0px;left:-10px;background:blue;opacity:0;z-index:250;cursor:default;"},newlayer);
newelm.addEventListener("mouseover", function(evt){
this.style.opacity = 0.5;
},false);
newelm.addEventListener("mouseout", function(evt){
this.style.opacity = 0;
},false);
*/
// UP Button
newelm=createElement("div",{id:newlayer.id+"Up",alt:"up","class":"link queueItemButton queueItemUpButton"},newlayer);
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_QueUpButton"));},false);
newelm.addEventListener("click", function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
// GM_log("swap" + queueNum + " : " + queueNum-1);
zoneList[zoneNrL].swap(queueNum, queueNum-1);
// GM_log("Before scrollTop:" + $("divAutoPflanzeQueBox"+zoneNrL).scrollTop);
$("divAutoMatQueueBox"+zoneNrL).scrollLeft=Math.max(0,Math.min($("divAutoMatQueueBox"+zoneNrL).scrollWidth,((queueNum+2)*queueItemBoxWidth)) - $("divAutoMatQueueBox"+zoneNrL).clientWidth);
// GM_log("After scrollTop:" + $("divAutoPflanzeQueBox"+zoneNrL).scrollTop);
updateQueueBox(zoneNrS, zoneNrL);
zoneNr=null;zoneNrL=null;queueNum=null;
},false);
// Down Button
newelm=createElement("div",{id:newlayer.id+"Down",alt:"down","class":"link queueItemButton queueItemDownButton"},newlayer);
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_QueDownButton"));},false);
newelm.addEventListener("click", function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
// GM_log("swap" + queueNum + " : " + queueNum+1);
zoneList[zoneNrL].swap(queueNum, queueNum+1);
// GM_log("Before scrollTop:" + $("divAutoPflanzeQueBox"+zoneNrL).scrollTop);
$("divAutoMatQueueBox"+zoneNrL).scrollLeft=Math.max(0,Math.min($("divAutoMatQueueBox"+zoneNrL).scrollWidth,((queueNum+2)*queueItemBoxWidth)) - $("divAutoMatQueueBox"+zoneNrL).clientWidth);
// GM_log("After scrollTop:" + $("divAutoPflanzeQueBox"+zoneNrL).scrollTop);
updateQueueBox(zoneNrS, zoneNrL);
zoneNrS=null;zoneNrL=null;queueNum=null;
},false);
// Item
if(fzType=="windmill"){
newelm=createElement("div",{"id":newlayer.id+"Item","class":"link windmillItemProduct"},newlayer);
createElement("div",{"class":"fmm"+PRODSTOP,style:"position:relative;"},newelm);
}else if(fzType=="sawmill"||fzType=="carpentry"||fzType=="forest"){
newelm=createElement("div",{"id":newlayer.id+"Item","class":"link forestryItemProduct"},newlayer);
createElement("div",{"class":"f_symbol"+PRODSTOP,style:"position:relative;"},newelm);
}else{
newelm=createElement("div",{id:newlayer.id+"Item","class":"link queueItemProduct v"+PRODSTOP},newlayer);
}
newelm.addEventListener("click", function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
switch(getBuildingTyp(zoneNrS)){
case "windmill":
drawMillChooseItemBox(zoneNrS, zoneNrL, queueNum, $("divChooseBoxInner"));
break;
case "sawmill":case "carpentry":case "forest":
drawForestryChooseItemBox(zoneNrS, zoneNrL, queueNum, $("divChooseBoxInner"));
break;
case 4:
drawFoodworldChooseItemBox(zoneNrS, zoneNrL, queueNum, $("divChooseBoxInner"));
break;
default:
drawQueueChooseItemBox(zoneNrS, zoneNrL, queueNum, $("divChooseBoxInner"));
}
},false);
newelm.addEventListener("mouseover", function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, toolTipMain(zoneNrS, zoneNrL, queueNum, this.parentNode));
},false);
// Minus Button
newelm=createElement("div",{id:newlayer.id+"M",alt:"-","class":"link queueItemButton queueItemMinButton"},newlayer);
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_QueMin"));},false);
newelm.addEventListener("click", function(){
// GM_log("Minus button id " + this.id.substring(0,this.id.length-1));
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
var inputID=this.id.substring(0,this.id.length-1)+"I1";
var stepping=((getZoneType(zoneNrS)!="windmill")&&(zoneList[zoneNrL][queueNum][3]))?STEPPINGRACK:STEPPINGFIELD;
$(inputID).value=parseFloat($(inputID).value.replace(regDelimThou,"").replace(regDelimDeci,".")) - stepping;
change($(inputID));
},false);
// Plus Button
newelm=createElement("div",{id:newlayer.id+"P",alt:"+","class":"link queueItemButton queueItemPlusButton"},newlayer);
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_QuePlus"));},false);
newelm.addEventListener("click", function(){
// GM_log("Plus button id " + this.id.substring(0,this.id.length-1));
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
var inputID=this.id.substring(0,this.id.length-1)+"I1";
var stepping=((getZoneType(zoneNrS)!="windmill")&&(zoneList[zoneNrL][queueNum][3]))?STEPPINGRACK:STEPPINGFIELD;
$(inputID).value=parseFloat($(inputID).value.replace(regDelimThou,"").replace(regDelimDeci,".")) + stepping;
change($(inputID));
},false);
// Behaviour Type Button
newelm=createElement("div",{id:newlayer.id+"B",alt:"Behaviour","class":"link queueItemButton queueItemBehaviourButton"},newlayer);
newelm.style.backgroundImage=(zoneNrS!="windmill"&&zoneList[zoneNrL][queueNum][3])?"url("+IMAGES["functionR"]+")":"url("+IMAGES["functionF"]+")";
newelm.addEventListener("mouseover", function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, (zoneNrS!="windmill"&&zoneList[zoneNrL][queueNum][3])?getText("automat_QueBehaviourR"):getText("automat_QueBehaviourF"));
},false);
newelm.addEventListener("click", function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
var inputValue=$(this.id.substring(0,this.id.length-1)+"I1");
// GM_log("Behaviour button: zoneNrL:" + zoneNrL + " queueNum:" + queueNum);
zoneList[zoneNrL][queueNum][3]=!zoneList[zoneNrL][queueNum][3];
if(zoneNrS=="windmill"){
this.style.backgroundImage="url("+IMAGES["functionF"]+")";
}else{
if(zoneList[zoneNrL][queueNum][3]){
// rack Behaviour
this.style.backgroundImage="url("+IMAGES["functionR"]+")";
inputValue.value=(unsafeData.prodMinRack&&(unsafeData.prodMinRack[0][zoneList[zoneNrL][queueNum][0]]!=undefined))?unsafeData.prodMinRack[0][zoneList[zoneNrL][queueNum][0]]:(unsafeData.prodStock[0][zoneList[zoneNrL][queueNum][0]]?unsafeData.prodStock[0][zoneList[zoneNrL][queueNum][0]]:0)+((120/unsafeData.prodPlantSize[0])*inputValue.parentNode.getAttribute("itogo"));
zoneList[zoneNrL][queueNum][2]=0;
}else{
// field Behaviour
this.style.backgroundImage="url("+IMAGES["functionF"]+")";
inputValue.value=inputValue.parentNode.getAttribute("iTogo");
zoneList[zoneNrL][queueNum][2]=0;
}
}
toolTip.adjust(this);
change(inputValue); //this includes a updateQueueBox
inputValue=null;
},false);
//Mode Button
if(OPTION_ITEM_REPEAT){
newelm=createElement("div",{id:newlayer.id+"Mode",alt:"Mode","class":"link queueItemButton queueItemModeButton"},newlayer);
newelm.style.backgroundImage=(getZoneType(zoneNrS)!=1 || zoneList[zoneNrL][queueNum][4])?"url("+IMAGES["mode_repeat"]+")":"url("+IMAGES["mode_1time"]+")";
newelm.addEventListener("mouseover", function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, (getZoneType(zoneNrS)==1 && zoneList[zoneNrL][queueNum][4])?getText("automat_QueBehaviourR"):getText("automat_QueBehaviourF"));
},false);
newelm.addEventListener("click", function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
// GM_log("Behaviour button: zoneNrL:" + zoneNrL + " queueNum:" + queueNum);
if(getZoneType(zoneNrS)!=1){
zoneList[zoneNrL][queueNum][4]=true;
this.style.backgroundImage="url("+IMAGES["mode_1time"]+")";
}else{
zoneList[zoneNrL][queueNum][4]=!zoneList[zoneNrL][queueNum][4];
this.style.backgroundImage="url("+(zoneList[zoneNrL][queueNum][4]?IMAGES["mode_repeat"]:IMAGES["mode_1time"])+")"; // repeat mode
}
toolTip.adjust(this);
updateQueueBox(zoneNrS, zoneNrL);
},false);
newelm=createElement("input",{id:newlayer.id+"IListRepeat",value:((zoneList[zoneNrL][queueNum][5]==undefined)?REPEAT_NO_LIMIT:zoneList[zoneNrL][queueNum][5]),maxlength:"4",size:"3","class":"queueItemInput3 queueItemInputWidth2"},newlayer);
newelm.addEventListener("change", function(){
try{
// GM_log("Input field change :" + this.value);
if(/^-?(0|[1-9]\d*)$/.test(this.value)){
if(this.value < 1) this.value=1;
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
zoneList[zoneNrL][queueNum][5]=Math.max(1,Math.min(999, this.value));
updateQueueBox(zoneNrS, zoneNrL);
}else{
this.value=(isNaN(parseInt(this.value,"")))?1:parseInt(this.value,"");
}
}catch(err){GM_logError("drawQueueItemBox InputRepeatField changed \n"+err);}
},false);
}
// Input Field
newelm=createElement("input",{id:newlayer.id+"I2",disabled:true,value:((zoneList[zoneNrL][queueNum][2]==undefined)?0:zoneList[zoneNrL][queueNum][2]),maxlength:"4",size:"3","class":"queueItemInput2 queueItemInputWidth2"},newlayer);
newelm=createElement("input",{id:newlayer.id+"I1",value:0,maxlength:(zoneNrS!="windmill"&&zoneList[zoneNrL][queueNum][3]?"6":"4"),size:"3","class":"queueItemInput1 queueItemInputWidth2"},newlayer);
newelm.value=(zoneList[zoneNrL][queueNum][1]==undefined)?1:zoneList[zoneNrL][queueNum][1];
newelm.addEventListener("change", function(){
try{
// GM_log("Input field change :" + this.value);
if(/^-?(0|[1-9]\d*)$/.test(this.value)){
if(this.value < 1) this.value=1;
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
zoneList[zoneNrL][queueNum][1]=(zoneNrS!="windmill"&&zoneList[zoneNrL][queueNum][3])? this.value:Math.max(1,Math.min(9999, this.value));
updateQueueBox(zoneNrS, zoneNrL);
}else{
this.value=(isNaN(parseInt(this.value,"")))?1:parseInt(this.value,"");
}
}catch(err){GM_logError("drawQueueItemBox InputField changed \n"+err);}
},false);
/*
newelm.addEventListener("mouseover", function(){
$(this.id+"Min").style.visibility = "visible";
$(this.id+"Min").style.top = (this.clientHeight -2) + "px";
$(this.id+"Plus").style.visibility = "visible";
$(this.id+"Plus").style.top = (this.clientHeight -2) + "px";
},false);
newelm.addEventListener("mouseout", function(){
$(this.id+"Min").style.visibility = "hidden";
$(this.id+"Plus").style.visibility = "hidden";
},false);
//createElement("div",{id:newelm.id+"Min",alt:"-","class":"link queueItemButton queueButtonMin"},newlayer);
//createElement("div",{id:newelm.id+"Plus",alt:"+","class":"link queueItemButton queueButtonPlus"},newlayer);
*/
// infinity sign
createElement("div",{id:newlayer.id+"T","class":"queueItemText queueItemTextInf"},newlayer);
// add button.
newelm=createElement("img",{id:newlayer.id+"A","class":"link queueItemAddButton",src:GFX+"buildingupdatebutton_off.png"},newlayer);
newelm.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_QueAddAboveText"));},false);
newelm.addEventListener("click",function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
if(zoneNrS=="windmill"){
zoneList[zoneNrL].splice(queueNum,0,DEFAULT_ZONELIST_MILL.clone());
}else{
zoneList[zoneNrL].splice(queueNum,0,DEFAULT_ZONELIST_ITEM.clone());
zoneList[zoneNrL][queueNum][0]=zoneList[zoneNrL][queueNum+1][0];
}
reFillQueueBox(zoneNrS, zoneNrL, queueNum);
click($("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Item"));
},false);
newelm.addEventListener("mouseover", function(evt){
this.setAttribute("src",GFX+"buildingupdatebutton_on.png");
toolTip.show(evt, getText("automat_QueAddAboveText"));
},false);
newelm.addEventListener("mouseout", function(evt){
this.setAttribute("src",GFX+"buildingupdatebutton_off.png");
},false);
// Delete Button
newelm=createElement("img",{id:newlayer.id+"D","class":"link queueItemDeleteButton",src:GFX+"button_cancel_off.png"},newlayer);
newelm.addEventListener("mouseover", function(evt){
this.setAttribute("src",GFX+"button_cancel_on.png");
toolTip.show(evt, getText("automat_QueDeleteText"));
},false);
newelm.addEventListener("mouseout", function(evt){
this.setAttribute("src",GFX+"button_cancel_off.png");
},false);
newelm.addEventListener("click", function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
var foundActive=false;
zoneList[zoneNrL].splice(queueNum,1);
for(var i=0;i<zoneList[zoneNrL].length;i++){
if(zoneList[zoneNrL][i][1] > zoneList[zoneNrL][i][2]){
foundActive=true;
break;
}
}
if(!foundActive){
for(var i=0;i<zoneList[zoneNrL].length;i++){zoneList[zoneNrL][i][2]=0;}
}
if(zoneList[zoneNrL].length==queueNum){
removeElement(this.parentNode);
updateQueueBox(zoneNrS, zoneNrL);
}else{
reFillQueueBox(zoneNrS, zoneNrL, queueNum);
}
},false);
// End Time
createElement("div",{id:newlayer.id+"ET","class":"queueItemTime",style:"height:"+queueItemBoxTimeHeight+"px;"},newlayer);
newlayer=null;newelm=null;appendTo=null;
if(DEVMODE_FUNCTION){ GM_log("End drawQueueItemBox :" + zoneNrL + " : " + queueNum); }
}catch(err){GM_logError("drawQueueItemBox \n"+err);}
}
function drawQueueListSmall(zoneNrF, zoneNrL, appendTo){
if(zoneNrL==undefined || zoneNrL==null) zoneNrL=getZoneListId(zoneNrF);
appendTo.style.display="none";
appendTo.innerHTML="";
appendTo.setAttribute("zoneNrF",zoneNrF);
appendTo.setAttribute("zoneNrL",zoneNrL);
var lRepeat=(!OPTION_LIST_REPEAT || zoneNrF=="windmill")?false:!settings.get("account","useQueueList")?false:zoneSettings[zoneNrL]["repeat"]==undefined?false:zoneSettings[zoneNrL]["repeat"];
var lShuffle=!settings.get("account","useQueueList")?false:zoneSettings[zoneNrL]["shuffle"]==undefined?false:zoneSettings[zoneNrL]["shuffle"];
var fzType=getBuildingTyp(zoneNrF);
createElement("div",{id:"divQueueItemListTitle"+zoneNrL,"class":"divQueueItemListTitle"},appendTo, getZoneName(0,zoneNrF,zoneNrL, null, false, true, true));
createElement("div",{"class":"divQueueItemListTitle2"},appendTo,((lRepeat && lShuffle)?getText("automat_QueRepeatShuffle"):(lShuffle?getText("automat_QueShuffle"):(lRepeat?getText("automat_QueRepeat"):""))));
createElement("div",{style:"clear:both;"},appendTo);
var newdiv=null;
if(false && fzType==3){//OPTION this show the factory begin product..
for(var k=0;k<BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)].length;k++){
newdiv=createElement("div",{id:"divQueueItemListList"+zoneNrL+"Q"+k+"Item","class":"divQueueItemListChooseItem v"+BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)][k]},appendTo);
createElement("div",{"class":"divQueueItemListNumber"},newdiv, FEEDBONUSTIME[BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)][k]]);
}
}else{
for(queueNum=0;queueNum<zoneList[zoneNrL].length; queueNum++){
if(!settings.get("account","useQueueList") && queueNum>0 && getBuildingTyp(zoneNrL)==1) break;
if(fzType=="windmill"){
newdiv=createElement("div",{id:"divQueueItemListList"+zoneNrL+"Q"+queueNum+"Item","class":"divQueueItemListChooseItem"},appendTo);
createElement("div",{"class":"fmm"+zoneList[zoneNrL][queueNum][0],style:"position:relative;"},newdiv);
}else if(fzType=="sawmill"||fzType=="carpentry"||fzType=="forest"){
newdiv=createElement("div",{id:"divQueueItemListList"+zoneNrL+"Q"+queueNum+"Item","class":"divQueueItemListChooseItem f_symbol"+zoneList[zoneNrL][queueNum][0]},appendTo);
}else{
newdiv=createElement("div",{id:"divQueueItemListList"+zoneNrL+"Q"+queueNum+"Item","class":"divQueueItemListChooseItem v"+zoneList[zoneNrL][queueNum][0]},appendTo);
}
if(fzType!=3 && zoneList[zoneNrL][queueNum][0]!=PRODSTOP){
var iLastInf=((zoneList[zoneNrL].length-1)==queueNum) && !lRepeat && !lShuffle;
var amount=""+Math.max(0,zoneList[zoneNrL][queueNum][1] - zoneList[zoneNrL][queueNum][2]);
createElement("div",{"class":"divQueueItemListNumber"},newdiv,((!settings.get("account","useQueueList") && fzType==1)||lRepeat&&iLastInf)?sign_inf:amount);
}
}
}
newdiv=null;
appendTo.style.display="block";
}
function drawQueueChooseItemBox(zoneNrS, zoneNrL, queueNum, appendTo){
try{
// GM_log("Begin drawQueueChooseItemBox zoneNrS="+zoneNrS+" zoneNrL="+zoneNrL+" queueNum="+queueNum+" appendTo.id="+appendTo.id);
if(zoneNrL==undefined || zoneNrL==null){ zoneNrL=getZoneListId(zoneNrS); }
if(queueNum==undefined){ queueNum=0; }
appendTo.innerHTML="";
appendTo.setAttribute("zoneNrS",zoneNrS);
appendTo.setAttribute("zoneNrL",zoneNrL);
appendTo.setAttribute("queueNum",queueNum);
var fzZoneType=getZoneType(zoneNrS);
createElement("div",{"id":"divChooseTitle"+zoneNrL,"class":"queueTitle"},appendTo, getZoneName(0,zoneNrS,zoneNrL, ($("divChooseBoxInner")==appendTo)?queueNum:null, true, true, true));
createElement("div",{"id":"divChooseEndTime"+zoneNrL,"class":"queueTime"},appendTo);
createElement("div",{"style":"clear:both;"},appendTo);
newdiv=createElement("div",{id:"divChooseItem"+zoneNrL+"Q"+queueNum + "I"+PRODSTOP,"class":"divChooseItem link v"+PRODSTOP,"product":PRODSTOP},appendTo);
newdiv.addEventListener("click",function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
zoneList[zoneNrL][queueNum]=DEFAULT_ZONELIST_ITEM.clone();
toolTip.hide(this);
if(this.parentNode==$("divChooseBoxInner")) click($("divChooseBoxClose"));
updateQueueBox(zoneNrS, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, toolTipProductSmall(zoneNrS, zoneNrL, queueNum, this));
},false);
for(var iProd=0;iProd<unsafeData.prodName[0].length;iProd++){
//if((unsafeData.prodTyp[0][iProd]=="v")&&!(unsafeData.prodBlock[0][iProd]&&unsafeData.prodBlock[0][iProd].match(/l/))){
if((unsafeData.PRODUCT2BUILDING[0][iProd]==fzZoneType)&&!(unsafeData.prodBlock[0][iProd]&&unsafeData.prodBlock[0][iProd].match(/[ulq]/))){
newdiv=createElement("div",{"id":"divChooseItem"+zoneNrL+"Q"+queueNum+"I"+iProd,"class":"divChooseItem link v"+iProd,"product":iProd},appendTo);
newdiv.style.opacity=(unsafeData.prodStock[0][iProd]&&unsafeData.prodStock[0][iProd]>0)?1:0.4;
newdiv.addEventListener("click",function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
var product=parseInt(this.getAttribute("product"),10);
if(zoneList[zoneNrL][queueNum][0]!=product){
zoneList[zoneNrL][queueNum][0]=product;
zoneList[zoneNrL][queueNum][1]=(zoneNrS!="windmill"&&zoneList[zoneNrL][queueNum][3])?((unsafeData.prodMinRack&&(unsafeData.prodMinRack[0][product]!=undefined))?unsafeData.prodMinRack[0][product]:100):(zoneList[zoneNrL][queueNum][1]>=1?zoneList[zoneNrL][queueNum][1]:1);
zoneList[zoneNrL][queueNum][2]=0;
}
toolTip.hide(this);
if(this.parentNode==$("divChooseBoxInner")) click($("divChooseBoxClose"));
updateQueueBox(zoneNrS, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, toolTipProductSmall(zoneNrS, zoneNrL, queueNum, this));
},false);
}
}
/*
if(settings.get("account","useQueueList")){ //TODO //display powerups
createElement("div",{style:"clear:both;"},appendTo);
createElement("div",{style:"width:100%;border-top:1px solid black;margin-top:4px;padding-top:4px;height:0px;"},appendTo);
for(var v in unsafeWindow.poweruprack){
if(!unsafeWindow.poweruprack.hasOwnProperty(v)){ continue; }
if(unsafeWindow.poweruprack[v][5][0]==0){
rProd=unsafeWindow.poweruprack[v][0];
iProd=unsafeWindow.poweruprack[v][5][1]==0?unsafeWindow.poweruprack[v][5][2][0]:unsafeWindow.poweruprack[v][5][1][0];
newdiv=createElement("div",{id:"divChooseItem"+zoneNrL+"Q"+queueNum+"R"+rProd,"class":"divChooseItem link r"+rProd,"product":rProd},appendTo);
createElement("div",{"class":"kp"+iProd,style:"position:absolute;right:0px;bottom:0px;"},newdiv);
// newdiv.addEventListener("click", function(){
// },false);
newdiv.addEventListener("mouseover",function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, toolTipProductSmall(zoneNrS, zoneNrL, queueNum, this));
},false);
}
}
}
*/
if(appendTo==$("divChooseBoxInner")){
$("divChooseBox").style.display="block";
$("divChooseBox").style.top=Math.round(255 - $("divChooseBox").offsetHeight/2)+"px";
}
newdiv=null;appendTo=null;
updateQueueBox(zoneNrS, zoneNrL);
// GM_log("End drawQueueChooseItemBox :" + zoneNrL);
}catch(err){GM_logError("drawQueueChooseItemBox \n"+err);}
}
function drawFactoryChooseItemBox(zoneNrS, zoneNrL, appendTo){
try{
// GM_log("Begin drawFactoryChooseItemBox :" + zoneNrS+":"+zoneNrL);
var zoneNrF=zoneNrS.toString().replace(/\.\d+$/,"");
if(zoneNrL==undefined || zoneNrL==null){ zoneNrL=getZoneListId(zoneNrS); }
appendTo.innerHTML="";
appendTo.setAttribute("zoneNrF",zoneNrF);
appendTo.setAttribute("zoneNrS",zoneNrS);
appendTo.setAttribute("zoneNrL",zoneNrL);
appendTo.setAttribute("queueNum",0);
createElement("div",{"id":"divChooseTitle"+zoneNrL,"class":"queueTitle"},appendTo, getZoneName(0,zoneNrS,zoneNrL,null,true,true,true,true));
createElement("div",{"id":"divChooseEndTime"+zoneNrL,"class":"queueTime"},appendTo);
createElement("div",{"style":"clear:both;"},appendTo);
newdiv=createElement("div",{"class":"divChooseItem link v"+PRODSTOP,"id":"divChooseItem"+zoneNrL+"Q0I"+PRODSTOP},appendTo);
if(zoneList[zoneNrL][0][0]==PRODSTOP){ newdiv.style.border="2px solid black"; }
newdiv.addEventListener("click",function(){
var zoneNrF=this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
zoneList[zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone();
if(this.parentNode==$("divChooseBoxInner")){ click($("divChooseBoxClose")); }
updateQueueBox(zoneNrF, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
var zoneNrF=this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
toolTip.show(evt, toolTipProductSmall(zoneNrF, zoneNrL, 0, this));
},false);
for(var v in unsafeData.BUILDING_INPUT[getZoneType(zoneNrS)]){
if(!unsafeData.BUILDING_INPUT[getZoneType(zoneNrS)].hasOwnProperty(v)){ continue; }
if(unsafeData.prodBlock[0][v]){ continue; }
newdiv=createElement("div",{"class":"divChooseItem link v"+v,"id":"divChooseItem"+zoneNrL+"Q0I"+v},appendTo);
if(zoneList[zoneNrL][0][0]==v){ newdiv.style.border="2px solid black"; }
newdiv.addEventListener("click",function(){
var zoneNrF=this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
zoneList[zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone();
zoneList[zoneNrL][0][0]=parseInt(/Q0I(.*)$/.exec(this.id)[1],10);
if(this.parentNode==$("divChooseBoxInner")){ click($("divChooseBoxClose")); }
updateQueueBox(zoneNrF, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
toolTip.show(evt, toolTipProductSmall(zoneNrS, zoneNrL, 0, this));
},false);
}
if(appendTo==$("divChooseBoxInner")){
$("divChooseBox").style.display="block";
$("divChooseBox").style.top=Math.round(255 - $("divChooseBox").offsetHeight/2)+"px";
}
updateQueueBox(zoneNrF, zoneNrL);
zoneFeedCurr=null;zoneProdCurr=null;
newdiv=null;appendTo=null;
// GM_log("End drawFactoryChooseItemBox :" + zoneNrL);
}catch(err){GM_logError("drawFactoryChooseItemBox \n"+err);}
}
function drawStableChooseFeedBox(zoneNrF, zoneNrL, appendTo){
try{
// GM_log("Begin drawStableChooseFeedBox zoneNrF:" + zoneNrF + " zoneNrL:"+zoneNrL);
if(zoneNrL==undefined || zoneNrL==null) zoneNrL=getZoneListId(zoneNrF);
var level=parseInt($("levelnum").innerHTML,10);
// catch bad data
// should be zoneList[zoneNrL]=[[feed1,amount1,0,false],[feed2,amount2,0,false]]
// or if deactivated [[PRODSTOP,amount1,0],[PRODSTOP,amount2,0]]
if(zoneList[zoneNrL].length!=2){
zoneList[zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY2.clone();
}else{
if(zoneList[zoneNrL][0][0]==PRODSTOP){ zoneList[zoneNrL][0]=DEFAULT_ZONELIST_ITEM.clone(); }
if(zoneList[zoneNrL][1][0]==PRODSTOP){ zoneList[zoneNrL][1]=DEFAULT_ZONELIST_ITEM.clone(); }
}
var feedSort=[,];
var feedAmount=[0,0];
var feedMax=[0,0];
var feedTime=[,];
// the time needed if full fed
var growTime=30 * unsafeData.prodGrowTime[0][unsafeData.BUILDING2PRODUCT[unsafeData.zones.getBuilding(zoneNrF)][0]] * getFarmZoneBonus(zoneNrF, null);
if(unsafeWindow.premium==0 && level>9){ growTime -=1; } // small hack. non-premiums cant feed completely
function calcStableChooseFeedBox(index,val){
var noTime=false;
// GM_log("calcStableChooseFeedBox "+index+":"+val);
feedAmount[index]=val;
var cand=appendTo.getElementsByClassName("divChooseFeed");
cand[index].getElementsByClassName("divChooseFeedAmountSpan")[0].innerHTML=feedAmount[index];
cand=null;
if(feedAmount[0]+feedAmount[1]==0){
// no feed
zoneList[zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY2;
}else{
// feed
var calcTime=feedAmount[index]*feedTime[index];
index=(index+1)%2;
if(feedSort[index]){
if(feedAmount[index]>0){
if(feedAmount[(index+1)%2]>0){ calcTime++; } // a bit time is lost when 2 feeds are used
var help=calcTime+feedAmount[index]*feedTime[index];
while((feedAmount[index]>0) && (help>growTime)){
feedAmount[index]--;
help=calcTime+feedAmount[index]*feedTime[index];
}
calcTime=help-1;
}
}
if(feedAmount[0]>feedAmount[1]){
zoneList[zoneNrL]=[[feedSort[0],feedAmount[0],0,false],[feedSort[1],feedAmount[1],0,false]];
}else{
zoneList[zoneNrL]=[[feedSort[1],feedAmount[1],0,false],[feedSort[0],feedAmount[0],0,false]];
}
}
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList", implode(zoneList,"calcStableChooseFeedBox/zoneList"));
updateQueueBox(zoneNrF, zoneNrL);
}
appendTo.innerHTML="";
appendTo.setAttribute("zoneNrF",zoneNrF);
appendTo.setAttribute("zoneNrL",zoneNrL);
appendTo.setAttribute("queueNum",0);
createElement("div",{"id":"divChooseTitle"+zoneNrL,"class":"queueTitle"},appendTo, getZoneName(0,zoneNrF,zoneNrL,null,true,true,true,true));
var newdiv=createElement("div",{"id":"divChooseEndTime"+zoneNrL,"class":"divChooseFeedTime"},appendTo);
createElement("div",{"style":"clear:both;"},appendTo);
var newdiv1,newspan;
for(var k=0;k<BUILDING2FEED[getZoneType(zoneNrF)].length;k++){
var iProd=BUILDING2FEED[getZoneType(zoneNrF)][k];
var queueNum=(zoneList[zoneNrL][0][0]==iProd?0:1);
newdiv=createElement("div",{"name":k,"queueNum":queueNum,"class":"divChooseFeed"},appendTo);
newitem=createElement("div",{id:"divChooseItem"+zoneNrL+"Q"+queueNum+"I","class":"divChooseFeedIcon v"+iProd,"product":iProd},newdiv);
newitem.addEventListener("mouseover", function(evt){
var zoneNrF=this.parentNode.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.parentNode.getAttribute("zoneNrL");
toolTip.show(evt, toolTipProductSmall(zoneNrF, zoneNrL, this.parentNode.getAttribute("name"), this));
},false);
// if(unsafeWindow.produkt_level[iProd]<=level){
if(!(unsafeData.prodBlock[0][iProd]&&unsafeData.prodBlock[0][iProd].match(/l/))){
feedSort[k]=iProd;
feedAmount[k]=zoneList[zoneNrL][queueNum][1];
feedTime[k]=FEEDBONUSTIME[iProd]/unsafeData.zones.getAnimals(zoneNrF);
feedMax[k]=Math.floor(growTime/feedTime[k],1);
newdiv1=createElement("div",{"class":"link divChooseFeedAmount","id":"divChooseFeedAmount"+zoneNrL+"Q"+iProd+"I"},newdiv);
var help=((($("divChooseBoxInner")==$("divChooseEndTime"+zoneNrL).parentNode)?243:243)/feedMax[k])-1; //TODO
for(var v=1;v<=Math.max(1,feedMax[k]);v++){
newval=createElement("div",{style:"width:"+help+"px;"+(v==1?"border:none;":"")},newdiv1);
newval.setAttribute("value",v);
newval.addEventListener("mouseover", function(evt){ toolTip.show(evt, this.getAttribute("value"));},false);
}
newdiv1.addEventListener("click",function(event){
var help=parseInt(event.target.getAttribute("value"),10);
if(!isNaN(help)){ calcStableChooseFeedBox(parseInt(this.parentNode.getAttribute("name"),10),help); }
},false);
newdiv1=createElement("div",{style:"float:left;margin-top:2px;margin-left:5px;color:black;font-weight:bold;"},newdiv);
createElement("span",{"class":"divChooseFeedAmountSpan","id":"divChooseFeedAmountSpan"+zoneNrL+"Q"+iProd+"I"},newdiv1,zoneList[zoneNrL][0][1]);
createElement("span",{style:"margin-right:5px;"},newdiv1," "+unsafeData.prodName[0][iProd]);
newdiv1=createElement("div",{style:"float:right;margin-top:2px;color:black;font-weight:bold;"},newdiv);
newspan=createElement("span",{"class":"divChooseFeedButton link"},newdiv1,feedMax[k]);
newspan.addEventListener("click",function(event){
var help=parseInt(this.parentNode.parentNode.getAttribute("name"),10);
calcStableChooseFeedBox(help,feedMax[help]);
},false);
newspan=createElement("span",{"class":"divChooseFeedButton link"},newdiv1,"+");
newspan.addEventListener("click",function(event){
var help=parseInt(this.parentNode.parentNode.getAttribute("name"),10);
calcStableChooseFeedBox(help,Math.min(feedMax[help],feedAmount[help]+1));
},false);
newspan=createElement("span",{"class":"divChooseFeedButton link"},newdiv1,"-");
newspan.addEventListener("click",function(event){
var help=parseInt(this.parentNode.parentNode.getAttribute("name"),10);
calcStableChooseFeedBox(help,Math.max(0,feedAmount[help]-1));
},false);
newspan=createElement("span",{"class":"divChooseFeedButton link"},newdiv1,"0");
newspan.addEventListener("click",function(event){
var help=parseInt(this.parentNode.parentNode.getAttribute("name"),10);
calcStableChooseFeedBox(help,0);
},false);
}
}
if(appendTo==$("divChooseBoxInner")){
$("divChooseBox").style.display="block";
$("divChooseBox").style.top=Math.round(255 - $("divChooseBox").offsetHeight/2)+"px";
}
// updateQueueBox(zoneNrF, zoneNrL);
calcStableChooseFeedBox(0,feedAmount[0]);
newdiv=null;newdiv1=null;newspan=null;newitem=null;newval=null;
// GM_log("End drawStableChooseFeedBox :" + zoneNrF);
}catch(err){GM_logError("drawStableChooseFeedBox \n"+err);}
}
function drawMillChooseItemBox(zoneNrF, zoneNrL, queueNum, appendTo){
try {
// GM_log("Begin drawMillChooseItemBox :" + queueNum);
if(zoneNrL==undefined || zoneNrL==null) zoneNrL=getZoneListId(zoneNrF);
if(queueNum==undefined) queueNum=0;
appendTo.innerHTML="";
appendTo.setAttribute("zoneNrF",zoneNrF);
appendTo.setAttribute("zoneNrL",zoneNrL);
appendTo.setAttribute("queueNum",queueNum);
createElement("div",{"id":"divChooseTitle"+zoneNrL,"class":"queueTitle"},appendTo, getZoneName(0,zoneNrF,zoneNrL, ($("divChooseBoxInner")==appendTo)?queueNum:null), false, true ,true);
createElement("div",{"id":"divChooseEndTime"+zoneNrL,"class":"queueTime"},appendTo);
createElement("div",{"style":"clear:both;"},appendTo);
newdiv=createElement("div",{id:"divChooseItem"+zoneNrL+"Q"+queueNum + "I"+PRODSTOP,"class":"divMillChooseItem link","product":PRODSTOP},appendTo);
newdiv.addEventListener("click",function(){
var zoneNrF=this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
// GM_log("Click" + zoneNrF + " : " + queueNum + " : " + 0);
zoneList[zoneNrL][queueNum]=DEFAULT_ZONELIST_MILL.clone();
toolTip.hide(this);
if(this.parentNode==$("divChooseBoxInner")) click($("divChooseBoxClose"));
updateQueueBox(zoneNrF, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){ toolTip.show(evt, getText("automat_QueDontWork"));},false);
newdiv.style.backgroundColor=(zoneList[zoneNrL][0][0]==PRODSTOP)? "black":"";
createElement("div",{"class":"fm"+PRODSTOP,style:"position:relative;"},newdiv);
createElement("div",{"class":"divMillChooseItemNumber"},newdiv,sign_inf);
for(var iProd in autoMillStorage){
if(!autoMillStorage.hasOwnProperty(iProd)){continue;}
if((autoMillStorage[iProd][0]-autoMillStorage[iProd][1]) > 0){
newdiv=createElement("div",{id:"divChooseItem"+zoneNrL+"Q"+queueNum+"I"+iProd,"class":"divMillChooseItem link","product":iProd},appendTo);
newdiv.addEventListener("click",function(){
var zoneNrF=this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
var recipe=parseInt(this.getAttribute("product"),10);
// GM_log("Click" + zoneNrF + " : " + queueNum + " : " + recipe);
if(zoneList[zoneNrL][queueNum][0]!=recipe) zoneList[zoneNrL][queueNum]=[recipe,1,0,0,[]];
toolTip.hide(this);
if(this.parentNode==$("divChooseBoxInner")) click($("divChooseBoxClose"));
updateQueueBox(zoneNrF, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
toolTip.show(evt, unsafeWindow.showFormulaInfos(parseInt(this.childNodes[0].getAttribute("class").replace("fm",""),10)));
},false);
newdiv.style.backgroundColor=(zoneList[zoneNrL][queueNum][0]==iProd)? "black":"";
createElement("div",{"class":"fm"+iProd,style:"position:absolute;"},newdiv);
createElement("div",{"class":"divMillChooseItemNumber"},newdiv,(autoMillStorage[iProd][0]-autoMillStorage[iProd][1]));
}
}
if(appendTo==$("divChooseBoxInner")){
$("divChooseBox").style.display="block";
$("divChooseBox").style.top=Math.round(255 - $("divChooseBox").offsetHeight/2)+"px";
}
updateQueueBox(zoneNrF,zoneNrL);
newdiv=null;appendTo=null;
// GM_log("End drawMillChooseItemBox :" + queueNum);
}catch(err){GM_logError("drawMillChooseItemBox \n"+err);}
}
function drawForestryChooseItemBox(zoneNrF, zoneNrL, queueNum, appendTo){
try{
// GM_log("Begin drawForestryChooseItemBox zoneNrF:"+zoneNrF+" zoneNrL:" + zoneNrL);
var fzType=getBuildingTyp(zoneNrF);
var zoneStockTyp = (fzType=="forest"?"f1":(fzType=="sawmill"?"f3":(fzType=="carpentry"?"f4":null)));
// GM_log("drawForestryChooseItemBox zoneStockTyp:"+zoneStockTyp);
if(zoneNrL==undefined || zoneNrL==null) zoneNrL=getZoneListId(zoneNrF);
if(queueNum==undefined) queueNum=0;
var level=parseInt($("levelnum").innerHTML,10);
appendTo.innerHTML="";
appendTo.setAttribute("zoneNrF",zoneNrF);
appendTo.setAttribute("zoneNrL",zoneNrL);
appendTo.setAttribute("queueNum",queueNum);
createElement("div",{"id":"divChooseTitle"+zoneNrL,"class":"queueTitle"},appendTo, getZoneName(0,zoneNrF,zoneNrL, ($("divChooseBoxInner")==appendTo)?queueNum:null, true, true, true));
createElement("div",{"id":"divChooseEndTime"+zoneNrL,"class":"queueTime"},appendTo);
createElement("div",{"style":"clear:both;"},appendTo);
newdiv=createElement("div",{id:"divChooseItem"+zoneNrL+"Q"+queueNum + "I"+PRODSTOP,"class":"divChooseItem link f_symbol"+PRODSTOP,"product":PRODSTOP},appendTo);
newdiv.addEventListener("click",function(){
var zoneNrF =this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
zoneList[zoneNrL][queueNum]=DEFAULT_ZONELIST_ITEM.clone();
toolTip.hide(this);
if(this.parentNode==$("divChooseBoxInner")) click($("divChooseBoxClose"));
updateQueueBox(zoneNrF, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
var zoneNrF=this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, toolTipProductSmall(zoneNrF, zoneNrL, queueNum, this));
},false);
// GM_log("drawForestryChooseItemBox prodName:"+implode(unsafeData.prodName[1],"GMprodName[1]"));
for(var iProd in unsafeData.prodName[1]){
if(!unsafeData.prodName[1].hasOwnProperty(iProd)){continue;}
if(unsafeData.prodTyp[1][iProd]!=zoneStockTyp){continue;}
var help,opacity=false;
// GM_log("drawForestryChooseItemBox iProd:"+iProd+" prodTyp:"+unsafeData.prodTyp[1][iProd]+" prodBlock:"+unsafeData.prodBlock[1][iProd]);
if(!(unsafeData.prodBlock[1][iProd]&&unsafeData.prodBlock[1][iProd].match(/q/))){
newdiv=createElement("div",{"id":"divChooseItem"+zoneNrL+"Q"+queueNum+"I"+iProd,"class":"divChooseItem link f_symbol"+iProd,"product":iProd},appendTo);
opacity=false;help=null;
for(var i in unsafeData.prodRequire[1][iProd]){
if(!unsafeData.prodRequire[1][iProd].hasOwnProperty(i)){continue;}
help=unsafeData.prodRequire[1][iProd][i];
//GM_log("drawForestryChooseItemBox prodStock["+help[0]+"]["+help[1]+"]:"+unsafeData.prodStock[help[0]][help[1]]+" > "+help[2]);
opacity=opacity&&(unsafeData.prodStock[help[0]][help[1]]>help[2]);
}
newdiv.style.opacity=(opacity)?0.4:1;
newdiv.addEventListener("click",function(){
var zoneNrF=this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
var product=parseInt(this.getAttribute("product"),10);
if(zoneList[zoneNrL][queueNum][0]!=product){
zoneList[zoneNrL][queueNum][0]=product;
zoneList[zoneNrL][queueNum][1]=(zoneNrF!="windmill"&&zoneList[zoneNrL][queueNum][3])?((unsafeData.prodMinRack&&(unsafeData.prodMinRack[0][product]!=undefined))?unsafeData.prodMinRack[0][product]:100):(zoneList[zoneNrL][queueNum][1]>=1?zoneList[zoneNrL][queueNum][1]:1);
zoneList[zoneNrL][queueNum][2]=0;
}
toolTip.hide(this);
if(this.parentNode==$("divChooseBoxInner")) click($("divChooseBoxClose"));
updateQueueBox(zoneNrF, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
var zoneNrF=this.parentNode.getAttribute("zoneNrF");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, toolTipProductSmall(zoneNrF, zoneNrL, queueNum, this));
},false);
}
}
if(appendTo==$("divChooseBoxInner")){
$("divChooseBox").style.display="block";
$("divChooseBox").style.top=Math.round(255 - $("divChooseBox").offsetHeight/2)+"px";
}
newdiv=null;appendTo=null;
updateQueueBox(zoneNrF, zoneNrL);
// GM_log("End drawForestryChooseItemBox zoneNrF:"+zoneNrF+" zoneNrL:" + zoneNrL);
}catch(err){GM_logError("drawForestryChooseItemBox iProd:"+iProd+"\n"+err);}
}
function drawFoodworldChooseItemBox(zoneNrS, zoneNrL, queueNum, appendTo){
try{
// GM_log("Begin drawFoodworldChooseItemBox zoneNrS="+zoneNrS+" zoneNrL="+zoneNrL+" queueNum="+queueNum+" appendTo.id="+appendTo.id);
if(zoneNrL==undefined || zoneNrL==null){ zoneNrL=getZoneListId(zoneNrS); }
if(queueNum==undefined){ queueNum=0; }
appendTo.innerHTML="";
appendTo.setAttribute("zoneNrS",zoneNrS);
appendTo.setAttribute("zoneNrL",zoneNrL);
appendTo.setAttribute("queueNum",queueNum);
var fzZoneType=getZoneType(zoneNrS);
createElement("div",{"id":"divChooseTitle"+zoneNrL,"class":"queueTitle"},appendTo, getZoneName(0,zoneNrS,zoneNrL, ($("divChooseBoxInner")==appendTo)?queueNum:null, true, true, true));
createElement("div",{"id":"divChooseEndTime"+zoneNrL,"class":"queueTime"},appendTo);
createElement("div",{"style":"clear:both;"},appendTo);
newdiv=createElement("div",{id:"divChooseItem"+zoneNrL+"Q"+queueNum + "I"+PRODSTOP,"class":"divChooseItem link v"+PRODSTOP,"product":PRODSTOP},appendTo);
newdiv.addEventListener("click",function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
zoneList[zoneNrL][queueNum]=DEFAULT_ZONELIST_ITEM.clone();
toolTip.hide(this);
if(this.parentNode==$("divChooseBoxInner")) click($("divChooseBoxClose"));
updateQueueBox(zoneNrS, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, toolTipProductSmall(zoneNrS, zoneNrL, queueNum, this));
},false);
for(var iProd=0;iProd<unsafeData.prodName[0].length;iProd++){
if(fzZoneType==unsafeData.PRODUCT2BUILDING[0][iProd]){ // display only appropriate products for current building
if(!unsafeData.prodBlock[0][iProd].match(/[ulq]/)){
newdiv=createElement("div",{"id":"divChooseItem"+zoneNrL+"Q"+queueNum+"I"+iProd,"class":"divChooseItem link v"+iProd,"product":iProd},appendTo);
newdiv.style.opacity=(unsafeData.prodStock[0][iProd]&&unsafeData.prodStock[0][iProd]>0)?1:0.4;
newdiv.addEventListener("click",function(){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
var product=parseInt(this.getAttribute("product"),10);
if(zoneList[zoneNrL][queueNum][0]!=product){
zoneList[zoneNrL][queueNum][0]=product;
zoneList[zoneNrL][queueNum][1]=(zoneNrS!="windmill"&&zoneList[zoneNrL][queueNum][3])?((unsafeData.prodMinRack&&(unsafeData.prodMinRack[0][product]!=undefined))?unsafeData.prodMinRack[0][product]:100):(zoneList[zoneNrL][queueNum][1]>=1?zoneList[zoneNrL][queueNum][1]:1);
zoneList[zoneNrL][queueNum][2]=0;
}
toolTip.hide(this);
if(this.parentNode==$("divChooseBoxInner")) click($("divChooseBoxClose"));
updateQueueBox(zoneNrS, zoneNrL);
},false);
newdiv.addEventListener("mouseover", function(evt){
var zoneNrS=this.parentNode.getAttribute("zoneNrS");
var zoneNrL=this.parentNode.getAttribute("zoneNrL");
var queueNum=parseInt(this.parentNode.getAttribute("queueNum"),10);
toolTip.show(evt, toolTipProductSmall(zoneNrS, zoneNrL, queueNum, this));
},false);
}
}
}
if(appendTo==$("divChooseBoxInner")){
$("divChooseBox").style.display="block";
$("divChooseBox").style.top=Math.round(255 - $("divChooseBox").offsetHeight/2)+"px";
}
newdiv=null;appendTo=null;
updateQueueBox(zoneNrS, zoneNrL);
// GM_log("End drawFoodworldChooseItemBox :" + zoneNrL);
}catch(err){GM_logError("drawFoodworldChooseItemBox \n"+err);}
}
function updateQueueBox(zoneNrS,zoneNrL){
try{
if(DEVMODE_FUNCTION){ GM_log("Begin updateQueueBox zoneNrS="+zoneNrS+" zoneNrL="+zoneNrL); }
if(zoneNrS==undefined){ return; }
var err_trace="init";
if(zoneNrL==undefined || zoneNrL==null){ zoneNrL=getZoneListId(zoneNrS); }
var fzType=getBuildingTyp(zoneNrS);
var fzZoneType=getZoneType(zoneNrS);
var fzWindmill=(fzType=="windmill");
var fzForestry=(fzType=="forest"||fzType=="sawmill"||fzType=="carpentry");
var iType=(fzWindmill?3:(fzForestry?1:0));
var noTime=false;
var level=parseInt($("levelnum").innerHTML,10);
var zones=getZonesFromList(zoneNrL);
var lShowTime=(zones.length>0);
var zoneTimes=getZoneTimes(zoneNrL);
// GM_log("updateQueueBox zoneNrS="+zoneNrS+" zoneNrL="+zoneNrL+" zonetimes="+implode(zoneTimes,"updateQueueBox/zoneTimes"));
var help,prod;
if(fzWindmill){ reCalculateWindmill(); }
// automat icons
err_trace="automat icons collect";
var automatIcons=[];
for(var i=0;i<zones.length;i++){
if(isVisibleZone(zones[i])){
automatIcons.push(zones[i]);
if(zones[i].match(/\.1$/)){
automatIcons.push(zones[i].replace(/\.1$/,""));
}
}
}
if(fzWindmill||fzForestry){
automatIcons.push("global_"+zoneNrS);
}
err_trace="automat icons update";
for(var i=0;i<automatIcons.length;i++){
var farmIcon=$("divAutomatIcon_"+automatIcons[i]);
if(farmIcon){
switch(fzType){
case "windmill":
// farmIcon.setAttribute("class","link divWindmillIcon");
farmIcon.childNodes[0].setAttribute("class","fmm"+zoneList[zoneNrL][0][0]);
break;
case "forest":case "sawmill":case "carpentry":
farmIcon.childNodes[0].setAttribute("class","f_symbol"+zoneList[zoneNrL][0][0]);
// farmIcon.setAttribute("class","link divForestryIcon f_symbol"+zoneList[zoneNrL][0][0]);
break;
case 1: // Field
case 3: // Factory
case 4: // Foodworld
farmIcon.setAttribute("class","link divZoneIcon v"+zoneList[zoneNrL][0][0]);
break;
case 2: // Stable
//catch wrong feed
var futter1=BUILDING2FEED[fzZoneType][0];
var futter2=BUILDING2FEED[fzZoneType][1];
for(var queueNum=0;queueNum<zoneList[zoneNrL].length;queueNum++){
if((zoneList[zoneNrL][queueNum][0]!=futter1)&&(zoneList[zoneNrL][queueNum][0]!=futter2)&&(zoneList[zoneNrL][queueNum][0]!=PRODSTOP)){
zoneList[zoneNrL][queueNum]=DEFAULT_ZONELIST_ITEM.clone();
queueNum--;
}
}
queueNum=null;
farmIcon.setAttribute("class","link divZoneIcon v"+zoneList[zoneNrL][0][0]);
break;
}
farmIcon.setAttribute("product",zoneList[zoneNrL][0][0]);
farmIcon.setAttribute("zoneBeginTime",implode(zoneTimes,"updateQueueBox/zoneTimes"));
farmIcon.style.display="block";
farmIcon=null;
}
}
//queue list
err_trace="queue list";
if($("divAutoMatQueueBox"+zoneNrL)){
// GM_log("updateQueueBox Box :" + zoneNrL);
var totalInQue=0;
var foundStop=false;
var lRepeat=(!OPTION_LIST_REPEAT || zoneSettings[zoneNrL]["repeat"]==undefined)?false:zoneSettings[zoneNrL]["repeat"];
var lShuffle=zoneSettings[zoneNrL]["shuffle"]==undefined?false:zoneSettings[zoneNrL]["shuffle"];
var newRackAmount=new Array(); //array with all culterd products until that moment.
var fRepeat=OPTION_LIST_REPEAT?lRepeat:false; //foundRepeat
for(queueNum=0;queueNum<zoneList[zoneNrL].length;queueNum++){
// GM_log("updateQueueBox Box :" + zoneNrS + ":"+queueNum + " | " + zoneList[zoneNrL].length);
var iRepeat=(!OPTION_ITEM_REPEAT||fzWindmill)?false:zoneList[zoneNrL][queueNum][4];
fRepeat=fRepeat||(OPTION_ITEM_REPEAT?iRepeat:false);
var iLastInf=fzWindmill?false:(((zoneList[zoneNrL].length-1)==queueNum) && !fRepeat && !lShuffle);
var iRackMode=!iLastInf && !fzWindmill && zoneList[zoneNrL][queueNum][3];
var iProd=parseInt(zoneList[zoneNrL][queueNum][0],10);
var iStop=(iProd==PRODSTOP);
var iDone=iRackMode?0:parseInt(zoneList[zoneNrL][queueNum][2],10);
var iTot=parseInt(zoneList[zoneNrL][queueNum][1],10);
var iTogo=iRackMode?0:(iLastInf?(11*(zones.length)):iTot-iDone);
var iTogoAmount=0,iTogoScore=0;
var iRequireMissing=false;
if(iStop){
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).style.backgroundColor=(foundStop?"red":"transparent");
foundStop=true;
}else{
for(var i in unsafeData.prodRequire[iType][iProd]){
if(!unsafeData.prodRequire[iType][iProd].hasOwnProperty(i)){continue;}
if(iRequireMissing){continue;}
if(unsafeData.prodRequire[iType][iProd][i][0]>0){
if(iTot*unsafeData.prodRequire[iType][iProd][i][2]-unsafeData.prodStock[unsafeData.prodRequire[iType][iProd][i][0]][unsafeData.prodRequire[iType][iProd][i][1]]>0){
iRequireMissing=true;
}
}
}
if(!newRackAmount[iProd] && !fzWindmill){ newRackAmount[iProd]=calcInGameProductAmount(iProd, zoneNrS, null, true); }
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).style.backgroundColor=(foundStop?"red":(iRequireMissing?"yellow":"transparent"));
}
if(settings.get("account","showQueueTime")){
var beginTime=new Object();
var timeArray=new Object();
var timesArray=new Object();
var iTogoArray=new Object();
var endTime=zoneTimes[getLowestTimeFarmZone(zoneTimes)];
var currFeldPositions=0;
if(fzWindmill){
beginTime[zoneNrS]=zoneTimes[zoneNrS];
timeArray[zoneNrS]=calcProductionTime(iProd, zoneNrS);
if(!timesArray[zoneNrS]) timesArray[zoneNrS]=new Array();
iTogoArray[zoneNrS]=0;
for(var k=0;k<iTogo;k++){
zoneTimes[zoneNrS] +=timeArray[zoneNrS];
if(timesArray[zoneNrS].length<=10){ timesArray[zoneNrS].push(zoneTimes[zoneNrS]); }
iTogoArray[zoneNrS]++;
}
endTime=zoneTimes[zoneNrS];
}else if(iTot<=0 || iStop){ //don't do any thing just give the begin info.
for(var fz in zoneTimes){
if(!zoneTimes.hasOwnProperty(fz)){ continue; }
if(isNaN(iTogoArray[fz])) iTogoArray[fz]=0;
iTogoArray[fz]++;
if(!beginTime[fz]) beginTime[fz]=zoneTimes[fz];
if(!timeArray[fz]) timeArray[fz]=calcProductionTime(iProd, getZoneNameCorrected(fz));
}
}else if(!iRackMode){
for(var k=0;k<iTogo;k++){
var fz=getLowestTimeFarmZone(zoneTimes);
var bt=getBuildingTyp(fz);
if(!beginTime[fz]) beginTime[fz]=zoneTimes[fz];
if(!timeArray[fz]) timeArray[fz]=calcProductionTime(iProd, fz);
if(isNaN(iTogoArray[fz])) iTogoArray[fz]=0;
iTogoArray[fz]++;
currFeldPositions=calcProductPositions(iProd, fz);
zoneTimes[fz] +=timeArray[fz]+((unsafeWindow.premium==1)?0:(settings.get("country","pause")[0]/1000)*currFeldPositions);
if(!timesArray[fz]){ //this is the amount that is planted on a field. that last field returns them.
timesArray[fz]=new Array();
if(!fzForestry){ //TODO should be done with the prodrequire == prodYield check..
// iTogoAmount += currFeldPositions;
}
}
if(timesArray[fz].length<=10) timesArray[fz][timesArray[fz].length]=zoneTimes[fz];
iTogoAmount +=calcProductAmount(iProd, fz, currFeldPositions, zoneTimes[fz], false);
iTogoScore +=calcProductScore(iProd, fz, currFeldPositions, zoneTimes[fz]);
if(endTime < zoneTimes[fz]) endTime=zoneTimes[fz];
}
}else{ // if(iRackMode){
while((newRackAmount[iProd]+iTogoAmount) < iTot){
var fz=getLowestTimeFarmZone(zoneTimes);
var cfz=getZoneNameCorrected(fz);
if(!beginTime[fz]) beginTime[fz]=zoneTimes[fz];
if(!timeArray[fz]) timeArray[fz]=calcProductionTime(iProd, cfz);
if(isNaN(iTogoArray[fz])) iTogoArray[fz]=0;
iTogoArray[fz]++;
currFeldPositions=calcProductPositions(iProd,cfz);
zoneTimes[fz] +=timeArray[fz]+(unsafeWindow.premium==1?0:(settings.get("country","pause")[1]/1000)*currFeldPositions);
if(!timesArray[fz]){
timesArray[fz]=new Array();
iTogoAmount +=currFeldPositions;//this is the amount that is plantend on a field. that last field returns them.
}
if(timesArray[fz].length<=10) timesArray[fz][timesArray[fz].length]=zoneTimes[fz];
iTogoAmount +=calcProductAmount(iProd, cfz, currFeldPositions, zoneTimes[fz], true);
iTogoScore +=calcProductScore(iProd, cfz, currFeldPositions, zoneTimes[fz]);
iTogo++;
if(endTime < zoneTimes[fz]) endTime=zoneTimes[fz];
}
// GM_log("updateAMount:"+newRackAmount[iProd]);
}
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("timeArray",implode(timeArray,"updateQueueBox/timeArray"));
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("iTogoArray",implode(iTogoArray.sortObj(),"updateQueueBox/iTogoArray"));
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("timesArray",implode(timesArray.sortObj(),"updateQueueBox/timesArray"));
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("zoneBeginTime",implode(beginTime.sortObj(),"updateQueueBox/beginTime"));
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("zoneEndTime",implode(zoneTimes,"updateQueueBox/zoneTimes"));
timeArray=null;beginTime=null;timesArray=null;iTogoArray=null;
}else{
iTogoAmount=iTogo*calcProductAmount(iProd, zoneNrS);
iTogoScore=iTogo*calcProductScore(iProd, zoneNrS);
}
if(!fzWindmill && !iStop){
newRackAmount[iProd] +=iTogoAmount;
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("iTogo",iTogo);//Not in Mill needed
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("iTogoAmount",iTogoAmount);//Not in Mill needed
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("iTogoScore",iTogoScore);//Not in Mill needed
}
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("totalInQue",totalInQue);
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).setAttribute("foundStop",foundStop);
totalInQue +=iTogo;
// GM_log("updateQueueBox Box :" + zoneNrL + ":"+queueNum + " | 4");
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Item").style.opacity=(iTogo<=0 && !iStop)? 0.4:1;
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Item").setAttribute("product",iProd);
if(fzWindmill){
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Item").childNodes[0].className="fmm"+iProd;
}else if(fzForestry){
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Item").childNodes[0].className="f_symbol"+iProd;
}else{
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Item").className="link queueItemProduct v"+iProd;
}
// GM_log("updateQueueBox Box :" + zoneNrL + ":"+queueNum + " | 5");
$("divAutoMatQueueBox"+zoneNrL).style.width=($("divAutoMatQueueBox"+zoneNrL).parentNode==$("divQueueBoxInner"))?"348px":"530px";
$("divAutoMatQueueBox"+zoneNrL).style.height=row7+2+((settings.get("account","showQueueTime") && lShowTime)?queueItemBoxTimeHeight:0)+"px";
$("divAutoMatButton"+zoneNrL).style.height=row7+2+((settings.get("account","showQueueTime") && lShowTime)?queueItemBoxTimeHeight:0)+"px";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"I1").className=(iRackMode)?"queueItemInput1 queueItemInputWidth1":"queueItemInput1 queueItemInputWidth2";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"I1").value=(iTot==undefined)?1:iTot; //TODO remove setting val here
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"I1").style.display=(iLastInf || iStop)?"none":"block";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"I1").maxLength=(iRackMode)?"6":"4";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"I2").value=(iDone==undefined)?0:iDone; //TODO remove setting val here
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"I2").style.opacity=(iTogo<=0)? 0.4:1;
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"I2").style.display=(!iRackMode && (iRepeat || lRepeat) && !iStop)?"block":"none";
if(OPTION_ITEM_REPEAT){
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Mode").style.display=(!iRackMode && !iStop)?"block":"none";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Mode").style.backgroundImage="url("+(zoneList[zoneNrL][queueNum][4]?IMAGES["mode_repeat"]:IMAGES["mode_1time"])+")";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"IListRepeat").style.display=(!iRackMode && (iRepeat || lRepeat) && !iStop)?"block":"none";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"IListRepeat").value=(zoneList[zoneNrL][queueNum][5]==undefined)?REPEAT_NO_LIMIT:zoneList[zoneNrL][queueNum][5];
}
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"M").style.opacity=iTogo<=0? 0.4:1;
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"M").style.display=(iLastInf || iStop || iTot<=1) ?"none":"block";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"P").style.display=(iLastInf || iStop || (fzWindmill && autoMillStorage[iProd][0]<=autoMillStorage[iProd][1])) ?"none":"block";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"ET").innerHTML=(settings.get("account","showQueueTime") && lShowTime)?iLastInf?sign_inf:(getDateText(endTime,0) + "<br/>" + getDaytimeStr(endTime,true)):null;
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"ET").style.color=noTime? "#DD0000":"black";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"ET").style.display=(iTogo<=0 || foundStop || !settings.get("account","showQueueTime") || !lShowTime)?"none":"block";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"T").innerHTML=(iStop)?_TEXTE_STOP:sign_inf;
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"T").setAttribute("class",(iStop?"queueItemText queueItemTextStop":"queueItemText queueItemTextInf"));
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"T").style.display=(iLastInf || iStop)?"block":"none";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Up").style.display=(queueNum==0) ?"none":"block";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"Down").style.display=((zoneList[zoneNrL].length-1)==queueNum) ?"none":"block";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"A").style.top=((iRackMode))?row4+"px":"";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"D").style.left=(iRackMode)?col3+"px":"";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"D").style.display=(zoneList[zoneNrL].length > 1) ?"block":"none";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"B").style.display=(fzWindmill || iLastInf || iStop)?"none":"block";
$("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum+"B").style.backgroundImage="url("+(iRackMode?IMAGES["functionR"]:IMAGES["functionF"])+")";
// GM_log("updateQueueBox Box :" + zoneNrL + ":"+queueNum + " END");
}
// GM_log("updateQueueBox Box :" + zoneNrL + ":"+queueNum + " AFTER");
$("divAutoMatEndTime"+zoneNrL).style.display=(settings.get("account","showQueueTime"))?"block":"none";
if(settings.get("account","showQueueTime")){
$("divAutoMatEndTime"+zoneNrL).innerHTML=(!fRepeat && !lShuffle && !foundStop && !fzWindmill)? getText("automat_inftext"):(getText("automat_QueTimeReady") + (lShowTime?(((!foundStop && (lRepeat || iRepeat || noTime))?" ~ ":" ") + getDateText(endTime,0) + " "+ getDaytimeStr(endTime,true)):" ~ ")); // why +- (\u00B1)?
$("divAutoMatEndTime"+zoneNrL).style.color=(noTime?"#DD0000":((foundStop || fRepeat)?"#0000DD":"#000000"));
}
}
zoneTimes=null;
//ChooseBox part
err_trace="ChooseBox";
var divChooseEndTimeCurr = $("divChooseEndTime"+zoneNrL)
if(divChooseEndTimeCurr){
var zoneTimes=getZoneTimes(zoneNrL);
// GM_log("updateQueueBox chooseBox zoneNrS:" + zoneNrS + " zoneNrL:" + zoneNrL + " queueNum:" + queueNum );
var queueNum=divChooseEndTimeCurr.parentNode.getAttribute("queueNum");
var foundStop=false;
for(var i=0;i<=queueNum;i++){
if(foundStop=zoneList[zoneNrL][i][0]==PRODSTOP) break;
}
// GM_log("updateQueueBox chooseBox foundStop:" + foundStop + " lShowTime:"+lShowTime);
switch(fzType){
case 1:case 4:{ // fields
// GM_log("updateQueueBox chooseBox fields 1:" + zoneNrS);
if(settings.get("account","showQueueTime")){
if($("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum) && lShowTime){
var zoneBeginTime=explode($("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).getAttribute("zoneBeginTime"),"updateQueueBox/chooseBox/zoneBeginTime",{});
}else{
var zoneBeginTime=zoneTimes;
}
var fz=getLowestTimeFarmZone(zoneBeginTime);
var productTime=calcProductionTime(zoneList[zoneNrL][queueNum][0],fz);
divChooseEndTimeCurr.style.display=lShowTime?"block":"none";
divChooseEndTimeCurr.parentNode.setAttribute("zoneBeginTime",implode(zoneBeginTime,"updateQueueBox/chooseBox/zoneBeginTime"));
divChooseEndTimeCurr.style.color=noTime? "#DD0000":"black";
divChooseEndTimeCurr.innerHTML=(foundStop? getText("automat_QueDontWork"):(($("divChooseBoxInner")==divChooseEndTimeCurr.parentNode)?getText("automat_QueTimeFirstReady"):getText("automat_QueTimeReady")) + " " + getDateText(zoneBeginTime[fz]+productTime,0) + " "+ getDaytimeStr(zoneBeginTime[fz]+productTime,true));
}
// GM_log("updateQueueBox chooseBox fields 2:" + zoneNrS);
help=$("divChooseBoxInner").querySelectorAll(".link");
for(var i=help.length-1;i>=0;i--){
prod=parseInt(help[i].getAttribute("product"),10);
help[i].style.border=(zoneList[zoneNrL][queueNum][0]==prod?"2px solid black":"");
}
zoneBeginTime=null;fz=null;productTime=null;help=null;
break;}
case 2:{ // stable
if(settings.get("account","showQueueTime")){
divChooseEndTimeCurr.parentNode.setAttribute("zoneBeginTime",implode(zoneTimes,"updateQueueBox/chooseBox/zoneTimes"));
divChooseEndTimeCurr.style.display=lShowTime?"block":"none";
//for(var queueNum=0;queueNum<zoneList[zoneNrL].length;queueNum++){
for(var k=0;k<BUILDING2FEED[fzZoneType].length;k++){
var iProd=BUILDING2FEED[fzZoneType][k];
var queueNum=(zoneList[zoneNrL][0][0]==iProd?0:1);
if(!(unsafeData.prodBlock[0][iProd]&&unsafeData.prodBlock[0][iProd].match(/l/))){
$("divChooseFeedAmountSpan"+zoneNrL+"Q"+iProd+"I").innerHTML=zoneList[zoneNrL][queueNum][1];
var cand2=$("divChooseFeedAmount"+zoneNrL+"Q"+iProd+"I").getElementsByTagName("div");
for(var v=0;v<cand2.length;v++){
cand2[v].style.backgroundColor=(parseInt(cand2[v].getAttribute("value"),10)<=zoneList[zoneNrL][queueNum][1]?"blue":"");
}
cand2=null;
}
iProd=null;
}
if(lShowTime){
var iProd=unsafeData.BUILDING2PRODUCT[fzZoneType][0];
var duration=calcProductionTime(iProd,zoneNrS);
var endTime=zoneTimes[zoneNrS] + duration;
divChooseEndTimeCurr.style.color=noTime? "#DD0000":"black";
if(zoneList[zoneNrL][0][1]==PRODSTOP && zoneList[zoneNrL][1][1]==PRODSTOP){
divChooseEndTimeCurr.innerHTML=getText("automat_QueDontWork");
}else{
// divChooseEndTimeCurr.innerHTML=getText("automat_QueTimeReady") + " " + getDateText(endTime,0) + " "+ getDaytimeStr(endTime,true);
divChooseEndTimeCurr.innerHTML=getTimeStr(duration,true)+" "+getText("shortHours") + " " + getDateText(endTime,0) + " "+ getDaytimeStr(endTime,true);
}
}
}
break;}
case 3:{ // factory
$("divChooseItem"+zoneNrL+"Q"+queueNum+"I"+PRODSTOP).style.border=((zoneList[zoneNrL][queueNum][0]==PRODSTOP)?"2px solid black":"");
for(var v in unsafeData.BUILDING_INPUT[fzZoneType]){
if(!unsafeData.BUILDING_INPUT[fzZoneType].hasOwnProperty(v)){ continue; }
if(unsafeData.prodBlock[0][v]){ continue; }
$("divChooseItem"+zoneNrL+"Q"+queueNum+"I"+v).style.border=((zoneList[zoneNrL][queueNum][0]==v)?"2px solid black":"");
}
if(settings.get("account","showQueueTime")){
divChooseEndTimeCurr.parentNode.setAttribute("zoneBeginTime",implode(zoneTimes,"updateQueueBox/chooseBox/zoneTimes"));
divChooseEndTimeCurr.style.display=lShowTime?"block":"none";
if(lShowTime){
var fz=getLowestTimeFarmZone(zoneTimes);
var endTime=zoneTimes[fz] + calcProductionTime(zoneList[zoneNrL][queueNum][0],fz);
divChooseEndTimeCurr.style.color=noTime? "#DD0000":"black";
divChooseEndTimeCurr.innerHTML=(foundStop?getText("automat_QueDontWork"):(($("divChooseBoxInner")==divChooseEndTimeCurr.parentNode)?getText("automat_QueTimeFirstReady"):getText("automat_QueTimeReady")) + " " + getDateText(endTime,0) + " "+ getDaytimeStr(endTime,true));
fz=null;endTime=null;
}
}
zoneFeedCurr=null;zoneProdCurr=null;
break;}
case "windmill":{ // (fzWindmill)
if(settings.get("account","showQueueTime")){
divChooseEndTimeCurr.parentNode.setAttribute("zoneBeginTime",implode(zoneTimes,"updateQueueBox/chooseBox/zoneBeginTimes"));
divChooseEndTimeCurr.style.display=lShowTime?"block":"none";
if(lShowTime){
var endTime=zoneTimes[zoneNrS] + calcProductionTime(zoneList[zoneNrL][queueNum][0],zoneNrS);
divChooseEndTimeCurr.style.color=noTime? "#DD0000":"black";
divChooseEndTimeCurr.innerHTML=(foundStop? getText("automat_QueDontWork"):(($("divChooseBoxInner")==divChooseEndTimeCurr.parentNode)?getText("automat_QueTimeFirstReady"):getText("automat_QueTimeReady")) + " " + getDateText(endTime,0) + " "+ getDaytimeStr(endTime,true));
}
}
$("divChooseItem"+zoneNrL+"Q"+queueNum+"I"+PRODSTOP).style.border=(zoneList[zoneNrL][queueNum][0]==PRODSTOP?"2px solid black":"");
for(var iProd=0;iProd<autoMillStorage.length;iProd++){
if(!autoMillStorage.hasOwnProperty(iProd)){continue;}
if((autoMillStorage[iProd][0]-autoMillStorage[iProd][1])>0){
$("divChooseItem"+zoneNrL+"Q"+queueNum+"I"+iProd).style.border=(zoneList[zoneNrL][queueNum][0]==iProd)?"2px solid black":"";
}
}
iProd=null;endTime=null;
break;}
case "forest":case "sawmill":case "carpentry":{ // (fzForestry)
// GM_log("updateQueueBox chooseBox forestry :" + zoneNrS);
if(settings.get("account","showQueueTime")){
if($("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum) && lShowTime){
var zoneBeginTime=explode($("divAutoMatQueueItemBox"+zoneNrL+"Q"+queueNum).getAttribute("zoneBeginTime"),"updateQueueBox/chooseBox/zoneBeginTime",{});
}else{
var zoneBeginTime=zoneTimes;
}
var fz=getLowestTimeFarmZone(zoneBeginTime);
var productTime=calcProductionTime(zoneList[zoneNrL][queueNum][0],fz);
// GM_log("updateQueueBox chooseBox fields 1:" + zoneNrS + " queueNum:" + queueNum + " fz:" + fz + " productTime:" + productTime + " zoneTimes:" + implode(zoneBeginTime,"") + " uhr:" + zoneBeginTime[fz]+ ":" + typeof productTime);
divChooseEndTimeCurr.style.display=lShowTime?"block":"none";
divChooseEndTimeCurr.parentNode.setAttribute("zoneBeginTime",implode(zoneBeginTime,"updateQueueBox/chooseBox/zoneBeginTime"));
divChooseEndTimeCurr.style.color=noTime? "#DD0000":"black";
divChooseEndTimeCurr.innerHTML=(foundStop? getText("automat_QueDontWork"):(($("divChooseBoxInner")==divChooseEndTimeCurr.parentNode)?getText("automat_QueTimeFirstReady"):getText("automat_QueTimeReady")) + " " + getDateText(zoneBeginTime[fz]+productTime,0) + " "+ getDaytimeStr(zoneBeginTime[fz]+productTime,true));
}
// GM_log("updateQueueBox chooseBox fields 2:" + zoneNrS);
$("divChooseItem"+zoneNrL+"Q"+queueNum+"I"+PRODSTOP).style.border=(zoneList[zoneNrL][queueNum][0]==PRODSTOP?"2px solid black":"");
for(var iProd=0;iProd<unsafeData.prodName[1].length;iProd++){
if((unsafeData.prodTyp[1][iProd]=="v")&&!(unsafeData.prodBlock[1][iProd]&&unsafeData.prodBlock[1][iProd].match(/l/))){
$("divChooseItem"+zoneNrL+"Q"+queueNum+"I"+iProd).style.border=(zoneList[zoneNrL][queueNum][0]==iProd?"2px solid black":"");
}
}
zoneBeginTime=null;fz=null;productTime=null;
break;}
}
queueNum=null;zoneTimes=null;
}
divChooseEndTimeCurr=null;
if(DEVMODE_FUNCTION){ GM_log("End updateQueueBox :" + zoneNrS);}
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneSettings",implode(zoneSettings,"updateQueueBox/zoneSettings"));
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList", implode(zoneList,"updateQueueBox/zoneList"));
checkReadyZone();
}catch(err){GM_logError("updateQueueBox ("+err_trace+") zoneNrS="+zoneNrS+" zoneNrL="+zoneNrL+"\n"+err);}
}
function redrawQueueBox(zoneNrS, zoneNrL, appendTo){
if(DEVMODE_FUNCTION){ GM_log("Begin redrawQueueBox zoneNrS="+zoneNrS+" zoneNrL="+zoneNrL+" appendTo.id=" + appendTo.id);}
if(zoneNrL==undefined || zoneNrL==null) zoneNrL=getZoneListId(zoneNrS);
if($("divChooseBox").style.display=="block") click($("divChooseBoxClose"));
if($("divQueueBox").style.display=="block") click($("divQueueBoxClose"));
drawQueueBox(zoneNrS, zoneNrL, appendTo);
if(DEVMODE_FUNCTION){ GM_log("End redrawQueueBox"); }
}
function reFillQueueBox(zoneNrF, zoneNrL, scrollToQueue){
if(DEVMODE_FUNCTION){ GM_log("Begin reFillQueueBox zoneNrF="+zoneNrF+" zoneNrL="+zoneNrL+" scrollToQueue=" +scrollToQueue);}
if(zoneNrL==undefined || zoneNrL==null) zoneNrL=getZoneListId(zoneNrF);
// GM_log("Begin2 reFillQueueBox zoneNrF:"+ zoneNrF+" zoneNrL:"+ zoneNrL+" scrollToQueue:" + scrollToQueue);
if($("divAutoMatQueueBox"+zoneNrL)){
$("divAutoMatQueueBox"+zoneNrL).innerHTML="";
$("divAutoMatQueueBox"+zoneNrL).style.visibility="hidden";
for(queueNum=0;queueNum<zoneList[zoneNrL].length; queueNum++){
drawQueueItemBox(zoneNrF, zoneNrL, queueNum, $("divAutoMatQueueBox"+zoneNrL));
}
updateQueueBox(zoneNrF, zoneNrL);
$("divAutoMatQueueBox"+zoneNrL).style.visibility="visible";
var scrlelm=$("divAutoMatQueueBox"+zoneNrL);
if(scrollToQueue==undefined || scrollToQueue==null){
scrlelm.scrollLeft=0;
}else{
scrlelm.scrollLeft=Math.max(0,Math.min(scrlelm.scrollWidth,((scrollToQueue+2)*queueItemBoxWidth)) - scrlelm.clientWidth);
}
$("divAutoMatScrollLeft"+zoneNrL).style.display=((scrlelm.scrollWidth > scrlelm.clientWidth)?"block":"none");
$("divAutoMatScrollRight"+zoneNrL).style.display=((scrlelm.scrollWidth > scrlelm.clientWidth)?"block":"none");
$("divAutoMatScrollLeft"+zoneNrL).style.visibility=(scrlelm.scrollLeft>0?"visible":"hidden");
$("divAutoMatScrollRight"+zoneNrL).style.visibility=((scrlelm.scrollLeft + scrlelm.clientWidth)<scrlelm.scrollWidth?"visible":"hidden");
scrlelm=null;
}else if($("divAutomatIcon_"+zoneNrF)){
updateQueueBox(zoneNrF, zoneNrL);
}else{
GM_logWarning("reFillQueueBox zoneNrF="+zoneNrF+" zoneNrL="+zoneNrL+" scrollToQueue=" +scrollToQueue+"\nQueueBox not found");
}
if(DEVMODE_FUNCTION){ GM_log("End reFillQueueBox :"+zoneNrF);}
}
function toolTipProductSmall(zoneNrS, zoneNrL, queueNum, parent){
try{
var zoneNrF=zoneNrS.toString().replace(/\.\d+$/,"");
if(zoneNrL==undefined || zoneNrL==null){ zoneNrL=getZoneListId(zoneNrS); }
var fzType=getBuildingTyp(zoneNrF);
var isIcon=(parent.id.search("divAutomatIcon_")!=-1);
var isTimeLine=(parent.parentNode.id.indexOf("lineZone")==0);
var lZonesAmount=getZonesFromList(zoneNrL).length;
var lShowTime=(lZonesAmount > 0);
var fzWindmill=(fzType=="windmill");
var fzForestry=(fzType=="sawmill"||fzType=="carpentry"||fzType=="forest");
var fzPowerUp=(fzType=="powerup");//TODO powerup
var iType=(fzWindmill?3:(fzForestry?1:0));
var noTime=false;
// GM_log("toolTipProductSmall 0 zoneNrF:" + zoneNrF + " zoneNrL:" + zoneNrL + " queueNum:" + queueNum + " isIcon:" + isIcon +" fzType:"+ fzType + " zoneTyp:"+getZoneType(zoneNrF)+ " parent:"+parent.innerHTML);
if(isIcon){
if(fzType==2){
var iProd=(zoneList[zoneNrL][0][0]==PRODSTOP?PRODSTOP:unsafeData.BUILDING2PRODUCT[getZoneType(zoneNrF)][0]);
// }else if(fzType==3){
// var iProd=(zoneList[zoneNrL][0][0]==PRODSTOP?PRODSTOP:zoneList[zoneNrL][0][0]);
}else{
var iProd=zoneList[zoneNrL][0][0];
}
if(settings.get("account","showQueueTime")) var zoneBeginTime=explode(parent.getAttribute("zoneBeginTime"),"toopTipProductSmall/[0]/zoneBeginTime",{});
// GM_log(" fyldType:"+ fzType + " zoneTyp:"+getZoneType(zoneNrF) + " iProd:"+ iProd);
}else if(isTimeLine){
var iProd=parseInt(parent.getAttribute("iProd"),10); //unsafeData.BUILDING2PRODUCT[getZoneType(zoneNrF)];
if(settings.get("account","showQueueTime")){
var zoneBeginTime=new Array();
zoneBeginTime[zoneNrF]=parseFloat(parent.getAttribute("zoneBeginTime"));
}
}else if(fzType==2){ // stable
var iProd=unsafeData.BUILDING2PRODUCT[getZoneType(zoneNrL)][0]; // zoneNrF?
//parseInt(parent.getAttribute("class").replace("divChooseFeedIcon v",""),10);
if(settings.get("account","showQueueTime")) var zoneBeginTime=explode(parent.parentNode.parentNode.getAttribute("zoneBeginTime"),"zoneBeginTimeStable");
// }else if(fzType==3){ // factory
// var iProd=parseInt(parent.getAttribute("class").replace("divChooseItem link v",""),10);
// if(settings.get("account","showQueueTime")) var zoneBeginTime=explode(parent.parentNode.getAttribute("zoneBeginTime"),"zoneBeginTimeFactory");
}else if(fzWindmill){
var iProd=parseInt(parent.firstElementChild.getAttribute("class").replace("fmm",""),10); //TODO getAttribute("product")
if(settings.get("account","showQueueTime")) var zoneBeginTime=explode(parent.parentNode.getAttribute("zoneBeginTime"),"toopTipProductSmall/[2]/zoneBeginTime",{});
}else if(fzForestry){
var iProd=parseInt(parent.getAttribute("class").replace("divChooseItem link f_symbol",""),10);
if(settings.get("account","showQueueTime")) var zoneBeginTime=explode(parent.parentNode.getAttribute("zoneBeginTime"),"toopTipProductSmall/[5]/zoneBeginTime",{});
}else if(fzPowerUp){//parseInt(parent.getAttribute("class").replace("divChooseItem link r",""),10)>0){
var iProd=parseInt(parent.getAttribute("class").replace("divChooseItem link r",""),10);
if(settings.get("account","showQueueTime")) var zoneBeginTime=explode(parent.parentNode.getAttribute("zoneBeginTime"),"toopTipProductSmall/[3]/zoneBeginTime",{});
}else{ // Field, Factory
var iProd=parseInt(parent.getAttribute("class").replace("divChooseItem link v",""),10);
if(settings.get("account","showQueueTime")) var zoneBeginTime=explode(parent.parentNode.getAttribute("zoneBeginTime"),"toopTipProductSmall/[4]/zoneBeginTime",{});
}
var iStop=(iProd==PRODSTOP);
var foundStop=false;
for(var i=0;i<queueNum;i++){
if(foundStop=zoneList[zoneNrL][i][0]==PRODSTOP) break;
}
if(settings.get("account","showQueueTime") && !isTimeLine && lShowTime && !isIcon){ //this is to find the first field that is ready.
var fz=getLowestTimeFarmZone(zoneBeginTime);
}else{
var fz=zoneNrS;
}
var productTime;
if(!iStop){productTime=calcProductionTime(iProd,fz);}
var content=createElement("div");
var newrow,newdiv,newspan;
// GM_log("toolTipProductSmall fz:"+fz);
//TODO texte "Recipe"
createElement("div",{"class":"queueTitle"},content, fzPowerUp?"Recipe":getZoneName(0,zoneNrS,zoneNrL,(fzType!=1||isIcon)?null:queueNum,true,true,!isIcon||lZonesAmount==1,true));
// createElement("div",{style:"font-weight:bold;"},content,iStop?getText("automat_stop").toTitleCase():(fzWindmill?unsafeWindow.formulas[0][iProd][2]:(fzPowerUp?unsafeWindow.poweruprack[iProd][2]:unsafeData.prodName[iType][iProd])));
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
// GM_log("toolTipProductSmall 1 zoneNrF:" + zoneNrF + " zoneNrL:" + zoneNrL + " queueNum: " + queueNum + " zoneBeginTime:"+implode(zoneBeginTime,"")) ;
if(fzPowerUp){
//TODO add tooltip for recipes
}else{
if(iStop){
createElement("div",{style:""},content,getText("automat_stop").toTitleCase());
}else{
if(fzType!=2 || isIcon || isTimeLine){
newrow=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newrow, getText("automat_QueGives"));
newdiv=createElement("div",{"class":"tableTd2"},newrow);
produktPic(iType,iProd,newdiv);
createElement("span",{},newdiv, calcProductAmount(iProd, zoneNrL)+" " + unsafeData.prodName[iType][iProd]);
newdiv=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newdiv,"");
pointsFormat(calcProductScore(iProd, zoneNrL),"span",createElement("div",{"class":"tableTd2"},newdiv));
createElement("div",{"class":"tableSeperater"},content);createElement("div",{"class":"tableSeperater"},content);
newrow=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newrow,getText("automat_QueTimeThis"));
createElement("div",{"class":"tableTd2"},newrow, getTimeStr(productTime,true) + " " + getText("shortHours"));
}
// GM_log("End toolTipProductSmall 2 : " + zoneNrF + " : " + queueNum);
if(fzType==2 && (isIcon || isTimeLine)){
createElement("div",{"class":"tableSepBorder"},createElement("div",{"class":"tableSeperater"},content));
createElement("div",{"class":"tableSepBorder"},createElement("div",{"class":"tableSeperater"},content));
newrow=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newrow, getText("automat_QueUses"));
newdiv=createElement("div",{"class":"tableTd2"},newrow);
produktPic(iType,zoneList[zoneNrL][0][0],newdiv);
createElement("span",{},newdiv,zoneList[zoneNrL][0][1] + " " + unsafeData.prodName[iType][zoneList[zoneNrL][0][0]]);
if(zoneList[zoneNrL][1][1]>0){
newrow=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newrow,"");
newdiv=createElement("div",{"class":"tableTd2"},newrow);
produktPic(iType,zoneList[zoneNrL][1][0],newdiv);
createElement("span",{},newdiv, zoneList[zoneNrL][1][1] + " " + unsafeData.prodName[iType][zoneList[zoneNrL][1][0]]);
}
}else if(fzType==3){
createElement("div",{"class":"tableSepBorder"},createElement("div",{"class":"tableSeperater"},content));
createElement("div",{"class":"tableSepBorder"},createElement("div",{"class":"tableSeperater"},content));
for(var i=0;i<unsafeData.BUILDING_INPUT[getZoneType(zoneNrL)][iProd][0].length;i++){
newrow=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newrow,i==0?getText("automat_QueUses"):"");
newdiv=createElement("div",{"class":"tableTd2"},newrow);
produktPic(iType,unsafeData.BUILDING_INPUT[getZoneType(zoneNrL)][iProd][0][i][0],newdiv);
createElement("span",{},newdiv, numberFormat(unsafeData.BUILDING_INPUT[getZoneType(zoneNrL)][iProd][0][i][1]) + " " + unsafeData.prodName[0][unsafeData.BUILDING_INPUT[getZoneType(zoneNrL)][iProd][0][i][0]]);
}
}
}
if(fzType==2){
if(isIcon || isTimeLine){ createElement("div",{"class":"tableSeperater"},content);createElement("div",{"class":"tableSeperater"},content);}
newrow=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newrow, getText("automat_QueFutter"));
newdiv=createElement("div",{"class":"tableTd2"},newrow);
produktPic(iType,BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)][0],newdiv);
createElement("span",{},newdiv, getTimeStr(FEEDBONUSTIME[BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)][0]]/unsafeData.zones.getAnimals(zoneNrF)) + " " + unsafeData.prodName[0][BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)][0]]);
newrow=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newrow, "");
newdiv=createElement("div",{"class":"tableTd2"},newrow);
produktPic(0,BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)][1],newdiv);
createElement("span",{},newdiv, getTimeStr(FEEDBONUSTIME[BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)][1]]/unsafeData.zones.getAnimals(zoneNrF)) + " " + unsafeData.prodName[0][BUILDING2FEED[unsafeData.zones.getBuilding(zoneNrF)][1]]);
}
if(settings.get("account","showQueueTime") && !isTimeLine && lShowTime && (!iStop || foundStop)){
if(lZonesAmount > 1 || fzType=="sawmill"){
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
createElement("div",{style:"display:block"},content,queueNum==0?getText("automat_QueTimeNextReady"):getText("automat_QueTimeFirstReady"));//getText("automat_usedFarmFieldsReadyAt"));
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:1px;border-bottom:1px dashed black;"},content);
// GM_log ("toolTipProductSmall zoneArray:" + print_r(zoneArray));
for(var fz in zoneBeginTime){
if(!zoneBeginTime.hasOwnProperty(fz)){ continue; }
var cfz=getBuildingTyp(fz);//TODO cfz name change
// GM_log("toolTipProductSmall Title :" + gardenNr + "/" + fz);
newrow=createElement("div",{style:"display:table-row;white-space:nowrap;"+(fz!=zoneNrF&&isIcon?"color:#505050;":"")},content);
createElement("div",{"style":"display:table-cell;"},newrow,getZoneName(0,fz,fz,null,false,true,true,false));
createElement("div",{"style":"display:table-cell;padding:0px 2px;"},newrow, "->");
createElement("div",{"style":"display:table-cell;padding:0px 3px;font-weight:bold;"},newrow, getDateText(Math.max(now,zoneBeginTime[fz])+calcProductionTime(iProd,fz),0).toLowerCase());
createElement("div",{"style":"display:table-cell;padding:0px 3px;"},newrow, getDaytimeStr(Math.max(now,zoneBeginTime[fz])+calcProductionTime(iProd,fz),true));
}
}else{
createElement("div",{"class":"tableSepBorder"},createElement("div",{"class":"tableSeperater"},content));createElement("div",{"class":"tableSepBorder"},createElement("div",{"class":"tableSeperater"},content));
newrow=createElement("div",{style:"display:table-row;width:100%;"},content);
createElement("div",{"class":"tableTd1"},newrow,queueNum==0?getText("automat_QueTimeNextReady"):getText("automat_QueTimeFirstReady"));//getText("automat_usedFarmFieldsReadyAt"));
createElement("div",{"class":"tableTd2"},newrow, "<b>"+getDateText(Math.max(now,zoneBeginTime[fz])+productTime,0).toLowerCase()+"</b> "+getDaytimeStr(Math.max(now,zoneBeginTime[fz])+productTime,true));
}
}
if(iStop){
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
createElement("div",{style:""},content,fzWindmill?getText("automat_MillStop0"):(fzType==1?getText("automat_QueStop0"):getText("automat_QueDontWork")));
}else if(foundStop){
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
createElement("div",{style:""},content,fzWindmill?getText("automat_MillStoped"):getText("automat_QueueStoped"));
}else{
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
createElement("div",{style:""},content,fzWindmill?getText("automat_MillDoWork"):getText("automat_QueDoWork"));
}
}
var thisTitle=content.innerHTML;
content=null;fz=null;zoneBeginTime=null;newrow=null;newdiv=null;productTime=null;
//%PRODNAME%=iProd name
thisTitle=thisTitle.replace(/%PRODNAME%/gi, unsafeData.prodName[0][iProd]);
// GM_log("End toolTipProductSmall : " + zoneNrF + " : " + queueNum);
return thisTitle;
}catch(err){GM_logError("toolTipProductSmall\nzoneNrF="+zoneNrF+" zoneNrL="+zoneNrL+" queueNum="+queueNum+" parent.id="+parent.id+"\n"+err);return "Error. See console.";}
}
function toolTipMain(zoneNrF, zoneNrL, queueNum, parent){
if(zoneNrF=="windmill"){
return toolTipRecipe(zoneNrF, zoneNrL, queueNum, parent);
}else if(zoneNrF=="sawmill"||zoneNrF=="carpentry"||zoneNrF=="forest"){
return toolTipProduct(zoneNrF, zoneNrL, queueNum, parent);
}else{
return toolTipProduct(zoneNrF, zoneNrL, queueNum, parent);
}
}
function toolTipProduct(zoneNrF, zoneNrL, queueNum, parent){
try{
if(zoneNrL==undefined || zoneNrL==null) zoneNrL=getZoneListId(zoneNrF);
// GM_log("Begin toolTipProduct zoneNrF="+zoneNrF+" zoneNrL="+zoneNrL+" queueNum="+queueNum+" parent.id="+parent.id);
var totalInQue=parseInt(parent.getAttribute("totalInQue"),10);
var foundStop=parent.getAttribute("foundStop")=="true";
var lRepeat=(!OPTION_LIST_REPEAT || zoneSettings[zoneNrL]["repeat"]==undefined)?false:zoneSettings[zoneNrL]["repeat"];
var lShuffle=zoneSettings[zoneNrL]["shuffle"]==undefined?false:zoneSettings[zoneNrL]["shuffle"];
var iRepeat=(!OPTION_ITEM_REPEAT)?false:zoneList[zoneNrL][queueNum][4];
var iLastInf=((zoneList[zoneNrL].length-1)==queueNum) && !(lRepeat || iRepeat) && !lShuffle;
var iRackMode=zoneNrL!="windmill" && zoneList[zoneNrL][queueNum][3];
var iProd=parseInt(zoneList[zoneNrL][queueNum][0],10);
var iTot=parseInt(zoneList[zoneNrL][queueNum][1],10);
var iDone=iRackMode?0:parseInt(zoneList[zoneNrL][queueNum][2],10);
var iStop=(iProd==PRODSTOP);
var lShowTime=getZonesFromList(zoneNrL).length > 0;
var fzType=getBuildingTyp(zoneNrF);
var fzWindmill=(fzType=="windmill");
var fzPowerUp=(fzType=="powerup");//TODO powerup
var fzForestry=(fzType=="sawmill"||fzType=="carpentry"||fzType=="forest");
var iType=(fzWindmill?2:(fzForestry?1:0));
// GM_log("toolTipProductSmall fzType:"+fzType);
if(settings.get("account","showQueueTime") && lShowTime){
var iTogoArray=explode(parent.getAttribute("iTogoArray"),"toolTipProduct/iTogoArray",{});
var timeArray=explode(parent.getAttribute("timeArray"),"toolTipProduct/timeArray",{});
var timesArray=explode(parent.getAttribute("timesArray"),"toolTipProduct/timesArray",{});
var zoneBeginTime=explode(parent.getAttribute("zoneBeginTime"),"toolTipProduct/zoneBeginTime",{});
var zoneEndTime=explode(parent.getAttribute("zoneEndTime"),"toolTipProduct/zoneEndTime",{});
var equalTimeArray=timeArray.allEqual();
}
var iTogo=parseInt(parent.getAttribute("iTogo"),10);
var iTogoAmount=parseInt(parent.getAttribute("iTogoAmount"),10);
var iTogoScore=parseInt(parent.getAttribute("iTogoScore"),10);
var iDoneAmount=calcProductAmount(iProd, zoneNrF, null, null, true) * iDone;
var iDoneScore=calcProductScore(iProd, zoneNrF, null, null) * iDone;
var content=createElement("div");
createElement("div",{"class":"queueTitle"},content,iRackMode?getText("automat_QueRackMode"):(((lRepeat || iRepeat) && lShuffle)?getText("automat_QueRepeatShuffle"):(lShuffle?getText("automat_QueShuffle"):((lRepeat || iRepeat)?getText("automat_QueRepeat"):(iTot<=1?getText("automat_QueFieldInRow1"):getText("automat_QueFieldInRowX"))))));
createElement("div",{style:"font-weight:bold;"},content,(iStop)?getText("automat_stop").toTitleCase():(fzWindmill)?unsafeWindow.formulas[0][iProd][2]:(fzPowerUp)?unsafeWindow.poweruprack[iProd][2]:unsafeData.prodName[iType][iProd]);
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
if(iStop){
createElement("div",{style:""},content,(totalInQue==0)?getText("automat_QueStop0"):(totalInQue==1)? getText("automat_QueStop1"):getText("automat_QueStopX"));
}else{
if((lRepeat || iRepeat || lShuffle || iRackMode) && iTogo<=0){//iTot<=iDone){
var newspan=createElement("div",{style:"display:block"},content,((iRackMode && !(lRepeat || iRepeat) && !lShuffle)?getText("automat_QueRoundDoneR"):(iDone<=1?getText("automat_QueRoundDone1"):getText("automat_QueRoundDoneX"))));
}else{ //normal
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("yield"));
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("points"));
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_fields")); //TODO texte -> "fields" much be "zone" for isNaN(zoneNrF)
if(!extendedListReg.test(zoneNrL)){
if(!iRackMode){ //TOTAL
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,(lRepeat || iRepeat || lShuffle ?getText("automat_QueRoundMake"):getText("automat_QueFieldMake")));
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, (equalTimeArray?"":" ~ ") + (iLastInf?sign_inf:numberFormat(iTogoAmount+iDoneAmount)+sign_mult));
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, (equalTimeArray?"":" ~ ") + (iLastInf?sign_inf:numberFormat(iTogoScore+iDoneScore)));
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, (iLastInf?sign_inf:numberFormat(iTot)));
if((lRepeat || iRepeat || lShuffle) && iDone>0){ //DONE
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_QueRoundMade"));
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, (equalTimeArray?"":" ~ ") + numberFormat(iDoneAmount)+sign_mult);
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, (equalTimeArray?"":" ~ ") + numberFormat(iDoneScore));
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, iDone);
}
}
}
if(iTogo>0){//TOGO
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan, (lRepeat || iRepeat || lShuffle ?getText("automat_QueRoundToGo"):getText("automat_QueFieldToGo")));
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, (settings.get("account","showQueueTime")?"":" ~ ") + (iLastInf?sign_inf:numberFormat(iTogoAmount)+sign_mult));
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, (settings.get("account","showQueueTime")?"":" ~ ") + (iLastInf?sign_inf:numberFormat(iTogoScore)));
createElement("div",{style:"display:table-cell;padding-right:10px;text-align:right;"},newspan, (iLastInf?sign_inf:numberFormat(iTogo)));
}
}
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
// GM_log("toolTipProduct Title :" + zoneNrF + ": 1");
if(foundStop){
createElement("div",{"style":""},content,getText("automat_QueueStoped"));
}else if(settings.get("account","showQueueTime") && lShowTime && (iTogo>0)){
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_QueTimeThis"));
//createElement("div",{style:"display:table-cell;"},newspan, getTimeStr(timeArray[zoneNrF],true) + " " + getText("shortHours"));
createElement("div",{style:"display:table-cell;"},newspan, (equalTimeArray?"":" ~ ") + getTimeStr(timeArray.average(),true) + " " + getText("shortHours"));
if((lRepeat || iRepeat || lShuffle)&& !iLastInf){
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_QueTimeRound"));
//createElement("div",{style:"display:table-cell;"},newspan, getTimeStr(timeArray[zoneNrF]*Math.max(iTogo+iDone,0),true) + " " + getText("shortHours"));
createElement("div",{style:"display:table-cell;"},newspan, (equalTimeArray?"":" ~ ") + getTimeStr(timeArray.averageFieldTime(Math.max(iTogo+iDone,1)),true) + " " + getText("shortHours"));
}
//GM_log("toolTipProduct Title :" + zoneNrF + ": 2");
if(iTogo>0){
if(!iLastInf){
var beginTime=zoneBeginTime[getLowestTimeFarmZone(zoneBeginTime)];
var endTime=zoneEndTime[getHighestTimeFarmZone(zoneEndTime)];
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_QueTimeToGo"));
createElement("div",{style:"display:table-cell;"},newspan, getTimeStr(endTime - beginTime,true) + " " + getText("shortHours"));
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_QueTimeReady"));
createElement("div",{style:"display:table-cell;"},newspan, getDateText(endTime,0).toLowerCase() + " " + getDaytimeStr(endTime,true));
beginTime=null;endTime=null;
}
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:1px;border-bottom:1px solid black;"},content);
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan);
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("automat_number"));
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("total"));
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("automat_lack"));
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("product"));
var help;
for(var i in unsafeData.prodRequire[iType][iProd]){
if(!unsafeData.prodRequire[iType][iProd].hasOwnProperty(i)){continue;}
help=unsafeData.prodRequire[iType][iProd][i].clone();
var newspan=createElement("div",{style:"display:table-row;"},content);
if(help[0]<0){
createElement("div",{style:"display:table-cell;"},newspan);
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, numberFormat(help[1]));
help[1]*=iTot;
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, numberFormat(help[1]));
help[1]-=unsafeData.money;
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, help[1]>0?numberFormat(help[1]):"");
createElement("div",{style:"display:table-cell;padding-left:8px;"},newspan,getText("gamecurrency"));
}else{
produktPic(help[0],help[1],newspan);
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, numberFormat(help[2]));
help[2]*=iTot;
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, numberFormat(help[2]));
help[2]-=unsafeData.prodStock[help[0]][help[1]];
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, help[2]>0?numberFormat(help[2]):"");
createElement("div",{style:"display:table-cell;padding-left:8px;"},newspan,unsafeData.prodName[help[0]][help[1]]);
}
}
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:1px;border-bottom:1px solid black;"},content);
createElement("div",{style:"display:block"},content,getText("automat_usedFarmFieldsReadyAt"));
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:1px;border-bottom:1px dashed black;"},content);
var timesCount=0;
for(var fz in timesArray){
if(!timesArray.hasOwnProperty(fz)){ continue; }
timesCount=Math.max(timesArray[fz].length,timesCount);
}
for(var fz in timesArray){
if(!timesArray.hasOwnProperty(fz)){ continue; }
// GM_log("toolTipProduct Title :" + zoneNrF + "/" + fz);
var newspan=createElement("div",{style:"display:table-row;white-space:nowrap;"},content);
if(lShowTime){
createElement("div",{style:"display:table-cell;"},newspan, getZoneName(0,fz,fz,null,false,true,true,false)); //Math.ceil(fz/6) + "." + getGarden(fz));
createElement("div",{style:"display:table-cell;padding:0px 2px;"},newspan, "->");
createElement("div",{style:"display:table-cell;text-align:right;"},newspan, iTogoArray[fz]);
createElement("div",{style:"display:table-cell;text-align:right;padding:0px 3px;"},newspan, sign_mult);
createElement("div",{style:"display:table-cell;padding:0px 2px;"},newspan,getTimeStr(timeArray[fz],true) + " " + getText("shortHours"));
createElement("div",{style:"display:table-cell;padding:0px 2px;"},newspan, "->");
}
for(k=0;k < Math.min(10,timesCount-1);k++){
createElement("div",{style:"display:table-cell;padding:0px 3px;"},newspan, (k<(timesArray[fz].length-1))?(k==0&&queueNum>0?"<b>"+getDateText(timesArray[fz][k],0)+"</b> ":"")+getDaytimeStr(timesArray[fz][k],true):" ");
}
if(timesCount>=11) createElement("div",{style:"display:table-cell;padding:0px 2px;"},newspan, timesArray[fz].length>=11?" .... ":"");
if(!iLastInf){
createElement("div",{style:"display:table-cell;padding:0px 3px;"},newspan, "<b>"+getDateText(zoneEndTime[fz],0) + "</b> " + getDaytimeStr(zoneEndTime[fz],true));
}else{
createElement("div",{style:"display:table-cell;padding:0px 3px;"},newspan, sign_inf);
}
}
timesArray=null;fz=null;k=null;
}
}
}
var thisTitle=content.innerHTML;
content=null;newspan=null;timeArray=null;zoneBeginTime=null;zoneEndTime=null;timesArray=null;
//%PRODNAME%=product name, %FLDFROM%=field nr from, %FLDTO%=field nr until,
thisTitle=thisTitle.replace(/%PRODNAME%/gi, unsafeData.prodName[iType][iProd]);
thisTitle=thisTitle.replace(/%FLDFROM%/gi, totalInQue + (iProd==PRODSTOP?0:1));
thisTitle=thisTitle.replace(/%FLDTO%/gi, iLastInf?sign_inf:(totalInQue+iTot));
// GM_log("End toolTipProduct :" + zoneNrF + " : " + queueNum);
return thisTitle;
}catch(err){GM_logError("toolTipProduct \n"+err);return "Error. See console.";}
}
function toolTipRecipe(zoneNrF, zoneNrL, queueNum, parent){
try{
// GM_log("Begin toolTipRecipe :" + zoneNrF + " : " + queueNum);
if(zoneNrL==undefined || zoneNrL==null) zoneNrL=getZoneListId(zoneNrF);
var totalInQue=parseInt(parent.getAttribute("totalInQue"),10);
var foundStop=parent.getAttribute("foundStop")=="true";
var lRepeat=(!OPTION_LIST_REPEAT || zoneSettings[zoneNrL]["repeat"]==undefined)?false:zoneSettings[zoneNrL]["repeat"];
var lShuffle=zoneSettings[zoneNrL]["shuffle"]==undefined?false:zoneSettings[zoneNrL]["shuffle"];
var iProd=parseInt(zoneList[zoneNrL][queueNum][0],10);
var iTot=parseInt(zoneList[zoneNrL][queueNum][1],10);
var iDone=parseInt(zoneList[zoneNrL][queueNum][2],10);
var iStop=(iProd==PRODSTOP);
var lShowTime=getZonesFromList(zoneNrL).length > 0;
if(settings.get("account","showQueueTime") && lShowTime){
var timeArray=explode(parent.getAttribute("timeArray"),"toolTipRecipe/timeArray",false);
var timesArray=explode(parent.getAttribute("timesArray"),"toolTipRecipe/timesArray",false);
var zoneBeginTime=explode(parent.getAttribute("zoneBeginTime"),"toolTipRecipe/zoneBeginTime",false);
var zoneEndTime=explode(parent.getAttribute("zoneEndTime"),"toolTipRecipe/zoneEndTime",false);
}
var content=createElement("div");
createElement("div",{"class":"queueTitle"},content,(zoneSettings[zoneNrL]["shuffle"]?getText("automat_MillShuffle"):(iTot<=1?getText("automat_MillInRow1"):getText("automat_MillInRowX"))));
createElement("div",{style:"font-weight:bold;"},content,(iStop?getText("automat_stop").toTitleCase():unsafeWindow.formulas[0][iProd][2]));
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
//item title info creation
if(iStop){
createElement("div",{style:""},content,(totalInQue==0)?getText("automat_MillStop0"):(totalInQue==1)? getText("automat_MillStop1"):getText("automat_MillStopX"));
}else{
if(unsafeWindow.formulas[0][iProd]){
var info=unsafeWindow.formulas[0][iProd];
if(settings.get("account","showQueueTime") && lShowTime){
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_MillTimeThis"));
createElement("div",{style:"display:table-cell;"},newspan,getTimeStr(timeArray["windmill"],true) + " " + getText("shortHours"));
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_MillTimeTotal"));
createElement("div",{style:"display:table-cell;"},newspan,getTimeStr(timeArray["windmill"]*Math.max(iTot,0),true) + " " + getText("shortHours"));
if(!foundStop){
var beginTime=zoneBeginTime[getLowestTimeFarmZone(zoneBeginTime)]; //not used !?
var endTime=zoneEndTime[getHighestTimeFarmZone(zoneEndTime)]; //not used !?
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_MillTimeReady"));
createElement("div",{style:"display:table-cell;"},newspan,getDateText(zoneEndTime[zoneNrF],0).toLowerCase() + " " + getDaytimeStr(zoneEndTime[zoneNrF],true));
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:1px;border-bottom:1px solid black;"},content);
}
}
for( var bonus=0;bonus<info[5].length;bonus++){if(!!info[5][bonus]) break;}
if(bonus!=undefined){
var newspan=createElement("div");
createElement("div",{"class":"kp"+info[5][bonus][0],style:"float:left;"},newspan);
createElement("div",{style:"float:left; margin-left:5px; width:250px;"},newspan,getText("automat_MillPowerUpText_"+bonus));
createElement("div",{style:"clear:both;"},newspan);
newspan.innerHTML=newspan.innerHTML.replace("%PRODUCT%",unsafeData.prodName[0][info[5][bonus][0]]);
newspan.innerHTML=newspan.innerHTML.replace("%AMOUNT%",info[5][bonus][1] * iTot);
newspan.innerHTML=newspan.innerHTML.replace("%TIME%", getTimeStr(info[5][bonus][2])); //bonus=0
newspan.innerHTML=newspan.innerHTML.replace("%CROP%",'+' + info[5][bonus][1]); //bonus=1
newspan.innerHTML=newspan.innerHTML.replace("%POINTS%",'+' + info[5][bonus][1]); //bonus=2
var newspan=createElement("div",{style:"margin:2px 0px 2px 0px;"},content, newspan.innerHTML);
}
var newspan=createElement("div",{style:"margin:2px 0px 2px 0px;"},content);
createElement("img",{src:GFX+"points.gif",style:"float:left;display:block;margin:0px 2px 0px 1px;width:12px;"},newspan);
createElement("div",{style:"float:left; margin-left:5px;"},newspan,numberFormat(info[8] * iTot) + " " + getText("points"));
createElement("div",{style:"clear:both;"},newspan);
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:1px;border-bottom:1px solid black;"},content);
createElement("div","",content,getText("automat_MillIngredients"));
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:1px;border-bottom:1px dotted black;"},content);
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan);
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("automat_number"));
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("total"));
if(zoneList[zoneNrL][queueNum][3]<0){
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("automat_lack"));
//createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("total") + " " + getText("automat_lack"));
}
createElement("div",{style:"display:table-cell;padding-left:5px;"},newspan,getText("product"));
for(var j=0;j<info[3].length;j++){
if(info[3][j]){
var newspan=createElement("div",{style:"display:table-row;"},content);
//image
createElement("div",{"class":"kp"+info[3][j][0], style:"float:left;"},newspan);
//reciep product number
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, numberFormat(info[3][j][1]) + sign_mult);
//reciep product number total autolist
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, numberFormat(iTot * info[3][j][1]) + sign_mult);
//reciep product number missing total autolist
if(zoneList[zoneNrL][queueNum][4][j]<0){
//createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, numberFormat(iTot * info[3][j][1]) + sign_mult);
createElement("div",{style:"display:table-cell;padding-left:8px;text-align:right;"},newspan, numberFormat(Math.abs(zoneList[zoneNrL][queueNum][4][j])) + sign_mult);
}else if(zoneList[zoneNrL][queueNum][3]<0){ //somewhere else there is a shortage: show empty td
//createElement("div",{style:"display:table-cell;padding-left:8px;"},newspan);
createElement("div",{style:"display:table-cell;padding-left:8px;"},newspan);
}
//name
createElement("div",{style:"display:table-cell;padding-left:8px;"},newspan,unsafeData.prodName[0][info[3][j][0]]);
}
}
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:1px;border-bottom:1px solid black;"},content);
var newspan=createElement("div",{style:"display:table-row;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_MillRecipesBought"));
createElement("div",{style:"display:table-cell;"},newspan,numberFormat(autoMillStorage[iProd][0]));
var newspan=createElement("div",{style:"display:table-row;text-align:left;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_MillRecipesUsed"));
createElement("div",{style:"display:table-cell;"},newspan,numberFormat(autoMillStorage[iProd][1]));
var newspan=createElement("div",{style:"display:table-row;text-align:left;"},content);
createElement("div",{style:"display:table-cell;padding-right:10px;"},newspan,getText("automat_MillRecipesBake"));
createElement("div",{style:"display:table-cell;"},newspan,numberFormat(autoMillStorage[iProd][2]));
if(settings.get("account","showQueueTime") && !foundStop && lShowTime){
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:1px;border-bottom:1px solid black;"},content);
createElement("div",{style:"display:block"},content,getText("automat_usedFarmFieldsReadyAt"));
createElement("div",{style:"margin:2px 0px 2px 0px;width:100%;height:1px;border-bottom:1px dashed black;"},content);
var timesCount=0;
for(var fz in timesArray){
if(!timesArray.hasOwnProperty(fz)){ continue; }
timesCount=Math.max(timesArray[fz].length,timesCount);
}
for(var fz in timesArray){
if(!timesArray.hasOwnProperty(fz)){ continue; }
// GM_log("updateQueueBox Title :" + gardenNr + "/" + fz);
var newspan=createElement("div",{style:"display:table-row;white-space:nowrap;"},content);
for(k=0;k < Math.min(10,timesCount-1);k++){
createElement("div",{style:"display:table-cell;padding:0px 3px;"},newspan, (k<(timesArray[fz].length-1))?(k==0?"<b>"+getDateText(timesArray[fz][k],0)+"</b> ":"")+getDaytimeStr(timesArray[fz][k],true):" ");
}
if(timesCount>=11) createElement("div",{style:"display:table-cell;padding:0px 2px;"},newspan, timesArray[fz].length>=11?" .... ":"");
createElement("div",{style:"display:table-cell;padding:0px 3px;"},newspan, "<b>"+getDateText(zoneEndTime[fz],0) + "</b> " + getDaytimeStr(zoneEndTime[fz],true));
}
timesArray=null;fz=null;k=null;
}
info=null;
}
if(foundStop){
createElement("div",{style:"margin:4px 0px 4px 0px;width:100%;height:1px;border-bottom:1px solid black;"},content);
createElement("div",{style:""},content,getText("automat_MillStoped"));
}
}
var thisTitle=content.innerHTML;
content=null;newspan=null;timeArray=null;zoneBeginTime=null;zoneEndTime=null;
// GM_log("toolTipRecipe Box :"+queueNum + " | 2");
thisTitle=thisTitle.replace(/%PRODNAME%/gi, (iProd==PRODSTOP?getText("automat_stop"):unsafeWindow.formulas[0][iProd][2]));
thisTitle=thisTitle.replace(/%FLDFROM%/gi, totalInQue + (iProd==PRODSTOP?0:1));
thisTitle=thisTitle.replace(/%FLDTO%/gi, totalInQue + iTot);
// GM_log("End toolTipRecipe :" + zoneNrF + " : " + queueNum);
return thisTitle;
}catch(err){GM_logError("toolTipRecipe \n"+err);return "Error. See console.";}
}
function setNextQueueItem(zoneNrS){
try{
if(DEVMODE){
GM_log("setNextQueueItem zoneNrS="+zoneNrS);
logBubble.add("Setting next queue item ("+zoneNrS+")");
}
var zoneNrL=getZoneListId(zoneNrS);
if(isNaN(zoneList[zoneNrL][0][1])){ zoneList[zoneNrL][0]=DEFAULT_ZONELIST_ITEM.clone(); }
if(isNaN(zoneList[zoneNrL][0][2])){ zoneList[zoneNrL][0][2]=0; }
if((settings.get("account","useQueueList")||isNaN(zoneNrS)) && (zoneList[zoneNrL][0][0]!=PRODSTOP) && (!zoneList[zoneNrL][0][3])){
if((OPTION_LIST_REPEAT && (zoneSettings[zoneNrL]["repeat"]))||(OPTION_ITEM_REPEAT && (zoneList[zoneNrL][0][4]))){
zoneList[zoneNrL][0][2]++;
}else{
zoneList[zoneNrL][0][1]--;
}
}
reSortQueue(zoneNrS, true); //->reFillQueueBox
if(DEVMODE){GM_log("End setNextQueueItem :" + zoneNrS);}
return zoneList[zoneNrL][0];
}catch(err){ GM_logError("setNextQueueItem zoneNrS="+zoneNrS+"\n"+err);return DEFAULT_ZONELIST_ITEM.clone(); }
}
function reSortQueue(zoneNrF, nextItemMode){
try{
if(DEVMODE){
GM_log("reSortQueue "+zoneNrF);
logBubble.add("reSort queue items ("+zoneNrF+")");
}
var itemsRackDone=0,itemsRepeatDone=0,itemsStopsFound=0,iDoRack=false;
var zoneNrL=getZoneListId(zoneNrF);
if((settings.get("account","useQueueList")||isNaN(zoneNrF)) && (zoneList[zoneNrL][0][0]!=PRODSTOP) && (nextItemMode || (((zoneList[zoneNrL][0][3] && calcInGameProductAmount(zoneList[zoneNrL][0][0],zoneNrF,null,true) < zoneList[zoneNrL][0][1]) || (!zoneList[zoneNrL][0][3] && zoneList[zoneNrL][0][1]<=((OPTION_ITEM_REPEAT && zoneList[zoneNrL][0][4])||(OPTION_LIST_REPEAT&&zoneSettings[zoneNrL]["repeat"])?zoneList[zoneNrL][0][2]:0))) ))){
// && (getBuildingTyp(zoneNrF)==1||isNaN(zoneNrF))
// GM_log("auto plant volgende " + zoneList[zoneNrL][0][0]);
for(i=0;i<zoneList[zoneNrL].length;i++){
if(zoneList[zoneNrL][i][0]==PRODSTOP){
itemsStopsFound++;
}else if(zoneList[zoneNrL][i][3]){
if(calcInGameProductAmount(zoneList[zoneNrL][i][0],zoneNrF,null,true) > zoneList[zoneNrL][i][1]){
itemsRackDone++;
}
// }else if((zoneList[zoneNrL][i][5]!=REPEAT_NO_LIMIT && zoneList[zoneNrL][i][5]<=(REPEAT_RESTART+(zoneList[zoneNrL][i][1]<=zoneList[zoneNrL][i][2]?1:0)) && OPTION_ITEM_REPEAT && zoneList[zoneNrL][i][4])||(OPTION_LIST_REPEAT && zoneSettings[zoneNrL]["repeat"]&& zoneList[zoneNrL][i][1]<=zoneList[zoneNrL][i][2])){
// }else if((zoneList[zoneNrL][i][5]!=REPEAT_NO_LIMIT && zoneList[zoneNrL][i][5]<=(REPEAT_RESTART+(zoneList[zoneNrL][i][1]<=zoneList[zoneNrL][i][2]?1:0)) && OPTION_ITEM_REPEAT && zoneList[zoneNrL][i][4])||(((OPTION_LIST_REPEAT && zoneSettings[zoneNrL]["repeat"])||(zoneList[zoneNrL][i][5]==REPEAT_NO_LIMIT)) && zoneList[zoneNrL][i][1]<=zoneList[zoneNrL][i][2])){
}else if((zoneList[zoneNrL][i][1]<=zoneList[zoneNrL][i][2] && OPTION_ITEM_REPEAT && zoneList[zoneNrL][i][4])||(OPTION_LIST_REPEAT && zoneSettings[zoneNrL]["repeat"] && zoneList[zoneNrL][i][1]<=zoneList[zoneNrL][i][2])){
itemsRepeatDone++;
}
}
//if(DEVMODE) GM_log("reSortQueue itemsRackDone:"+itemsRackDone+" itemsRepeatDone:"+itemsRepeatDone+" itemsStopsFound:"+itemsStopsFound+" length:"+zoneList[zoneNrL].length);
if(zoneList[zoneNrL].length==itemsRackDone){
//if(DEVMODE){GM_log("reSortQueue "+zoneNrF+":4");}
//if(DEVMODE) GM_log("Added PRODSTOP zoneNrL:"+zoneNrL + " itemsRackDone:"+itemsRackDone+" : "+ typeof itemsRackDone);
zoneList[zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
}else if(zoneList[zoneNrL].length==1 && 1==itemsRepeatDone && zoneList[zoneNrL][0][5]<=REPEAT_RESTART && zoneList[zoneNrL][0][5]!=REPEAT_NO_LIMIT){
zoneList[zoneNrL][0]=DEFAULT_ZONELIST_ITEM.clone();
}else if(zoneSettings[zoneNrL]["shuffle"] && zoneList[zoneNrL].length==(itemsRepeatDone+itemsRackDone+itemsStopsFound)){
for(queueNum=0;queueNum<zoneList[zoneNrL].length;queueNum++){
if(OPTION_ITEM_REPEAT && zoneList[zoneNrL][0][4] && zoneList[zoneNrL][0][1]<=zoneList[zoneNrL][0][2] && zoneList[zoneNrL][0][5]!=REPEAT_NO_LIMIT){
zoneList[zoneNrL][0][5]--;
}
zoneList[zoneNrL][queueNum][2]=0;
}
}
if(zoneList[zoneNrL][0][0]==PRODSTOP){
reFillQueueBox(zoneNrF);
return zoneList[zoneNrL][0][0];
}
do {
//GM_log("Begin Do:" + zoneList[zoneNrL][0][0]);
iDoRack=zoneList[zoneNrL][0][3] && calcInGameProductAmount(zoneList[zoneNrL][0][0],zoneNrF,null,true) < zoneList[zoneNrL][0][1];
if((OPTION_ITEM_REPEAT && zoneList[zoneNrL][0][4])||(OPTION_LIST_REPEAT && zoneSettings[zoneNrL]["repeat"])){ //repeat
if(zoneList[zoneNrL][0][3] && !iDoRack && !zoneSettings[zoneNrL]["shuffle"]){
zoneList[zoneNrL].push(zoneList[zoneNrL].splice(0,1)[0]);
}else if(zoneList[zoneNrL][0][1]<=zoneList[zoneNrL][0][2]){
if(!zoneSettings[zoneNrL]["shuffle"]){
zoneList[zoneNrL][0][2]=0; //in a loop without shuffel there is no end of a list
//if(DEVMODE){GM_log("reSortQueue "+zoneNrF + " queue:"+print_r(zoneList[zoneNrL][0],"",true));}
if(zoneList[zoneNrL][0][5]!=REPEAT_NO_LIMIT && OPTION_ITEM_REPEAT && zoneList[zoneNrL][0][4]){//extra check should not be needed but incase i forgot a state.
zoneList[zoneNrL][0][5]--;
}
}
//GM_log("reSortQueue "+zoneNrF+" zoneList[zoneNrL][0][5]:"+zoneList[zoneNrL][0][5]+" REPEAT_RESTART:"+REPEAT_RESTART);
if(zoneList[zoneNrL][0][5]<=REPEAT_RESTART && zoneList[zoneNrL][0][5]!=REPEAT_NO_LIMIT){
if(zoneList[zoneNrL].length<=1){
//GM_log("reSortQueue "+zoneNrF +" length<=1");
zoneList[zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone();
}else{
//GM_log("reSortQueue "+zoneNrF +" length>1");
zoneList[zoneNrL].splice(0,1);
}
}
if(zoneList[zoneNrL].length>1){
zoneList[zoneNrL].push(zoneList[zoneNrL].splice(0,1)[0]);
}
}
}else if(zoneList[zoneNrL][0][3]){
if(!iDoRack){
if(zoneList[zoneNrL].length<=1){
zoneList[zoneNrL][0]=DEFAULT_ZONELIST_ITEM.clone(); // stop if no items to go.
}else{
zoneList[zoneNrL].splice(0,1);
}
}
}else if(zoneList[zoneNrL][0][1]<=0 && zoneList[zoneNrL].length<=1 && !zoneSettings[zoneNrL]["shuffle"]){
zoneList[zoneNrL][0][1]=1; // reset to 1 only for displaying in repeat modus needed.
}else if(zoneList[zoneNrL][0][1]<=0 && zoneList[zoneNrL].length<=1 && zoneSettings[zoneNrL]["shuffle"]){
zoneList[zoneNrL][0]=DEFAULT_ZONELIST_ITEM.clone(); // stop if no items to go. //TODO do i realy have to stop. if no rackmode no repeat length=1 and shuffle or do i have to repeat as is !shuffle?
}else if(zoneList[zoneNrL][0][1]<=0){
zoneList[zoneNrL].splice(0,1);
}
if(zoneSettings[zoneNrL]["shuffle"]){
zoneList[zoneNrL].shuffle();
}
//TODO do here remove PRODSTOP in shuffle or repeat mode list and not in RACK-mode
}while (((zoneList[zoneNrL][0][3] && calcInGameProductAmount(zoneList[zoneNrL][0][0],zoneNrF,null,false)>=zoneList[zoneNrL][0][1])||(!zoneList[zoneNrL][0][3] && (zoneList[zoneNrL][0][1]<=(((OPTION_ITEM_REPEAT && zoneList[zoneNrL][0][4])||(OPTION_LIST_REPEAT && zoneSettings[zoneNrL]["repeat"]))?zoneList[zoneNrL][0][2]:0)))) && zoneList[zoneNrL].length>=1 && zoneList[zoneNrL][0][0]!=PRODSTOP);
//GM_log("End Do:" + zoneList[zoneNrL][0][0]);
}
if(zoneList[zoneNrL].length<1){
zoneList[zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone();
}
itemsRackDone=null;itemsRepeatDone=null;itemsStopsFound=null;iDoRack=null;
reFillQueueBox(zoneNrF);
// GM_log("End reSortQueue :" + zoneNrF);
return zoneList[zoneNrL][0][0];
}catch(err){GM_logError("reSortQueue \n"+err);return PRODSTOP;}
}
function reSortWindmill(shuffle){
try{
if(DEVMODE){GM_log("Begin reSortWindmill shuffle:"+shuffle);}
if(DEVMODE){logBubble.add("reSortWindmill items");}
var zoneNrF="windmill";
var zoneNrS="windmill.1";
var zoneNrL=getZoneListId(zoneNrS);
do {
if(shuffle){
zoneList[zoneNrL].shuffle();
}
if(zoneList[zoneNrL][0][0]==PRODSTOP){
break;
}else if(autoMillStorage[zoneList[zoneNrL][0][0]]&&autoMillStorage[zoneList[zoneNrL][0][0]][2]<=0){
var pCount=0;
for(var rId=0;rId<zoneList[zoneNrL].length;rId++){
pCount +=(zoneList[zoneNrL][0][0]==PRODSTOP?1:(autoMillStorage[zoneList[zoneNrL][rId][0]][2]<=0?1:0));
}
if(pCount==zoneList[zoneNrL].length){ //if none recipe can be milled which are bought due to product shortage
zoneList[zoneNrL].unshift(DEFAULT_ZONELIST_MILL.clone()); //insert stop item at begin
}else{
zoneList[zoneNrL].push(zoneList[zoneNrL].splice(0,1)[0]); //add first item to the end of array
}
}else if(zoneList[zoneNrL].length==0 || zoneList[zoneNrL][0][1]<=0 && zoneList[zoneNrL].length<=1){
zoneList[zoneNrL]=DEFAULT_ZONELIST_MILL_ARRAY.clone(); // stop if no items to go.
break;
}else if(zoneList[zoneNrL][0][1]<=0){
zoneList[zoneNrL].splice(0,1); // delete first items
}
}while (zoneList[zoneNrL][0][1]<=0 || zoneList[zoneNrL].length==0 || (zoneList[zoneNrL][0][0]!=PRODSTOP && (!autoMillStorage[zoneList[zoneNrL][0][0]]||autoMillStorage[zoneList[zoneNrL][0][0]][2]<=0)));
}catch(err){GM_logError("reSortWindmill \n"+err);}
}
//[zoneNrF][QueNr][0]=product number, [1]=number to grow, [2]=number grown in loop modus, [3]=Behaviour (Field (default), Rack, Time(//TODO)), [4]=mode (1 time (default), repeat)
//[zoneNrF][mill][0]=product number, [1]=number to grow, [2]=number grown in loop modus, [3]=Min([4]), [4]=Array([X]=Max recipes for product X)
//autoMillStorage: {[rId][0]=number bought, [1]=total number in zoneList[getZoneListId("windmill")], [2]=max number of recieps on products global Math.min([3][pId]), [3][pId]=max number of recieps for this products per products
function reCalculateWindmill(){
try{
if(DEVMODE){GM_log("Begin reCalculateWindmill");}
if(DEVMODE){logBubble.add("reCalculateWindmill");}
var err_trace = "init";
var zoneNrF="windmill";
var zoneNrS="windmill.1"; // TODO: For all slots
var zoneNrL=getZoneListId(zoneNrS);
var autoMillUsedProducts=new Array();
err_trace="1";
for(var rId in autoMillStorage){
if(!autoMillStorage.hasOwnProperty(rId)){continue;}
if(autoMillStorage[rId][0]==0){
delete autoMillStorage[rId];
}else{
autoMillStorage[rId][1]=0;
autoMillStorage[rId][2]=NEVER; //max that can be baked.
}
}
err_trace="2";
for(var v=0;v<zoneList[zoneNrL].length;v++){
var rId=zoneList[zoneNrL][v][0];
zoneList[zoneNrL][v][2]=0;
zoneList[zoneNrL][v][3]=NEVER;
zoneList[zoneNrL][v][4]=new Array();
if(rId!=PRODSTOP){ // don't do anything with STOP
if(autoMillStorage[rId]){
autoMillStorage[rId][1] +=parseInt(zoneList[zoneNrL][v][1],10); // hold total number of recipe counter
if(autoMillStorage[rId][1] > autoMillStorage[rId][0]){ // change the zoneList[zoneNrL] amount to the max amount that is bought
zoneList[zoneNrL][v][1] -=(autoMillStorage[rId][1] - autoMillStorage[rId][0]);
autoMillStorage[rId][1]=autoMillStorage[rId][0];
if(zoneList[zoneNrL][v][1]<=0){
zoneList[zoneNrL].splice(v,1);
v--;
continue;
}
}
//give the lowest number of recieps that can be made with these products.
for(var i=0;i<unsafeWindow.formulas[0][rId][3].length;i++){
var pId=unsafeWindow.formulas[0][rId][3][i][0]; //product number in formulas
var pNum=unsafeWindow.formulas[0][rId][3][i][1]; //amount in formulas
var rNum=(unsafeData.prodStock[0][pId])?parseInt(unsafeData.prodStock[0][pId],10):0;
if(!autoMillUsedProducts[pId]) autoMillUsedProducts[pId]=0;
// GM_log("Calculate: " + i + " : " + rNum + " : " + pNum);
var mx=rNum/pNum ; //(rNum - autoMillUsedProducts[pId])/pNum;
autoMillStorage[rId][2]=Math.min(autoMillStorage[rId][2],mx<0?Math.ceil(mx):Math.floor(mx));
autoMillUsedProducts[pId] +=(pNum * zoneList[zoneNrL][v][1]);
zoneList[zoneNrL][v][4][i]=rNum - autoMillUsedProducts[pId];
zoneList[zoneNrL][v][3]=Math.min(zoneList[zoneNrL][v][3],Math.floor(zoneList[zoneNrL][v][4][i]));
}
}else{ //if the rId is not bought
zoneList[zoneNrL].splice(v,1);
v--;
break;
}
}
}
err_trace="prodMinRackAddon";
unsafeWindow.prodMinRackAddon.removeAll(0,getText("automat_titleQueue")+" "+getText("windmill"));
for(var v=0;v<autoMillUsedProducts.length;v++){
if(autoMillUsedProducts[v]>0){
// GM_log("prodMinRackAddon add windmill\n"+implode([0,v,getText("automat_titleQueue")+" "+getText("windmill"),autoMillUsedProducts[v]]));
unsafeWindow.prodMinRackAddon.add(0,v,getText("automat_titleQueue")+" "+getText("windmill"),autoMillUsedProducts[v]);
}
}
autoMillUsedProducts=null;
err_trace="saving";
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_autoMillStorage",implode(autoMillStorage,"reCalculateWindmill/autoMillStorage"));
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList,"reCalculateWindmill/zoneList"));
// GM_log("End reCalculateWindmill");
}catch(err){ GM_logError("reCalculateWindmill ("+err_trace+")\n"+err);}
}
function checkReadyZone(fz){
try{
if(DEVMODE_FUNCTION){GM_log("Begin checkReadyZone fz:"+fz+" readyZone:"+implode(unsafeData.readyZone,"checkReadyZone/readyZone"));}
var help,lz;
if(!bot.isActive()){
return false;
}else if(fz){
lz = getZoneListId(fz);
if((help=unsafeData.readyZone[fz])&&help[2]&&((help[1]=="w")||(help[1]=="r" && (zoneList[lz][0][0]!=PRODSTOP||!settings.get("account","disableCropFields")))||(help[1]=="e" && zoneList[lz][0][0]!=PRODSTOP))){
if(!zoneWaiting[fz]){
if(isNaN(fz)){
if(settings.get("account","botUse"+getGarden(fz).toTitleCase())){ botArbiter.add(getGarden(fz)); }
} else {
botArbiter.add("farm");
}
} else {
GM_log("checkReadyZone fz="+fz+" zoneWaiting="+getDateText(zoneWaiting[fz])+" "+getDaytimeStr(zoneWaiting[fz]));
}
}
}else{
for(var fz in unsafeData.readyZone){
if(!unsafeData.readyZone.hasOwnProperty(fz)){ continue; }
if((help=unsafeData.readyZone[fz])&&help[2]){
lz = getZoneListId(fz);
if((help[1]=="w")||(help[1]=="r" && (zoneList[lz][0][0]!=PRODSTOP||!settings.get("account","disableCropFields")))||(help[1]=="e" && zoneList[lz][0][0]!=PRODSTOP)){
if(zoneWaiting[fz]){
GM_log("checkReadyZone fz="+fz+" zoneWaiting="+getDateText(zoneWaiting[fz])+" "+getDaytimeStr(zoneWaiting[fz]));
} else {
if(isNaN(fz)){
if(settings.get("account","botUse"+getGarden(fz).toTitleCase())){
botArbiter.add(getGarden(fz));
}
} else {
botArbiter.add("farm");
}
}
}
}
}
}
if(DEVMODE_FUNCTION){GM_log("End checkReadyZone fz:"+fz+" return:"+false);}
return false;
}catch(err){ GM_logError("checkReadyZone fz="+fz+"\n readyZone="+implode(unsafeData.readyZone,"checkReadyZone/readyZone")+"\n"+err);}
}
function getReadyZone(location){
if(DEVMODE_FUNCTION){GM_log("Begin getReadyZone location:"+location+" readyZone:"+implode(unsafeData.readyZone,"getReadyZone/readyZone"));}
var help,zoneNrS,zoneNrL;
if(!bot.isActive()){
return null;
}else{
for(var zoneNrS in unsafeData.readyZone){
if(!unsafeData.readyZone.hasOwnProperty(zoneNrS)){ continue; }
if((help=unsafeData.readyZone[zoneNrS])&&help[2]&&((location==undefined)||(location==help[0]))){
zoneNrL = getZoneListId(zoneNrS);
if((help[1]=="w")||(help[1]=="r" && (zoneList[zoneNrL][0][0]!=PRODSTOP||!settings.get("account","disableCropFields")))||(help[1]=="e" && zoneList[zoneNrL][0][0]!=PRODSTOP)){
if(zoneWaiting[zoneNrS]){
GM_log("getReadyZone zoneNrS="+zoneNrS+" zoneWaiting="+getDateText(zoneWaiting[zoneNrS])+" "+getDaytimeStr(zoneWaiting[zoneNrS]));
} else if((!isNaN(zoneNrS))||settings.get("account","botUse"+getGarden(zoneNrS).toTitleCase())){
return zoneNrS;
}
}
}
}
}
if(DEVMODE_FUNCTION){ GM_log("End getReadyZone location:"+location+" return:"+null); }
return null;
}
// Bot-functions handling fields,stables and factories
/*
function autoZone(){
try{
if(DEVMODE_FUNCTION){GM_log("Begin autoZone readyZone:"+implode(unsafeData.readyZone,"autoZone/readyZone"));}
if(DEVMODE){ logBubble.add("autoZone"); }
// busy=true;
if(!busy){ GM_log("BUSY NOT SET: autoZone"); return false;}
var farmNr=(unsafeWindow.forestry_quicknavi?"f1":((unsafeWindow.cities&&unsafeWindow.city)?("c"+unsafeWindow.city):(parseInt(unsafeWindow.farm,10)-1)));
var zoneNrF=null;
zoneNrF=getReadyZone(farmNr);
if(DEVMODE){GM_log("autoZone 1 farmNr:"+farmNr+" zoneNrF:"+zoneNrF);}
if(zoneNrF==null){
zoneNrF=getReadyZone();
if(DEVMODE){GM_log("autoZone 2 zoneNrF:"+zoneNrF);}
if(zoneNrF==null){ // nothing to work (all fields waiting !?)
if(DEVMODE){GM_log("autoZone farmNr:"+farmNr+" zoneNrF:"+zoneNrF);}
autoZoneFinish();
}else{
handled.zoneBuildingTyp=getBuildingTyp(zoneNrF);
GM_log("autoZone handled.zoneBuildingTyp:"+handled.zoneBuildingTyp);
switch(handled.zoneBuildingTyp){
case 1:case 2:case 3:
document.addEventListener("gameFarmOpened",function(){
document.removeEventListener("gameFarmOpened",arguments.callee,false);
logBubble.add("Arrived in farm");
autoZone();
},false);
window.setTimeout(function(){
logBubble.add("Change to farm "+(parseInt(unsafeData.readyZone[zoneNrF][0],10)+1));
click($("farmlinks").getElementsByClassName("link")[unsafeData.readyZone[zoneNrF][0]]);
},settings.getPause(true));
break;
case "windmill":
document.addEventListener("gameCity2",function(){
document.removeEventListener("gameCity2",arguments.callee,false);
logBubble.add("Arrived in city 2");
autoZone();
},false);
window.setTimeout(function(){
logBubble.add("Change to city 2");
click($top("citylineitem2"));
},settings.getPause(true));
break;
case "forest":
case "sawmill":
case "carpentry":
document.addEventListener("gameOpenForestry",function(){
document.removeEventListener("gameOpenForestry",arguments.callee,false);
logBubble.add("Arrived in forestry");
autoZone();
},false);
window.setTimeout(function(){
logBubble.add("Change to forestry");
click($top("speedlink_forestry"));
},settings.getPause(true));
break;
}
}
}else{
handled.zoneNr=getGarden(zoneNrF);
handled.zoneNrF=zoneNrF;
handled.zoneNrL=getZoneListId(zoneNrF);
handled.zoneBuildingTyp=getBuildingTyp(zoneNrF);
unsafeWindow.jsTimeStamp=unsafeWindow.Zeit.Client - unsafeWindow.Zeit.Verschiebung;
if(!unsafeData.readyZone[handled.zoneNrS][2]){
// close wrong zone
var OpenZoneNrF=getOpenZoneNrF();
if(OpenZoneNrF!=handled.zoneNrF){
if($("gardenmaincontainer").style.display=="block"){ click($("gardencancel").getElementsByClassName("link")[0]); }
if($("innermaincontainer").style.display=="block"){ click($("cancelscreen").getElementsByClassName("link")[0]); }
}
if(unsafeData.readyZone[handled.zoneNrS][1]=="e" && zoneList[handled.zoneNrL][0][0]==PRODSTOP){
if(handled.zoneNrF=="windmill"||handled.zoneNrF=="sawmill"||handled.zoneNrF=="carpentry"||handled.zoneNrF=="forest"){
autoZoneFinish();
}else if(unsafeWindow.forestry_unlock!=undefined){
autoZoneFinish($("button_cancel"+handled.zoneNrF));
}else if(handled.zoneBuildingTyp>1){
autoZoneFinish($("cancelscreen").getElementsByClassName("link")[0]);
}else{
autoZoneFinish($("gardencancel").getElementsByClassName("link")[0]);
}
}else if(OpenZoneNrF!=handled.zoneNrF){
if(DEVMODE) GM_log("click zone: " + farmNr + "." + handled.zoneNr + " readyZone=" +implode(unsafeData.readyZone,"autoZone/readyZone"));
switch(handled.zoneBuildingTyp){
case 1:
document.addEventListener("gameFieldOpened",function(){//gameFieldModified
document.removeEventListener("gameFieldOpened",arguments.callee,false);//gameFieldModified
autoZoneHandle();
},false);
click($("zone"+handled.zoneNr).firstElementChild.firstElementChild);
break;
case 2:
document.addEventListener("gameOpenStable",function(){
document.removeEventListener("gameOpenStable",arguments.callee,false);
autoZoneHandle();
},false);
click($("zone"+handled.zoneNr).firstElementChild.firstElementChild);
break;
case 3:
document.addEventListener("gameOpenFactory",function(){
document.removeEventListener("gameOpenFactory",arguments.callee,false);
autoZoneHandle();
},false);
click($("zone"+handled.zoneNr).firstElementChild.firstElementChild);
break;
default://sawmill/carpentry/forest/windmill => not need to open an extra zone inside the farm/forestry/city
autoZoneHandle();
break;
}
if(DEVMODE){GM_log("autoZone click zone:"+handled.zoneNr+" readyZone:"+implode(unsafeData.readyZone,"autoZone/readyZone"));}
logBubble.add("Open zone "+handled.zoneNr);
}else{
logBubble.add("Zone "+handled.zoneNr+" is opened");
autoZoneHandle();
}
}
}
if(DEVMODE_FUNCTION){ GM_log("End autoZone handled.zoneNr:"+handled.zoneNr);}
}catch(err){GM_logError("boterror \n"+err);autoZoneFinish();} //busy=false;
}
*/
function autoZoneHandle(runId){
/*
DE-1: ERROR autoZoneHandle case 2* handled.zoneNrF=18
readyZone:{}
TypeError: can't convert undefined to object
DE-1: ERROR autoZoneHandle case 2* handled.zoneNrF=14
readyZone:{"15":{"0":2,"1":"r","2":true},"18":{"0":2,"1":"r","2":true}}
TypeError: can't convert undefined to object
*/
if(DEVMODE_FUNCTION){GM_log("Begin autoZoneHandle"); }
bot.setAction("autoZoneHandle");
window.setTimeout(function(){
switch(handled.zoneBuildingTyp){
case 1:
//-- GM_log("autoZoneHandle run nextFkt case:1");
try{
if(!unsafeData.zones.getProduction(handled.zoneNrF)[3]){
if(DEVMODE){ logBubble.add("Field-Data not ready"); }
logBubble.add("Field-Data not ready");
window.setTimeout(autoZoneHandle,settings.getPause());
}else{
autoZoneCrop();
window.setTimeout(function(runId){
return function(){
if(unsafeData.readyZone[handled.zoneNrS]&&(unsafeData.readyZone[handled.zoneNrS][1]=="w")){
unsafeData.readyZone[handled.zoneNrS][2]=false;
autoFarmWater(runId,1,false,true); // just water
}else if(zoneList[handled.zoneNrL][0][0]==PRODSTOP){
autoZoneFinish(runId,$("gardencancel"));
}else{
reSortQueue(handled.zoneNrF, false);
autoFarmPlantInit(runId,zoneList[handled.zoneNrL][0][0]); // init planting
}
}
}(runId),settings.getPause());
}
}catch(err){GM_logError("autoZoneHandle case 1 handled.zoneNrF:"+handled.zoneNrF+" readyZone:"+implode(unsafeData.readyZone,"autoZoneHandle/readyZone")+" \n"+err);}
break;
case 2:
//-- GM_log("autoZoneHandle run nextFkt case:2");
// try{
// autoZoneCrop();
// }catch(err){GM_logError("autoZoneHandle case 2 handled.zoneNrF="+handled.zoneNrF+"\nreadyZone:"+implode(unsafeData.readyZone,"autoZoneHandle/readyZone")+" \n"+err);}
window.setTimeout(function(runId){
try{
bot.setAction("autoZoneHandle(2,cases)");
if(!unsafeData.readyZone[handled.zoneNrS]){
bot.setAction("autoZoneHandle(2,autoZoneFinish)");
autoZoneFinish(runId,$("building_inner").querySelector(".big_close"));
}else{
bot.setAction("autoZoneHandle(2,autoFarmStable)");
unsafeData.readyZone[handled.zoneNrS][2]=false;
autoFarmStable(runId,1,false,true,zoneList[handled.zoneNrL][0][0],0,zoneList[handled.zoneNrL][0][1]);
}
}catch(err){GM_logError("autoZoneHandle case 2* handled.zoneNrF="+handled.zoneNrF+"\nreadyZone:"+implode(unsafeData.readyZone,"autoZoneHandle/readyZone")+" \n"+err);}
},settings.getPause(),runId);
break;
case 3:
//-- GM_log("autoZoneHandle run nextFkt case:3");
try{
autoZoneCrop();
window.setTimeout(function(runId){
if(zoneList[handled.zoneNrL][0][0]==PRODSTOP){
autoZoneFinish(runId,$("cancelscreen").getElementsByClassName("link")[0]);
}else{
if (unsafeData.readyZone[handled.zoneNrS] === undefined) {
autoZoneFinish(runId,$("cancelscreen").getElementsByClassName("link")[0]);
} else {
unsafeData.readyZone[handled.zoneNrS][2]=false;
autoFarmFactory(runId,1);
}
}
},settings.getPause(),runId);
}catch(err){GM_logError("autoZoneHandle case 3 handled.zoneNrF:"+handled.zoneNrF+" readyZone:"+implode(unsafeData.readyZone,"autoZoneHandle/readyZone")+" \n"+err);}
break;
/*
case "windmill":
autoWindmill();
break;
case "sawmill":
reSortQueue(handled.zoneNrF, false);
autoForestrySawmill();
break;
case "carpentry":
reSortQueue(handled.zoneNrF, false);
autoForestryCarpentry();
break;
case "forest":
try{
if(!unsafeData.getProduction(handled.zoneNrF)[3]){
if(DEVMODE){ logBubble.add("Field-Data not ready"); }
window.setTimeout(autoZoneHandle,settings.getPause());
}else{
autoZoneCrop();
window.setTimeout(function(){
if(unsafeData.readyZone[handled.zoneNrS]&&(unsafeData.readyZone[handled.zoneNrS][1]=="w")){
unsafeData.readyZone[handled.zoneNrS][2]=false;
autoForestryWatering();
}else if(zoneList[handled.zoneNrL][0][0]==PRODSTOP){
autoZoneFinish();
}else{
reSortQueue(handled.zoneNrF, false);
autoForestryPlantInit(zoneList[handled.zoneNrL][0][0]); // init planting
}
},settings.getPause());
}
}catch(err){GM_logError("autoZoneHandle case forest handled.zoneNrF:"+handled.zoneNrF+" readyZone:"+implode(unsafeData.readyZone,"autoZoneHandle/readyZone")+" \n"+err);}
break;
*/
}
},settings.getPause());
}
function autoZoneCrop(){
try{
var zoneTyp;
switch(unsafeData.gameLocation[0]){
case "farm":
if($("gardenmaincontainer").style.display=="block"){ zoneTyp=1; }
else if($("innermaincontainer").style.display=="block"){ zoneTyp=unsafeData.BUILDINGTYPE[unsafeWindow.locationinfo[6]]; }
break;
case "forestry": zoneTyp="forest";
break;
}
if(DEVMODE){GM_log("autoZoneCrop zoneTyp"+zoneTyp);}
switch (zoneTyp){
case 1:
var cropable=false;
var NowServer=unsafeWindow.Zeit.Server;
var emptycounter=0;
for(var v=1;v<=120;v++){
// GM_log(v);
if((unsafeWindow.garten_kategorie[v]=="v") && (unsafeWindow.garten_zeit[v]!="0") && (parseInt(unsafeWindow.garten_zeit[v],10)<NowServer)){
cropable=true;
break;
}
}
if(DEVMODE){GM_log("Cropping cropable:"+cropable);}
if(cropable){
logBubble.add("Cropping");
unsafeData.zones.getProduction(handled.zoneNrF)[3]=false;
click($("cropall").getElementsByTagName("img")[0]);
return true;
}else{
return false;
}
break;
case 2:
if($("globalbox").style.display=="block"){
// click($("globalbox_button1"));
return true;
}else{
return false;
}
break;
case 3:
if($("globalbox").style.display=="block"){
click($("globalbox_button1"));
return true;
}else{
return false;
}
break;
case "forest":
try{
var cropable=false,v;
for(var i=0;i<unsafeWindow.forestry_area.length;i++){
v=unsafeWindow.forestry_area[i]['position'];
//GM_log("Cropping forestry_area["+i+"]['category']="+unsafeWindow.forestry_area[i]['category']+" forestry_area["+i+"]['block']="+unsafeWindow.forestry_area[i]['block']+" forestry_area_time["+v+"]="+unsafeWindow.forestry_area_time[v]);
if(unsafeWindow.forestry_area[i]['category']==1 && unsafeWindow.forestry_area[i]['block']==0 && unsafeWindow.forestry_area_time[v]!=undefined && unsafeWindow.forestry_area_time[v]<=0 && !unsafeData.zones.getProduction("forest")[2]<25){
var prod=20+parseInt(unsafeWindow.forestry_area[i]["productid"],10);
if(unsafeData.prodStock[1][prod]+unsafeData.prodYield[1][prod]<=unsafeData.prodStockMax[1][prod]){
cropable=true;
break;
}
}
}
v=null;
}catch(err){GM_logError("forest cropping i:"+i+" v:"+v+"\n"+err);}
if(DEVMODE){GM_log("Cropping cropable:"+cropable);}
if(cropable){
logBubble.add("Cropping");
unsafeData.zones.getProduction("forest")[3]=false;
click($("forestry_forest_button2"));
return true;
}else{
return false;
}
break;
default:
return false;
}
// GM_log("End ernte do nothing");
} catch(err){GM_logError("autoZoneCrop \n"+err);return false;}
}
function autoZoneFinish(runId,closeButton){
// closeButton is optional, a click is fired on it
if(DEVMODE){GM_log("autoZoneFinish handled.zoneNrF:"+handled.zoneNrF +" closeButton:"+(closeButton?closeButton.id:closeButton) + " readyZone:"+implode(unsafeData.readyZone,"autoZoneFinish/readyZone"));}
//if(DEVMODE){GM_log("autoZoneFinish arg caller:"+autoZoneFinish.caller.toString());}
bot.setAction("autoZoneFinish: init");
var help;
if((help=unsafeData.zones.getProduction(handled.zoneNrF))&&(!help[3])){
bot.setAction("autoZoneFinish: data not ready");
window.setTimeout(autoZoneFinish,settings.getPause(),runId,closeButton);
}else {
if(bot.isActive()){
bot.setAction("autoZoneFinish: close zone");
if(closeButton){ // Close
try{
click(closeButton);
}catch(err){
GM_logError("autoZoneFinish closeButton\n"+err);
autoZoneFinish(runId);
}
}else if(closeButton!=undefined){
if(DEVMODE){GM_log("autoZoneFinish not found handled.zoneNrF:"+handled.zoneNrF+" closeButton:"+(closeButton?closeButton.id:closeButton));}
}
bot.setAction("autoZoneFinish: reFillQueueBox");
if(handled.zoneNrL){
reFillQueueBox(handled.zoneNrF,handled.zoneNrL);
}
bot.end();
// initiate working progress of next zone
bot.setAction("autoZoneFinish: checkReadyZone");
checkReadyZone();
}else{
bot.setAction("autoZoneFinish: bot.deactivate");
bot.deactivate();
}
}
if(DEVMODE){GM_log("autoZoneFinish end");}
}
function autoFarm(runId){
try{
if(bot.checkRun("autoFarm",runId)){
if(DEVMODE_FUNCTION){GM_log("Begin autoFarm readyZone:"+implode(unsafeData.readyZone,"autoFarm/readyZone"));}
if(DEVMODE){ logBubble.add("autoFarm"); }
bot.setAction("autoFarm");
var farmNr=(parseInt(unsafeWindow.farm,10)-1);
var zoneNrS=getReadyZone(farmNr);
if(DEVMODE){ GM_log("autoFarm 1 farmNr:"+farmNr+" zoneNrS="+zoneNrS); }
if(zoneNrS==null){
bot.setAction("autoFarm: wrong farm");
for(var i=0;i<parseInt(unsafeWindow.farmamount,10);i++){
if((zoneNrS==null)&&(i!=farmNr)){ zoneNrS=getReadyZone(i); }
}
if(DEVMODE){GM_log("autoFarm 2 zoneNrS:"+zoneNrS);}
if(zoneNrS==null){ // nothing to work (all fields waiting !?)
if(DEVMODE){GM_log("autoFarm farmNr:"+farmNr+" zoneNrS="+zoneNrS);}
autoZoneFinish(runId);
}else{
document.addEventListener("gameFarmOpened",function(runId){
return function(){
document.removeEventListener("gameFarmOpened",arguments.callee,false);
logBubble.add("Arrived in farm");
window.setTimeout(autoFarm,settings.getPause(),runId);
}
}(runId),false);
logBubble.add("Change to farm "+(unsafeData.readyZone[zoneNrS][0]+1));
click($("speedlink_farm"+(unsafeData.readyZone[zoneNrS][0]+1)));
}
}else{
bot.setAction("autoFarm: correct farm");
handled.set(zoneNrS);
try{ unsafeWindow.jsTimeStamp=unsafeWindow.Zeit.Client - unsafeWindow.Zeit.Verschiebung; }catch(err){}
if(unsafeData.readyZone[handled.zoneNrS][2]){ // TODO else
bot.setAction("autoFarm: farm opened");
var OpenZoneNrF=getOpenZoneNrF();
if((unsafeData.readyZone[handled.zoneNrS][1]=="e")&&(zoneList[handled.zoneNrL][0][0]==PRODSTOP)){
autoZoneFinish(runId);
}else if(OpenZoneNrF!=handled.zoneNrF){
// close wrong zone
if($("gardenmaincontainer").style.display=="block"){
bot.setAction("autoFarm: farm opened, close gardenmaincontainer");
logBubble.add("Closing field container");
click($("gardencancel"));
window.setTimeout(autoFarm,settings.getPause(),runId);
}else if($("innermaincontainer").style.display=="block"){
bot.setAction("autoFarm: farm opened, close innermaincontainer");
logBubble.add("Closing factory container");
click($("cancelscreen").getElementsByClassName("link")[0]);
window.setTimeout(autoFarm,settings.getPause(),runId);
}else if($("building_inner").style.display=="block"){
bot.setAction("autoFarm: farm opened, close building_inner");
logBubble.add("Closing stable container");
click($("building_inner").querySelector(".big_close"));
window.setTimeout(autoFarm,settings.getPause(),runId);
}else{
// open zone
if(DEVMODE){ GM_log("autoFarm click zone: "+farmNr+"."+handled.zoneNr+" readyZone=" +implode(unsafeData.readyZone,"autoFarm/readyZone")); }
logBubble.add("Opening zone "+handled.farmNr+"-"+handled.zoneNr);
switch(handled.zoneBuildingTyp){
case 1:
document.addEventListener("gameFieldOpened",function(runId){
return function(){
document.removeEventListener("gameFieldOpened",arguments.callee,false);
window.setTimeout(autoZoneHandle,settings.getPause(),runId);
}
}(runId),false);
click($("farm"+handled.farmNr+"_pos"+handled.zoneNr+"_click"));
break;
case 2:
document.addEventListener("gameOpenStable",function(runId){
return function(){
document.removeEventListener("gameOpenStable",arguments.callee,false);
window.setTimeout(autoZoneHandle,settings.getPause(),runId);
}
}(runId),false);
click($("farm"+handled.farmNr+"_pos"+handled.zoneNr+"_click"));
break;
case 3:
switch(getZoneType(handled.zoneNrF)){
case 13: case 14:{
document.addEventListener("gameOpenFactoryOil",function(runId){
return function(){
document.removeEventListener("gameOpenFactoryOil",arguments.callee,false);
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,1);
}
}(runId),false);
break;}
case 16:{
document.addEventListener("gameOpenFactoryKnitting",function(runId){
return function(){
document.removeEventListener("gameOpenFactoryKnitting",arguments.callee,false);
window.setTimeout(autoFarmFactoryKnitting,settings.getPause(),runId,1);
}
}(runId),false);
break;}
case 19:{
document.addEventListener("gameOpenMegafield",function(runId){
return function(){
document.removeEventListener("gameOpenMegafield",arguments.callee,false);
window.setTimeout(autoFarmMegafield,settings.getPause(),runId,1);
}
}(runId),false);
break;}
default:{
document.addEventListener("gameOpenFactory",function(runId){
return function(){
document.removeEventListener("gameOpenFactory",arguments.callee,false);
window.setTimeout(autoZoneHandle,settings.getPause(),runId);
}
}(runId),false);
}
}
click($("farm"+handled.farmNr+"_pos"+handled.zoneNr+"_click"));
break;
}
}
}else{
logBubble.add("Zone "+handled.farmNr+"-"+handled.zoneNr+" is opened");
autoZoneHandle(runId);
}
}
}
if(DEVMODE_FUNCTION){ GM_log("End autoFarm handled.zoneNr:"+handled.zoneNr);}
}
}catch(err){GM_logError("autoFarm\n"+err);autoZoneFinish(runId);} //busy=false;
}
function autoFarmCrop(runId,v){
try{
if(bot.checkRun("autoFarm",runId,true)){
if(DEVMODE){ GM_log("autoFarmCrop "+v); }
bot.setAction("autoFarmCrop "+v);
var wait=false;
if(unsafeWindow.mode!="1"){
window.setTimeout(autoFarmCrop,settings.getPause(),runId,v);
click($("ernten"));
}else{
if(unsafeWindow.garten_kategorie[v]=="v"){
var z=parseInt(unsafeWindow.garten_zeit[v],10);
if((z>0)&&(unsafeWindow.garten_x[v]==1)&&(unsafeWindow.garten_y[v]==1)){ // first part plants
if(z<unsafeWindow.Zeit.Server){
wait=true;
unsafeData.zones.flagProduction(handled.zoneNrF);
click($("f"+v));
}
}
}
if(v<120){
window.setTimeout(autoFarmCrop,wait?settings.getPause(true):0,runId,v+1);
}else{
autoZoneFinish(runId);
}
}
}
}catch(err){GM_logError("autoFarmCrop runId="+runId+"\n"+err);}
}
function autoFarmPlantInit(runId,rackitemNr){
try{
if(bot.checkRun("autoFarmPlantInit",runId)){
if(DEVMODE) GM_log("autoFarmPlantInit :"+rackitemNr + "(" + typeof rackitemNr+")");
bot.setAction("autoFarmPlantInit");
logBubble.add("Initializing planting ("+rackitemNr+")");
if(unsafeWindow.racksort&&(unsafeWindow.racksort>4)){
// non-plant-rack opened
logBubble.add("Switching rack to plants");
document.addEventListener("gameUpdateRack",function(runId,rackitemNr){
return function(){
document.removeEventListener("gameUpdateRack",arguments.callee,false);
window.setTimeout(autoFarmPlantInit,settings.getPause(),runId,rackitemNr);
};
}(runId,rackitemNr),false);
click($("rackcat1"));
}else if(!(unsafeData.prodStock[0][rackitemNr]&&unsafeData.prodStock[0][rackitemNr]>0)){
// product is missing
// this is correct set, even if rack is updating
logBubble.add("Plant is not in rack",10,"red");
autoFarmPlantDefault(runId);
}else if(unsafeWindow.selected==rackitemNr){
// calculate time of next cropping
// here its not important if rack is updating
var time=NEVER;
var NowServer=unsafeWindow.Zeit.Server;
for(var v=1;v<=120;v++){
if(unsafeWindow.garten_kategorie[v]=="v"){ // only plants
var z=parseInt(unsafeWindow.garten_zeit[v],10);
if(z>0){
time=Math.min(time,z-NowServer);
}
}
}
time=Math.max(time,0);
if(time<=settings.get("account","seedWaitForCrop")){
zoneWaiting[handled.zoneNrF]=now+time;
window.setTimeout(function(){ //TIMEOUT
for(var fz in zoneWaiting){
if(!zoneWaiting.hasOwnProperty(fz)){continue;}
if(zoneWaiting[fz]<=now){ delete zoneWaiting[fz]; }
}
checkReadyZone();
},(1000*time)+settings.getPause());
logBubble.add("Waiting for crop in "+getTimeStr(time));
if(DEVMODE){GM_log("initAutoPlant Waiting for crop in "+getTimeStr(time));}
autoZoneFinish(runId);
return false;
}
// Correct plant selected
if(calcEmptyProductPositions(rackitemNr,handled.zoneNrF)>0){
if((unsafeWindow.premium==1) && (unsafeWindow.currentuserlevel>=unsafeWindow.autoplantlevel)){
autoFarmPlantPremium(runId,1);
}else{
autoFarmPlant(runId,1,false,true);
}
}else{
autoFarmPlantDefault(runId);
}
}else{
logBubble.add("Wrong plant selected");
var nextRack=(unsafeWindow.racksort%unsafeWindow.userracks)+1;
while(unsafeWindow.racklocks&&unsafeWindow.racklocks[nextRack]){
nextRack=(nextRack%unsafeWindow.userracks)+1;
}
if($("rackitem"+rackitemNr)){
if(unsafeWindow.updateRackBusy){
// Rack not loaded
logBubble.add("Rack not loaded",10,"red");
document.addEventListener("gameUpdateRack",function(runId,rackitemNr){
return function(){
document.removeEventListener("gameUpdateRack",arguments.callee,false);
window.setTimeout(autoFarmPlantInit,settings.getPause(),runId,rackitemNr);
};
}(runId,rackitemNr),false);
}else{
if($("rackitem"+rackitemNr).style.display!="none"){
logBubble.add("Seed found");
click($("rackitem"+rackitemNr)); // rackitem found
window.setTimeout(autoFarmPlantInit,settings.get("country","pause")[0],runId,rackitemNr);
}else if(unsafeWindow.racksort!=nextRack){
// call next rack
document.addEventListener("gameUpdateRack",function(runId,rackitemNr){
return function(){
document.removeEventListener("gameUpdateRack",arguments.callee,false);
window.setTimeout(autoFarmPlantInit,settings.getPause(),runId,rackitemNr);
};
}(runId,rackitemNr),false);
logBubble.add("Switching to next rack ("+nextRack+")");
click($("rackswitch"+nextRack));
}else{
// should not happen
logBubble.add("Invisible non-empty rackitem and only 1 rack",10,"red");
autoFarmPlantDefault(runId);
}
}
}else if(unsafeWindow.racksort!=nextRack){
// rackamount>0 but no rackitem
// = 2nd, 3rd or 4th rack was not loaded yet
document.addEventListener("gameUpdateRack",function(runId,rackitemNr){
return function(){
document.removeEventListener("gameUpdateRack",arguments.callee,false);
window.setTimeout(autoFarmPlantInit,settings.getPause(),runId,rackitemNr);
};
}(runId,rackitemNr),false);
logBubble.add("Switching to next rack ("+nextRack+")(rackitem not found)");
click($("rackswitch"+nextRack));
// unsafeWindow.updateRack((1+parseInt(unsafeWindow._currRack,10))%unsafeWindow.userracks); // call next rack
}else{// rackamount>0 but no rackitem and 1 rack
// should not happen because thats "product is missing" (1.case)
logBubble.add("No rackitem but rackamount and only 1 rack",10,"red");
autoFarmPlantDefault(runId);
}
nextRack=null;
}
}
}catch(err){GM_logError("autoFarmPlantInit runId="+runId+"\n"+err);}
}
function autoFarmPlantDefault(runId){
try{
if(bot.checkRun("autoFarmPlantDefault",runId)){
if(DEVMODE) GM_log("autoFarmPlantDefault");
bot.setAction("autoFarmPlantDefault");
logBubble.add("Searching other plant");
if(unsafeWindow.updateRackBusy){
// Rack not loaded
logBubble.add("Rack not loaded",10,"red");
document.addEventListener("gameUpdateRack",function(runId){
return function(){
document.removeEventListener("gameUpdateRack",arguments.callee,false);
window.setTimeout(autoFarmPlantDefault,settings.getPause(),runId);
};
}(runId),false);
}else{
var rackitemNr=null;
// try emergency plants
for(var v=0;v<emergencyPlants.length;v++){
if(unsafeData.prodStock[0][emergencyPlants[v]]&&unsafeData.prodStock[0][emergencyPlants[v]]>0&&(calcEmptyProductPositions(emergencyPlants[v],handled.zoneNrF)>0)){
rackitemNr=emergencyPlants[v];
logBubble.add("Taking emergency plant "+rackitemNr);
autoFarmPlantInit(runId,rackitemNr);
return;
}
}
if(rackitemNr==null){
// first plant in loaded rack
var cand=$("rackItems").getElementsByClassName("sack");
for(var v=0;v<cand.length;v++){
if(cand[v].style.display=="none"){ continue; }
var prod=cand[v].id.replace("rackitem","");
if((unsafeData.prodTyp[0][prod]=="v")&&(calcEmptyProductPositions(prod,handled.zoneNrF)>0)){
rackitemNr=prod;
break;
}
}
cand=null;
if(rackitemNr!=null){
logBubble.add("Taking "+unsafeData.prodName[0][rackitemNr]);
autoFarmPlantInit(runId,rackitemNr);
return;
}else if(unsafeWindow.userracks>1){
// does a plant exist in other rack?
var plants=false;
for(var v=0;v<unsafeData.prodTyp[0].length;v++){ // all
if((unsafeData.prodTyp[0][v]=="v")&&(calcEmptyProductPositions(v,handled.zoneNrF)>0)&&unsafeData.prodStock[0][v]&&unsafeData.prodStock[0][v]>0){
plants=true;
break;
}
}
if(plants){
document.addEventListener("gameUpdateRack",function(runId){
return function(){
document.removeEventListener("gameUpdateRack",arguments.callee,false);
window.setTimeout(autoFarmPlantDefault,settings.getPause(),runId);
};
}(runId),false);
logBubble.add("Switching to next rack");
unsafeWindow.updateRack((1+parseInt(unsafeWindow._currRack,10))%unsafeWindow.userracks); // call next rack
}else{
logBubble.add("No plant in racks.<br>Would add stop.",10,"red");
autoZoneFinish(runId,$("gardencancel"));
}
}else{
logBubble.add("No plant in rack.<br>Would add stop.",10,"red");
autoZoneFinish(runId,$("gardencancel"));
}
}
}
}
}catch(err){GM_logError("autoFoodworldBuilding runId="+runId+"\n"+err);}
}
function autoFarmPlant(runId,v,didPlant,isBot){
try{
if(bot.checkRun("autoFarmPlant",runId,!isBot)){
if(DEVMODE_FUNCTION){GM_log("Begin autoFarmPlant :"+v+":"+didPlant+":"+isBot);}
bot.setAction("autoFarmPlant");
if(v==1){ logBubble.add(getText("automat_planting")); }
if(unsafeWindow.mode!="0"){ click($("anpflanzen")); }
if(v<121){
if((unsafeData.prodTyp[0][unsafeWindow.selected]=="v")&&unsafeData.prodStock[0][unsafeWindow.selected]&&unsafeData.prodStock[0][unsafeWindow.selected]>0){
bot.setAction("autoFarmPlant "+getText("automat_planting"));
if(v%12==1){ linecount=0; }
var frei=true;
if(unsafeWindow.garten_kategorie[v] && ((unsafeWindow.garten_kategorie[v]!="v") || (unsafeWindow.garten_zeit[v]!="0"))){ frei=false; }
else{
if(unsafeWindow.global_x=="2"){
if(v%12==0){ frei=false; }
else{
w=v+1;
if(unsafeWindow.garten_kategorie[w] && ((unsafeWindow.garten_kategorie[w]!="v") || (unsafeWindow.garten_zeit[w]!="0"))){ frei=false; }
else{
if(unsafeWindow.global_y=="2"){
if(v>108){ frei=false; }
else{
w=v+12;
if(unsafeWindow.garten_kategorie[w] && ((unsafeWindow.garten_kategorie[w]!="v") || (unsafeWindow.garten_zeit[w]!="0"))){ frei=false; }
else{
w=v+13;
if(unsafeWindow.garten_kategorie[w] && ((unsafeWindow.garten_kategorie[w]!="v") || (unsafeWindow.garten_zeit[w]!="0"))){ frei=false; }
}
}
}
}
}
}
}
if(frei){
unsafeData.zones.flagProduction(handled.zoneNrF);
click($("f"+v));
v+=parseInt(unsafeWindow.global_x,10);
linecount +=parseInt(unsafeWindow.global_x,10);
if(linecount>11){ v +=12*(parseInt(unsafeWindow.global_y,10)-1); }
window.setTimeout(autoFarmPlant,settings.getPause(true),runId,v,true,isBot);
}else{
autoFarmPlant(runId,v+1,didPlant,isBot);
}
}else{
logBubble.add("Invalid plant");
if(didPlant&&isBot){ setNextQueueItem(handled.zoneNrS); }
autoFarmWater(runId,1,didPlant,isBot);
}
}else{
GM_log("All fields done");
logBubble.add("All fields done");
if(autoZoneCrop()){
window.setTimeout(autoFarmPlant,settings.getPause(),runId,1,didPlant,isBot);
}else{
if(didPlant&&isBot){ setNextQueueItem(handled.zoneNrS); }
window.setTimeout(autoFarmWater,settings.getPause(),runId,1,didPlant,isBot);
}
}
if(DEVMODE_FUNCTION){GM_log("End autoFarmPlant :"+ v);}
}
}catch(err){GM_logError("autoFarmPlant runId="+runId+"\n"+err);}
}
function autoFarmPlantPremium(runId, step){
try{
if(bot.checkRun("autoFarmPlantPremium",runId)){
bot.setAction("autoFarmPlantPremium ("+step+")");
var help,help2,action=null,listeningEvent=null;
switch(step){
case 1:{ // call automatic planting
logBubble.add("(Premium) "+getText("automat_planting"));
var leereFelder=0;
for(var v=1;v<=120;v++){
if(unsafeWindow.garten_kategorie[v]=="v"){
if(!unsafeWindow.garten_prod[v]){ leereFelder++; }
}else{
if((unsafeWindow.garten_kategorie[v]!="z") && (unsafeWindow.garten_kategorie[v]!="u")){ leereFelder++; }
}
}
if(leereFelder>0){
action=function(){ click($("autoplantbuttoninner")); }; // open automat
listeningEvent="gameOpenGlobalBox";
}else{
autoFarmWater(runId,1,false,true);
}
break;}
case 2:{ // commit automatic planting
unsafeData.zones.flagProduction(handled.zoneNrF);
setNextQueueItem(handled.zoneNrS);
action=function(){ click($("globalbox_button1")); }
listeningEvent="gameFieldPlanted";
break;}
case 3:{
autoFarmWater(runId,1,true,true);
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoFarmPlantPremium,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
help=null;listeningEvent=null;action=null;
}
}catch(err){GM_logError("autoFarmPlantPremium runId="+runId+" step="+step+"\n"+err);}
}
function autoFarmWater(runId,v,didPlant,isBot){
try{
if(bot.checkRun("autoFarmWater",runId,!isBot)){
if(isBot&&!settings.get("account","autoWater")){ // bot shall not water (option)
autoZoneFinish(runId,$("gardencancel"));
}else{
if(DEVMODE_FUNCTION){GM_log("Begin autoFarmWater :"+v);}
bot.setAction("autoFarmWater "+v+": init");
if(DEVMODE&&v==1){ GM_log("autoFarmWater :"+v); }
if(v==1){ logBubble.add(getText("automat_watering")); }
if($("tooltipwaterall")){
bot.setAction("autoFarmWater "+v+": premium");
logBubble.add("Water all");
unsafeData.zones.flagProduction(handled.zoneNrF);
document.addEventListener("gameFieldWatered",function(runId,v,didPlant,isBot){
return function(){
document.removeEventListener("gameFieldWatered",arguments.callee,false);
window.setTimeout(autoZoneFinish,settings.getPause(),runId,isBot?$("gardencancel"):null);
};
}(runId,v,didPlant,isBot),false);
click($("waterall").getElementsByTagName("img")[0]);
}else if(unsafeWindow.mode!="2"){
click($("giessen"));
window.setTimeout(autoFarmWater,settings.getPause(),runId,v,didPlant,isBot);
}else{
bot.setAction("autoFarmWater "+v+": non-premium");
if(v<121){
if((unsafeWindow.garten_kategorie[v]=="v") && (unsafeWindow.garten_zeit[v]!="0") && (isNaN(parseInt(unsafeWindow.garten_wasser[v],10))||(parseInt(unsafeWindow.garten_wasser[v],10)+86400<unsafeWindow.Zeit.Server))){
bot.setAction("autoFarmWater "+v+": click ");
unsafeData.zones.flagProduction(handled.zoneNrF);
click($("f"+v));
window.setTimeout(autoFarmWater,settings.getPause(true),runId,v+parseInt(unsafeWindow.garten_max_x[v],10),didPlant,isBot);
}else{
bot.setAction("autoFarmWater "+v+": continue ");
autoFarmWater(runId,v+1,didPlant,isBot);
}
}else{
bot.setAction("autoFarmWater "+v+": finish ");
if(autoZoneCrop()){
bot.setAction("autoFarmWater "+v+": finish, crop-able");
window.setTimeout(autoFarmPlant,settings.getPause(),runId,1,didPlant,isBot);
}else{
bot.setAction("autoFarmWater "+v+": finish, not crop-able");
click($("anpflanzen"));
window.setTimeout(autoZoneFinish,settings.getPause(),runId,isBot?$("gardencancel"):null);
}
}
}
if(DEVMODE_FUNCTION){GM_log("End autoFarmWater :"+v);}
}
}
}catch(err){GM_logError("autoFarmWater runId="+runId+"\n"+err);}
}
function autoFarmStable(runId,step,didFeed,isBot,sorte,feedcounter,maxFeed){
try{
// GM_log("autoFarmStable runId="+runId+" step="+step+" didFeed="+didFeed+" isBot="+isBot+" sorte="+sorte+" feedcounter="+feedcounter+" maxFeed="+maxFeed);
if(bot.checkRun("autoFarmStable",runId,!isBot)){
var help,action=null,listeningEvent=null;
bot.setAction("autoFarmStable ("+step+")");
// Error displayed
if($("errorboxinner").style.display=="block"){ step=9; } // exit
switch(step){
case 1:{ // init
logBubble.add("Feeding");
autoFarmStable(runId,isBot?step+1:5,didFeed,isBot,sorte,feedcounter,maxFeed);
break;}
case 2:{ // crop
help=$("globalbox");
if(help&&(help.style.display=="block")){
click($("globalbox_button1"));
window.setTimeout(autoFarmStable,3*settings.getPause(true),runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed);
}else{
autoFarmStable(runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed);
}
break;}
case 3:{ // check if active
if(zoneList[handled.zoneNrL][0][0]==PRODSTOP){
autoFarmStable(runId,9,didFeed,isBot,sorte,feedcounter,maxFeed);
}else{
autoFarmStable(runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed);
}
break;}
case 4:{ // check storage of feed
if(unsafeData.prodStock[0][sorte]&&unsafeData.prodStock[0][sorte]>0){
window.setTimeout(autoFarmStable, 3*settings.getPause(true),runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed)
}else{
// feed not found
if(1+parseInt(unsafeWindow._currRack,10)<unsafeWindow.userracks){
step--;
action=function(){
unsafeWindow.updateRack(1+parseInt(unsafeWindow._currRack,10)); // switch to last rack
}
listeningEvent="gameUpdateRack";
}else{
if(sorte==zoneList[handled.zoneNrL][0][0]){
autoFarmStable(runId,step,didFeed,isBot,zoneList[handled.zoneNrL][1][0],0,zoneList[handled.zoneNrL][1][1]); // do other food
}else{
if(unsafeData.readyZone[handled.zoneNrS]){
logBubble.add("No feed.<br>Stopping zone.",10,"red");
zoneList[handled.zoneNrL][0][0]=PRODSTOP; // sleep zone
updateQueueBox(handled.zoneNrF);
}
autoFarmStable(runId,9,didFeed,isBot,sorte,feedcounter,maxFeed); // exit
}
}
}
break;}
case 5:{ // Feeding (Premium): start
if((unsafeWindow.premium==1) || (parseInt($("levelnum").innerHTML,10)<10)){ // check if premium feeding
click($("feed_item"+sorte).firstElementChild); // start feed
window.setTimeout(autoFarmStable,3*settings.getPause(true),runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed);
} else {
autoFarmStable(runId,8,didFeed,isBot,sorte,feedcounter,maxFeed); // go to non-premium feeding
}
break;}
case 6:{ // Feeding (Premium): amount
if(help=$("building_dialogbox_input")){
maxFeed=Math.min(unsafeData.prodStock[0][sorte],maxFeed);
logBubble.add(getText("automat_feeding")+"<br>"+maxFeed+" "+unsafeData.prodName[0][sorte]);
help.value=maxFeed; // enter amount
keyup(help);
help=null;
window.setTimeout(autoFarmStable,3*settings.getPause(true),runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed);
}else{
window.setTimeout(autoFarmStable,1000,runId,step,didFeed,isBot,sorte,feedcounter,maxFeed);
}
break;}
case 7:{ // Feeding (Premium): submit
feedcounter+=maxFeed;
unsafeData.prodStock[0][sorte]-=maxFeed;
didFeed=true;
click($("building_dialogbox_submit"));
if(isBot&&(sorte==zoneList[handled.zoneNrL][0][0])&&(zoneList[handled.zoneNrL][1])&&(zoneList[handled.zoneNrL][1][1]>0)){
window.setTimeout(autoFarmStable,3*settings.getPause(true),runId,4,didFeed,isBot,zoneList[handled.zoneNrL][1][0],0,zoneList[handled.zoneNrL][1][1]); // do other food
}else{
window.setTimeout(autoFarmStable,3*settings.getPause(true),runId,9,didFeed,isBot,sorte,feedcounter,maxFeed); // exit
}
break;}
case 8:{ // Feeding (Non-Premium)
feedcounter++;
unsafeData.prodStock[0][sorte]--;
didFeed=true;
logBubble.add(getText("automat_feeding")+"<br>"+feedcounter+" "+unsafeData.prodName[0][sorte]);
click($("feed_item"+sorte).firstElementChild); // give feed
if(feedcounter>=maxFeed){
if((sorte==zoneList[handled.zoneNrL][0][0]) && (zoneList[handled.zoneNrL][1][1]>0)){
window.setTimeout(autoFarmStable,3*settings.getPause(true),runId,4,didFeed,isBot,zoneList[handled.zoneNrL][1][0],0,zoneList[handled.zoneNrL][1][1]); // do other food
}else{
window.setTimeout(autoFarmStable,3*settings.getPause(true),runId,9,didFeed,isBot,sorte,feedcounter,maxFeed); // exit
}
}else{
window.setTimeout(autoFarmStable,settings.getPause(true),runId,step,true,isBot,sorte,feedcounter,maxFeed); // next feeding
}
break;}
case 9:{ // click errorbox if opened
if($("errorboxinner").style.display=="block"){
click($("errorboxfooterinner").getElementsByClassName("link")[0]);
window.setTimeout(autoFarmStable,settings.getPause(),runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed);
} else {
autoFarmStable(runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed);
}
break;}
case 10:{ // exit
autoZoneFinish(runId,isBot?$("building_inner").querySelector(".big_close"):null);
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step,didFeed,isBot,sorte,feedcounter,maxFeed){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoFarmStable,settings.getPause(),runId,step+1,didFeed,isBot,sorte,feedcounter,maxFeed);
};
}(listeningEvent,runId,step,didFeed,isBot,sorte,feedcounter,maxFeed),false);
}
if(action){ action(); }
help=null;listeningEvent=null;action=null;
}
}catch(err){GM_logError("autoFarmStable runId="+runId+" step="+step+" didFeed="+didFeed+" isBot="+isBot+" sorte="+sorte+" feedcounter="+feedcounter+" maxFeed="+maxFeed+"\n"+err);}
}
function autoFarmFactory(runId,step){
try{
if(!step){ step=1; }
if(bot.checkRun("autoFarmFactory",runId)){
bot.setAction("autoFarmFactory ("+step+")",true);
var action=null,listeningEvent=null;
switch(step){
case 1:{
if($("innermaincontainer").style.display=="block"){
logBubble.add(getText("automat_automatFactory"));
if($("infoblock"+unsafeWindow.locationinfo[6])){ // zone is running
autoFarmFactory(runId,4); // exit
} else {
// click on "Produktion starten"
click($("advancedproductionbutton"+unsafeWindow.locationinfo[6]+"_"+unsafeData.BUILDING_INPUT[getZoneType(handled.zoneNrL)][zoneList[handled.zoneNrL][0][0]][0][0][0]).firstElementChild);
window.setTimeout(autoFarmFactory,settings.getPause(),runId,step+1);
}
}else{
window.setTimeout(autoFarmFactory,settings.getPause(),runId,step);
}
break;}
case 2:{
if($("globalbox").style.display=="block"){
click($("globalbox_button1"));
setNextQueueItem(handled.zoneNrS);
window.setTimeout(autoFarmFactory,settings.getPause(),runId,step+1);
}else{
window.setTimeout(autoFarmFactory,settings.getPause(),runId,step);
}
break;}
case 3:{
if($("infoblock"+unsafeWindow.locationinfo[6]) && $("infoblock"+unsafeWindow.locationinfo[6]).style.display=="block"){
autoFarmFactory(runId,4);
}else{
window.setTimeout(autoFarmFactory,settings.getPause(),runId,step);
}
break;}
case 4:{ // exit
autoZoneFinish(runId,$("cancelscreen").getElementsByClassName("link")[0]);
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoFarmFactory,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
listeningEvent=null;action=null;
}
}catch(err){ GM_logError("autoFarmFactory("+step+")\n"+err); }
}
function autoFarmFactoryOil(runId,step){
try{
if(!step){ step=1; }
if(bot.checkRun("autoFarmFactoryOil",runId)){
bot.setAction("autoFarmFactoryOil ("+step+")",true);
var action=null,listeningEvent=null;
switch(step){
case 1:{ // init
// TODO check required products earlier (recalcQueue)
if(unsafeData.zones.getBlock(handled.zoneNrS)){
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,6);
}else{
if(zoneList[handled.zoneNrL][0][0]!=PRODSTOP){
var req=unsafeData.BUILDING_INPUT[getZoneType(handled.zoneNrS)][zoneList[handled.zoneNrL][0][0]][0];
for(var i=0;i<req.length;i++){
if(unsafeData.prodStock[0][req[i][0]]<req[i][1]){
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
}
}
}
if(unsafeData.zones.getEndtime(handled.zoneNrS)==NEVER){ // empty
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,3);
}else if(unsafeData.zones.getEndtime(handled.zoneNrS)<=unsafeWindow.Zeit.Server){ // cropable
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step+1);
}else{ // busy
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,6);
}
}
break;}
case 2:{ // crop
// unsaeData.valErnte
var div=$("oil_slot"+handled.slot);
if(div){
unsafeData.readyZone[handled.zoneNrS][2]=false;
click(div);
div=null;
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step+1);
}else{
autoFarmFactoryOil(runId,step+1);
}
break;}
case 3:{ // click slot
if(unsafeData.readyZone[handled.zoneNrS]){
if(unsafeData.readyZone[handled.zoneNrS][2]&&(unsafeData.readyZone[handled.zoneNrS][1]=="e")){
if(zoneList[handled.zoneNrL][0][0]==PRODSTOP){
autoFarmFactoryOil(runId,6);
}else{
var div=$("oil_slot"+handled.slot);
click(div);
div=null;
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step+1);
}
} else {
// wait for response
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step);
}
}else{
autoFarmFactoryOil(runId,6);
}
break;}
case 4:{ // click oil
var div=$("oil_selectbox");
if(div&&(div.style.display=="block")){
div=div.querySelector(".oil"+zoneList[handled.zoneNrL][0][0]);
if(div){
click(div.parentNode);
setNextQueueItem(handled.zoneNrS);
div=null;
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step+1);
} else {
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step);
}
}else{
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step);
}
break;}
case 5:{ // wait for response
if(unsafeData.readyZone[handled.zoneNrS]){
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step);
} else {
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step+1);
}
break;}
case 6:{ // start other slot or exit
var zoneNrS,zoneNrL,help,next=false;
for(var slot=1;slot<=3;slot++){
zoneNrS=handled.zoneNrF+"."+slot;
if((help=unsafeData.readyZone[zoneNrS])&&help[2]){
zoneNrL=getZoneListId(zoneNrS);
if(((help[1]=="r")&&((zoneList[zoneNrL][0][0]!=PRODSTOP)||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[zoneNrL][0][0]!=PRODSTOP))){
next=true;
handled.set(zoneNrS);
break;
}
}
}
if(next){
autoFarmFactoryOil(runId,1);
}else{
autoZoneFinish(runId,$("cancelscreen").getElementsByClassName("link")[0]);
}
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoFarmFactoryOil,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
listeningEvent=null;action=null;
}
}catch(err){ GM_logError("autoFarmFactoryOil("+step+")\n"+err); }
}
function autoFarmFactoryKnitting(runId,step){
try{
if(!step){ step=1; }
if(bot.checkRun("autoFarmFactoryKnitting",runId)){
bot.setAction("autoFarmFactoryKnitting ("+step+")",true);
var action=null,listeningEvent=null;
switch(step){
case 1:{ // init
// TODO check required products earlier (recalcQueue)
if(unsafeData.zones.getBlock(handled.zoneNrS)){
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
autoFarmFactoryKnitting(runId,5);
}else{
if(zoneList[handled.zoneNrL][0][0]!=PRODSTOP){
var req=unsafeData.BUILDING_INPUT[getZoneType(handled.zoneNrS)][zoneList[handled.zoneNrL][0][0]][0];
for(var i=0;i<req.length;i++){
if(unsafeData.prodStock[0][req[i][0]]<req[i][1]){
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
}
}
}
if(unsafeData.zones.getEndtime(handled.zoneNrS)==NEVER){ // empty
window.setTimeout(autoFarmFactoryKnitting,settings.getPause(),runId,3);
}else if(unsafeData.zones.getEndtime(handled.zoneNrS)<=unsafeWindow.Zeit.Server){ // cropable
window.setTimeout(autoFarmFactoryKnitting,settings.getPause(),runId,step+1);
}else{ // busy
window.setTimeout(autoFarmFactoryKnitting,settings.getPause(),runId,5);
}
}
break;}
case 2:{ // crop
var div=$("strickerei_slot"+handled.slot);
if(div){
listeningEvent="gameFactoryKnittingCropped";
action=function(){
unsafeData.readyZone[handled.zoneNrS][2]=false;
click(div);
div=null;
};
}else{
autoFarmFactoryKnitting(runId,5);
}
break;}
case 3:{ // open slot
if(!unsafeData.readyZone[handled.zoneNrS]){
autoFarmFactoryKnitting(runId,5);
}else if((unsafeData.readyZone[handled.zoneNrS][1]!="e")||!unsafeData.readyZone[handled.zoneNrS][2]){
// wait for response
window.setTimeout(autoFarmFactoryKnitting,settings.getPause(),runId,step);
} else if(zoneList[handled.zoneNrL][0][0]==PRODSTOP){
autoFarmFactoryKnitting(runId,5);
}else if(!$("strickerei_slot"+handled.slot).onclick.toString().match(/strickereiSelection/)){
logBubble.add("LOGIC ERROR autoFarmFactoryKnitting 3: onclick="+$("strickerei_slot"+handled.slot).onclick);
GM_log("LOGIC ERROR autoFarmFactoryKnitting 3: onclick="+$("strickerei_slot"+handled.slot).onclick);
autoFarmFactoryKnitting(runId,5);
}else{
listeningEvent="gameFactoryKnittingDialogStart";
action=function(){
click($("strickerei_slot"+handled.slot));
};
}
break;}
case 4:{ // select production
var div=$("strickerei_selection");
if(div&&(div.style.display=="block")){
div=$("strickerei_selection").querySelector('div[style*="strickerei_p'+zoneList[handled.zoneNrL][0][0]+'"]');
if(div){
listeningEvent="gameFactoryKnittingStarted";
action=function(){
click(div.parentNode.parentNode);
setNextQueueItem(handled.zoneNrS);
div=null;
};
} else {
window.setTimeout(autoFarmFactoryKnitting,settings.getPause(),runId,step);
}
}else{
window.setTimeout(autoFarmFactoryKnitting,settings.getPause(),runId,step);
}
break;}
case 5:{ // start other slot or exit
var zoneNrS,zoneNrL,help,next=false;
for(var slot=1;slot<=3;slot++){
zoneNrS=handled.zoneNrF+"."+slot;
if((help=unsafeData.readyZone[zoneNrS])&&help[2]){
zoneNrL=getZoneListId(zoneNrS);
if(((help[1]=="r")&&((zoneList[zoneNrL][0][0]!=PRODSTOP)||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[zoneNrL][0][0]!=PRODSTOP))){
next=true;
handled.set(zoneNrS);
break;
}
}
}
if(next){
autoFarmFactoryKnitting(runId,1);
}else{
autoZoneFinish(runId,$("cancelscreen").getElementsByClassName("link")[0]);
}
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoFarmFactoryKnitting,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
listeningEvent=null;action=null;
}
}catch(err){ GM_logError("autoFarmFactoryKnitting("+step+")\n"+err); }
}
function autoFarmMegafield(runId,step){
try{
if(!step){ step=1; }
if(bot.checkRun("autoFarmMegafield",runId)){
bot.setAction("autoFarmMegafield ("+step+")",true);
var action=null,listeningEvent=null;
switch(step){
case 1:{ // init
// TODO
if(unsafeWindow.megafield_data.tour){
autoFarmMegafield(runId,5);
}else{
autoFarmMegafield(runId,step+1);
}
break;}
case 2:{ // crop vehicle
if(unsafeWindow.megafield_vehicle_id&&(unsafeWindow.megafield_tour_type=="harvest")){
if(unsafeWindow.megafield_data.vehicles[unsafeWindow.megafield_vehicle_id].durability>0){
autoFarmMegafield(runId,step+1);
}else{
// TODO buy vehicle
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
}
}else{
// TODO select vehicle
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
}
break;}
case 3:{ // crop vehicle
if(unsafeWindow.megafield_plant_pid>0){
click($("megafield_vehicle_select_slot"));
autoFarmMegafield(runId,step+1);
}else{
autoFarmMegafield(runId,step+1);
}
break;}
case 4:{ // crop
var area=unsafeWindow.megafield_data.area;
var areaSize=unsafeData.BUILDING_SIZE["19"][0]*unsafeData.BUILDING_SIZE["19"][1];
// Generate route
var i=0;
while(i<=areaSize){
for(i=1;i<=areaSize;i++){
if(area[i]&&(area[i].remain<0)&&($("megafield_tile_tour"+i).className=="megafield_area_tour_possible")){
click($("megafield_tile"+i));
break;
}
}
}
// Commit
if($("megafield_vehicle_go"+unsafeWindow.megafield_vehicle_id).style.display=="block"){
listeningEvent="gameMegafieldTourStarted";
action=function(){ click($("megafield_vehicle_go"+unsafeWindow.megafield_vehicle_id)); };
}
break;}
case 5:{ // Plant
autoFarmMegafield(runId,step+1);
break;}
case 6:{ // Exit
if(unsafeWindow.megafield_data.tour){
zoneWaiting[handled.zoneNrF]=now+unsafeWindow.megafield_data.tour.remain;
window.setTimeout(function(){
for(var fz in zoneWaiting){
if(!zoneWaiting.hasOwnProperty(fz)){continue;}
if(zoneWaiting[fz]<=now){ delete zoneWaiting[fz]; }
}
checkReadyZone();
},(1000*unsafeWindow.megafield_data.tour.remain)+settings.getPause());
logBubble.add("Waiting for crop in "+getTimeStr(unsafeWindow.megafield_data.tour.remain)); // TODO text
}
autoZoneFinish(runId);
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoFarmMegafield,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
listeningEvent=null;action=null;
}
}catch(err){ GM_logError("autoFarmMegafield("+step+")\n"+err); }
}
function autoWindmill(runId,step){
try{
if(!step){ step=1; }
if(settings.get("account","botUseWindmill")&&bot.checkRun("autoWindmill",runId)){
bot.setAction("autoWindmill ("+step+")",true);
var action=null,listeningEvent=null;
switch(step){
case 1: // init and open city
handled.set("windmill.1");
reSortWindmill(false); // checks if recipe is possible
if(zoneList[handled.zoneNrL].length==0){ zoneList[handled.zoneNrL]=DEFAULT_ZONELIST_MILL_ARRAY; }
if(unsafeData.readyZone["windmill"]&&(unsafeData.readyZone["windmill"][1]=="e")&&(zoneList[handled.zoneNrL][0][0]==PRODSTOP)){
// Windmill is empty and no recipe to do
autoWindmill(runId,8); // exit
}else{
listeningEvent="gameCity2";
action=function(){ click($top("speedlink_city2")); };
}
break;
case 2: // open windmill
// test if possible $("windmillproductiontime").style.display=="block"
listeningEvent="gameOpenWindmill";
action=function(){ click($("cityzone_2_1")); };
break;
case 3: // get powerup
if(unsafeData.zones.getEndtime(handled.zoneNrS)<unsafeWindow.Zeit.Server){
listeningEvent="gameWindmillCropped";
action=function(){ click($("windmill_slot"+handled.slot)); };
}else{
autoWindmill(runId,step+1);
}
break;
case 4: // open slot
listeningEvent="gameWindmillDialogStart";
action=function(){ click($("windmill_slot"+handled.slot)); };
break;
case 5: // click new recipe
if(zoneList[handled.zoneNrL][0][0]!=PRODSTOP){
var newdiv=$("windmill_formula_select_inner").querySelector(".fm"+zoneList[handled.zoneNrL][0][0]);
if(newdiv){
listeningEvent="gameWindmillDialogCommit";
action=function(){
click(newdiv.parentNode);
newdiv=null;
};
} else {
// TODO: why is the recipe not available?
autoWindmill(runId,8); // exit
}
} else {
autoWindmill(runId,8); // exit
}
break;
case 6: // confirm new recipe
if($("windmill_paper").style.display=="block"){
listeningEvent="gameWindmillStarted";
action=function(){
unsafeData.readyZone[handled.zoneNrL][2]=false;
click($("windmill_paper_commit"));
};
} else {
window.setTimeout(autoWindmill,settings.getPause(),runId,step);
}
break;
case 7: // wait for response
if(unsafeData.readyZone[handled.zoneNrL]){
window.setTimeout(autoWindmill,settings.getPause(),runId,step);
} else {
botArbiter.clear("windmill");
//if($("windmillproductiontime").style.display=="block"){
// windmill started -> pop from queue
if(isNaN(zoneList[handled.zoneNrL][0][1])){ zoneList[handled.zoneNrL][0][1]=1; }
if(autoMillStorage[zoneList[handled.zoneNrL][0][0]]&&autoMillStorage[zoneList[handled.zoneNrL][0][0]][2]>0){
zoneList[handled.zoneNrL][0][1]--;
autoMillStorage[zoneList[handled.zoneNrL][0][0]][0]--;
}
if(zoneList[handled.zoneNrL][0][1]<=0 && zoneList[handled.zoneNrL].length<=1){ zoneList[handled.zoneNrL]=DEFAULT_ZONELIST_MILL_ARRAY.clone(); }
// } else {
// // windmill not started -> stop queue
// zoneList[zoneNrL].unshift(DEFAULT_ZONELIST_MILL.clone()); //insert stop item at begin
// }
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList,"autoWindmill/zoneList"),"autoWindmill/zoneList");
reCalculateWindmill();
reSortWindmill(zoneSettings[handled.zoneNrL]["shuffle"]);
reFillQueueBox(handled.zoneNrF, handled.zoneNrL, 0);
autoWindmill(runId,step+1);
}
break;
case 8: // close windmill
if($("windmillinner").style.display=="block"){
click($("windmillinner").querySelector(".big_close"));
window.setTimeout(autoWindmill,settings.getPause(),runId,step+1);
} else {
autoWindmill(runId,step+1);
}
case 9: //
bot.end();
botArbiter.check(); // -> calls activatePowerUp if needed
break;
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoWindmill,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
listeningEvent=null;action=null;
}
}catch(err){ GM_logError("autoWindmill("+step+")\n"+err); }
}
function checkPowerUp(mode){
try{
var foundPowerUp=false;
if(settings.get("account","powerUpActivate")){
for(var v in unsafeWindow.poweruprack){ // find powerup
if(!unsafeWindow.poweruprack.hasOwnProperty(v)){ continue; }
if(unsafeWindow.poweruprack[v][5] && unsafeWindow.poweruprack[v][5][0] && unsafeWindow.poweruprack[v][5][0][1]){
foundPowerUp=v;
break;
}
}
}
return mode==0?(!!foundPowerUp):foundPowerUp;
}catch(err){ GM_logError("checkPowerUp\n"+err);return null; }
}
function autoActivatePowerUp(runId,step,foundPowerUp){
try{
// GM_log("autoLottery runId="+runId+" step="+step);
if(bot.checkRun("autoActivatePowerUp",runId)){
if(!settings.get("account","powerUpActivate")){
step=5;
}else if(!step){
step=1;
}
// logBubble.add("autoActivatePowerUp "+[runId,step,foundPowerUp]);
bot.setAction("autoActivatePowerUp ("+step+")");
var help,action=null,listeningEvent=null;
switch(step){
case 1:{
foundPowerUp=checkPowerUp();
if(foundPowerUp==null){ // no power-up
logBubble.add("Power-up: Exiting, no powerup found",5,"red");
if($("powerupselector").style.display=="block"){ click($("powerupbar")); }
autoActivatePowerUp(runId,5,foundPowerUp) // exit
}else if(unsafeWindow.farm!=1){ //switch to farm
listeningEvent="gameFarmOpened";
action=function(){
logBubble.add("Power-up: Goto Farm",5,"green");
click($("speedlink_farm1"));
};
}else if(unsafeWindow.poweruprack[foundPowerUp]){
autoActivatePowerUp(runId,step+1,foundPowerUp);
}else{
logBubble.add("Power-up: Exiting, unknown combination",5,"red");
if($("powerupselector").style.display=="block"){ click($("powerupbar")); }
autoActivatePowerUp(runId,5,foundPowerUp) // exit
}
break;}
case 2:{ // open power-up container
if($("powerupselector").style.display=="block"){
autoActivatePowerUp(runId,step+1,foundPowerUp);
}else{
listeningEvent="gamePoweruprackUpdated";
action=function(){
logBubble.add("Power-up: Open container",5,"green");
click($("powerupbar"));
};
}
break;}
case 3:{ // click power-up / scroll to power-up
var help;
if(help=$("powerup_rackitem"+unsafeWindow.poweruprack[foundPowerUp][0]+"_tt")){
listeningEvent="gameOpenGlobalBox";
action=function(){
logBubble.add("Power-up: Click power-up",5,"green");
click(help.parentNode);
};
}else if(help=$("powerselectorcontent")){
help=parseInt(/activatePowerupCommit\((\d+)/.exec(help.firstElementChild.getAttribute("onclick"))[1],10);
listeningEvent="gamePoweruprackUpdated";
if(help<foundPowerUp){
action=function(){
logBubble.add("Power-up: Scroll up",5,"green");
click($("powerselectornaviup"));
};
}else{
action=function(){
logBubble.add("Power-up: Scroll down",5,"green");
click($("powerselectordown"));
};
}
}else{
autoActivatePowerUp(runId,5,foundPowerUp) // exit
}
break;}
case 4:{ // confirm power-up
listeningEvent="gamePoweruprackUpdated";
action=function(){
logBubble.add("Power-up: Confirm power-up",5,"green");
click($("globalbox_button1"));
};
break;}
case 5:{ // close container
// botArbiter.add("activatePowerUp");
if($("powerupselector").style.display=="block"){
logBubble.add("Power-up: Close container",5,"green");
autoZoneFinish(runId,$("powerselectorclose"));
}else{
autoZoneFinish(runId);
}
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step,foundPowerUp){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoActivatePowerUp,settings.getPause(),runId,step+1,foundPowerUp);
};
}(listeningEvent,runId,step,foundPowerUp),false);
}
if(action){ action(); }
help=null;listeningEvent=null;action=null;
}
}catch(err){GM_logError("autoActivatePowerUp runId="+runId+" step="+step+"\n"+err);}
}
function autoForestry(runId){
try{
if(!settings.get("account","botUseForestry")){
GM_log("FORESTRY BOT OFF: autoForestry");
}else if(bot.checkRun("autoForestry",runId)){
bot.setAction("autoForestry");
var zoneNrS=getReadyZone("forestry");
if(zoneNrS==null){
GM_log("autoForestry. no ready zone\nreadyZone="+implode(unsafeData.readyZone));
autoZoneFinish(runId);
}else{
handled.set(zoneNrS);
try{ unsafeWindow.jsTimeStamp=unsafeWindow.Zeit.Client - unsafeWindow.Zeit.Verschiebung; }catch(err){}
if(unsafeData.readyZone[handled.zoneNrS][2]){
switch(handled.zoneBuildingTyp){
case "forest": autoForestryForest(runId,1,1,false,true); break;
case "sawmill":
case "carpentry": autoForestryBuilding(runId,1); break;
}
}else{
GM_log("autoForestry. data not ready\nreadyZone[handled.zoneNrS]="+implode(unsafeData.readyZone[handled.zoneNrS]));
autoZoneFinish(runId); // TODO else
}
}
}
if(DEVMODE_FUNCTION){ GM_log("End autoForestry handled.zoneNr:"+handled.zoneNr);}
}catch(err){GM_logError("autoForestry runId="+runId+"\n"+err);autoZoneFinish(runId);} //busy=false;
}
function autoForestryForest(runId,step,field,didPlant,isBot){
try{
// GM_log("autoForestryForest runId="+runId+" step="+step+" field="+field+" didPlant="+didPlant+" isBot="+isBot);
if(settings.get("account","botUseForestry")&&bot.checkRun("autoForestryForest",runId,!isBot)){
bot.setAction("autoForestryForest ("+step+")");
var help,action=null,listeningEvent=null;
switch(step){
case 1:{ // init
if(zoneList[handled.zoneNrL].length==0){ zoneList[handled.zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone(); }
if(unsafeData.prodTyp[1][zoneList[handled.zoneNrL][0][0]]!="f1"){ zoneList[handled.zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone(); }
// open forestry
if((help=unsafeData.readyZone[handled.zoneNrL])&&help[2]&&(!zoneWaiting[handled.zoneNrL])&&((help[1]=="w")||((help[1]=="r")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP)))){
listeningEvent="gameOpenForestry";
action=function(){ click($("speedlink_forestry")); };
}else{
autoForestryForest(runId,9,field,didPlant,isBot); // -> exit
}
break;}
case 2:{ // set zoneWaiting
var time=NEVER;
var NowServer=unsafeWindow.Zeit.Server;
for(var v=0;v<unsafeWindow.forestry_area_time.length;v++){ //use area_time because this holds only planted fields or if just emptied==0
if(unsafeWindow.forestry_area_time[v]>0){
time=Math.min(time,unsafeWindow.forestry_area_time[v]);
}
}
time=Math.max(time,0);
if(time<=settings.get("account","seedWaitForCrop")){
zoneWaiting[handled.zoneNrF]=now+time;
window.setTimeout(function(){
for(var fz in zoneWaiting){
if(!zoneWaiting.hasOwnProperty(fz)){continue;}
if(zoneWaiting[fz]<=now){ delete zoneWaiting[fz]; }
}
checkReadyZone();
},(1000*time)+settings.getPause());
logBubble.add("Waiting for crop in "+getTimeStr(time)); // TODO text
autoForestryForest(runId,9,field,didPlant,isBot); // -> exit
}else{
autoForestryForest(runId,step+1,field,didPlant,isBot);
}
break;}
case 3:{ // cropping
if((!isBot)||(zoneList[handled.zoneNrL][0][0]!=PRODSTOP)||(!settings.get("account","disableCropFields"))){
logBubble.add("Forest automat<br>Cropping"); //TODO texte
if(!unsafeData.zones.getProduction(handled.zoneNrS)[3]){
// logBubble.add("autoForestryForest step="+step+"\ndata not ready");
window.setTimeout(autoForestryForest,settings.getPause(),runId,step,field,didPlant,isBot);
}else if(unsafeWindow.premium==1){
if(unsafeData.zones.getEndtime(handled.zoneNrS)<unsafeWindow.Zeit.Server){
listeningEvent="gameOpenForestry";
action=function(){ click($top("forestry_forest_button2")); };
}else{
autoForestryForest(runId,step+1,field,didPlant,isBot);
}
}else if(field<=25){
for(var i in unsafeWindow.forestry_area){ //if not in forestry_area the field is empty
if(!unsafeWindow.forestry_area.hasOwnProperty(i)){continue;}
if(parseInt(unsafeWindow.forestry_area[i]["position"],10)==field){
break;
}
}
if((unsafeWindow.forestry_area[i]["category"]==1)&&(unsafeWindow.forestry_area[i]["block"]=="0")&&(unsafeWindow.forestry_area[i]["ready"]==1)){
var prod=20+parseInt(unsafeWindow.forestry_area[i]["productid"],10);
if(unsafeData.prodStock[1][prod]+unsafeData.prodYield[1][prod]<=unsafeData.prodStockMax[1][prod]){
unsafeData.prodStock[1][prod]+=unsafeData.prodYield[1][prod];
unsafeData.zones.flagProduction(handled.zoneNrS);
click($("forestry_pos"+field));
window.setTimeout(autoForestryForest,settings.getPause(true),runId,step,field+1,didPlant,isBot);
}else{
logBubble.add("Crop of tree "+field+" not possible due to stock capacity.");
autoForestryForest(runId,step,field+1,didPlant,isBot);
}
}else{
autoForestryForest(runId,step,field+1,didPlant,isBot);
}
}else if(isBot){
autoForestryForest(runId,step+1,1,didPlant,isBot);
}else{
autoForestryForest(runId,9,1,didPlant,isBot); // -> exit
}
}else{
autoForestryForest(runId,step+1,1,didPlant,isBot);
}
break;}
case 4:{ // select tree
if(zoneList[handled.zoneNrL][0][0]==PRODSTOP){
autoForestryForest(runId,8,1,didPlant,isBot); // -> water
}else if((unsafeWindow.premium!=1)&&(zoneList[handled.zoneNrL][0][0]!=unsafeWindow.forestry_plant)){
logBubble.add("Forest automat<br>Select tree"); //TODO texte
if(help=$("f_stock_item"+zoneList[handled.zoneNrL][0][0])){
click(help);
window.setTimeout(autoForestryForest,settings.getPause(true),runId,step,field,didPlant,isBot);
}else{ // tree not available
logBubble.add("Tree not available"); //TODO texte
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone()); //add PRODSTOP to begin of list
updateQueueBox(handled.zoneNrS);
autoForestryForest(runId,8,1,didPlant,isBot); // -> water
}
}else{
autoForestryForest(runId,step+1,1,didPlant,isBot);
}
break;}
case 5:{ // planting
if(field==1){
logBubble.add("Forest automat<br>"+getText("automat_planting")); //TODO texte
}
help=false;
for(var i in unsafeWindow.forestry_area){ //if not in forestry_area the field is empty
if(!unsafeWindow.forestry_area.hasOwnProperty(i)){continue;}
if(parseInt(unsafeWindow.forestry_area[i]["position"],10)==field){
help=true;
break;
}
}
if(help){
autoForestryForest(runId,step,field+1,didPlant,isBot);
}else if(field>25){
autoForestryForest(runId,7,1,didPlant,isBot); // finish planting
}else if(unsafeWindow.premium==1){
click($("forestry_forest_button6"));
window.setTimeout(autoForestryForest,settings.getPause(true),runId,step+1,field,didPlant,isBot);
}else{
unsafeData.zones.flagProduction(handled.zoneNrS);
logBubble.add("click field:"+field,10,"orange"); //TODO texte
click($("forestry_pos"+field));
window.setTimeout(autoForestryForest,settings.getPause(true),runId,step,field+1,true,isBot);
}
break;}
case 6:{ // premium planting: select tree and commit
var help=$("forestry_autoplant_pid");
if(help.value==zoneList[handled.zoneNrL][0][0]){
unsafeData.zones.flagProduction(handled.zoneNrS);
click($("globalbox_button1"));
window.setTimeout(autoForestryForest,settings.getPause(true),runId,step+1,field,true,isBot);
}else{
help.value=zoneList[handled.zoneNrL][0][0];
window.setTimeout(autoForestryForest,settings.getPause(),runId,step,field,didPlant,isBot);
}
break;}
case 7:{ // finish planting
if(unsafeData.zones.getProduction(handled.zoneNrS)[3]){
// if(autoZoneCrop()){ ... go back }
if(isBot&&didPlant){ setNextQueueItem(handled.zoneNrS); }
autoForestryForest(runId,step+1,1,didPlant,isBot);
}else{
window.setTimeout(autoForestryForest,settings.getPause(),runId,step,field,didPlant,isBot);
}
break;}
case 8:{ // watering
if(unsafeData.zones.getBonus(handled.zoneNrF)>0){
logBubble.add("Forest automat<br>"+getText("automat_watering")); //TODO texte
if(!unsafeData.zones.getProduction(handled.zoneNrS)[3]){
window.setTimeout(autoForestryForest,settings.getPause(),runId,step,field,didPlant,isBot);
}else if(unsafeData.zones.getWatertime(handled.zoneNrS)<unsafeWindow.Zeit.Server){
unsafeData.zones.flagProduction(handled.zoneNrS);
listeningEvent="gameOpenForestry";
action=function(){ click($top("forestry_forest_button1")); };
}else{
autoForestryForest(runId,step+1,field,didPlant,isBot);
}
}else{
autoForestryForest(runId,step+1,field,didPlant,isBot);
}
break;}
case 9:{ // exit
autoZoneFinish(runId);
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step,field,didPlant,isBot){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoForestryForest,settings.getPause(),runId,step+1,field,didPlant,isBot);
};
}(listeningEvent,runId,step,field,didPlant,isBot),false);
}
if(action){ action(); }
help=null;listeningEvent=null;action=null;
}
}catch(err){GM_logError("autoForestryForest runId="+runId+" step="+step+" field="+field+" didPlant="+didPlant+" isBot="+isBot+"\n"+err);}
}
function autoForestryBuilding(runId,step){
try{
// GM_log("autoForestryBuilding runId="+runId+" step="+step+" handled.zoneNrS="+handled.zoneNrS);
if(settings.get("account","botUseForestry")&&bot.checkRun("autoForestryBuilding",runId)){
bot.setAction("autoForestryBuilding ("+step+")");
var help,action=null,listeningEvent=null;
switch(step){
case 1:{ // init and open forestry
if(zoneList[handled.zoneNrL].length==0){ zoneList[handled.zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone(); }
if(handled.zoneNrF=="sawmill"){
if(unsafeData.prodTyp[1][zoneList[handled.zoneNrL][0][0]]!="f3"){ zoneList[handled.zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone(); }
}else{
if((unsafeData.prodTyp[1][zoneList[handled.zoneNrL][0][0]]!="f4")&&(unsafeData.prodTyp[1][zoneList[handled.zoneNrL][0][0]]!="f5")){ zoneList[handled.zoneNrL]=DEFAULT_ZONELIST_ITEM_ARRAY.clone(); }
}
if((help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&(((help[1]=="r")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP)))){
if((help=$("forestry_container"))&&(help.style.display=="block")){
autoForestryBuilding(runId,step+1);
}else{
action=function(){ click($("speedlink_forestry")); };
listeningEvent="gameOpenForestry";
}
}else{
autoForestryBuilding(runId,8); // -> exit
}
break;}
case 2:{ // check required products and open building
help=true;
if(zoneList[handled.zoneNrL][0][0]!=PRODSTOP){
help=unsafeData.prodRequire[1][zoneList[handled.zoneNrL][0][0]];
if(typeof help=="object"){
for(var i=0;i<help.length;i++){
if(unsafeData.prodStock[help[i][0]][help[i][1]]<help[i][2]){
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
break;
}
}
}
}
if((help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&(((help[1]=="r")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP)))){
if((help=$("forestry_building_inner"))&&(help.style.display=="block")&&(help.className==(handled.zoneNrF=="sawmill"?"forestry_building_inner_back1":"forestry_building_inner_back2"))){
autoForestryBuilding(runId,step+1);
}else{
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Opening"); //TODO texte
action=function(){ click($("forestry_building_click"+(handled.zoneNrF=="sawmill"?"1":"2"))); };
listeningEvent="game"+handled.zoneNrF.capitalize()+"Opened";
}
}else{
autoForestryBuilding(runId,8); // -> exit
}
break;}
case 3:{ // cropping
if((help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&(help[1]=="r")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP||!settings.get("account","disableCropFields"))){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Cropping"); //TODO texte
if(help=$("forestry_building_inner_slot_info"+handled.slot)){
action=function(){ click(help); };
listeningEvent="game"+handled.zoneNrF.capitalize()+"Cropped";
}else{
autoForestryBuilding(runId,step+2);
}
}else{
autoForestryBuilding(runId,step+2);
}
break;}
case 4:{ // confirm
autoForestryBuilding(runId,step+1);
break;}
case 5:{ // open slot
if(zoneList[handled.zoneNrL][0][0]!=PRODSTOP){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Opening slot"); //TODO texte
action=function(){ click($("forestry_building_inner_slot_info"+handled.slot)); };
listeningEvent="game"+handled.zoneNrF.capitalize()+"SlotOpened";
}else{
autoForestryBuilding(runId,8); //->exit
}
break;}
case 6:{ // start production
if((help=$("forestry_selectproduction_scrollcontent"))&&(help=help.querySelector(".f_symbol"+zoneList[handled.zoneNrL][0][0]))&&(help=help.parentNode.parentNode)&&(help.getAttribute("onclick")!="")){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Start production"); //TODO texte
action=function(){ click(help); };
listeningEvent="gameOpenGlobalBox";
}else{
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
autoForestryBuilding(runId,8); //->exit
}
break;}
case 7:{ // confirm
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Confirm start production"); //TODO texte
action=function(){
click($("globalbox_button1"));
setNextQueueItem(handled.zoneNrS);
};
listeningEvent="game"+handled.zoneNrF.capitalize()+"Started";
break;}
case 8:{ // other slots
var zoneNrS,zoneNrL,help,next=false;
for(var slot=1;slot<=3;slot++){
zoneNrS=handled.zoneNrF+"."+slot;
if((help=unsafeData.readyZone[zoneNrS])&&help[2]){
zoneNrL=getZoneListId(zoneNrS);
if(((help[1]=="r")&&((zoneList[zoneNrL][0][0]!=PRODSTOP)||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[zoneNrL][0][0]!=PRODSTOP))){
next=true;
handled.set(zoneNrS);
break;
}
}
}
if(next){
autoForestryBuilding(runId,2);
}else{
autoZoneFinish(runId,$("forestry_building_inner").querySelector(".big_close")); // exit
}
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoForestryBuilding,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
help=null;listeningEvent=null;action=null;
}
}catch(err){GM_logError("autoForestryBuilding runId="+runId+" step="+step+"\n"+err);}
}
function autoDonkey(runId, step) {
try {
if (bot.checkRun("autoDonkey", runId)) {
var help, action=null, listeningEvent=null;
if (!step) { step=1; }
bot.setAction("autoDonkey (" + step + ")");
switch (step) {
case 1: { // go to farm 1
if (unsafeWindow.farm == 1) {
autoDonkey(runId, step + 1);
} else {
listeningEvent="gameFarmOpened";
action=function(){
logBubble.add("Goto Farm 1",5,"green");
click($("speedlink_farm1"));
};
}
break; }
case 2: { // open donkey
if ($("globalbox").style.display == "block" || $("box_donkeydialog").style.display == "block") {
autoDonkey(runId, step + 1);
} else {
listeningEvent = "gameDonkeyResponse";
action = function() {
logBubble.add("Donkey: Opening", 5, "green");
click($("farm_inner_waltraud"));
};
}
break; }
case 3: { // exit
logBubble.add("Donkey: Exiting", 5, "green");
if ($("box_donkeydialog").style.display == "block") { // Donkey gain dailog
autoZoneFinish(runId, $("box_donkeydialogsubmit").getElementsByTagName("button")[0]);
} else if ($("globalbox").style.display == "block") { // Donkey already visited today
autoZoneFinish(runId, $("globalbox_button1"));
} else if ($("buybox_donkey").style.display == "block") { // Donkey not bought
autoZoneFinish(runId, $("buybox_donkey").getElementsByClassName("close")[0]);
} else {
autoZoneFinish(runId);
}
break;}
}
if (listeningEvent) {
document.addEventListener(listeningEvent, function(listeningEvent, runId, step){
return function() {
document.removeEventListener(listeningEvent, arguments.callee, false);
window.setTimeout(autoDonkey, settings.getPause(), runId, step+1);
};
} (listeningEvent, runId, step), false);
}
if (action) { action(); }
help=null; listeningEvent=null; action=null;
}
} catch (err) {
GM_logError("autoDonkey runId=" + runId + "\n" + err);
}
}
function autoLottery(runId,step){
try{
// GM_log("autoLottery runId="+runId+" step="+step);
if(bot.checkRun("autoLottery",runId)){
var help,action=null,listeningEvent=null;
if(!step){ step=1; }
bot.setAction("autoLottery ("+step+")");
switch(step){
case 1:{ // go to city 2
if(unsafeWindow.city==2){
autoLottery(runId,step+1);
}else{
listeningEvent="gameCity2";
action=function(){
logBubble.add("Goto City 2",5,"green");
click($top("speedlink_city2"));
};
}
break;}
case 2:{ // open lottery
if($("lotterycontainer").style.display=="block"){
autoLottery(runId,step+1);
}else{
listeningEvent="gameLotteryOpen";
action=function(){
logBubble.add("Lottery: Opening",5,"green");
click($("cityzone_2_8"));
};
}
break;}
case 3:{ // Daily lot: get lot
if(($("lotterycontainer").style.display=="block") && ($("dailylotleft").style.display!="none")){
listeningEvent="gameLotteryGotDailyLot";
action=function(){
logBubble.add("Lottery: Getting daily lot",5,"green");
click($("dailylot"));
};
}else{
autoLottery(runId,6); // exit
}
break;}
case 4:{ // Daily lot: got lot
if($("currentlot").style.display=="block"){
logBubble.add("Lottery: Got daily lot",5,"green");
var lotid=$("currentlot").style.backgroundImage.match(/lotback_(\d*).jpg/i)[1];
//GM_log("lottery currentlot id:"+lotid + ":");
if(settings.get("account","lotteryDailyLot") && (lotid==null?false:(!(unsafeData.lotteryCollectForPrize["total"]&&unsafeData.lotteryCollectForPrize["total"][lotid])?false:(unsafeData.lotteryCollectForPrize["total"][lotid]>=(unsafeWindow.lotrack[lotid]?unsafeWindow.lotrack[lotid]:0))))){
logBubble.add("Lottery: Saving lot",5,"green");
click($("prizeslotkeeplot"));
window.setTimeout(autoLottery,settings.getPause(),runId,6); // exit
}else{
listeningEvent="gameLotteryGotPrize";
action=function(){
logBubble.add("Lottery: Getting prizes",5,"green");
click($("prizeslotgetprize"));
};
window.setTimeout(autoLottery,settings.getPause(),runId,step+2);
}
}
break;}
case 5:{ // Daily lot: got prize
if($("globalbox").style.display=="block"){
click($("globalbox_button1"));
window.setTimeout(autoLottery,settings.getPause(),runId,step+1);
}else{
autoLottery(runId,step+1);
}
break;}
case 6:{ // exit
if($("lotterycontainer").style.display=="block"){
logBubble.add("Lottery: Exiting",5,"green");
autoZoneFinish(runId,$("lotteryhead").getElementsByClassName("link")[0]);
}else{
autoZoneFinish(runId);
}
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoLottery,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
help=null;listeningEvent=null;action=null;
}
}catch(err){GM_logError("autoLottery runId="+runId+" step="+step+"\n"+err);}
}
/* quest-bot needs review
function checkQuest(){
if(DEVMODE_FUNCTION){GM_log("Begin checkQuest");}
var doQuest=true;
var questNr=parseInt(unsafeData.questData["farm"]["1"]["nr"],10);
if(unsafeData.questData["farm"]["1"]["state"]==2){
var iId,iType;
for(var i=0;i<unsafeData.QUESTS["farm"]["1"][questNr][0].length;i++){
iType=0;
iId=unsafeData.QUESTS["farm"]["1"][questNr][0][i][0];
//GM_log("checkQuest iId:"+iId+" doQuest:"+doQuest+" prodStock[0]["+iId+"]:"+unsafeData.prodStock[0][iId]+" GMprodMinRackInit[0]["+iId+"]:"+unsafeData.prodMinRackInit[0][iId]+" QUESTS["+questNr+"][0]["+i+"][1]:"+unsafeData.QUESTS["farm"]["1"][questNr][0][i][1]);
doQuest=doQuest&&unsafeData.prodStock[iType][iId]&&(unsafeData.prodStock[iType][iId]>(unsafeData.prodMinRackInit[iType][iId]+unsafeData.QUESTS["farm"]["1"][questNr][0][i][1]));
//doQuest=doQuest&&unsafeData.prodStock[iType][iId]&&(unsafeData.prodStock[iType][iId]>(unsafeData.prodMinRack[iType][iId]+(unsafeData.prodMinRackSettings["valMinRackQuest"]?0:unsafeData.QUESTS["farm"]["1"][questNr][0][i][1])));
//GM_log("checkQuest iId:"+iId+" doQuest:"+doQuest);
if(!doQuest) break;
}
iId=null;
}
if(DEVMODE_FUNCTION){GM_log("End checkQuest doQuest:"+doQuest);}
return doQuest;
}
function autoActivateQuest(){
if(DEVMODE_FUNCTION){GM_log("Begin autoActivateQuest"); }
if(!busy){ GM_log("BUSY NOT SET: autoActivateQuest"); return false;}
var questNr=unsafeData.questData["farm"]["1"]["nr"];
logBubble.add("Looking for Quest:"+questNr,5,"green");
if(!checkQuest()){
logBubble.add("Exiting to low number of product available",5,"red");
window.setTimeout(autoZoneFinish,settings.getPause());
}else if((unsafeData.questData["farm"]["1"]["state"]==0 || unsafeWindow.city==1) && $("errorboxcity").style.display=="block"){
logBubble.add("Exiting no Quest found to accept or finish",5,"red");
click($("errorboxfootercity").firstElementChild);
window.setTimeout(autoZoneFinish,settings.getPause());
}else if(unsafeWindow.city!=1){
document.addEventListener("gameCity1",function(){
document.removeEventListener("gameCity1",arguments.callee,false);
logBubble.add("Arrived in city 1",5,"green");
window.setTimeout(autoActivateQuest,settings.getPause());
},false);
logBubble.add("Goto City 1",5,"green");
click($top("citylineitem1"));
}else if(unsafeData.questData["farm"]["1"]["state"]>0 && unsafeWindow.city==1 && $("questboxcity").style.display!="block"){ //open quest box
logBubble.add("Open Quest "+questNr,5,"green");
if(DEVMODE){ GM_log("Open Quest "+questNr); }
unsafeWindow.fillQuestBox(questNr);
window.setTimeout(autoActivateQuest,settings.getPause());
}else if(valQuestActivate && valQuestActivateUntilNr>=questNr && unsafeWindow.city==1 && $("questboxcity").style.display=="block" && unsafeData.questData["farm"]["1"]["state"]==1){ //accept quest
if(DEVMODE){ GM_log("Accept Quest "+questNr); }
document.addEventListener("gameQuestAccepted",function(){//todo this does n't work
document.removeEventListener("gameQuestAccepted",arguments.callee,false);
logBubble.add("Accepted Quest "+questNr,5,"green");
autoZoneFinish();
},false);
click($("questboxfootercity").firstElementChild);
}else if(valQuestSolving && valQuestSolvingUntilNr>=questNr && unsafeWindow.city==1 && $("questboxcity").style.display=="block" && unsafeData.questData["farm"]["1"]["state"]==2){ //finish quest
if(DEVMODE){ GM_log("Finish Quest "+questNr); }
document.addEventListener("gameQuestFinished",function(){ //todo this does n't work
document.removeEventListener("gameQuestFinished",arguments.callee,false);
logBubble.add("Finished Quest "+questNr,5,"green");
autoZoneFinish();
},false);
click($("questboxfootercity").firstElementChild);
}else{
logBubble.add("Exiting quest unknown combination",10,"red");
autoZoneFinish();
}
if(DEVMODE_FUNCTION){GM_log("End autoActivateQuest");}
}
function checkLodgeQuest(){
if(DEVMODE_FUNCTION){GM_log("Begin checkLodgeQuest");}
//LQUESTS["campaign"]["nr"][[[type,id,amount]],waittime,points,[[type,tekst]]]
var doQuest=false;
var campaignNr="1";
var lquestNr=unsafeData.questData["lodge"][campaignNr]["nr"];
if(unsafeData.questData["lodge"][campaignNr]["time"]<=now){
//if(DEVMODE_FUNCTION){GM_log("Mid checkLodgeQuest doQuest:"+doQuest+" time:"+(now-unsafeData.questData["lodge"][campaignNr]["time"]));}
var iId,iType;
for(var i=0;i<unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0].length;i++){
iType=unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0][i][0];
iId=unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0][i][1];
//GM_log("checkLodgeQuest iId:"+iId+" doQuest:"+doQuest+" prodStock["+iType+"]["+iId+"]:"+unsafeData.prodStock[iType][iId]+" GMprodMinRackInit["+iType+"]["+iId+"]:"+unsafeData.prodMinRackInit[iType][iId]+" LQUESTS["+campaignNr+"]["+lquestNr+"][0]["+i+"]:"+unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0][i]);
iAdd=unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0][i][2]-((unsafeData.questData["lodge"][campaignNr][iId]&&unsafeData.questData["lodge"][campaignNr][iId]["type"]==iType)?unsafeData.questData["lodge"][campaignNr][iId]["sum"]:0); //unsafeData.questData["lodge"][campaignNr][fId]["type":0,"max":0,"sum":0]
iAdd=Math.min(iAdd,(unsafeData.prodStock[iType][iId]-unsafeData.prodMinRackInit[iType][iId]));
doQuest=doQuest||(unsafeData.prodStock[iType][iId]>0&&iAdd>0);
GM_log("checkLodgeQuest iId:"+iId+" doQuest:"+doQuest+" iAdd:"+iAdd);
}
iId=null;iType=null;iAdd=null;
}else{
doQuest=false;
}
if(DEVMODE_FUNCTION){GM_log("End checkLodgeQuest doQuest:"+doQuest);}
return doQuest;
}
function autoActivateLodgeQuest(didGive){
if(DEVMODE_FUNCTION){GM_log("Begin autoActivateLodgeQuest");}
//if(!busy){ GM_log("BUSY NOT SET: autoActivateQuest"); return false;}
if(didGive==undefined){didGive=false;}
var campaignNr="1";
var lquestNr=unsafeData.questData["lodge"][campaignNr]["nr"];
if(!didGive){
logBubble.add("Looking for Campaign:"+campaignNr+" Lodge Quest:"+lquestNr,5,"green");
}
if(unsafeData.questData["lodge"][campaignNr]["time"]>now){
logBubble.add("Exiting you stil have to wait some more",5,"red");
window.setTimeout(autoZoneFinish,settings.getPause(),$("forestry_questlist_close"));
}else if(!checkLodgeQuest()){
logBubble.add("Exiting to low number of product available",5,"red");
window.setTimeout(autoZoneFinish,settings.getPause(),$("forestry_questlist_close"));
}else if(unsafeWindow.city!=2){
document.addEventListener("gameCity2",function(){
document.removeEventListener("gameCity2",arguments.callee,false);
logBubble.add("Arrived in city 2",5,"green");
window.setTimeout(autoActivateLodgeQuest,settings.getPause(),true);
},false);
logBubble.add("Goto City 2",5,"green");
click($top("citylineitem2"));
}else if(unsafeWindow.city==2 && unsafeData.questData["lodge"][campaignNr]["time"]<=now && $("forestry_questlist_container").style.display!="block"){ //open quest box
document.addEventListener("gameOpenCampaign",function(){
document.removeEventListener("gameOpenCampaign",arguments.callee,false);
logBubble.add("Opened Lodge Quest",5,"green");
window.setTimeout(autoActivateLodgeQuest,settings.getPause(),true);
},false);
click($("cityzone_2_9")); //unsafeWindow.initCampaigns();
}else if(unsafeWindow.city==2 && unsafeData.questData["lodge"][campaignNr]["time"]<=now && $("forestry_questlist_container").style.display=="block"){ //quest box is open
var iId,iType,iAdd;
for(var i=0;i<unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0].length;i++){
iType=unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0][i][0];
iId=unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0][i][1];
iAdd=unsafeData.QUESTS["lodge"][campaignNr][lquestNr][0][i][2]-((unsafeData.questData["lodge"][campaignNr][iId]&&unsafeData.questData["lodge"][campaignNr][iId]["type"]==iType)?unsafeData.questData["lodge"][campaignNr][iId]["sum"]:0); //unsafeData.questData["lodge"][campaignNr][fId]["type":0,"max":0,"sum":0]
iAdd=Math.min(iAdd,(unsafeData.prodStock[iType][iId]-unsafeData.prodMinRackInit[iType][iId]));
if(unsafeData.prodStock[iType][iId]&&iAdd>0){
//GM_log("Add in iStock:"+iStock+" iAdd:"+iAdd);
logBubble.add("Add #"+iAdd+" of "+unsafeData.prodName[iType][iId],5,"green");
$("globalcommitbox").addEventListener("DOMAttrModified",function(iAdd){
return function(){
logBubble.add("Add in #"+iAdd+" of "+unsafeData.prodName[iType][iId],5,"green");
$("globalcommitbox").removeEventListener("DOMAttrModified",arguments.callee,false);
$("forestry_questentry_value").value=iAdd;
click($("globalcommitboxfooter").firstElementChild);
document.addEventListener("gameOpenCampaign",function(){
document.removeEventListener("gameOpenCampaign",arguments.callee,false);
window.setTimeout(autoActivateLodgeQuest,settings.getPause(),true);
},false);
};
}(iAdd),false);
click($("forestry_quest_entry"+campaignNr+"_"+lquestNr+"_"+(iType+1)+"_"+iId));
break;
}
}
iId=null;iType=null;iAdd=null;
}
if(DEVMODE_FUNCTION){GM_log("End autoActivateLodgeQuest");}
}
*/
function autoFarmersmarket(runId){
try{
if(!settings.get("account","botUseFarmersmarket")){
GM_log("FARMERSMARKET BOT OFF: autoFarmersmarket");
}else if(bot.checkRun("autoFarmersmarket",runId)){
bot.setAction("autoFarmersmarket");
var zoneNrS=getReadyZone("farmersmarket");
if(zoneNrS==null){
GM_log("autoFarmersmarket: no ready zone\nreadyZone="+implode(unsafeData.readyZone));
autoZoneFinish(runId);
}else{
handled.set(zoneNrS);
try{ unsafeWindow.jsTimeStamp=unsafeWindow.Zeit.Client - unsafeWindow.Zeit.Verschiebung; }catch(err){}
autoFarmersmarketBuilding(runId,1);
// if(unsafeData.readyZone[handled.zoneNrS][2]){
// switch(handled.zoneBuildingTyp){
// case 4:
// break;}
// }else{
// GM_log("autoFarmersmarket: data not ready\nreadyZone[handled.zoneNrS]="+implode(unsafeData.readyZone[handled.zoneNrS]));
// autoZoneFinish(runId); // TODO else
// }
}
}
if(DEVMODE_FUNCTION){ GM_log("End autoFarmersmarket handled.zoneNrF:"+handled.zoneNrF);}
}catch(err){GM_logError("autoFarmersmarket runId="+runId+"\n"+err);autoZoneFinish(runId);}
}
function autoFarmersmarketBuilding(runId, step, field){
try{
// GM_log("autoFarmersmarketBuilding runId="+runId+" step="+step+" handled.zoneNrS="+handled.zoneNrS);
if(settings.get("account","botUseFarmersmarket")&&bot.checkRun("autoFarmersmarketBuilding",runId)){
bot.setAction("autoFarmersmarketBuilding ("+step+")");
var help,help2,action=null,listeningEvent=null;
switch(step){
case 1:{ // check required products
if((zoneList[handled.zoneNrL][0][0]!=PRODSTOP)&&(help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&((help[1]=="r")||(help[1]=="e"))){
help=unsafeData.prodRequire[0][zoneList[handled.zoneNrL][0][0]]
if(typeof help=="object"){
for(var i=0;i<help.length;i++){
if(help[i][0]<0){
if(unsafeData.money<help[i][1]){
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
break;
}
}else{
if(unsafeData.prodStock[help[i][0]][help[i][1]]<help[i][2]){
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
break;
}
}
}
}
}
autoFarmersmarketBuilding(runId,step+1);
break;}
case 2:{ // open farmersmarket
if((help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&(((help[1]=="r")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP)))){
if(unsafeData.gameLocation[0]!="farmersmarket"){
action=function(){ click($("speedlink_farmersmarket")); };
listeningEvent="gameFarmersmarketOpened";
}else{
autoFarmersmarketBuilding(runId,step+1);
}
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
break;}
case 3:{ // open farmersmarket building
if((help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&(((help[1]=="r")&&((zoneList[handled.zoneNrL][0][0]!=PRODSTOP)||(!settings.get("account","disableCropFields"))))||((help[1]=="e")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP)))){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Opening"); //TODO texte
help=/-(\d)$/.exec(handled.zoneNrF)[1]; // determine which building to work on
if($("farmersmarket_pos"+help+"_inner").style.display != "block"){
action=function(){ click($("farmersmarket_pos"+help+"_click")); };
listeningEvent="gameFarmersmarketOpened"+help;
// }else if("wrong building is opened"){
// logBubble.add("autoFarmersmarketBuilding: This is not the right building. Bailing out.")
// autoFarmersmarketBuilding(runId,9); // finish (and start over)
}else{
autoFarmersmarketBuilding(runId,step+1);
}
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
break;}
case 4:{ // harvest
help=unsafeData.readyZone[handled.zoneNrS];
if((unsafeData.readyZone[handled.zoneNrS][1]=="r")&&((zoneList[handled.zoneNrL][0][0]!=PRODSTOP)||(!settings.get("account","disableCropFields")))){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Cropping"); //TODO texte
switch(handled.zoneBuildingTyp){
case 1:{
// TODOmanual crop
if((help=$("flowerarea_buttons"))&&(help=help.querySelector(".flowerarea_modus_harvest_all"))){
action=function(){ click(help); };
listeningEvent="gameFarmersmarketCropped";
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
break;}
case 4:{
if(help=$("nursery_slot_item" + handled.slot)){
action=function(){ click(help); };
listeningEvent="gameFarmersmarketCropped";
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
break;}
}
}else{
autoFarmersmarketBuilding(runId,step+1);
}
break;}
case 5:{ // init production
help=unsafeData.readyZone[handled.zoneNrS];
if(zoneList[handled.zoneNrL][0][0]==PRODSTOP){
logBubble.add("No production selected."); //TODO texte
autoFarmersmarketBuilding(runId,9); // -> exit
}else if(help[1]=="e"){
switch(handled.zoneBuildingTyp){
case 1:{ // select flower
// confirm cropping result
if((help=$("globalbox")) && (help.style.display == "block")){
if(help=$("globalbox_button1")){
click(help);
}
}
// select flower
logBubble.add("Initializing planting ("+zoneList[handled.zoneNrL][0][0]+")"); //TODO texte
if(unsafeWindow.racksort&&(unsafeWindow.racksort!=30)&&(unsafeWindow.racksort!=31)&&(unsafeWindow.racksort!=32)&&(unsafeWindow.racksort!=33)){
// non-flower-rack opened
logBubble.add("Switching rack"); //TODO texte
step--;
action=function(){ click($("rackcat30")); };
listeningEvent="gameUpdateRack";
}else if(!(unsafeData.prodStock[0][zoneList[handled.zoneNrL][0][0]]&&unsafeData.prodStock[0][zoneList[handled.zoneNrL][0][0]]>0)){
// product is missing
// this is correct set, even if rack is updating
logBubble.add("Flower is not in rack",10,"red"); //TODO texte
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
autoFarmersmarketBuilding(runId,9); // -> exit
}else if(unsafeWindow.selected==zoneList[handled.zoneNrL][0][0]){
// Correct product selected
// calculate time of next cropping
// here its not important if rack is updating
var time=NEVER;
var NowServer=unsafeWindow.Zeit.Server;
var tempZoneProductionData=unsafeData.zones.getProduction(handled.zoneNrS);
for(var iType=0;iType<tempZoneProductionData[0].length;iType++){
for(var iProd in tempZoneProductionData[0][iType]){
if(!tempZoneProductionData[0][iType].hasOwnProperty(iProd)){ continue; }
if((unsafeData.prodTyp[iType][iProd]!="u")&&(unsafeData.prodTyp[iType][iProd]!="z")){ // only products
for(var i=0;i<tempZoneProductionData[0][iType][iProd].length;i++){
if(tempZoneProductionData[0][iType][iProd][i][2]>0){
time=Math.min(time,tempZoneProductionData[0][iType][iProd][i][2]-NowServer);
}
}
}
}
}
time=Math.max(time,0);
if(time<=settings.get("account","seedWaitForCrop")){
logBubble.add("Waiting for crop in "+getTimeStr(time));
zoneWaiting[handled.zoneNrF]=now+time;
window.setTimeout(function(){ //TIMEOUT
for(var fz in zoneWaiting){
if(!zoneWaiting.hasOwnProperty(fz)){continue;}
if(zoneWaiting[fz]<=now){ delete zoneWaiting[fz]; }
}
checkReadyZone();
},(1000*time)+settings.getPause());
autoFarmersmarketBuilding(runId,9); // -> exit
}else if(calcEmptyProductPositions(zoneList[handled.zoneNrL][0][0],handled.zoneNrF)>0){
autoFarmersmarketBuilding(runId,step+1,1);
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
}else{
logBubble.add("Wrong plant selected");
var nextRack=null;
var allRacks=[30,31,32,33];
for(var i=allRacks.length-1;i>-1;i--){
if($("rackswitch"+allRacks[i])){
if(allRacks[i]==unsafeWindow.racksort){
nextRack=allRacks[(i+1)%allRacks.length];
break;
}
}else{
allRacks.splice(i,1);
}
}
if(help=$("rackitem"+zoneList[handled.zoneNrL][0][0])){
if(unsafeWindow.updateRackBusy){
// Rack not loaded
logBubble.add("Rack not loaded",10,"red");
step--;
listeningEvent="gameUpdateRack";
}else if(help.style.display!="none"){
logBubble.add("Seed found");
click(help); // rackitem found
window.setTimeout(autoFarmersmarketBuilding,settings.getPause(),runId,step);
}else if(unsafeWindow.racksort!=nextRack){
// call next rack
logBubble.add("Switching to next rack ("+nextRack+")");
step--;
action=function(){ click($("rackswitch"+nextRack)); };
listeningEvent="gameUpdateRack";
}else{
// should not happen
logBubble.add("Invisible non-empty rackitem and only 1 rack",10,"red");
autoFarmersmarketBuilding(runId,9); // -> exit
}
}else if(unsafeWindow.racksort!=nextRack){
// rackamount>0 but no rackitem
// = 2nd, 3rd or 4th rack was not loaded yet
logBubble.add("Switching to next rack ("+nextRack+")(rackitem not found)");
step--;
action=function(){ click($("rackswitch"+nextRack)); };
listeningEvent="gameUpdateRack";
// unsafeWindow.updateRack((1+parseInt(unsafeWindow._currRack,10))%unsafeWindow.userracks); // call next rack
}else{// rackamount>0 but no rackitem and 1 rack
// should not happen because thats "product is missing" (1.case)
logBubble.add("No rackitem but rackamount and only 1 rack",10,"red");
autoFarmersmarketBuilding(runId,9); // -> exit
}
}
break;}
case 4:{ // open slot
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Opening slot"); //TODO texte
if(help=$("nursery_slot_item" + handled.slot)){
action=function(){ click(help); };
listeningEvent="gameFarmersmarketSlotOpened";
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
break;}
}
}else{
logBubble.add("Zone not empty."); //TODO texte
autoFarmersmarketBuilding(runId,9); // -> exit
}
break;}
case 6:{
switch(handled.zoneBuildingTyp){
case 1:{
if((help=$("farmersmarket_pos1_inner"))&&(help=help.querySelector(".flowerarea_button_autoplant"))){
// premium planting
action=function(){ click(help); };
listeningEvent="gameFarmersmarketDialogStart";
}else{
// non-premium planting
unsafeWindow.flowerarea_modus="plant";
if(unsafeWindow.farmersmarket_data.flower_area){
for(var i=field;i<=unsafeData.BUILDING_SIZE["fl1"];i++){
if(!unsafeWindow.farmersmarket_data.flower_area[i]) {
action = function(){
help=$("flowerarea_tile"+i);
mouseover(help);
click(help);
mouseout(help);
}
window.setTimeout(autoFarmersmarketBuilding,settings.getPause(true),runId,step,i+1);
break;
}
}
}
if(action==null){ autoFarmersmarketBuilding(runId,8,1); }
}
break;}
case 4:{ // click production item
if((help=$("nursery_production_box")) && (help.style.display == "block")){
if((help=help.querySelector('div[onclick*="dialogNursery(\'production_commit\', '+handled.slot+', '+zoneList[handled.zoneNrL][0][0]+')"]')) && (!help.className.match("nursery_production_select_item_block"))){
// link is visible, can be clicked on
action=function(){ click(help); };
listeningEvent="gameFarmersmarketDialogCommit";
}else if(help=$("nursery_production_navi").querySelector(".nursery_production_navi_next")){
action=function(){ click(help); };
step--;
listeningEvent="gameFarmersmarketSlotOpened";
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
break;}
}
break;}
case 7:{ // commit
if((help=$("globalbox")) && (help.style.display == "block")){
if(help=$("globalbox_button1")){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Start production"); //TODO texte
action=function(){ click(help); };
listeningEvent="gameFarmersmarketStarted";
setNextQueueItem(handled.zoneNrS);
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
}else{
autoFarmersmarketBuilding(runId,9); // -> exit
}
break;}
case 8:{
switch(handled.zoneBuildingTyp){
case 1:{
if((help=$("farmersmarket_pos1_inner"))&&(help=help.querySelector(".flowerarea_modus_water_all"))){
// premium watering
action=function(){ click(help); };
listeningEvent="gameFarmersmarketWatered";
}else{
// non-premium watering
unsafeWindow.flowerarea_modus="water";
if(unsafeWindow.farmersmarket_data.flower_area){
for(var i=field;i<=unsafeData.BUILDING_SIZE["fl1"];i++){
if((unsafeWindow.farmersmarket_data.flower_area[i])&&(unsafeWindow.farmersmarket_data.flower_area[i].water_remain<0)){
action = function(){
help=$("flowerarea_tile"+i);
mouseover(help);
click(help);
mouseout(help);
}
window.setTimeout(autoFarmersmarketBuilding,settings.getPause(true),runId,step,i+1);
break;
}
}
}
if(action==null){ autoFarmersmarketBuilding(runId,step+1); }
}
break;}
case 4:{
autoFarmersmarketBuilding(runId,9); // -> exit
break;}
}
break;}
case 9:{
var zoneNrS,zoneNrL,help,next=false;
if(unsafeData.zones.isMultiSlot(handled.zoneNrF)){
for(var slot=1;slot<=3;slot++){
zoneNrS=handled.zoneNrF+"."+slot;
if((help=unsafeData.readyZone[zoneNrS])&&help[2]){
zoneNrL=getZoneListId(zoneNrS);
if(((help[1]=="r")&&((zoneList[zoneNrL][0][0]!=PRODSTOP)||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[zoneNrL][0][0]!=PRODSTOP))){
next=true;
handled.set(zoneNrS);
break;
}
}
}
}
if(next){
autoFarmersmarketBuilding(runId,1);
}else{
help=/-(\d)$/.exec(handled.zoneNrF)[1];
autoZoneFinish(runId,$("farmersmarket_pos"+help+"_inner").querySelector(".big_close"));
}
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoFarmersmarketBuilding,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
help=null;listeningEvent=null;action=null;
}
}catch(err){GM_logError("autoFarmersmarketBuilding runId="+runId+" step="+step+"\n"+err);}
}
function autoFoodworld(runId){
try{
if(!settings.get("account","botUseFoodworld")){
GM_log("BOT OFF: autoFoodworld");
}else if(bot.checkRun("autoFoodworld",runId)){
bot.setAction("autoFoodworld");
var zoneNrS=getReadyZone("foodworld");
if(zoneNrS==null){
GM_log("autoFoodworld: no ready zone\nreadyZone="+implode(unsafeData.readyZone));
autoZoneFinish(runId);
}else{
handled.set(zoneNrS);
try{ unsafeWindow.jsTimeStamp=unsafeWindow.Zeit.Client - unsafeWindow.Zeit.Verschiebung; }catch(err){}
if(unsafeData.readyZone[handled.zoneNrS][2]){
switch(handled.zoneBuildingTyp){
case 4:
autoFoodworldBuilding(runId,1); break;
}
}else{
GM_log("autoFoodworld: data not ready\nreadyZone[handled.zoneNrS]="+implode(unsafeData.readyZone[handled.zoneNrS]));
autoZoneFinish(runId); // TODO else
}
}
}
if(DEVMODE_FUNCTION){ GM_log("End autoFoodworld handled.zoneNrF:"+handled.zoneNrF);}
}catch(err){GM_logError("autoFoodworld runId="+runId+"\n"+err);autoZoneFinish(runId);}
}
function autoFoodworldBuilding(runId, step){
try{
// GM_log("autoFoodworldBuilding runId="+runId+" step="+step+" handled.zoneNrS="+handled.zoneNrS);
if(settings.get("account","botUseFoodworld")&&bot.checkRun("autoFoodworldBuilding",runId)){
bot.setAction("autoFoodworldBuilding ("+step+")");
var help,help2,action=null,listeningEvent=null;
switch(step){
case 1:{ // check required products
if((zoneList[handled.zoneNrL][0][0]!=PRODSTOP)&&(help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&((help[1]=="r")||(help[1]=="e"))){
help2=true;
help=unsafeData.prodRequire[0][zoneList[handled.zoneNrL][0][0]]
if(typeof help=="object"){
for(var i=0;i<help.length;i++){
if(unsafeData.prodStock[help[i][0]][help[i][1]]<help[i][2]){
zoneList[handled.zoneNrL].unshift(DEFAULT_ZONELIST_ITEM.clone());
updateQueueBox(handled.zoneNrS);
help2=false;
break;
}
}
}
}
autoFoodworldBuilding(runId,step+1);
break;}
case 2:{ // open foodworld
if((help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&(((help[1]=="r")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP)))){
if($("foodworld").style.display != "block"){
action=function(){ click($("speedlink_foodworld")); };
listeningEvent="gameFoodworldOpened";
}else{
autoFoodworldBuilding(runId,step+1);
}
}else{
autoFoodworldBuilding(runId,7); // -> exit
}
break;}
case 3:{ // open foodworld building
if((help=unsafeData.readyZone[handled.zoneNrS])&&help[2]&&(((help[1]=="r")&&((zoneList[handled.zoneNrL][0][0]!=PRODSTOP)||(!settings.get("account","disableCropFields"))))||((help[1]=="e")&&(zoneList[handled.zoneNrL][0][0]!=PRODSTOP)))){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Opening"); //TODO texte
help=/-(\d)$/.exec(handled.zoneNrF)[1]; // determine which building to work on
if($("food_buildinginner").style.display != "block"){
action=function(){ click($("food_pos"+help)); };
listeningEvent="gameFoodworldOpened"+help;
}else if(help != /building_inner(\d)_\d/.exec($("food_buildinginner").className)[1]){
logBubble.add("autoFoodworldBuilding: This is not the right building. Bailing out.")
autoFoodworldBuilding(runId,7); // finish (and start over)
}else{
autoFoodworldBuilding(runId,step+1);
}
}else{
autoFoodworldBuilding(runId,7); // -> exit
}
break;}
case 4:{ // harvest
help=unsafeData.readyZone[handled.zoneNrS];
if((unsafeData.readyZone[handled.zoneNrS][1]=="r")&&((zoneList[handled.zoneNrL][0][0]!=PRODSTOP)||(!settings.get("account","disableCropFields")))){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Cropping"); //TODO texte
if((help=$("food_slot" + handled.slot + "_ready")) && (help.style.display=="block")){
action=function(){ click(help); };
listeningEvent="gameFoodworldCropped";
}else{
autoFoodworldBuilding(runId,7); // -> exit
}
}else{
autoFoodworldBuilding(runId,step+1);
}
break;}
case 5:{ // open slot
help=unsafeData.readyZone[handled.zoneNrS];
if((zoneList[handled.zoneNrL][0][0]!=PRODSTOP)&&(help[1]=="e")){
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Opening slot"); //TODO texte
if((help=$("food_slot" + handled.slot + "_ready")) && (help.style.display=="none")){
action=function(){ click($("food_slot" + handled.slot)); };
listeningEvent="gameFoodworldSlotOpened";
}else{
autoFoodworldBuilding(runId,7); // -> exit
}
}else{
logBubble.add("Could not find the empty slot to click on.");
autoFoodworldBuilding(runId,7);
}
break;}
case 6:{ // click production item
if((help=$("food_buildinginner_select")) && (help.style.display == "block")){
if((help=$("foodworld_bld_select_prod" + zoneList[handled.zoneNrL][0][0])) && (help.className == "link")){
// link is visible, can be clicked on
logBubble.add(handled.zoneNrF.capitalize()+" automat<br>Start production"); //TODO texte
action=function(){ click(help); };
listeningEvent="gameFoodworldStarted";
setNextQueueItem(handled.zoneNrS);
}else if((help=$("food_buildinginner_select_down")) && (help.style.display == "block")){
action=function(){ click(help); };
step--;
listeningEvent="gameFoodworldSlotOpened";
}else{
autoFoodworldBuilding(runId,7); // -> exit
}
}else{
autoFoodworldBuilding(runId,7); // -> exit
}
break;}
case 7:{
var zoneNrS,zoneNrL,help,next=false;
for(var slot=1;slot<=3;slot++){
zoneNrS=handled.zoneNrF+"."+slot;
if((help=unsafeData.readyZone[zoneNrS])&&help[2]){
zoneNrL=getZoneListId(zoneNrS);
if(((help[1]=="r")&&((zoneList[zoneNrL][0][0]!=PRODSTOP)||!settings.get("account","disableCropFields")))||((help[1]=="e")&&(zoneList[zoneNrL][0][0]!=PRODSTOP))){
next=true;
handled.set(zoneNrS);
break;
}
}
}
if(next){
autoFoodworldBuilding(runId,1);
}else{
autoZoneFinish(runId,$("food_buildinginner_close"));
}
break;}
}
if(listeningEvent){
document.addEventListener(listeningEvent,function(listeningEvent,runId,step){
return function(){
document.removeEventListener(listeningEvent,arguments.callee,false);
window.setTimeout(autoFoodworldBuilding,settings.getPause(),runId,step+1);
};
}(listeningEvent,runId,step),false);
}
if(action){ action(); }
help=null;listeningEvent=null;action=null;
}
}catch(err){GM_logError("autoFoodworldBuilding runId="+runId+" step="+step+"\n"+err);}
}
function checkFarmi(mode){
if(DEVMODE_FUNCTION){GM_log("Begin checkFarmi");}
var farmiNr=null;
var farmiAmount=0;
var farmiAcceptRemove=new Array();
for(var i in unsafeWindow.farmisinfo[0]){
if(!unsafeWindow.farmisinfo[0].hasOwnProperty(i)){ continue; }
if(settings.get("account","farmiReject") && !unsafeWindow.farmisinfo[0][i]["sold"] && unsafeWindow.farmisinfo[0][i]["costQuotient"] < settings.get("account","farmiRejectUntilNr")){
if(DEVMODE){GM_log("gameFarmiReject farmiNr:"+i);}
if(farmiNr==null){ farmiNr=i; }
farmiAmount++;
}else if(settings.get("account","farmiAccept") && !unsafeWindow.farmisinfo[0][i]["sold"] && unsafeWindow.farmisinfo[0][i]["costQuotient"]>=settings.get("account","farmiAcceptAboveNr") && !unsafeWindow.farmisinfo[0][i]["missing"] && ((settings.get("account","farmiAcceptBelowMinValue")&&!unsafeWindow.farmisinfo[0][i]["belowMinRackInit"]) || !unsafeWindow.farmisinfo[0][i]["belowMinRack"])){
if(DEVMODE){GM_log("farmiAccept farmiNr:"+farmiNr);}
if(farmiNr==null){ farmiNr=i; }
farmiAmount++;
}else if(settings.get("account","farmiAccept") && settings.get("account","farmiRemoveMissing") && !unsafeWindow.farmisinfo[0][i]["sold"] && unsafeWindow.farmisinfo[0][i]["costQuotient"]>=settings.get("account","farmiAcceptAboveNr") && unsafeWindow.farmisinfo[0][i]["missing"]){
farmiAcceptRemove.push([i,unsafeWindow.farmisinfo[0][i]["price"]-unsafeWindow.farmisinfo[0][i]["marketValue"]]);
}
}
if(settings.get("account","farmiRemoveMissing") && farmiAcceptRemove.length > settings.get("account","farmiRemoveMissingAboveNr")){
farmiAmount += (farmiAcceptRemove.length-settings.get("account","farmiRemoveMissingAboveNr"));
farmiAcceptRemove.sort(function(a,b){return (parseInt(b[1],10)-parseInt(a[1],10));});
farmiAcceptRemove.splice(0,settings.get("account","farmiRemoveMissingAboveNr"));
farmiAcceptRemove.reverse();
if(DEVMODE){GM_log("farmiAcceptedRemove farmiNr:"+farmiNr+" farmiAcceptRemove:"+implode(farmiAcceptRemove,"checkFarmi/farmiAcceptRemove"));}
if(farmiNr==null){farmiNr = farmiAcceptRemove[0][0];}
}
if(DEVMODE_FUNCTION){ GM_log("End checkFarmi");}
switch (mode){
case 2:
return [farmiAmount,farmiNr,farmiAcceptRemove];
break;
case 1:
if(farmiNr!=null){
botArbiter.add("farmi");
}
break;
case 0:
default:
return (farmiNr!=null);
break;
}
}
function autoFarmi(){
if(DEVMODE_FUNCTION){ GM_log("Begin autoFarmi"); }
if(!bot.isBusy()){ GM_log("BUSY NOT SET: autoFarmi"); return false;}
logBubble.add("Begin for Farmi",5,"green");
try{
var help=checkFarmi(2);
var farmiNr=help[1];
var farmiAmount=help[0];
var farmiAcceptRemove = help[2];
GM_log("autoFarmi farmiAmount:"+farmiAmount+" farmiNr:"+farmiNr);
if(farmiAmount>0){
if(unsafeWindow.farm!=1){
// change farm
document.addEventListener("gameFarmOpened",function(){
document.removeEventListener("gameFarmOpened",arguments.callee,false);
logBubble.add("arrived in farm");
if(DEVMODE){GM_log("arrived in farm");}
autoFarmi();
},false);
if(DEVMODE){GM_log("change farm to 1");}
logBubble.add("change farm to 1");
click($("speedlink_farm1"));
// click($("farmlinks").getElementsByClassName("link")[0]);
}else if(unsafeWindow.farm==1){
var doFarmiInterval=window.setInterval(function(farmiNr,farmiAmount){
try{
if($("cart").style.display=="block"){
try {
window.clearInterval(doFarmiInterval);
doFarmiInterval=null;
} catch (err){}
if(farmiAmount>=1){
document.addEventListener("gameFarmiResponse",function(){
document.removeEventListener("gameFarmiResponse",arguments.callee,false);
window.setTimeout(function(){
logBubble.add("Do next Farmi");
autoFarmi();
},3000);
},false);
if(settings.get("account","farmiReject") && !unsafeWindow.farmisinfo[0][farmiNr]["sold"] && unsafeWindow.farmisinfo[0][farmiNr]["costQuotient"] < settings.get("account","farmiRejectUntilNr")){
if(DEVMODE){GM_log("farmiReject farmiNr:"+farmiNr);}
unsafeWindow.handleFarmi(farmiNr,2);
unsafeWindow.farmisinfo[0][farmiNr]["sold"]=1;
}else if(settings.get("account","farmiAccept") && !unsafeWindow.farmisinfo[0][farmiNr]["sold"] && unsafeWindow.farmisinfo[0][farmiNr]["costQuotient"]>=settings.get("account","farmiAcceptAboveNr") && !unsafeWindow.farmisinfo[0][farmiNr]["missing"] && ((settings.get("account","farmiAcceptBelowMinValue")&&!unsafeWindow.farmisinfo[0][farmiNr]["belowMinRackInit"]) || !unsafeWindow.farmisinfo[0][farmiNr]["belowMinRack"])){
if(DEVMODE){GM_log("farmiAccept farmiNr:"+farmiNr);}
unsafeWindow.handleFarmi(farmiNr,1);
unsafeWindow.farmisinfo[0][farmiNr]["sold"]=1;
}else if(settings.get("account","farmiAccept") && settings.get("account","farmiRemoveMissing") && !unsafeWindow.farmisinfo[0][farmiNr]["sold"] && unsafeWindow.farmisinfo[0][farmiNr]["costQuotient"]>=settings.get("account","farmiAcceptAboveNr") && unsafeWindow.farmisinfo[0][farmiNr]["missing"]){
if(DEVMODE){GM_log("farmiAcceptedRemove farmiNr:"+farmiNr);}
unsafeWindow.handleFarmi(farmiNr,2);
unsafeWindow.farmisinfo[0][farmiNr]["sold"]=1;
}else{
GM_log("valFarmi Null farmiNr:"+farmiNr);
}
}
}
if(DEVMODE){ GM_log("Click Farmi:"+farmiNr,5,"green"); }
logBubble.add("Click Farmi:"+farmiNr,5,"green");
click($("kunde_"+farmiNr));
}catch(err){GM_logError("autoFarmi farmiNr:"+farmiNr+" farmiAmount:"+farmiAmount+"\n"+err);}
},settings.getPause(true),farmiNr,farmiAmount);
}else{
logBubble.add("Exiting farmi unknown combination",10,"red");
if(DEVMODE){ GM_log("Exiting farmi unknown combination"); }
bot.end();
}
}else{
logBubble.add("Exiting no farmi");
if(DEVMODE){ GM_log("Exiting no farmi"); }
bot.end();
}
}catch(err){GM_logError("autoFarmi farmiNr:"+farmiNr+" farmiAmount:"+farmiAmount+"\n"+err);}
}
function doGameSessionEnds(){ //NOTICE: Use only in combination with botArbiter.add("sessionEnds");
// if(DEVMODE){ logBubble.add("doGameSessionEnds"); }
click($("divSessionEnd"));
}
function doGameOtherAccReady(){ //NOTICE: Use only in combination with botArbiter.add("otherAccReady");
// if(DEVMODE){ logBubble.add("doGameOtherAccReady"); }
click($("linkOtherAccReady"));
}
function drawButtons(){
if(!$("divAutomatButtonOverview")){
newdiv=createElement("div",{"id":"divAutomatButtonOverview","class":"link beraterButtonIcon hoverBgGreen","mouseOverText":getText("automat_buttonOverview")},$("divBeraterButtons"));
createElement("img",{"class":"link","src":IMAGES["gear"],"style":"position:relative;top:3px;left:0;width:28px;height:28px;"},newdiv);
newdiv.addEventListener("click",function(){
unsafeWindow.buildInfoPanel("automatOverview");
},false);
}
}
function drawZoneListTable(currZoneType){
try{
var newtable=createElement("table",{style:"",border:"1",cellspacing:"0",style:"margin-bottom:10px;"});
newtable.addEventListener("mouseout",function(event){
for(var y=0;y<this.rows.length;y++){
for(var x=0;x<this.rows[y].cells.length;x++){
this.rows[y].cells[x].style.backgroundColor="";
}
}
},false);
newtable.addEventListener("mouseover",function(event){
var node=event.target;
while((node!=this)&&(node.nodeName!="TD")){ node=node.parentNode;}
if(node!=this){
var posX=node.cellIndex;
var posY=node.parentNode.rowIndex;
if(node.parentNode.cells.length>1){
if(0<posX){
for(var v=0;v<this.rows.length;v++){
if(this.rows[v].cells[posX]){ this.rows[v].cells[posX].style.backgroundColor="lightblue"; }
}
}
if(0<posY){
for(var v=0;v<this.rows[posY].cells.length;v++){
if(this.rows[posY].cells[v]){ this.rows[posY].cells[v].style.backgroundColor="lightblue"; }
}
}
}
}
},false);
// collect the handled zones
var zones=new Array();
for(var fz in unsafeData.ALL_SLOTS){
if(!unsafeData.ALL_SLOTS.hasOwnProperty(fz)){ continue; }
if(unsafeData.zones.getBlock(fz)){ continue; }
if(getZoneType(fz)!=currZoneType){ continue; }
zones.push(fz);
}
// build table
var newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
var newtd=createElement("td",{"style":"text-align:right;border-bottom:none;"},newtr,"Zone"); // TODO texte
for(var i=0;i<zones.length;i++){
newtd=createElement("td",{"align":"center","style":"width:10px;","rowspan":2},newtr,getZoneName(0,zones[i],zones[i],null,false,true,false,false)+"<br>"+getZoneName(0,zones[i],zones[i],null,false,false,true,false).replace(/,/g,"<br>"));
}
if(currZoneType=="1"){
newtd=createElement("td",{align:"center","rowspan":2},newtr);
}
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
createElement("td",{"style":"text-align:left;border-top:none;"},newtr,getText("automat_titleQueue"));
for(var lz in zoneList){
if(!zoneList.hasOwnProperty(lz)){ continue; }
if(lz==0 || lz=="windmill"){ continue; }
var extendedList=extendedListReg.exec(lz);
if((!extendedList && currZoneType!=getZoneType(lz)) || (extendedList && currZoneType!=1)) continue;
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"nowrap":"","style":"width:50px;text-align:right;","class":"link","lz":lz}, newtr, getZoneName(0,lz,lz,null,false,true,true,false));
// !!extendedList?
// getText("automat_titleGeneral").replace(" "," ")+" "+extendedList[1]
// :getText("automat_titleQueue")+" "+((isNaN(Number(lz))?lz:(Math.ceil(lz/6)+"."+getGarden(lz))))
newtd.addEventListener("mouseover",function(evt){
var zoneNrL=this.getAttribute("lz");
var content=createElement("div");
drawQueueListSmall(zoneNrL, zoneNrL, content);
createElement("div",{"style":"margin:4px 0px 4px 0px;width:100%;height:0px;border-bottom:1px solid black;"},content);
createElement("div",{"class":"queueTitle"},content,getText("automat_queueshow"));
toolTip.show(evt, content.innerHTML);
content=null;
},false);
newtd.addEventListener("click",function(){
var zoneNrL=this.getAttribute("lz");
switch(getBuildingTyp(zoneNrL)){
case 1:
if(settings.get("account","useQueueList")){
redrawQueueBox(zoneNrL, zoneNrL, $("divQueueBoxInner"));
}else{
drawQueueChooseItemBox(zoneNrL, zoneNrL, 0, $("divChooseBoxInner"));
}
break;
case 2:
drawStableChooseFeedBox(zoneNrL, zoneNrL, $("divChooseBoxInner"));
break;
case 3:
if(settings.get("account","useQueueList")){
drawQueueBox(zoneNrL,zoneNrL,$("divChooseBoxInner"));
}else{
drawFactoryChooseItemBox(zoneNrL,zoneNrL,$("divChooseBoxInner"));
}
break;
case "windmill": case 4:
redrawQueueBox(zoneNrL, zoneNrL, $("divQueueBoxInner"));
break;
}
},false);
for(var i=0;i<zones.length;i++){
var fz=zones[i];
newtd=createElement("td",{align:"center"},newtr);
var inp=createElement("input",{id:"inputZoneList"+lz,name:"farmZone"+fz,"class":"link",type:"radio",checked:getZoneListId(fz)==lz},newtd);
inp.addEventListener("click",function(){
var lz=this.id.replace("inputZoneList","");
var fz=this.name.replace("farmZone","");
setZoneListId(fz,lz);
updateQueueBox(fz,lz);
},false);
inp.addEventListener("mouseover", function(evt){
var lz=this.id.replace("inputZoneList","");
var content=createElement("div");
drawQueueListSmall(lz, lz, content);
toolTip.show(evt, content.innerHTML);
},false);
}
if(currZoneType=="1"){
newtd=createElement("td",{align:"center"},newtr);
if(extendedList){
inp=createElement("img",{id:"inputZoneListDelete"+lz,"class":"link",style:"display:inline-block;width:15px;height:15px;",src:GFX+"button_cancel_off.png"},newtd);
inp.addEventListener("mouseover", function(evt){
this.setAttribute("src",GFX+"button_cancel_on.png");
toolTip.show(evt, "Delete this queue");
},false);
inp.addEventListener("mouseout", function(evt){
this.setAttribute("src",GFX+"button_cancel_off.png");
},false);
inp.addEventListener("click", function(){
var lz=this.id.replace("inputZoneListDelete","");
deleteZoneInList(lz);
click($("infoPanelZoneList"));
},false);
}
}
}
if(currZoneType=="1"){
var newtr=createElement("tr",{style:"line-height:18px;"},newtable);
var newtd=createElement("td",{align:"center",colspan:(zones.length+2)},newtr);
inp=createElement("button",{id:"inputZonesToGeneral","class":"link",style:"display:block;width:110px;margin:5px;padding:1px;"},newtd,"Add" + getText("automat_titleQueue"));
inp.addEventListener("click",function(){
addZoneToList();
click($("infoPanelZoneList"));
},false);
}
newtr=null;newtd=null;inp=null;help=null;zones=null;
return newtable;
}catch(err){GM_logError("drawZoneListTable currZoneType:"+currZoneType+" \n"+err);return newtable;}
}
unsafeWindow.buildInfoPanelAutomat=function(mode,mode2){
try{
var div;
if(div=$("divQueueBoxClose")){ click(div); }
if(div=$("divChooseBoxClose")){ click(div); }
div=null;
switch(mode){
case "automatChangelog": buildInfoPanelChangelog(); break;
case "automatOverview": buildInfoPanelOverview(mode2); break;
}
}catch(err){GM_logError("buildInfoPanelAutomat\n"+err);}
}
function buildInfoPanelChangelog(){
try{
var table,tr,td,div;
var container=$("infoPanelInner");
container.innerHTML="";
// Head
newdiv=createElement("div",{"class":"borderBottom1Black","style":"height:50px;"},container);
table=createElement("table",{"border":"0","cellspacing":"0","style":"width:100%;"},newdiv);
tr=createElement("tr",{},table);
createElement("td",{"class":"tnormal","style":"color:black;font-weight:bold;text-align:center;height:40px;"},tr,getText("automat")+" "+VERSION);
createElement("td",{},tr);
// Body
newdiv=createElement("div",{"style":"height:470px;width:100%;overflow:auto;"},container);
table=createElement("table",{"border":"0","cellspacing":"0","style":"width:100%;"},newdiv);
tr=createElement("tr",{},table);
createElement("th",{},tr,getText("version"));
createElement("th",{},tr,getText("date"));
createElement("th",{},tr,getText("change"));
for(var i=CHANGELOG.length-1;i>-1;i--){
tr=createElement("tr",{"class":"hoverBgCc9 borderBottom1dashedGrey"},table);
createElement("td",{},tr,CHANGELOG[i][0]);
createElement("td",{},tr,CHANGELOG[i][1]);
td=createElement("td",{},tr);
div=createElement("ul",{},td);
for(var j=0;j<CHANGELOG[i][2].length;j++){
createElement("li",{},div,CHANGELOG[i][2][j][LANGUAGE=="de"?0:1]);
}
}
container=null;table=null;tr=null;td=null;div=null;
}catch(err){GM_logError("buildInfoPanelChangelog\n"+err);}
}
function buildInfoPanelOverview(mode){
try{
var newtable,newdiv,newdiv1,newdiv2,help;
var modeDefault={"filterZone":"farm1,","filterType":"1,2,3,"};
var modeOld=explode(GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_modeOverViewFarms"),"buildInfoPanelOverview/modeOld");
if(typeof modeOld!="object"){ modeOld=modeDefault; }
if(typeof mode!="object"){ mode=modeOld; }
for(var v in modeDefault){
if(!modeDefault.hasOwnProperty(v)){ continue; }
if(mode[v]==undefined){ mode[v]=(modeOld[v]==undefined?modeDefault[v]:modeOld[v]); }
}
GM_setValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_modeOverViewFarms",implode(mode,"buildInfoPanelOverview/mode"));
newdiv=$("infoPanelInner");
newdiv.innerHTML="";
newdiv=createElement("div",{"id":"infoPanelHeader","style":"height:35px;width:100%;border:0px solid red;-moz-user-select:none;"},newdiv);
newdiv.addEventListener("mouseover", function(event){
var node=event.target;
while((node!=this)&&(!node.getAttribute("mouseOverText"))){ node=node.parentNode; }
if(node!=this){ toolTip.show(event,node.getAttribute("mouseOverText")); }
},false);
newdiv1=createElement("div",{"id":"farmlinks2","name":0,"class":"farmlinks"},newdiv);
newdiv1.addEventListener("click",function(filter){
return function(event){
var thisFilter=event.target.getAttribute("filter");
if(thisFilter){
if(!event.ctrlKey){
filter=thisFilter;
}else if(filter.search(thisFilter)!=-1){
filter.replace(thisFilter,"")
}else{
filter+=thisFilter;
}
buildInfoPanelOverview({"filterZone":filter});
}
}}(mode["filterZone"]),false);
for(var farmNr=1;farmNr<=unsafeWindow.farmamount;farmNr++){ // Farm-Buttons
if(mode["filterZone"].search("farm"+farmNr+",")==-1){
newdiv2=createElement("div",{"filter":"farm"+farmNr+",","class":"link speedlink speedlink_farm"+farmNr,"mouseOverText":getText("automat_title_on_farm"+farmNr)},newdiv1);
}else{
newdiv2=createElement("div",{"filter":"farm"+farmNr+",","class":"link speedlink speedlink_farm"+farmNr+"_active","mouseOverText":getText("automat_title_off_farm"+farmNr)},newdiv1);
}
createElement("span",{"filter":"farm"+farmNr+",","class":"speedlink_text"},newdiv2,farmNr);
}
if(!unsafeData.zones.getBlock(unsafeData.ALL_ZONES["farmersmarket"][0])){
if(mode["filterZone"].search("farmersmarket,")==-1){
createElement("div",{"filter":"farmersmarket,","class":"link speedlink speedlink_farmersmarket","mouseOverText":getText("automat_title_on_farmersmarket")},newdiv1);
}else{
createElement("div",{"filter":"farmersmarket,","class":"link speedlink speedlink_farmersmarket","mouseOverText":getText("automat_title_off_farmersmarket")},newdiv1);
}
}
for(var j=0;j<unsafeData.ALL_ZONES["city"].length;j++){
if(!unsafeData.zones.getBlock(unsafeData.ALL_ZONES["city"][j])){
if(mode["filterZone"].search("city,")==-1){
createElement("div",{"filter":"city,","class":"link speedlink speedlink_city1","mouseOverText":getText("automat_title_on_city")},newdiv1);
}else{
createElement("div",{"filter":"city,","class":"link speedlink speedlink_city1_active","mouseOverText":getText("automat_title_off_city")},newdiv1);
}
break;
}
}
for(var j=0;j<unsafeData.ALL_ZONES["forestry"].length;j++){
if(!unsafeData.zones.getBlock(unsafeData.ALL_ZONES["forestry"][j])){
if(mode["filterZone"].search("forestry,")==-1){
createElement("div",{"filter":"forestry,","class":"link speedlink speedlink_forestry","mouseOverText":getText("automat_title_on_forestry")},newdiv1);
}else{
createElement("div",{"filter":"forestry,","class":"link speedlink speedlink_forestry_active","mouseOverText":getText("automat_title_off_forestry")},newdiv1);
}
break;
}
}
for(var j=0;j<unsafeData.ALL_ZONES["foodworld"].length;j++){
if(!unsafeData.zones.getBlock(unsafeData.ALL_ZONES["foodworld"][j])){
if(mode["filterZone"].search("foodworld,")==-1){
createElement("div",{"filter":"foodworld,","class":"link speedlink speedlink_foodworld","mouseOverText":getText("automat_title_on_foodworld")},newdiv1);
}else{
createElement("div",{"filter":"foodworld,","class":"link speedlink speedlink_foodworld_active","mouseOverText":getText("automat_title_off_foodworld")},newdiv1);
}
break;
}
}
newdiv1=createElement("div",{"id":"fieldlinks","name":1,"class":"fieldlinks","style":"-moz-user-select:none;"},newdiv);
newdiv1.addEventListener("click",function(filter){
return function(event){
var thisFilter=event.target.getAttribute("filter");
if(thisFilter){
if(!event.ctrlKey){
filter=thisFilter;
}else if(filter.search(thisFilter)!=-1){
filter.replace(thisFilter,"")
}else{
filter+=thisFilter;
}
buildInfoPanelOverview({"filterType":filter});
}
}}(mode["filterType"]),false);
for(var i=3;i>=1;i--){ // Zonetype-Buttons
if(mode["filterType"].search(i+",")==-1){
createElement("div",{"filter":i+",","class":"link fieldlinkitem"+i,"mouseOverText":getText("automat_title_on_type"+i)},newdiv1);
}else{
createElement("div",{"filter":i+",","class":"link fieldlinkitemactivate"+i,"mouseOverText":getText("automat_title_off_type"+i)},newdiv1);
}
}
newdiv=createElement("div",{style:"overflow-y:auto;overflow-x:hidden;width:100%;height:"+($("infoPanelInner").clientHeight-35)+"px;"},$("infoPanelInner"));
newtable=createElement("table",{"class":"border1",style:"width:100%;"},newdiv);
var newtr,newtd,zoneNrS;
// collect all handled zones
var zones=new Array();
for(var i in unsafeData.ALL_SLOTS){
if(!unsafeData.ALL_SLOTS.hasOwnProperty(i)){ continue; }
if(unsafeData.zones.getBlock(i)){ continue; }
if(unsafeData.ALL_SLOTS[i]=="farm"){
if(mode["filterZone"].search(unsafeData.ALL_SLOTS[i]+Math.ceil(parseInt(i,10)/6))!=-1){
zones.push([unsafeData.ALL_SLOTS[i]+Math.ceil(parseInt(i,10)/6),i]);
}
}else{
if(mode["filterZone"].search(unsafeData.ALL_SLOTS[i])!=-1){
zones.push([unsafeData.ALL_SLOTS[i],i]);
}
}
}
// GM_log("ALL_SLOTS:\n"+print_r(unsafeData.ALL_SLOTS,"",true,"\n"));
// GM_log("zones:\n"+print_r(zones,"",true,"\n"));
// build table
var old=null;
for(var i=0;i<zones.length;i++){
if(old!=zones[i][0]){
if(old!=null){
newtr=createElement("tr",{style:"line-height:1px;"},newtable);
newtd=createElement("td",{"colspan":"3",style:"background-color:black;"},newtr);
}
old=zones[i][0];
}
zoneNrS=zones[i][1];
zoneNrL=getZoneListId(zoneNrS);
// GM_log("loop farmNr:" + farmNr + " zoneNr:"+zoneNr + " zoneNrS:"+zoneNrS + " zoneNrL:"+zoneNrL+" feldtyp:"+getBuildingTyp(zoneNrF));
switch(getBuildingTyp(zoneNrS)){
case 1:{ // field
if((mode["filterType"].search("1,")!=-1) && !$("tdAutoMatOverview_"+zoneNrL)){
newtr=createElement("tr",{},newtable);
newtd=createElement("td",{"id":"tdAutoMatOverview_"+zoneNrL},newtr);
if(settings.get("account","useQueueList")){
drawQueueBox(zoneNrS, null, newtd);
}else{
drawQueueChooseItemBox(zoneNrS, null, 0, newtd);
}
}
break;}
case 2:{ //stable
if((mode["filterType"].search("2,")!=-1) && !$("tdAutoMatOverview_"+zoneNrL)){
newtr=createElement("tr",{},newtable);
newtd=createElement("td",{"id":"tdAutoMatOverview_"+zoneNrL},newtr);
drawStableChooseFeedBox(zoneNrS,null,newtd);
}
break;}
case 3:{ //factory
if((mode["filterType"].search("3,")!=-1) && !$("tdAutoMatOverview_"+zoneNrL)){
newtr=createElement("tr",{},newtable);
newtd=createElement("td",{"id":"tdAutoMatOverview_"+zoneNrL},newtr);
if(settings.get("account","useQueueList")){
drawQueueBox(zoneNrS,null,newtd);
}else{
drawFactoryChooseItemBox(zoneNrS,null,newtd);
}
}
break;}
default:{
if(!$("tdAutoMatOverview_"+zoneNrL)){
newtr=createElement("tr",{},newtable);
newtd=createElement("td",{"id":"tdAutoMatOverview_"+zoneNrL},newtr);
drawQueueBox(zoneNrS, null, newtd);
}
}
}
}
newtr=null;newtd=null;newinput=null;
newimg=null;newtable=null;newdiv=null;
}catch(err){GM_logError("buildInfoPanelOverview\n"+err);}
}
unsafeWindow.buildInfoPanelAutomatMenu=function(mode){
try{
var newdiv,newdiv1;
newdiv=$("infoPanelL");
newdiv1=createElement("div",{"style":"margin-top:15px;border-bottom:1px solid #685338;font-weight:bold;float:left;width:100%;"},newdiv,getText("automat"));
newdiv1.addEventListener("mouseover",function(event){
toolTip.show(event,getText("showChangelog"));
},false);
newdiv1.classList.add("link");
newdiv1.addEventListener("click",function(event){
unsafeWindow.buildInfoPanel("automatChangelog");
},false);
if(USERNAME){
newdiv1=createElement("div",{"id":"infoPanelNaviAutomatOptions","class":"link naviItem","style":"margin-top:5px;width:95px;"},newdiv,getText("options"));
newdiv1.addEventListener("click",function(event){ unsafeWindow.buildInfoPanelMenu("automatOptions"); },false);
newdiv1=createElement("div",{"id":"infoPanelNaviAutomatZonePairing","class":"link naviItem","style":"margin-top:5px;width:95px;"},newdiv,getText("automat_zonePairing"));
newdiv1.addEventListener("click",function(event){ unsafeWindow.buildInfoPanelMenu("automatZonePairing"); },false);
newdiv1=createElement("div",{"id":"infoPanelNaviAutomatDebugInfo","class":"link naviItem","style":"margin-top:5px;width:95px;"},newdiv,getText("automat_debugInfo"));
newdiv1.addEventListener("click",function(event){ unsafeWindow.buildInfoPanelMenu("automatDebugInfo"); },false);
}else{
createElement("div",{"id":"infoPanelNaviAutomatOptions","class":"naviItemInactive","style":"margin-top:5px;width:95px;"},newdiv,getText("options"));
createElement("div",{"id":"infoPanelNaviAutomatZonePairing","class":"naviItemInactive","style":"margin-top:5px;width:95px;"},newdiv,getText("automat_zonePairing"));
createElement("div",{"id":"infoPanelNaviAutomatDebugInfo","class":"naviItemInactive","style":"margin-top:5px;width:95px;"},newdiv,getText("automat_debugInfo"));
}
// switch call
switch(mode){
case "automatOptions": buildInfoPanelOptions(); break;
case "automatZonePairing": buildInfoPanelZonePairing(); break;
case "automatDebugInfo": buildInfoPanelDebugInfo(); break;
}
newdiv=null;newdiv1=null;
}catch(err){GM_logError("buildInfoPanelAutomatMenu\n"+err);}
}
function buildInfoPanelOptions(){
try{
var newdiv,newtable,newtr,newtd,inp;
newdiv=$("infoPanelNaviAutomatOptions");
newdiv.classList.remove("naviItem");
newdiv.classList.add("naviItemActive");
newdiv=$("infoPanelR");
newtable=createElement("table",{"class":"hoverRowBgCc9","style":"width:100%","border":"1"},newdiv);
// *********** FARM ***************************************
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
createElement("th",{colspan:"3"},newtr,getText("farm"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","autoPlant")},newtd);
inp.addEventListener("click",function(){
settings.set("account","autoPlant",this.checked);
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_autoPlant"));
newtr=createElement("tr",{style:"line-height:18px;"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","autoWater")},newtd);
inp.addEventListener("click",function(){
settings.set("account","autoWater",this.checked);
},false);
newtd=createElement("td",{colspan:"2"},newtr,getText("automat_settings_autoWater"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","autoFeed")},newtd);
inp.disabled=(unsafeWindow.premium==1 || parseInt(top.document.getElementById("levelnum").innerHTML,10)<10);
inp.addEventListener("click",function(){
settings.set("account","autoFeed",this.checked);
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_autoFeed"));
newtr=createElement("tr",{style:"line-height:18px;"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","disableCropFields")},newtd);
inp.addEventListener("click",function(){
settings.set("account","disableCropFields",this.checked);
checkReadyZone();
},false);
newtd=createElement("td",{colspan:"2"},newtr,getText("automat_settings_disableCropFields"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("select",{"class":"link"},newtd);
createElement("option",{"value":0},inp,"--");
createElement("option",{"value":5},inp,"5s");
createElement("option",{"value":10},inp,"10s");
createElement("option",{"value":30},inp,"30s");
createElement("option",{"value":60},inp,"1min");
createElement("option",{"value":120},inp,"2min");
createElement("option",{"value":300},inp,"5min");
createElement("option",{"value":600},inp,"10min");
inp.value=settings.get("account","seedWaitForCrop");
inp.addEventListener("change",function(){
settings.set("account","seedWaitForCrop",this.value);
},false);
newtd=createElement("td",{colspan:"2"},newtr,getText("automat_settings_seedWaitForCrop"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("input",{"id":"inputEmergencyPlants","style":"width:100px;text-align:center;background-color:transparent;","value":emergencyPlants.join(",")},newtd);
inp.addEventListener("change",function(){
emergencyPlants=this.value.split(/,/);
for(var v=emergencyPlants.length-1;0<=v;v--){
if((!unsafeData.prodTyp[0][emergencyPlants[v]])||(unsafeData.prodTyp[0][emergencyPlants[v]]!="v")||(unsafeData.prodBlock[0][emergencyPlants[v]].match(/l/))){
// check if the entry is a plant and not blocked by level
emergencyPlants.splice(v,1);
}
}
if(emergencyPlants.length==0){
// no entry=> set to default (Grain,Carrots)
emergencyPlants=[1,17];
}else{
// remove duplicates
for(var v=0;v<emergencyPlants.length;v++){
for(var w=emergencyPlants.length-1;v<w;w--){
if(emergencyPlants[v]==emergencyPlants[w]){
emergencyPlants.splice(w,1);
}
}
}
}
// update the select-box
var cell=$("selectEmergencyPlants");
for(var v=0;v<cell.children.length;v++){
var found=false;
for(var w=0;w<emergencyPlants.length;w++){
if(emergencyPlants[w]==cell.children[v].value){ found=true; }
}
cell.children[v].style.backgroundColor=(found?"#cc9":"");
}
this.value=emergencyPlants.join(",");
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_emergencyPlants", implode(emergencyPlants,"gameInfoPanelOpen/options/emergencyPlants"));
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_emergencyPlants"));
newdiv=createElement("div",{},newtd);
inp=createElement("select",{"class":"link","id":"selectEmergencyPlants"},newdiv);
for(var v=0;v<unsafeData.prodTyp[0].length;v++){
if((unsafeData.prodTyp[0][v]=="v")&&(!unsafeData.prodBlock[0][v].match(/l/))){
var found=false;
for(var w=0;w<emergencyPlants.length;w++){
if(emergencyPlants[w]==v){ found=true; }
}
createElement("option",{"value":v,"style":(found?"background-color:#cc9;":"")},inp,v+" "+unsafeData.prodName[0][v]+" ("+numberFormat(unsafeData.prodPlantSize[0][v])+")");
}
}
inp.addEventListener("change",function(){
var cell=$("inputEmergencyPlants");
cell.value +=","+this.value;
change(cell);
cell=null;
},false);
newtr=createElement("tr",{style:"line-height:18px;"},newtable);
newtd=createElement("td",{align:"center",width:"40"},newtr);
inp=createElement("input",{"class":"link",type:"checkbox",checked:settings.get("account","useQueueList")},newtd);
inp.addEventListener("click",function(){
settings.set("account","useQueueList",this.checked)
if($("divQueueBox").style.display=="block"){
var zoneNrF=$("divQueueBoxInner").getAttribute("zoneNrF");
click($("divQueueBoxClose"));
if(settings.get("account","useQueueList")){ click($("divAutomatIcon_"+zoneNrF)); }
}
},false);
newtd=createElement("td","",newtr,getText("automat_settings_useQueueList"));
inp=createElement("img",{"src":IMAGES["help"],"style":"margin-left:3px;height:14px;width:14px;"},newtd);
inp.addEventListener("mouseover",function(evt){ toolTip.show(evt,"<div style='width:300px'><b>"+getText("automat_help_3")[0]+"</b><br>"+getText("automat_help_3")[1]+"</div>"); },false);
inp=createElement("img",{"src":IMAGES["help"],"style":"margin-left:3px;height:14px;width:14px;"},newtd);
inp.addEventListener("mouseover",function(evt){ toolTip.show(evt,"<div style='width:300px'><b>"+getText("automat_help_9")[0]+"</b><br>"+getText("automat_help_9")[1]+"</div>"); },false);
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("button",{id:"inputDeleteAllQueueData","class":"link hoverBgCc9",style:"display:block;width:110px;margin:5px;padding:1px;"},newtd,getText("automat_set12a"));
inp.addEventListener("click",function(){
this.disabled=true;
zoneList={};
zoneSettings={};
zoneToList={};
for(var fz in unsafeData.ALL_SLOTS){
if(!unsafeData.ALL_SLOTS.hasOwnProperty(fz)){ continue; }
zoneList[fz]=(fz=="windmill"?DEFAULT_ZONELIST_MILL_ARRAY.clone():DEFAULT_ZONELIST_ITEM_ARRAY.clone());
zoneSettings[fz]={"repeat":false,"shuffle":false};
zoneToList[fz]=fz;
reFillQueueBox(fz,fz,0);
}
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList,"gameInfoPanelOpen/options/zoneList"));
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneSettings",implode(zoneSettings,"gameInfoPanelOpen/options/zoneSettings"));
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneToList",implode(zoneToList,"gameInfoPanelOpen/options/zoneToList"));
alert(getText("automat_set12b"));
this.disabled=false;
},false);
newtr=createElement("tr",{style:"line-height:18px;"},newtable);
newtd=createElement("td",{align:"center"},newtr);
inp=createElement("input",{"class":"link",type:"checkbox",checked:settings.get("account","showQueueTime")},newtd);
inp.addEventListener("click",function(){
settings.set("account","showQueueTime",this.checked)
for(var i=0;i<unsafeData.ALL_ZONES["farm"].length;i++){
updateQueueBox(unsafeData.ALL_ZONES["farm"][i]);
}
updateQueueBox("windmill",0);
//TODO ALL_SLOTS?
},false);
createElement("td",{colspan:"2"},newtr,getText("automat_settings_showQueueTime"));
// *********** FARMIE *************************************
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
newtd=createElement("th",{colspan:"3"},newtr,"Farmis"); // TODO texte
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"colspan":"3","align":"center"},newtr,"This bot needs a review ... :(");
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center","width":"40"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","botUseFarmi")},newtd);
inp.addEventListener("click",function(){
settings.set("account","botUseFarmi",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_botUse"));
newtr=createElement("tr",{"style":"line-height:18px;","set":"account_farmiReject"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox",checked:settings.get("account","farmiReject")},newtd);
inp.addEventListener("click",function(){
settings.set("account","farmiReject",this.checked);
botArbiter.check();
},false);
newtd=createElement("td",{colspan:"1"},newtr,getText("automat_settings_farmiReject"));
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("input",{"style":"width:100%;height:18px;direction:rtl",value:settings.get("account","farmiRejectUntilNr")+"%"},newtd);
inp.addEventListener("change",function(){
var help=parseInt(this.value.replace("%",""),10);
if(isNaN(help)){
this.value=settings.get("account","farmiRejectUntilNr")+"%";
}else{
settings.set("account","farmiRejectUntilNr",Math.max(0,Math.min(999,Math.min(help,settings.get("account","farmiAcceptAboveNr")))));
this.value=settings.get("account","farmiRejectUntilNr")+"%";
botArbiter.check();
}
},false);
newtr=createElement("tr",{style:"line-height:18px;","set":"account_farmiAccept"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link",type:"checkbox",checked:settings.get("account","farmiAccept")},newtd);
inp.addEventListener("click",function(){
settings.set("account","farmiAccept",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{colspan:"1"},newtr,getText("automat_settings_farmiAccept"));
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("input",{"style":"width:100%;height:18px;direction:rtl",value:settings.get("account","farmiAcceptAboveNr")+"%"},newtd);
inp.addEventListener("change",function(){
var help=parseInt(this.value.replace("%",""),10);
if(isNaN(help)){
this.value=settings.get("account","farmiAcceptAboveNr")+"%";
}else{
settings.set("account","farmiAcceptAboveNr",Math.max(0,Math.min(999,Math.max(help,settings.get("account","farmiRejectUntilNr")))));
this.value=settings.get("account","farmiAcceptAboveNr")+"%";
botArbiter.check();
}
},false);
newtr=createElement("tr",{style:"line-height:18px;","set":"account_farmiAcceptBelowMinValue"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link",type:"checkbox",checked:settings.get("account","farmiAcceptBelowMinValue")},newtd);
inp.addEventListener("click",function(){
settings.set("account","farmiAcceptBelowMinValue",this.checked);
botArbiter.check();
},false);
newtd=createElement("td",{colspan:"2"},newtr,getText("automat_settings_farmiAcceptBelowMinValue"));
newtr=createElement("tr",{style:"line-height:18px;","set":"account_farmiRemoveMissing"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link",type:"checkbox",checked:settings.get("account","farmiRemoveMissing")},newtd);
inp.addEventListener("click",function(){
settings.set("account","farmiRemoveMissing",this.checked);
botArbiter.check();
},false);
newtd=createElement("td",{colspan:"1"},newtr,getText("automat_settings_farmiRemoveMissing"));
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("input",{"style":"width:100%;height:18px;direction:rtl",value:settings.get("account","farmiRemoveMissingAboveNr")},newtd);
inp.addEventListener("change",function(){
var help=parseInt(this.value,10);
if(isNaN(help)){
this.value=settings.get("account","farmiRemoveMissingAboveNr");
}else{
settings.set("account","farmiRemoveMissingAboveNr",Math.max(0,Math.min(999,help)));
this.value=settings.get("account","farmiRemoveMissingAboveNr");
botArbiter.check();
}
},false);
// *********** FARMERSMARKET ***********************************
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
createElement("th",{"colspan":"3"},newtr,getText("farmersmarket"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center","width":"40"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","botUseFarmersmarket")},newtd);
inp.addEventListener("click",function(){
settings.set("account","botUseFarmersmarket",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_botUse"));
// *********** WALTRAUD ***********************************
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
createElement("th",{"colspan":"3"},newtr,getText("donkey"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center","width":"40"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","botUseDonkey")},newtd);
inp.addEventListener("click",function(){
settings.set("account", "botUseDonkey", this.checked);
// buildInfoPanelOptionsDisabling();
botArbiter.check();
}, false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_botUse"));
// *********** LOTTERY ************************************
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
newtd=createElement("th",{colspan:"3"},newtr,"Lottery"); // TODO texte
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center","width":"40"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","botUseLottery")},newtd);
inp.addEventListener("click",function(){
settings.set("account","botUseLottery",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_botUse"));
newtr=createElement("tr",{"style":"line-height:18px;","set":"account_lotteryActivate"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link",type:"checkbox","checked":settings.get("account","lotteryActivate")},newtd);
inp.addEventListener("click",function(){
settings.set("account","lotteryActivate",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{colspan:"2"},newtr,getText("automat_settings_lotteryActivate"));
newtr=createElement("tr",{"style":"line-height:18px;","set":"account_lotteryDailyLot"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link",type:"checkbox",checked:settings.get("account","lotteryDailyLot")},newtd);
inp.addEventListener("click",function(){
settings.set("account","lotteryDailyLot",this.checked);
},false);
newtd=createElement("td",{colspan:"2"},newtr,getText("automat_settings_lotteryDailyLot"));
// *********** QUEST **************************************
/* quest-bot needs review
newtr=createElement("tr",{style:"line-height:18px;"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{id:"inputvalQuestActivate","class":"link",type:"checkbox",checked:valQuestActivate||GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestActivate", false)},newtd);
inp.addEventListener("click",function(){
valQuestActivate=this.checked;
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestActivate", valQuestActivate);
if(valQuestActivate){botArbiter.check();}
},false);
inp.disabled=valQuestActivateUntilNr<unsafeData.questData["farm"]["1"]["nr"];
newtd=createElement("td",{colspan:"1"},newtr,getText("automat_settings_questActivate"));
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("select",{"id":"valQuestActivateUntilNrSelector","style":"width:100%;height:18px;direction:rtl"},newtd);
createElement("option",{"value":"-"},inp,"-");
for(var i=unsafeData.questData["farm"]["1"]["nr"];i<unsafeData.QUESTS["farm"]["1"].length;i++){
createElement("option",{"value":i},inp,i);
}
inp.value=(valQuestActivateUntilNr<unsafeData.questData["farm"]["1"]["nr"])?"-":valQuestActivateUntilNr;
inp.addEventListener("change",function(){
if(this.value=="-"){
valQuestActivateUntilNr=0;
}else{
valQuestActivateUntilNr=parseInt(this.value,10);
}
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestActivateUntilNr", valQuestActivateUntilNr);
$("inputvalQuestActivate").disabled=valQuestActivateUntilNr<unsafeData.questData["farm"]["1"]["nr"];
if(valQuestActivateUntilNr < unsafeData.questData["farm"]["1"]["nr"]) valQuestActivate=false;
if(valQuestActivate){botArbiter.check();}
},false);
newtr=createElement("tr",{style:"line-height:18px;"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{id:"inputvalQuestSolving","class":"link",type:"checkbox",checked:valQuestSolving||GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestSolving", false)},newtd);
inp.addEventListener("click",function(){
valQuestSolving=this.checked;
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestSolving", valQuestSolving);
if(valQuestSolving){botArbiter.check();}
},false);
inp.disabled=valQuestSolvingUntilNr<unsafeData.questData["farm"]["1"]["nr"];
newtd=createElement("td",{colspan:"1"},newtr,getText("automat_settings_questSolving"));
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("select",{"id":"valQuestActivateUntilNrSelector","style":"width:100%;height:18px;direction:rtl"},newtd);
createElement("option",{"value":"-"},inp,"-");
for(var i=unsafeData.questData["farm"]["1"]["nr"];i<unsafeData.QUESTS["farm"]["1"].length;i++){
createElement("option",{"value":i},inp,i);
}
inp.value=(valQuestSolvingUntilNr<unsafeData.questData["farm"]["1"]["nr"])?"-":valQuestSolvingUntilNr;
inp.addEventListener("change",function(){
if(this.value=="-"){
valQuestSolvingUntilNr=0;
}else{
valQuestSolvingUntilNr=parseInt(this.value,10);
}
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestSolvingUntilNr", valQuestSolvingUntilNr);
$("inputvalQuestSolving").disabled=valQuestSolvingUntilNr<unsafeData.questData["farm"]["1"]["nr"];
if(valQuestSolvingUntilNr < unsafeData.questData["farm"]["1"]["nr"]) valQuestSolving=false;
if(valQuestSolving){botArbiter.check();}
},false);
//TODO add valLodgeQuestSolving
newtr=createElement("tr",{style:"line-height:18px;"},newtable);
newtd=createElement("td",{align:"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{id:"inputvalLodgeQuestSolving","class":"link",type:"checkbox",checked:valLodgeQuestSolving||GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valLodgeQuestSolving", false)},newtd);
inp.addEventListener("click",function(){
valLodgeQuestSolving=this.checked;
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valLodgeQuestSolving", valLodgeQuestSolving);
if(valLodgeQuestSolving){botArbiter.check();}
},false);
newtd=createElement("td",{colspan:"1"},newtr,"setvalLodgeQuestSolving");//getText("automat_setvalLodgeQuestSolving"));
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp.disabled=valLodgeQuestSolvingUntilNr<unsafeData.questData["farm"]["1"]["nr"];
inp=createElement("select",{"id":"valLodgeQuestActivateUntilNrSelector","style":"width:100%;height:18px;direction:rtl"},newtd);
createElement("option",{"value":"-"},inp,"-");
for(var i=unsafeData.questData["farm"]["1"]["nr"];i<unsafeData.QUESTS["farm"]["1"].length;i++){
createElement("option",{"value":i},inp,i);
}
inp.value=(valLodgeQuestSolvingUntilNr<unsafeData.questData["farm"]["1"]["nr"])?"-":valLodgeQuestSolvingUntilNr;
inp.addEventListener("change",function(){
if(this.value=="-"){
valLodgeQuestSolvingUntilNr=0;
}else{
valLodgeQuestSolvingUntilNr=parseInt(this.value,10);
}
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valLodgeQuestSolvingUntilNr", valLodgeQuestSolvingUntilNr);
$("inputvalLodgeQuestSolving").disabled=valLodgeQuestSolvingUntilNr<unsafeData.questData["farm"]["1"]["nr"];
if(valLodgeQuestSolvingUntilNr < unsafeData.questData["farm"]["1"]["nr"]) valLodgeQuestSolving=false;
if(valLodgeQuestSolving){botArbiter.check();}
},false);
*/
// *********** WINDMILL ***********************************
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
createElement("th",{"colspan":"3"},newtr,getText("windmill"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center","width":"40"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","botUseWindmill")},newtd);
inp.addEventListener("click",function(){
settings.set("account","botUseWindmill",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{},newtr,getText("automat_settings_botUse"));
inp=createElement("img",{"src":IMAGES["help"],"style":"margin-left:3px;height:14px;width:14px;"},newtd);
inp.addEventListener("mouseover",function(evt){ toolTip.show(evt,"<div style='width:300px'><b>"+getText("automat_help_9")[0]+"</b><br>"+getText("automat_help_9")[1]+"</div>"); },false);
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("button",{"class":"link hoverBgCc9",style:"display:block;width:110px;margin:5px;padding:1px;"},newtd,getText("automat_set18a"));
inp.addEventListener("click",function(){
this.disabled=true;
zoneList["windmill"]=DEFAULT_ZONELIST_MILL_ARRAY;
zoneSettings["windmill"]={"shuffle":false,"lack":0,"detail":new Array()};
autoMillStorage=new Array();
reFillQueueBox("windmill","windmill",0);
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList));
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneSettings",implode(zoneSettings));
GM_setValue2(COUNTRY+"_"+SERVER+"_"+USERNAME+"_autoMillStorage",implode(autoMillStorage));
alert(getText("automat_set18b"));
this.disabled=false;
},false);
newtr=createElement("tr",{"style":"line-height:18px;","set":"account_powerUpActivate"},newtable);
newtd=createElement("td",{"align":"center","style":"max-width:120px;"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","powerUpActivate")},newtd);
inp.addEventListener("click",function(){
settings.set("account","powerUpActivate",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{colspan:"2"},newtr,getText("automat_settings_powerUpActivate"));
// *********** FOODWORLD ***********************************
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
createElement("th",{"colspan":"3"},newtr,getText("foodworld"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center","width":"40"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","botUseFoodworld")},newtd);
inp.addEventListener("click",function(){
settings.set("account","botUseFoodworld",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_botUse"));
// *********** FORESTRY ***********************************
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
createElement("th",{"colspan":"3"},newtr,getText("forestry"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center","width":"40"},newtr);
inp=createElement("input",{"class":"link","type":"checkbox","checked":settings.get("account","botUseForestry")},newtd);
inp.addEventListener("click",function(){
settings.set("account","botUseForestry",this.checked);
buildInfoPanelOptionsDisabling();
botArbiter.check();
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_botUse"));
//*****
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
createElement("th",{colspan:"3"},newtr,getText("automat_general"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("input",{"id":"settings_pauseShortMin","value":settings.get("country","pauseShort")[0],"size":"5px","style":"text-align:center;background-color:transparent;"},newtd);
inp.addEventListener("change",function(){
var val=settings.get("country","pauseShort");
val[0]=Math.max(0,Math.min(parseInt(this.value,10),val[1]));
this.value=val[0];
settings.set("country","pauseShort",val);
},false);
createElement("span","",newtd,"ms");
createElement("td",{},newtr,getText("automat_settings_pauseShortMin"));
newtd=createElement("td",{"rowspan":"2","style":"width:120px;"},newtr);
inp=createElement("button",{"class":"link hoverBgCc9","style":"display:block;width:110px;margin:5px;padding:1px;"},newtd,getText("automat_setToDefault"));
inp.addEventListener("click",function(){
var help=settings.reset("country","pauseShort");
$("settings_pauseShortMin").value=help[0];
$("settings_pauseShortMax").value=help[1];
},false);
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("input",{"id":"settings_pauseShortMax","value":settings.get("country","pauseShort")[1],"size":"5px","style":"text-align:center;background-color:transparent;"},newtd);
inp.addEventListener("change",function(){
var val=settings.get("country","pauseShort");
val[1]=Math.max(0,Math.max(parseInt(this.value,10),val[0]));
this.value=val[1];
settings.set("country","pauseShort",val);
},false);
createElement("span","",newtd,"ms");
createElement("td",{},newtr,getText("automat_settings_pauseShortMax"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("input",{"id":"settings_pauseMin","value":settings.get("country","pause")[0],"size":"5px","style":"text-align:center;background-color:transparent;"},newtd);
inp.addEventListener("change",function(){
var val=settings.get("country","pause");
val[0]=Math.max(0,Math.min(parseInt(this.value,10),val[1]));
this.value=val[0];
settings.set("country","pause",val);
},false);
createElement("span","",newtd,"ms");
createElement("td",{},newtr,getText("automat_settings_pauseMin"));
newtd=createElement("td",{"rowspan":"2","style":"width:120px;"},newtr);
inp=createElement("button",{"class":"link hoverBgCc9","style":"display:block;width:110px;margin:5px;padding:1px;"},newtd,getText("automat_setToDefault"));
inp.addEventListener("click",function(){
var help=settings.reset("country","pause");
$("settings_pauseMin").value=help[0];
$("settings_pauseMax").value=help[1];
},false);
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("input",{"id":"settings_pauseMax",value:settings.get("country","pause")[1],"size":"5px","style":"text-align:center;background-color:transparent;"},newtd);
inp.addEventListener("change",function(){
var val=settings.get("country","pause");
val[1]=Math.max(0,Math.max(parseInt(this.value,10),val[0]));
this.value=val[1];
settings.set("country","pause",val);
},false);
createElement("span","",newtd,"ms");
createElement("td",{},newtr,getText("automat_settings_pauseMax"));
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("input",{"id":"settings_maxDurationBotRun","value":settings.get("country","maxDurationBotRun"),"size":"5px","style":"text-align:center;background-color:transparent;"},newtd);
inp.addEventListener("change",function(){
var help=parseInt(this.value,10);
if (isNaN(help)){
this.value="";
}else{
if(help<0){ help*=-1; }
this.value=help;
settings.set("country","maxDurationBotRun",help);
}
},false);
createElement("span","",newtd,"s");
createElement("td",{},newtr,getText("automat_settings_maxDurationBotRun"));
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("button",{"class":"link hoverBgCc9","style":"display:block;width:110px;margin:5px;padding:1px;"},newtd,getText("automat_setToDefault"));
inp.addEventListener("click",function(){
$("settings_maxDurationBotRun").value=settings.reset("country","maxDurationBotRun");
},false);
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("input",{"id":"settings_maxDurationBotStep","value":settings.get("country","maxDurationBotStep"),"size":"5px","style":"text-align:center;background-color:transparent;"},newtd);
inp.addEventListener("change",function(){
var help=parseInt(this.value,10);
if (isNaN(help)){
this.value="";
}else{
if(help<0){ help*=-1; }
this.value=help;
settings.set("country","maxDurationBotStep",help);
}
},false);
createElement("span","",newtd,"s");
createElement("td",{},newtr,getText("automat_settings_maxDurationBotStep"));
newtd=createElement("td",{"style":"width:120px;"},newtr);
inp=createElement("button",{"class":"link hoverBgCc9","style":"display:block;width:110px;margin:5px;padding:1px;"},newtd,getText("automat_setToDefault"));
inp.addEventListener("click",function(){
$("settings_maxDurationBotStep").value=settings.reset("country","maxDurationBotStep");
},false);
newtr=createElement("tr",{"style":"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
inp=createElement("select",{"id":"input_botErrorBehaviour","class":"link"},newtd);
createElement("option",{"value":"reload"},inp,getText("automat_settings_pageReload"));
createElement("option",{"value":"restart"},inp,getText("automat_settings_botRestart"));
inp.value=settings.get("country","botErrorBehaviour");
inp.addEventListener("change",function(){
settings.set("country","botErrorBehaviour",this.value)
},false);
newtd=createElement("td",{"colspan":"2"},newtr,getText("automat_settings_botErrorBehaviour"));
// *****
newtr=createElement("tr",{"style":"background-color:#b69162;"},newtable);
createElement("th",{colspan:"3"},newtr,getText("automat_development"));
newtr=createElement("tr",{style:"line-height:18px;"},newtable);
newtd=createElement("td",{"align":"center"},newtr);
newinput=createElement("input",{"id":"inputDevmode","type":"checkbox","class":"link","checked":DEVMODE},newtd);
newinput.addEventListener("click",function(){GM_setValue2("devmode",DEVMODE=this.checked);},false);
createElement("td",{},newtr,"Developer Mode");
createElement("td",{},newtr);
newtr=createElement("tr",{},newtable);
newtd=createElement("td",{"align":"center"},newtr);
newinput=createElement("input",{"id":"inputDevmodeFunctions","type":"checkbox","class":"link","checked":DEVMODE_FUNCTION},newtd);
newinput.addEventListener("click",function(){GM_setValue2("devmode_function",DEVMODE_FUNCTION=this.checked);},false);
createElement("td",{},newtr,"Developer Function");
createElement("td",{},newtr,"Show function calls");
buildInfoPanelOptionsDisabling();
newdiv=null;newtable=null;newtr=null;newtd=null;inp=null;
}catch(err){GM_logError("buildInfoPanelOptions\n"+err);}
}
function buildInfoPanelOptionsDisabling(){
try{
var set,disabled,help,help2;
help=$("infoPanelR").querySelectorAll("[set]");
for(var i=help.length-1;i>=0;i--){
if(set=help[i].getAttribute("set").split("_")){
disabled=!settings.checkRequire(set[0],set[1]);
if(help[i].disabled!=disabled){
help[i].disabled=disabled;
help[i].style.opacity=(disabled?"0.6":"1");
}
}
help2=help[i].querySelectorAll("input");
for(var j=help2.length-1;j>=0;j--){
if(help2[j].disabled!=disabled){
help2[j].disabled=disabled;
}
}
}
help=null;
}catch(err){GM_logError("buildInfoPanelOptionsDisabling\n"+err);}
}
function buildInfoPanelZonePairing(){
try{
var container,newdiv;
newdiv=$("infoPanelNaviAutomatZonePairing");
newdiv.classList.remove("naviItem");
newdiv.classList.add("naviItemActive");
container=$("infoPanelR");
// count zones
var slotCount=new Object();
var zoneType;
for(var i in unsafeData.ALL_SLOTS){
if(!unsafeData.ALL_SLOTS.hasOwnProperty(i)){ continue; }
if(unsafeData.zones.getBlock(i)){ continue; }
zoneType=getZoneType(i);
if(!slotCount[zoneType]){ slotCount[zoneType]=0; }
slotCount[zoneType]++;
}
for(var i in slotCount){
if(!slotCount.hasOwnProperty(i)){ continue; }
if((i==1)||(slotCount[i]>1)){
newdiv=createElement("div",{"style":"font-weight:bold;"},container,isNaN(i)?getText(i):unsafeWindow.buildinginfos[0][i][10]);
newdiv.appendChild(drawZoneListTable(i));
}
}
container=null;newdiv=null;
}catch(err){GM_logError("buildInfoPanelZonePairing\n"+err);}
}
function buildInfoPanelDebugInfo(){
try{
newdiv=$("infoPanelNaviAutomatDebugInfo");
newdiv.classList.remove("naviItem");
newdiv.classList.add("naviItemActive");
container=$("infoPanelR");
newdiv=createElement("TEXTAREA", {"id":"debugbox","style":"width:99%;height:99%;"},container);
newdiv.innerHTML +="scriptversion:"+VERSION + ";\n";
newdiv.innerHTML +="neededVersionBerater:"+neededVersionBerater + ";\n";
newdiv.innerHTML +="neededVersionFunctionFile:"+neededVersionFunctionFile + ";\n";
newdiv.innerHTML +="zoneSettings:"+implode(zoneSettings,"Debug/zoneSettings") + ";\n";
newdiv.innerHTML +="zoneList:"+implode(zoneList,"Debug/zoneList") + ";\n";
newdiv.innerHTML +="zoneToList:"+implode(zoneToList,"Debug/zoneToList") + ";\n";
newdiv.innerHTML +="autoMillStorage:"+implode(autoMillStorage,"Debug/autoMillStorage") + ";\n";
newdiv.innerHTML +="emergencyPlants:"+implode(emergencyPlants,"Debug/emergencyPlants") + ";\n";
newdiv.innerHTML +="bot.isActive():"+bot.isActive()+ ";\n";
/* quest-bot needs review
newdiv.innerHTML +="valQuestActivate:"+valQuestActivate+ ";\n";
newdiv.innerHTML +="valQuestActivateUntilNr:"+valQuestActivateUntilNr+ ";\n";
newdiv.innerHTML +="valQuestSolving:"+valQuestSolving+ ";\n";
newdiv.innerHTML +="valQuestSolvingUntilNr:"+valQuestSolvingUntilNr+ ";\n";
newdiv.innerHTML +="valLodgeQuestSolving:"+valLodgeQuestSolving+ ";\n";
*/
newdiv.innerHTML +="devMode:"+DEVMODE+";\n";
container=null;newdiv=null;
}catch(err){GM_logError("buildInfoPanelDebugInfo\n"+err);}
}
// ***************************************************************************************************
function do_main(){
try{
// GM_log("AUTOMAT START");
if(DEVMODE){ logBubble.add("Automat-Script started"); }
// **************************************************
// Changes:
// ....
// GM_setValue2("changedata",1);
//
// **************************************************
// Show changelog of new version
var err_trace="Changelog of new version";
var container, newdiv;
if(CHANGELOG[CHANGELOG.length-1][0]!=GM_getValue("automatChangelogShownVersion","")){
container=createElement("div");
createElement("div",{},container,getText("automat_confirmChangelogVersion").replace("%1%",CHANGELOG[CHANGELOG.length-1][0]));
newdiv=createElement("ul",{},container);
for(var i=0;i<CHANGELOG[CHANGELOG.length-1][2].length;i++){
createElement("li",{},newdiv,CHANGELOG[CHANGELOG.length-1][2][i][LANGUAGE=="de"?0:1]);
}
alert2(container.innerHTML,getText("ok"),getText("showChangelog"),
function(){
GM_setValueCache("automatChangelogShownVersion",CHANGELOG[CHANGELOG.length-1][0]);
},
function(){
GM_setValueCache("automatChangelogShownVersion",CHANGELOG[CHANGELOG.length-1][0]);
unsafeWindow.buildInfoPanel("automatChangelog");
});
}
document.addEventListener("gameZoneReady",function(){
if(DEVMODE){ logBubble.add("event found:gameZoneReady: "+bot.isActive()); }
checkReadyZone();
},false);
/* quest-bot needs review
document.addEventListener("gameQuestNewAvailable",function(){
if(DEVMODE){ logBubble.add("event found:gameQuestNewAvailable: "+valQuestActivate); }
if(unsafeData.questData["farm"]["1"]["state"]==1 && valQuestActivate && valQuestActivateUntilNr>=unsafeData.questData["farm"]["1"]["nr"]){
botArbiter.add("quest");
}
},false);
document.addEventListener("gameQuestSolvable",function(){
if(DEVMODE){ logBubble.add("event found:gameQuestSolvable: "+valQuestSolving); }
if(unsafeData.questData["farm"]["1"]["state"]==2 && valQuestSolving && valQuestSolvingUntilNr>=unsafeData.questData["farm"]["1"]["nr"] && checkQuest()){
botArbiter.add("quest");
}
},false);
*/
err_trace="loading";
////--------------------------------------------------------------------------------------------------------------------------------
//[zoneNrF][QueNr][0]=product number, [1]=number to grow, [2]=number grown in loop modus, [3]=Behaviour (Field (default), Rack, Time(//TODO)), [4]=mode (1 time (default), repeat)
//[zoneNrF][mill][0]=product number, [1]=number to grow, [2]=number grown in loop modus, [3]=Min([4]), [4]=Array([X]=Max recipes for product X)
zoneList=explode(GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList"),"settings/zoneList",{});
if((typeof zoneList!="object")||(zoneList instanceof Array)){ zoneList={}; }
// check consistence
var bChanged=false;
for(var fz in zoneList){
if(!zoneList.hasOwnProperty(fz)){ continue; }
if(!(zoneList[fz] instanceof Array)){
GM_log("zoneList delete not array:"+fz+"("+getZoneType(fz)+")");
delete zoneList[fz]; bChanged=true; continue;
}
if(extendedListReg.test(fz)){ continue; }
if(!unsafeData.ALL_SLOTS[fz]){
GM_log("zoneList delete bad queue:"+fz+"("+getZoneType(fz)+")");
delete zoneList[fz]; bChanged=true; continue;
}
if(unsafeData.zones.getBlock(fz)){
GM_log("zoneList delete blocked queue:"+fz+"("+getZoneType(fz)+")");
delete zoneList[fz]; bChanged=true; continue;
}
}
// check completeness
for(var fz in unsafeData.ALL_SLOTS){
if(!unsafeData.ALL_SLOTS.hasOwnProperty(fz)){ continue; }
if(unsafeData.zones.getBlock(fz)){ continue; }
if(!zoneList[fz]){ createZoneList(fz); }
}
if(bChanged){ GM_setValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList,"settings/zoneList")); }
zoneSettings=explode(GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneSettings"),"settings/zoneSettings",{});
if((typeof zoneSettings!="object")||(zoneSettings instanceof Array)){ zoneSettings={}; }
zoneToList=explode(GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneToList"),"settings/zoneToList",{});
if((typeof zoneToList!="object")||(zoneToList instanceof Array)){ zoneToList={}; }
// check consistence
var bChanged=false;
for(var fz in zoneToList){
if(!zoneToList.hasOwnProperty(fz)){ continue; }
if(!unsafeData.ALL_SLOTS[fz]){
GM_log("zoneToList delete bad zone:"+fz+"("+getZoneType(fz)+"):"+zoneToList[fz]+"("+getZoneType(zoneToList[fz])+")");
delete zoneToList[fz]; bChanged=true; continue;
}
if(unsafeData.zones.getBlock(fz)){
GM_log("zoneToList delete blocked zone:"+fz+"("+getZoneType(fz)+"):"+zoneToList[fz]+"("+getZoneType(zoneToList[fz])+")");
delete zoneToList[fz]; bChanged=true; continue;
}
if((!extendedListReg.test(zoneToList[fz]))&&(!unsafeData.ALL_SLOTS[zoneToList[fz]])){
GM_log("zoneToList delete bad queue:"+fz+"("+getZoneType(fz)+"):"+zoneToList[fz]+"("+getZoneType(zoneToList[fz])+")");
delete zoneToList[fz]; bChanged=true; continue;
}
if(getZoneType(fz)!=getZoneType(zoneToList[fz])){
GM_log("zoneToList delete bad pairing:"+fz+"("+getZoneType(fz)+"):"+zoneToList[fz]+"("+getZoneType(zoneToList[fz])+")");
delete zoneToList[fz]; bChanged=true; continue;
}
}
if(bChanged){ GM_setValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneToList",implode(zoneToList,"settings/zoneToList")); }
// check completeness
for(var fz in unsafeData.ALL_SLOTS){
if(!unsafeData.ALL_SLOTS.hasOwnProperty(fz)){ continue; }
if(unsafeData.zones.getBlock(fz)){ continue; }
if(!zoneSettings[fz]){ zoneSettings[fz]={"repeat":false,"shuffle":false}; }
if(!zoneToList[fz]){ setZoneListId(fz,fz); }
}
zoneList.sortObj();
zoneSettings.sortObj();
zoneToList.sortObj();
if(settings.get("account","botUseWindmill")&&(unsafeWindow.currentuserlevel<8)){
settings.set("account","botUseWindmill",false);
}
emergencyPlants=explode(GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_emergencyPlants","[1,17]"),"settings/emergencyPlants",[1,17]); // Grain,Carrots
//autoMillStorage: {[rId][0]=number bought, [1]=total number in zoneList[getZoneListId("windmill")], [2]=max number of recieps on products global Math.min([3][pId]), [3][pId]=max number of recieps for this products per products
autoMillStorage=explode(GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_autoMillStorage","[]"),"settings/autoMillStorage",[]);
modeOverViewFarms=explode(GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_modeOverViewFarms"),"settings/modeOverViewFarms",null);
if(modeOverViewFarms==null){
modeOverViewFarms=[,true,true,true];
GM_setValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_modeOverViewFarms",implode(modeOverViewFarms,"settings/modeOverViewFarms"));
}
/* quest-bot needs review
valQuestActivate=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestActivate", false);
valQuestActivateUntilNr=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestActivateUntilNr", 0);
if(valQuestActivateUntilNr < unsafeData.questData["farm"]["1"]["nr"]) valQuestActivate=false;
valQuestSolving =GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestSolving", false);
valQuestSolvingUntilNr =GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valQuestSolvingUntilNr", 0);
if(valQuestSolvingUntilNr < unsafeData.questData["farm"]["1"]["nr"]) valQuestSolving=false;
valLodgeQuestSolving=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valLodgeQuestSolving", false);
// TODO add valLodgeQuestSolving limits
*/
if(unsafeWindow.premium==1 || parseInt(top.document.getElementById("levelnum").innerHTML,10)<10){ settings.set("account","autoFeed",false); }
//make generic queue Box
err_trace="generic queue Box";
newdiv=createElement("div",{id:"divQueueBox",style:"position:absolute;top:240px;left:170px;width:380px;padding:2.5% 3%;background-color:#b8a789;z-index:102;display:none;"},$("garten_komplett"));
createElement("img",{"src":GFX+"guild/help_back.jpg",style:"position:absolute;top:0;left:0;width:100%;height:100%;z-index:-1;"},newdiv);
var newimg=createElement("img",{id:"divQueueBoxClose","class":"link queueBoxClose",style:"position:absolute;right:2px;top:2px;","title":getText("automat_QueClose"),"src":GFX+"close.jpg"},newdiv);
newimg.addEventListener("click",function(event){if(this.id==event.target.id){
this.parentNode.style.display="none";
if($("divChooseBox").style.display="block" && $("divChooseBoxInner").getAttribute("zoneNrF")==$("divQueueBoxInner").getAttribute("zoneNrF")) click($("divChooseBoxClose"));
$("divQueueBoxInner").setAttribute("zoneNrF","");
$("divQueueBoxInner").setAttribute("zoneNrL","");
$("divQueueBoxInner").innerHTML="";
}},false);
createElement("div",{id:"divQueueBoxInner",style:""},newdiv);
//make chooseBox
err_trace="chooseBox";
newdiv=createElement("div",{id:"divChooseBox",style:"position:absolute;top:240px;left:170px;width:380px;padding:2.5% 3%;background-color:#b8a789;z-index:103;display:none;"},$("garten_komplett"));
createElement("img",{"src":GFX+"guild/help_back.jpg",style:"position:absolute;top:0;left:0;width:100%;height:100%;z-index:-1;"},newdiv);
var newimg=createElement("img",{id:"divChooseBoxClose","class":"link queueBoxClose",style:"position:absolute;right:2px;top:2px;","title":getText("automat_QueClose"),"src":GFX+"close.jpg"},newdiv);
newimg.addEventListener("click",function(event){if(this.id==event.target.id){
this.parentNode.style.display="none";
$("divChooseBoxInner").setAttribute("zoneNrF","");
$("divChooseBoxInner").setAttribute("zoneNrL","");
$("divChooseBoxInner").innerHTML="";
}},false);
createElement("div",{id:"divChooseBoxInner",style:""},newdiv);
newdiv=null;newimg=null;
GM_addStyle(
".rotate90 {-webkit-transform: rotate(90deg);-moz-transform: rotate(90deg);filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);}\n"+
".rotate180 {-webkit-transform: rotate(180deg);-moz-transform: rotate(180deg);filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2)}\n"+
".rotate270 {-webkit-transform: rotate(270deg);-moz-transform: rotate(270deg);filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);}"+
"#buildinginfo0, #buildinginfo1, #buildinginfo2, #buildinginfo3, #buildinginfo4, #buildinginfo5, #buildinginfo6 {top:52px; !important;}\n"+
".divZoneIcon {position:absolute;bottom:0;right:5px;z-index:3;border:2px solid black;border-radius:10px;background-color:#000000;}\n"+
"#divAutomatIconContainer {position:absolute;top:125px;left:1001px;width:76px;margin:2px 0px;}\n"+
".divWindmillIcon {position:relative;float:left;height:26px;width:26px;border:2px solid black;border-radius:10px;background-color:#CBAD85;margin:2px;padding:2px;}\n"+
".divForestryIcon {position:relative;float:left;height:25px;width:25px;border:2px solid black;border-radius:10px;background-color:#FFFFFF;margin:2px;padding:2.5px;}\n"+
".divFoodworldIcon {position:relative;float:left;height:25px;width:25px;border:2px solid black;border-radius:10px;background-color:#FFFFFF;margin:2px;padding:2.5px;}\n"+
".fmm"+PRODSTOP+" {background:url("+IMAGES["PRODSTOP_windmill_26"]+") no-repeat scroll 0 0 transparent;height:24px;width:26px;position:absolute;}\n"+
".fm"+PRODSTOP+" {background:url("+IMAGES["PRODSTOP_windmill_52"]+") no-repeat scroll 0 0 transparent;height:49px;width:52px;position:absolute;}\n"+
".v"+PRODSTOP+" {background:url("+IMAGES["PRODSTOP_30"]+") no-repeat scroll 0 0 transparent;height:30px;width:30px;!IMPORTANT}\n"+
".kp"+PRODSTOP+" {background:url("+IMAGES["PRODSTOP_15"]+") no-repeat scroll 0 0 transparent;height:15px;width:15px;!IMPORTANT}\n"+
".f_symbol"+PRODSTOP+" {background:url("+IMAGES["PRODSTOP_25"]+") no-repeat scroll 0 0 transparent;height:25px;width:25px;!IMPORTANT}\n"+
".f_m_symbol"+PRODSTOP+" {background:url("+IMAGES["PRODSTOP_15"]+") no-repeat scroll 0 0 transparent;height:15px;width:15px;!IMPORTANT}\n"+
".pointstar {background:url('"+GFX+"points.gif') no-repeat scroll 2 2 transparent;height:15px;width:15px;}\n"+
".tableTd1 {width:40%;display:table-cell;padding:0px 10px 0px 0px;white-space:nowrap;}\n"+
".tableTd2 {width:60%;display:table-cell;padding:0px 10px 0px 0px;white-space:nowrap;}\n"+
".tableSeperater {display:table-cell;padding:2px 0px 2px 0px;max-height:2px;}\n"+
".tableSepBorder {border-top:1px solid black;max-height:1px;width:100%;}\n"+
".divChooseFeedTime {float:right;color:black;font-weight:bold;}\n"+
".divChooseFeed {float:left;margin:2px;width:280px;}\n"+
".divChooseFeed div{float:left;}\n"+
".divChooseFeedIcon {border-radius:10px;border:2px solid grey;}\n"+
".divChooseFeedAmount {float:left;border:1px solid black;}\n"+
".divChooseFeedAmount div{float:left;height:17px;border-left:1px solid grey;}\n"+
".divChooseFeedAmount div:hover{background-color:red!important;}\n"+
".divChooseFeedButton{float:right;text-align:center;margin-left:1px;width:25px;border:1px solid black;}\n"+
".divChooseFeedButton:hover{color:black;background-color:blue;}\n"+
".divChooseItem {float:left;margin:5px;border-radius:10px;border:2px solid grey;}\n"+
".divChooseItem:hover {border:2px solid red;}\n"+
".divMillChooseItem {float:left;position:relative;margin:5px;width:52px;height:52px;border-radius:7px;}\n"+
".divMillChooseItem:hover {background-color:red;}\n"+
".divMillChooseItemNumber {position:absolute;right:0px;bottom:0px;margin:3px;color:black;font-weight:bold;font-size:16px;}\n"+
".divQueueItemListTitle {float:left;display:block;font-weight:bold;padding:0px 2px 1px 2px;}\n"+
".divQueueItemListTitle2 {float:right;display:block;font-weight:bold;padding:0px 2px 1px 2px;}\n"+
".divQueueItemListHeader {margin-bottom:3px;display:inline-block;}\n"+
".divQueueItemListSelect {float:right;position:relative;display:block;font-weight:bold;padding:0px 2px 1px 2px;margin-bottom:5px;}\n"+
".divQueueItemListBox {position:relative;display:block;border:1px solid black;margin:5px;min-height:45px;}\n"+
".divQueueItemListChooseItem {position:relative;display:inline-block;margin:3px 5px 13px 5px;border-radius:10px;border:2px solid grey;}\n"+
".divQueueItemListNumber {position:absolute;right:0px;bottom:-16px;font-weight:bold;font-size:12px;}\n"+
".divQueueItemListFooter {position:relative;display:block;height:40px;}\n"+
".divItem {float:left;margin:2px;border-radius:10px;border:2px solid grey;}\n"+
".queueTitle {display:inline-block;font-weight:bold;padding:0px 2px 1px 2px;}\n"+
".queueTime {float:right;display:block;font-weight:bold;padding:0px 2px 1px 2px;}\n"+
".queueBoxerButton {float:left;display:inline-block;left:0px;height:"+(row7+2)+"px;display:block;padding:0px 2px 0px 1px;border-right:1px solid black;}\n"+
".queueBoxerQueueBox {float:left;display:inline-block;white-space:nowrap;left:27px;overflow:hidden;}\n"+
".queueItemBox {text-align:center;display:inline-block;position:relative;width:"+(queueItemBoxWidth-1)+"px;border-right:1px solid black;height:100%;}\n"+
".queueButtonScrollLeft {float:left;display:block;margin-left:29px;background:url("+IMAGES["arrowleft"]+") no-repeat scroll left top transparent;height:17px;width:25px;}\n"+
".queueButtonScrollRight {float:right;display:block;margin-right:3px;background:url("+IMAGES["arrowright"]+") no-repeat scroll left top transparent;height:17px;width:25px;}\n"+
".queueBoxerButton .queueButtonScrollLeft {float:none;position:relative;margin:2px 1px 0px 0px;}\n"+
".queueBoxerButton .queueButtonScrollRight {float:none;position:relative;margin:2px 1px 0px 0px;}\n"+
".queueButtonRepeat,.queueButtonShuffle, .queueButtonRotate, .queueButtonAdd, .queueButtonAddAll, .queueButtonCopy{display:block;width:22px;height:16px;border:1px solid #6C441E;border-radius:5px;margin:2px 1px 0px 0px;background:#FFFFFF}\n"+
".queueButtonRepeat {background: #FFFFFF no-repeat 2px 0px;}\n"+
".queueButtonShuffle {background: #FFFFFF no-repeat 2px 0px;}\n"+
".queueButtonRotate {background: #FFFFFF no-repeat 3px 0px;}\n"+
".queueButtonAdd {background: url("+IMAGES["plus"]+") #FFFFFF no-repeat 4px 1px;}\n"+
".queueButtonCopy {background: url("+IMAGES["copy"]+") #FFFFFF no-repeat 3px 2px;}\n"+
".queueItemProduct {left:"+(col2-2)+"px;top:"+(row1)+"px;position:relative;border:2px solid grey;border-radius:10px;margin-left:2px;}\n"+
".windmillItemProduct {left:"+(col2-2)+"px;top:"+(row1)+"px;position:relative;border:2px solid grey;border-radius:10px;margin-left:2px;background-color:#CBAD85;width:26px;height:24px;padding:3px 2px 3px 2px;}\n"+
".forestryItemProduct {left:"+(col2-2)+"px;top:"+(row1)+"px;position:relative;border:2px solid grey;border-radius:10px;margin-left:2px;background-color:#FFFFFF;width:25px;height:25px;padding:2.5px;}\n"+
".queueItemInput1, .queueItemInput2, .queueItemInput3{position:absolute;height:11px;background-color:transparent;color:black;text-align:right;}\n"+
".queueItemInput1 {top:"+row3+"px;}\n"+
".queueItemInput2 {top:"+row4+"px;}\n"+
".queueItemInput3 {top:"+row6+"px;}\n"+
".queueItemInputWidth1 {width:"+(col4-col1-2)+"px;left:"+col1+"px;}\n"+
".queueItemInputWidth2 {width:"+(col4-col2-2)+"px;left:"+col2+"px;}\n"+
".queueButtonMin {left:0px;background:url("+IMAGES["minus"]+") no-repeat 0px 0px #FFFFFF;} \n"+
".queueButtonPlus {right:0px;background:url("+IMAGES["plus"]+") no-repeat 0px 0px #FFFFFF;} \n"+
".queueItemButton {border:1px solid #6C441E;position:absolute;width:13px;height:13px;}\n"+
".queueItemPlusButton {top:"+row1+"px;left:"+col1+"px;background:url("+IMAGES["plus"]+") no-repeat 0px 0px #FFFFFF;}\n"+
".queueItemMinButton {top:"+row2+"px;left:"+col1+"px;background:url("+IMAGES["minus"]+") no-repeat 0px 0px #FFFFFF;}\n"+
".queueItemUpButton {top:"+row5+"px;left:"+col1+"px;background:url("+IMAGES["singleArrowUp"]+") no-repeat 3px 2px #FFFFFF;}\n"+
".queueItemDownButton {top:"+row5+"px;left:"+col3+"px;background:url("+IMAGES["singleArrowDown"]+") no-repeat 5px 2px #FFFFFF;}\n"+
".queueItemBehaviourButton {top:"+row5+"px;left:"+col2+"px;background:no-repeat -1px -1px #FFFFFF;}\n"+
".queueItemModeButton {top:"+row6+"px;left:"+col1+"px;background:no-repeat 0px 0px #FFFFFF;}\n"+
".queueItemAddButton, .queueItemDeleteButton {display:block;position:absolute;width:15px;height:15px;}\n"+
".queueItemAddButton {top:"+row3+"px;left:"+col1+"px;}\n"+
".queueItemDeleteButton {top:"+row4+"px;left:"+col1+"px;}\n"+
".queueItemText {text-align:center;vertical-align:middle;position:absolute;width:"+(col4-col2)+"px;color:black;font-family:Verdana,sans-serif}\n"+
".queueItemTextInf {top:"+(row3-7)+"px;left:"+(col2)+"px;font-size:20px;font-weight:normal;}\n"+
".queueItemTextStop {top:"+(row3)+"px;left:"+(col2-2)+"px;font-size:12px;font-weight:bold;}\n"+
".queueItemTime {position:absolute;width:100%;overflow:hidden;text-align:center;border-top:1px solid black;margin:0px 1px;width:"+(queueItemBoxWidth-3)+"px;}\n"+
".queueItemTime {top:"+(row7+2)+"px;}\n"+
".hoverBgPurple:hover{background-color:#ff00ff!important;}\n"+
".hoverBgWhite:hover{background-color:#ffffff!important;}\n"+
".queueBoxSpacer {float:left;display:block;width:100%;padding:2px 0px 2px 0px;}\n"+
".queueBox {z-index:5;position:absolute;text-align:center;display:none;background-color: #b8a789;padding: 0px 0px 3px 0px;position:absolute;border:2px solid black;border-radius:10px;color:black;}\n"+
".queueBoxerGeneral {width:100%;overflow:hidden;overflow-y:auto;border-top:1px solid black;border-bottom:1px solid black}\n"+
".queueBoxerGeneral {max-height:280px;}\n"+
".queueBoxClose {float:right;top:3px;width:15px;height:15px;margin-right:1px;padding:2px 2px 2px 2px;}\n"+
".fieldlinks {height:25px;right:0;position:absolute;top:0;}\n"+
".fieldlinkitem1,.fieldlinkitem2,.fieldlinkitem3,.fieldlinkitemactivate1,.fieldlinkitemactivate2,.fieldlinkitemactivate3{float:right;color:#FFFFFF;font-size:16px;font-weight:bold;height:29px;margin-left:5px;padding-top:2px;text-align:center;height:34px;width:54px;}\n"+
".fieldlinkitem1{background:url("+IMAGES["zone_off_1"]+") no-repeat scroll 2px 0px transparent;}\n"+
".fieldlinkitemactivate1{background:url("+IMAGES["zone_on_1"]+") no-repeat scroll left top transparent;}\n"+
".fieldlinkitem2{background:url("+IMAGES["zone_off_2"]+") no-repeat scroll 2px 0px transparent;}\n"+
".fieldlinkitemactivate2{background:url("+IMAGES["zone_on_2"]+") no-repeat scroll left top transparent;}\n"+
".fieldlinkitem3 {background:url("+IMAGES["zone_off_3"]+") no-repeat scroll 2px 0px transparent;}\n"+
".fieldlinkitemactivate3{background:url("+IMAGES["zone_on_3"]+") no-repeat scroll left top transparent;}\n"+
".lineZoneItem {border-radius:3px;margin:1px 0px 1px 1px;display:inline-block;height:15px;overflow:hidden;}\n"+
".lineZoneItem:hover {background-color:red;}\n"+
".lineZoneTypeB1 {background-color:#800000}\n"+
".lineZoneTypeB2 {background-color:#808080}\n"+
".lineZoneTypeB3 {background-color:#808000}\n"+
".lineZoneTypeBmill {background-color:#DEDE16}\n"+
".lineZoneTypeL1 {background-color:#993300}\n"+
".lineZoneTypeL2 {background-color:#C0C0C0}\n"+
".lineZoneTypeL3 {background-color:#B08000}\n"+
".lineZoneTypeLmill {background-color:#C8C814}\n"+
"#lineZonemill {height:28px;}\n"+
".lineZone {display:block;white-space:nowrap;text-align:left;height:17px;width:100%;background-color:#333300;}\n"+
".ernte13 {position:absolute;top:98px;left:145px;width:30px;height:30px;border:2px solid black;border-radius:10px;}\n"+
".ernte14 {position:absolute;top:98px;left:210px;width:30px;height:30px;border:2px solid black;border-radius:10px;}\n"+
".ernte15 {position:absolute;top:98px;left:415px;width:30px;height:30px;border:2px solid black;border-radius:10px;}\n"+
".ernte16 {position:absolute;top:98px;left:480px;width:30px;height:30px;border:2px solid black;border-radius:10px;}\n"+
".r1, .r2, .r3, .r4, .r5, .r6, .r7, .r8, .r9, .r10, .r11, .r12, .r13, .r14, .r15, .r16, .r17, .r18, .r19, .r20, .r21 {background:url("+IMAGES["powerups"]+") no-repeat scroll left top transparent;height: 30px;width: 30px;position:relative;}\n"+
".r2, .r7, .r8, .r9, .r10, .r11, .r12, .r13, .r19, .r20 {background-position:0px -0.5px;}\n"+
".r3, .r5, .r15, .r18 {background-position:-31px -0.5px;}\n"+
".r1, .r4, .r6, .r14, .r16, .r17, .r21 {background-position:-61px -0.5px;}\n"+
""
);
//const row1=2;const row2=21;const row3=38;const row4=55;const row5=72;const row6=89;const row7=108;
//const col1=2;const col2=21;const col3=40;const col4=55;
// createElement("div",{"id":"divAutomatIconContainer"},$("divGame").children[0]);
drawButtons();
err_trace="listener gameFieldOpened";
document.addEventListener("gameFieldOpened",function(){ // field open
try{
if(settings.get("account","autoPlant")&&(!$("autoplantbutton"))){ //autoFarmPlant button
if((unsafeWindow.premium!=1)||(unsafeWindow.currentuserlevel<unsafeWindow.autoplantlevel)){
var newdiv=createElement("div",{"id":"autoplantbutton","class":"autoplantbutton link","style":"display:block;position:absolute;top:100px;left:273px;"},$("gardenmaincontainer")); // z-index:4;
newdiv.addEventListener("mouseover",function(event){
// this.src=GFX+"autoplant_on.png";
toolTip.show(event,getText("automat_automatPlanting"));
},false);
// newdiv.addEventListener("mouseout",function(){this.src=GFX+"autoplant_off.png";},false);
newdiv.addEventListener("click",function(){
unsafeWindow.jsTimeStamp=unsafeWindow.Zeit.Client - unsafeWindow.Zeit.Verschiebung;
handled.set(getFarmZone(unsafeWindow.currentposition?unsafeWindow.currentposition:1));
if(unsafeWindow.mode=="2"){
autoFarmWater(bot.start(),1,false,false);
}else{
autoFarmPlant(bot.start(),1,false,false);
}
},false);
newdiv=null;
}
}
if(DEVMODE){ for(var v=1;v<=unsafeData.BUILDING_SIZE["1"];v++){ $("f"+v).setAttribute("title",v+"|kat"+unsafeWindow.garten_kategorie[v]+"|zt"+unsafeWindow.garten_zeit[v]+"|wa"+unsafeWindow.garten_wasser[v]+"|pr"+unsafeWindow.garten_prod[v]);}} //only for viewing
cand=$("cropall").getElementsByTagName("img")[0];
if(!cand.getAttribute("onclick")){
cand.setAttribute("src",GFX+"leer.gif");
cand.setAttribute("onclick","parent.selectMode(1,true,top.selected);");
cand.addEventListener("click",function(){
autoFarmCrop(bot.start(),1);
},false);
}
cand=null;
showCropWeed();
}catch(err){GM_logError("eventListener:gameFieldOpened \n"+err);}
},false);
err_trace="listener gameCity2";
document.addEventListener("gameCity2",function(){
try{
// Automat icons
drawAutomatIcon("windmill","windmill.1",$("cityzone_2_1"),"position:absolute;bottom:0;right:0;");
}catch(err){GM_logError("eventListener:gameCity2 \n"+err);}
},false);
err_trace="listener gameOpenForestry";
document.addEventListener("gameOpenForestry",function(){
try{
// Cropping automat
if(unsafeWindow.premium!=1){
//logBubble.add("reset frestry croppping",10,"red");
$("forestry_forest_button2").setAttribute("onclick","");
$("forestry_forest_button2").addEventListener("click",function(){
if(!bot.isBusy()){
handled.set("forest");
autoForestryForest(bot.start(),3,1,false,false);
}
},false);
}
// Planting automat
var el1=createElement("img",{"id":"autoFarmForest","class":"link","style":"position:absolute;top:-25px;left:0;width:25px;height:25px;","src":GFX+"autoplant_off.png"},$("forestry_forest_buttons"));
el1.addEventListener("mouseover",function(evt){
this.src=GFX+"autoplant_on.png";
toolTip.show(evt,"Automatic planting"); // TODO texte
},false);
el1.addEventListener("mouseout",function(){this.src=GFX+"autoplant_off.png";},false);
el1.addEventListener("click",function(){
if(!bot.isBusy()){
handled.set("forest");
autoForestryForest(bot.start(),5,1,false,false);
}
},false);
// Automat icons
drawAutomatIcon("forest","forest",$("forestry_forest_buttons"),"margin-top:10px;");
if(!unsafeData.zones.getBlock("sawmill.1")){
drawAutomatIcon("sawmill","sawmill.1",$("forestry_building1"),"position:absolute;right:0pt;bottom:15px;");
}
if(!unsafeData.zones.getBlock("carpentry.1")){
drawAutomatIcon("carpentry","carpentry.1",$("forestry_building2"),"position:absolute;right:0pt;bottom:15px;");
}
el1=null;
}catch(err){GM_logError("eventListener:gameOpenForestry \n"+err);}
},false);
err_trace="listener gameSawmillOpened";
document.addEventListener("gameSawmillOpened",function(){
try{
var zoneNrF="sawmill";
var zoneNrS;
var container,help;
for(var slot=1;slot<=3;slot++){
zoneNrS=zoneNrF+"."+slot;
container=$("forestry_slot"+slot);
if(help=container.querySelector(".divForestryIcon")){
removeElement(help);
}
if(!unsafeData.zones.getBlock(zoneNrS)){
drawAutomatIcon(zoneNrS,zoneNrS,container,"left:-20px;bottom:-25px;");
}
}
container=null;help=null;
}catch(err){GM_logError("eventListener:gameSawmillOpened\n"+err);}
},false);
err_trace="listener gameCarpentryOpened";
document.addEventListener("gameCarpentryOpened",function(){
try{
var zoneNrF="carpentry";
var zoneNrS;
var container,help;
for(var slot=1;slot<=3;slot++){
zoneNrS=zoneNrF+"."+slot;
container=$("forestry_slot"+slot);
if(help=container.querySelector(".divForestryIcon")){
removeElement(help);
}
if(!unsafeData.zones.getBlock(zoneNrS)){
drawAutomatIcon(zoneNrS,zoneNrS,container,"left:-20px;bottom:-25px;");
}
}
container=null;help=null;
}catch(err){GM_logError("eventListener:gameCarpentryOpened\n"+err);}
},false);
err_trace="listener gameFoodworldOpened";
document.addEventListener("gameFoodworldOpened",function(){
try{
// Automat icons
for(var v=1;v<=4;v++){
if(!unsafeData.zones.getBlock("foodworld-"+v+".1")){
drawAutomatIcon("foodworld-"+v,"foodworld-"+v+".1",$("food_pos"+v),"position:absolute;right:-10px;bottom:-10px;");
}
}
}catch(err){GM_logError("eventListener:gameFoodworldOpened \n"+err);}
},false);
for(var v=1;v<=4;v++){
err_trace="listener gameFoodworldOpened"+v;
document.addEventListener("gameFoodworldOpened"+v,function(id){
return function(){
try{
var zoneNrF="foodworld-"+id;
var zoneNrS;
var container,help;
for(var slot=1;slot<=3;slot++){
zoneNrS=zoneNrF+"."+slot;
container=$("food_slot"+slot+"_back");
if(help=container.querySelector(".divZoneIcon")){
removeElement(help);
}
if(!unsafeData.zones.getBlock(zoneNrS)){
drawAutomatIcon(zoneNrS,zoneNrS,container,"left:-10px;");
}
}
container=null;help=null;
}catch(err){GM_logError("eventListener:gameFoodworldOpened"+id+"\n"+err);}
}
}(v),false);
}
function showCropWeed(){
try{
if(DEVMODE) logBubble.add("showCropWeed",5,"#880808");
var velds=new Array();
var newspan=null;
for(var v=1;v<=120;v++){
if(!velds[unsafeWindow.garten_prod[v]]) velds[unsafeWindow.garten_prod[v]]=new Array();
velds[unsafeWindow.garten_prod[v]].push(v);
}
for(var product in CROPCOST){
if(!CROPCOST.hasOwnProperty(product)){ continue; }
if(velds[product] && velds[product].length > 0){
if(!$("cropWeed"+product)){
newspan=createElement("div",{id:"cropWeed"+product,"class":"link ernte"+product+ " v"+product},$("gardenmaincontainer"));
newspan.addEventListener("click",function(){
try{
if(this.getAttribute("run")=="false"){
this.setAttribute("run",true);
bot.deactivate();
var product=this.getAttribute("product");
logBubble.add("Autoclear: "+unsafeData.prodName[0][product],5,"#880808");
this.style.border="2px solid red";
autoCropUndefined(explode(this.getAttribute("velds"),"showCropWeed/click/velds"), product);
}else{
this.setAttribute("run",false);
this.style.border="";
logBubble.add("Exiting Autoclear: stopping",5,"#880808");
}
}catch(err){GM_logError("showCropWeed Icon Click \n"+err);}
},false);
newspan.addEventListener("mouseover",function(evt){
var product=this.getAttribute("product");
var amount=explode(this.getAttribute("velds"),"showCropWeed/mouseover/velds").length;
toolTip.show(evt,getText("automat_removeAllWeed").replace("%PROD%",unsafeData.prodName[0][product]).replace("%TCOST%",moneyFormat(amount*CROPCOST[product])).replace("%AMOUNT%",amount).replace("%COST%",moneyFormat(CROPCOST[product])));
},false);
}else{
newspan=$("cropWeed"+product);
}
newspan.style.border="";
newspan.setAttribute("run",false);
newspan.setAttribute("product",product);
newspan.setAttribute("velds",implode(velds[product],"showCropWeed/velds"));
}else if($("cropWeed"+product)){
removeElement($("cropWeed"+product));
}
}
newspan=null;prods=null;product=null;
$("gardenclearer").style.display="none";
}catch(err){GM_logError("showCropWeed \n"+err);}
}
function autoCropUndefined(felds,product){
if(DEVMODE_FUNCTION){GM_log("begin autoCropUndefined: handled.zoneNr="+handled.zoneNr+" felds="+implode(felds,"autoCropUndefined/felds")+" product="+product);}
if(unsafeData.money < CROPCOST[product]){
logBubble.add("Exiting Autoclear: not enough money",5,"#880808");
showCropWeed();
}else if($("cropWeed"+product).getAttribute("run")=="true" && felds.length > 0){
logBubble.add("Autoclear: "+ felds.length +"x "+unsafeData.prodName[0][product],5,"#880808");
if(unsafeWindow.garten_prod[felds[0]]==product){
//unsafeWindow.raeumeFeld(handled.zoneNr,felds[0]);
$("globalbox").addEventListener("DOMAttrModified",function(){
if(this.style.display=="block"){
//logBubble.add(felds);
document.addEventListener("gameFieldDemolish",function(felds,product){
return function(){
try{
document.removeEventListener("gameFieldDemolish",arguments.callee,false);
felds.shift();
$("cropWeed"+product).setAttribute("velds",implode(felds,"autoCropUndefined/velds"));
if($("fundpopup").style.display=="block"){
click($("fundpopup").firstElementChild);
var cell;
logBubble.add("Found Money: "+((cell=$("fundpopupbetrag"))?cell.innerHTML:""),10,"green");
cell=null;
}
toolTip.adjust($("cropWeed"+product));
window.setTimeout(autoCropUndefined,settings.getPause(),felds,product);
}catch(err){GM_logError("autoCropUndefined/gameFieldDemolish felds:"+felds+" product:"+product+"\n"+err);}
}
}(felds,product),false);
click($("globalbox").getElementsByClassName("link")[0]);
this.removeEventListener("DOMAttrModified",arguments.callee,false);
}
},false);
click($("f"+felds[0]));
}
}else if(felds.length<=0){
felds=null;product=null;
logBubble.add("Exiting Autoclear: Done",5,"#880808");
showCropWeed();
}else{
showCropWeed();
}
}
err_trace="listener gameOpenStable";
document.addEventListener("gameOpenStable",function(){ // stable open
try{
if(settings.get("account","autoFeed")){ //autoFarmStable button
var zoneNrF=getFarmZone(unsafeWindow.currentposition);
var v=getZoneType(zoneNrF);
for(var w=0;w<BUILDING2FEED[v].length;w++){
if($("feed_item"+BUILDING2FEED[v][w])){
if(!$("autoFarmStable"+v+"t"+BUILDING2FEED[v][w])){
var newimg=createElement("img",{"id":"autoFarmStable"+v+"t"+BUILDING2FEED[v][w],"class":"link","style":"position:absolute;top:50px;width: 25px; height: 25px;z-index:11;","src":GFX+"autoplant_off.png"},$("feed_item"+BUILDING2FEED[v][w]));
newimg.addEventListener("mouseover",function(evt){
this.src=GFX+"autoplant_on.png";
toolTip.show(evt,"Automatic feeding"); // TODO texte
},false);
newimg.addEventListener("mouseout",function(){this.src=GFX+"autoplant_off.png";},false);
newimg.addEventListener("click",function(){
var help=/(\d+)t(\d+)/.exec(this.id);
handled.set(unsafeWindow.currentposition);
autoFarmStable(bot.start(),1,false,false,help[2],0,240); //could be calculated exactly
},false);
newimg=null;
}
}
}
}
}catch(err){GM_logError("eventListener:gameOpenStable \n"+err);}
},false);
err_trace="listener gameOpenFactoryOil";
document.addEventListener("gameOpenFactoryOil",function(){ // oil-factory open
try{
var zoneNrF=getFarmZone(unsafeWindow.currentposition);
var zoneNrS;
for(var slot=1;slot<=3;slot++){
zoneNrS=zoneNrF+"."+slot;
if(!unsafeData.zones.getBlock(zoneNrS)){
drawAutomatIcon(zoneNrS,zoneNrS,$("oil_slot"+slot),"left:-10px;");
}
}
}catch(err){GM_logError("eventListener:gameOpenFactoryOil \n"+err);}
},false);
err_trace="listener gameOpenFactoryKnitting";
document.addEventListener("gameOpenFactoryKnitting",function(){ // Knitting factory open
try{
var zoneNrF=getFarmZone(unsafeWindow.currentposition);
var zoneNrS;
for(var slot=1;slot<=3;slot++){
zoneNrS=zoneNrF+"."+slot;
if(!unsafeData.zones.getBlock(zoneNrS)){
drawAutomatIcon(zoneNrS,zoneNrS,$("strickerei_slot"+slot),"left:-10px;");
}
}
}catch(err){GM_logError("eventListener:gameOpenFactoryKnitting \n"+err);}
},false);
function drawFarmIcons(){
try{
var farmNR,zoneNr,zoneNrF;
for(var i=unsafeData.ALL_ZONES["farm"].length-1;i>=0;i--){
zoneNrF=unsafeData.ALL_ZONES["farm"][i];
if((!unsafeData.zones.getBlock(zoneNrF))&&(getBuildingTyp(zoneNrF)!=0)){
farmNR=Math.floor((unsafeData.ALL_ZONES["farm"][i]-1)/6)+1;
zoneNr=zoneNrF-6*(farmNR-1);
drawAutomatIcon(zoneNrF,zoneNrF+(unsafeData.zones.isMultiSlot(zoneNrF)?".1":""),$("farm"+farmNR+"_pos"+zoneNr),"");
}
}
}catch(err){GM_logError("drawFarmIcons\n"+err);}
}
document.addEventListener("gameFarmLoaded",drawFarmIcons,false);
function updateFarmIcons(){
try{
var zoneNrF;
for(var i=unsafeData.ALL_ZONES["farm"].length-1;i>=0;i--){
zoneNrF=unsafeData.ALL_ZONES["farm"][i];
if((!unsafeData.zones.getBlock(zoneNrF))&&(getBuildingTyp(zoneNrF)!=0)){
updateQueueBox(zoneNrF+(unsafeData.zones.isMultiSlot(zoneNrF)?".1":""));
}
}
}catch(err){GM_logError("updateFarmIcons\n"+err);}
}
document.addEventListener("gameFarmOpened",updateFarmIcons,false);
drawFarmIcons();
err_trace="devMode";
function viewDev(mode){
// GM_log("viewDev: " + mode);
if(mode!=""){
viewDevMode=explode(GM_getValue("viewDevMode",implode(["",""],"viewDev/viewDevMode"),"viewDev/viewDevMode",["",""]));
viewDevMode=viewDevMode.slice(0,1);
viewDevMode.unshift(mode);
GM_setValue2("viewDevMode",implode(viewDevMode,"viewDev/viewDevMode"));
}else{
viewDevMode=["",""];
GM_setValue2("viewDevMode",implode(["",""],"viewDev/viewDevMode"));
try{
window.clearInterval(autoDevRefresh);
autoDevRefresh=null;
}catch(err){
autoDevRefresh=null;
}
}
showDevMode();
}
function showDevMode(){
for(var i=0;i<viewDevMode.length;i++){
// GM_log("showDevMode: " + viewDevMode[i]);
switch (viewDevMode[i]){
case "punkte":
case "zoneToList":
case "zoneSettings":
case "zoneList":
case "autoMillStorage":
case "QUESTS":
case "now":
$("divPrintArray"+i).style.display="block";
$("divPrintArray"+i).innerHTML=viewDevMode[i]+"<br/>" + print_r(eval(viewDevMode[i]));
break;
case "":
$("divPrintArray"+i).style.display="none";
$("divPrintArray"+i).innerHTML="";
break;
default:
$("divPrintArray"+i).style.display="block";
$("divPrintArray"+i).innerHTML=viewDevMode[i]+"<br/>" + print_r(eval("unsafeWindow."+viewDevMode[i]));
// GM_log("unsafeWindow."+viewDevMode[i]+"="+implode(eval("unsafeWindow."+viewDevMode[i])));
break;
}
}
if(!autoDevRefresh){
autoDevRefresh=window.setInterval(function (){
showDevMode();
},1000);
}
}
if(DEVMODE){
newdiv=createElement("div",{id:"divPrintArray0",style:"height:100%;padding:4px;margin-bottom:30px;color:black;background-color:black;top:10px;float:left;border:1px solid red;"});
ALL.insertBefore(newdiv,$("uptoolbar"));
newdiv=createElement("div",{id:"divPrintArray1",style:"height:100%;padding:4px;margin-bottom:30px;color:black;background-color:black;top:10px;float:right;border:1px solid red;"});
ALL.insertBefore(newdiv,$("uptoolbar"));
GM_registerMenuCommand("View none", function(){viewDev("");});
//GM_registerMenuCommand("Refresh", function(){devRefresh("manual");});
//GM_registerMenuCommand("Auto Refresh", function(){devRefresh("auto");});
MenuCommand.sort();
for(i in MenuCommand){
if(!MenuCommand.hasOwnProperty(i)){ continue; }
GM_registerMenuCommand("View "+MenuCommand[i], function(i){return function(){viewDev(MenuCommand[i]);};}(i));
}
document.getElementsByTagName("body")[0].style.overflow="auto";
var autoDevRefresh=null;
var viewDevMode=explode(GM_getValue("viewDevMode",implode(["",""],"do_main/viewDevMode")),"do_main/viewDevMode",["",""]);
showDevMode();
}
document.addEventListener("gameReallocateBuilding",function(){
if(DEVMODE_FUNCTION){GM_log("Begin gameReallocateBuilding");}
try{
var building1=unsafeData.reallocateBuildingSet[0];
var building2=unsafeData.reallocateBuildingSet[1];
var zoneL1 = getZoneListId(building1);
var zoneL2 = getZoneListId(building2);
if(DEVMODE){GM_log("Automat gameReallocateBuilding: " + building1 + " : " + building2);}
var help;
help=zoneList[zoneL1].clone();
zoneList[zoneL1]=zoneList[zoneL2].clone();
zoneList[zoneL2]=help;
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneList",implode(zoneList,"gameReallocateBuilding/zoneList"));
help=zoneSettings[zoneL1].clone();
zoneSettings[zoneL1]=zoneSettings[zoneL2].clone();
zoneSettings[zoneL2]=help;
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneSettings",implode(zoneSettings,"gameReallocateBuilding/zoneSettings"));
help=zoneToList[building1].clone();
zoneToList[building1]=zoneToList[building2].clone();
zoneToList[building2]=help;
GM_setValueCache(COUNTRY+"_"+SERVER+"_"+USERNAME+"_zoneToList",implode(zoneToList,"gameReallocateBuilding/zoneToList"));
// GM_log("End Automat gameReallocateBuilding: " + building1 + " : " + building2);
}catch(err){GM_logError("gameReallocateBuilding \n"+err);}
if(DEVMODE_FUNCTION){GM_log("End gameReallocateBuilding");}
},false);
document.addEventListener("gameUpdateRack",function(){
// reCalculateWindmill();
},false);
// get dealer items
document.addEventListener("gameUpdateFormuladealerRack",function(){ // Bought a recipe
try{
var help=new Object();
for(var v=0; v<$("formuladealerrackinner").childNodes.length;v++){
if($("formuladealerrackinner").childNodes[v].childNodes.length > 0){
rId=parseInt($("formuladealerrackinner").childNodes[v].childNodes[0].getAttribute("class").replace("fmm",""),10);
rNum=parseInt($("formuladealerrackinner").childNodes[v].childNodes[1].innerHTML,10);
if(!!rId && !!rNum) help[rId]=[rNum,0,NEVER];
}
}
autoMillStorage=help.clone();
help=null;
reFillQueueBox("windmill","windmill",0);
}catch(err){GM_logError("eventListener:gameUpdateFormuladealerRack \n"+err);}
},false);
document.addEventListener("gameOpenWindmill",function(){ // Windmill
try{
// var help=new Object();
// for(var v=0; v<$("windmillformula").childNodes.length;v++){
// if($("windmillformula").childNodes[v].childNodes.length > 0){
// rId=parseInt($("windmillformula").childNodes[v].childNodes[0].getAttribute("class").replace("fm",""),10);
// rNum=parseInt($("windmillformula").childNodes[v].childNodes[1].innerHTML,10);
// if(!!rId && !!rNum) help[rId]=[rNum,0,NEVER];
// }
// }
// autoMillStorage=help.clone();
// help=null;
for(var slot=1;slot<=2;slot++){
var zoneNrS="windmill."+slot;
if(!unsafeData.zones.getBlock(zoneNrS)){
drawAutomatIcon(zoneNrS,zoneNrS,$("windmill_slot"+slot),"top:135px;");
}
}
reFillQueueBox("windmill","windmill",0);
}catch(err){GM_logError("eventListener:gameOpenWindmill \n"+err);}
},false);
// Farmersmarket
err_trace="listener gameFarmersmarketOpened";
document.addEventListener("gameFarmersmarketOpened",function(){
try{
// Automat icons
for(var v=1;v<=6;v++){
if(!unsafeData.zones.getBlock("farmersmarket-"+v)){
drawAutomatIcon("farmersmarket-"+v,"farmersmarket-"+v+(unsafeData.zones.isMultiSlot("farmersmarket-"+v)?".1":""),$("farmersmarket_pos"+v),"position:absolute;right:0;bottom:0;");
}
}
}catch(err){GM_logError("eventListener:gameFarmersmarketOpened \n"+err);}
},false);
//Bot Start-Stop-Button
err_trace="Start-Stop-Button";
newdiv=createElement("div",{"id":"divAutomatButtonBot","class":"link beraterButtonIcon hoverBgGreen"},$("divBeraterButtons"));
createElement("img",{"class":"rotating","src":IMAGES["gearFlat"],"style":"position:relative;top:2px;left:0;width:26px;height:26px;"},newdiv);
newdiv.addEventListener("click",function(){
if(bot.isActive()){
bot.deactivate();
}else{
bot.activate();
}
},false);
newdiv=createElement("div",{"id":"divBotInfo","class":"link blackbox","style":"position:fixed;bottom:0px;left:0px;z-index:999;"},ALL);
newdiv.addEventListener("mouseover",function(evt){
toolTip.show(evt,"Click to break Automat business");
},false);
newdiv.addEventListener("click",bot.end,false);
bot.init();
newdiv=createElement("div",{"id":"divCloseWindowLayer","class":"link ","style":"opacity:0.7;position:absolute;top:20px;z-index:101;display:none;background:black;height:84px;left:210px;width:770px;"},$("headercontainer"));
newdiv=createElement("div",{"id":"divCloseWindow","class":"link blackbox","style":"width:250px;display:none;text-align:center;padding:10px;border-radius:5px 5px 5px 5px;position:relative;z-index:101;top:30px;left:470px;"},$("headercontainer"));
newdiv.addEventListener("mouseover",function(evt){
toolTip.show(evt,"Restart closing timer");
},false);
newdiv.addEventListener("click",function(){
stopCloseWindowTimer();
},false);
/*
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"botArbiter.check");
link.addEventListener("click",function(){botArbiter.check();},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"autoForestryCrop");
link.addEventListener("click",function(){autoForestryCrop(1);},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"test 3");
link.addEventListener("click",function(){GM_log("test :" +reSortQueue(4,false));},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),getText("options"));
link.addEventListener("click",function(){
document.addEventListener("nodeInsertedInfoPanelLAutomat",function(){
click($("infoPanelLAutomat"));
document.removeEventListener("nodeInsertedInfoPanelLAutomat",arguments.callee,false);
},false);
click($("berateroptionen"));
},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),getText("automat_titleQueue"));
link.addEventListener("click",function(){
document.addEventListener("nodeInsertedInfoPanelLAutomat",function(){
click($("infoPanelZoneList"));
document.removeEventListener("nodeInsertedInfoPanelLAutomat",arguments.callee,false);
},false);
click($("berateroptionen"));
},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"test");
link.addEventListener("click",function(){
click($("multiframe").contentDocument.getElementsByClassName("link2")[0].firstElementChild);
},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"Q active");
link.addEventListener("click",function(){raiseEvent("gameQuestNewAvailable");},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"Q solve");
link.addEventListener("click",function(){raiseEvent("gameQuestSolvable");},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"PowerUp");
link.addEventListener("click",function(){botArbiter.add("activatePowerUp");},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"DailyLot");
link.addEventListener("click",function(){raiseEvent("gameLotteryDailyLotAvailable");},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"Windmill");
link.addEventListener("click",function(){raiseEvent("gameWindmillReady");},false);
link=createElement("button",{type:"button","class":"link2",style:"margin-left:3px;border:2px solid red;"},$("divBeraterButtons"),"Zone Ready");
link.addEventListener("click",function(){raiseEvent("gameZoneReady");},false);
*/
document.addEventListener("gameSessionEnds",function(){
botArbiter.add("sessionEnds");
},false);
document.addEventListener("gameLotteryDailyLotAvailable",function(){
if(settings.get("account","botUseLottery")&&settings.get("account","lotteryActivate")){
botArbiter.add("lottery");
}
},false);
document.addEventListener("gameOtherAccReady",function(){
botArbiter.add("otherAccReady");
},false);
document.addEventListener("gameFarmiNew",function(){
if(settings.get("account","botUseFarmi")){ checkFarmi(1); }
},false);
document.addEventListener("gameFarmOpened",function(){
if(settings.get("account","botUseFarmi")){ checkFarmi(1); }
},false);
} catch(err){GM_logError("do_main ("+err_trace+")\n"+err);}
}
function do_hilfe(){
GM_addStyle(
".queueButtonAddAll {display:inline-block;width:22px;height:16px;border:1px solid #6C441E;border-radius:5px;margin:0px 1px 0px 1px;}\n"+
".queueButtonAddAll {background: url("+IMAGES["reload_all"]+") #FFFFFF no-repeat 1px -1px;width:28px;}\n"+
".kp"+PRODSTOP+" {background:url("+IMAGES["PRODSTOP_15"]+") no-repeat scroll 0 0 transparent;height:15px;width:15px;!IMPORTANT}"
);
var newdiv=createElement("div",{},$("helpmenuLinks"));
var newa=createElement("a",{"class":"list_header","href":"#"},newdiv,getText("automat"));
newa.addEventListener("click",function(){
try{
var div,help,i=0;
var container=$("helpbody");
container.innerHTML="";
div=createElement("div",{"class":"tnormal"},container);
createElement("b",{},div,getText("automat"));
while(help=getText("automat_help_"+(i++))){
div=createElement("div",{"class":"tmenu"},container);
if(help[0]){ createElement("b",{},div,help[0]); }
if(help[1]){ createElement("p",{},div,help[1]); }
}
container=null;div=null;
}catch(err){GM_logError("help.click\n"+err);}
},false);
newdiv=null;newa=null;
}
function manageVariables(){
// 1: historic data - not reproducible!
// 2: collectable data, temporary data
// 3: options, settings
const variableInfo = { "GLOBAL":{"automatChangedata":["Data version",1],
"automatChangelogShownVersion":["",3],
"devmode":["Developer mode",3],
"devmode_function":["Developer mode",3],
"settings":["Settings",3]},
"COUNTRY":{"automatChangedata":["Data version",1],
"settings":["Settings",3]},
"SERVER":{"automatChangedata":["Data version",1],
"settings":["Settings",3]},
"USER":{"automatChangedata":["Data version",1],
"autoMillStorage":["Mill data",3],
"emergencyPlants":["Emergency plants",3],
"lotteryCollectForPrize":["Lottery collection data",3],
"raisedEvents":["Stack of raised event",2],
"settings":["Settings",3],
"valDevRefresh":["Developer",2],
"valQuestActivate":["Option",3],
"valQuestActivateUntilNr":["Option",3],
"valQuestSolving":["Option",3],
"valQuestSolvingUntilNr":["Option",3],
"viewDevMode":["Option",3],
"modeOverViewFarms":["Selection Automat-overview",3],
"zoneList":["Zone automat settings",3],
"zoneSettings":["Zone modes",3],
"zoneToList":["Zone pairing",3]}
};
function buildManageVariables(){
var container=$("divManageVariablesInner");
container.innerHTML="";
var containerPart = createElement("div",{"style":"height:10%;"},container);
createElement("div",{"style":"font-weight:bold;"},containerPart,"Variable Management "+getText("automat"));
var newinput=createElement("select",{"class":"link"},containerPart);
createElement("option",{"value":"GLOBAL"},newinput,"GLOBAL");
createElement("option",{"value":"ALL"},newinput,"ALL");
createElement("option",{"value":"UNKNOWN"},newinput,"UNKNOWN");
createElement("option",{"value":"USELESS"},newinput,"USELESS");
newinput.addEventListener("click",function(){
buildExportTable(this.value);
},false);
var variables = {};
variables["GLOBAL"] = [];
var help = cloneInto(GM_listValues(), unsafeWindow);
help.sort();
var help2;
for(var v=0;v<help.length;v++){
help2 = (/^([A-Z]{2}_\d+_.+?_)(.*)$/).exec(help[v]); // LNG_SERVER_USER_...
if(!help2){ help2 = (/^([A-Z]{2}_\d+_)(.*)$/).exec(help[v]); // LNG_SERVER_...
if(!help2){ help2 = (/^([A-Z]{2}_)(.*)$/).exec(help[v]); // LNG_...
} }
if(help2){
if(!variables[help2[1]]){
variables[help2[1]] = [];
createElement("option",{"value":help2[1]},newinput,help2[1]);
}
variables[help2[1]].push(help2[2]);
} else {
variables["GLOBAL"].push(help[v]); // GLOBAL
}
}
newinput=createElement("button",{"class":"link","style":"margin-left:20px;"},containerPart,"Select all");
newinput.addEventListener("click",function(){
var container=$("divManageVariablesInner");
var rows = container.children[1].getElementsByTagName("tr");
var checkedNew;
if(this.innerHTML=="Select all"){
checkedNew = true;
this.innerHTML="Unselect all";
} else {
checkedNew = false;
this.innerHTML="Select all";
}
for (var v=0;v<rows.length;v++){
rows[v].children[0].children[0].checked = checkedNew;
}
},false);
newinput=createElement("button",{"class":"link","style":"margin-left:20px;"},containerPart,"Delete");
newinput.addEventListener("click",function(){
var container=$("divManageVariablesInner");
var rows = container.children[1].getElementsByTagName("tr");
var variables = [];
var acc, varname;
var str = "Delete following variables:";
for (var v=0;v<rows.length;v++){
if(rows[v].children[0].children[0].checked){
acc = rows[v].children[1].innerHTML;
varname = rows[v].children[2].innerHTML;
variables.push(acc+varname);
if(variables.length<11){ str += "\n"+acc+varname; }
}
}
if(variables.length>0){
if(variables.length>10){ str += "\n..." }
if(confirm(str)){
for (var v=0;v<variables.length;v++){
GM_deleteValue(variables[v]);
}
buildManageVariables();
}
} else {
alert("Nothing selected");
}
},false);
newinput=createElement("button",{"class":"link","style":"margin-left:20px;"},containerPart,"Create storage string");
newinput.addEventListener("click",function(){
var container=$("divManageVariablesInner");
var rows = container.children[1].getElementsByTagName("tr");
var variables = [];
var acc, varname;
for (var v=0;v<rows.length;v++){
if(rows[v].children[0].children[0].checked){
acc = rows[v].children[1].innerHTML;
varname = rows[v].children[2].innerHTML;
variables.push([acc+varname,GM_getValue(acc+varname)]);
}
}
if(variables.length>0){
prompt("Copy this string to a text-file", implode(variables));
} else {
alert("Nothing selected");
}
},false);
newinput=createElement("button",{"class":"link","style":"margin-left:20px;"},containerPart,"Import storage string");
newinput.addEventListener("click",function(){
var data = prompt("Enter storage string");
if(data){
try{
data = explode(data,"buildImportTable/storageString");
buildImportTable(data);
}catch(err){ alert("Sorry. Can't read the entered string.\n"+err); }
}
},false);
newinput=createElement("button",{"class":"link","style":"margin-left:20px;"},containerPart,"Import OLD storage string");
newinput.addEventListener("click",function(){
var data = prompt("Enter storage string");
var user = prompt("Enter prefix like 'de_7_Johnny_' if needed");
if(data){
try{
data=data.split("::");
for(var v=0;v<data.length;v++){
data[v] = [,data[v].split(":")];
data[v][0] = user+data[v][1].splice(0,1)[0];
var impType=data[v][1].splice(0,1)[0];
data[v][1] = data[v][1].join(":");
if(impType == "n"){ data[v][1] = parseFloat(data[v][1],10); }
else if(impType == "b"){ data[v][1] = (data[v][1]=="true"); }
}
buildImportTable(data);
}catch(err){ alert("Sorry. Can't read the entered string.\n"+err); }
}
},false);
containerPart = createElement("div",{"style":"height:90%;overflow-y:scroll;"},container);
function buildExportTable(filter){
var container=$("divManageVariablesInner");
container.children[1].innerHTML = "";
var newtable=createElement("table",{"border":"1","class":"hoverRowBgCc9","style":"width:100%"},container.children[1]);
var newtr,newtd;
var help3=cloneInto(GM_listValues(), unsafeWindow);
var help=[],help2;
for(var v=0;v<help3.length;v++){
help2 = (/^([A-Z]{2}_\d+_.+?_)(.*)$/).exec(help3[v]); // COUNTRY_SERVER_USER_...
if(help2){
help[v] = [help2[1],help2[2],"USER"];
} else {
help2 = (/^([A-Z]{2}_\d+_)(.*)$/).exec(help3[v]); // COUNTRY_SERVER_...
if(help2){
help[v] = [help2[1],help2[2],"SERVER"];
} else {
help2 = (/^([A-Z]{2}_)(.*)$/).exec(help3[v]); // COUNTRY_...
if(help2){
help[v] = [help2[1],help2[2],"COUNTRY"];
} else {
help[v] = ["",help3[v],"GLOBAL"];
}
}
}
}
help.sort(function(a,b){
if(a[0]==b[0]){ return ((a[1]>b[1])-(a[1]<b[1])); }
else{ return ((a[0]>b[0])-(a[0]<b[0])); }
});
for(var v=0;v<help.length;v++){
switch(filter){
case "ALL": break;
case "GLOBAL":if(help[v][0]!=""){ continue; } break;
case "UNKNOWN":if(variableInfo[help[v][2]][help[v][1]]){ continue; } break;
case "USELESS":if((!variableInfo[help[v][2]][help[v][1]])||(variableInfo[help[v][2]][help[v][1]][1]!=5)){ continue; } break;
default: if(help[v][0]!=filter){ continue; }
}
help[v][4] = GM_getValue(help[v][0]+help[v][1]);
help[v][3] = "s";
// if(help[v][4]==""){ help[v][4]=" "; }
if(typeof help[v][4]=="number"){ help[v][3]="n"; }
else if(typeof help[v][4]=="boolean"){ help[v][3]="b"; }
else{ // help[v][4] = help[v][4].replace(/(:+)/g,":");
if(help[v][4].length>100){
help[v][4] = help[v][4].substr(0,97)+"...";
}
}
newtr=createElement("tr",{},newtable);
newtd = createElement("td",{},newtr);
createElement("input",{"type":"checkbox","class":"link","checked":false},newtd);
createElement("td",{},newtr,help[v][0]);
createElement("td",{},newtr,help[v][1]);
createElement("td",{},newtr,help[v][3]);
if(variableInfo[help[v][2]][help[v][1]]){
createElement("td",{},newtr,variableInfo[help[v][2]][help[v][1]][0]);
createElement("td",{},newtr,[,"historic data - not reproducible!","collectable data","options, settings","temporary data","useless, old data"][variableInfo[help[v][2]][help[v][1]][1]]);
} else {
createElement("td",{},newtr,"unknown");
createElement("td",{},newtr,"");
}
createElement("td",{},newtr,help[v][4]);
}
container=null;newtable=null;newtr=null;newtd=null;
}
buildExportTable("GLOBAL");
function buildImportTable(data){
var container=$("divManageVariablesInner");
container.children[1].innerHTML = "";
var newinput=createElement("button",{"class":"link"},container.children[1],"SAVE !");
newinput.addEventListener("click",function(){
var container=$("divManageVariablesInner");
var rows = container.children[1].getElementsByTagName("tr");
var variables = [];
var acc, varname;
for (var v=0;v<rows.length;v++){
if(rows[v].children[0].children[0].checked){
GM_setValue(data[v][0]+data[v][1],data[v][3]);
}
}
buildManageVariables();
},false);
var newtable=createElement("table",{"border":"1","class":"hoverRowBgCc9","style":"width:100%"},container.children[1]);
var newtr,newtd;
var help2;
var dataLevel;
for(var v=0;v<data.length;v++){
help2 = (/^([A-Z]{2}_\d+_.+?_)(.*)$/).exec(data[v][0]); // LNG_SERVER_USER_...
if(help2){
dataLevel = "USER";
data[v] = [help2[1],help2[2],"s",data[v][1]];
} else {
help2 = (/^([A-Z]{2}_\d+_)(.*)$/).exec(data[v][0]); // LNG_SERVER_...
if(help2){
dataLevel = "SERVER";
data[v] = [help2[1],help2[2],"s",data[v][1]];
} else {
help2 = (/^([A-Z]{2}_)(.*)$/).exec(data[v][0]); // LNG_...
if(help2){
dataLevel = "COUNTRY";
data[v] = [help2[1],help2[2],"s",data[v][1]];
} else {
dataLevel = "GLOBAL";
data[v] = ["",data[v][0],"s",data[v][1]];
}
}
}
if(typeof data[v][3]=="number"){ data[v][2]="n"; }
else if(typeof data[v][3]=="boolean"){ data[v][2]="b"; }
newtr=createElement("tr",{},newtable);
newtd = createElement("td",{},newtr);
createElement("input",{"type":"checkbox","class":"link","checked":true},newtd);
createElement("td",{},newtr,data[v][0]);
createElement("td",{},newtr,data[v][1]);
createElement("td",{},newtr,data[v][2]);
if(variableInfo[dataLevel][data[v][1]]){
createElement("td",{},newtr,variableInfo[dataLevel][data[v][1]][0]);
createElement("td",{},newtr,[,"historic data - not reproducible!","collectable data","options, settings","temporary data","useless, old data"][variableInfo[dataLevel][data[v][1]][1]]);
} else {
createElement("td",{},newtr,"unknown");
createElement("td",{},newtr,"");
}
if(data[v][3].length>100){
createElement("td",{},newtr,data[v][3].substr(0,97)+"...");
} else {
createElement("td",{},newtr,data[v][3]);
}
}
container=null;newtable=null;newtr=null;newtd=null;newinput=null;
}
container=null;containerPart=null;newselect=null;
newdiv=null;newinput=null;
}
if($("divManageVariables")){ return false; }
var newdiv=createElement("div",{"id":"divManageVariables","mode":"","style":"position:fixed;top:0;left:0;width:100%;height:100%;background-color:#b8a789;z-index:1000;display:block;"},ALL);
createElement("img",{"src":GFX+"guild/help_back.jpg","style":"position:absolute;top:0;left:0;width:100%;height:100%;z-index:-1;"},newdiv);
createElement("div",{"id":"divManageVariablesInner","class":"tnormal","style":"position:absolute;top:6%;left:5%;width:90%;height:88%;overflow:auto;"},newdiv);
var newimg=createElement("img",{"id":"infoPanelClose","class":"link","src":GFX+"close.jpg","style":"position:absolute;top:8px;right:8px;width:20px;height:20px;"},newdiv);
newimg.addEventListener("click",function(){ removeElement(this.parentNode); },false);
newdiv = null;newimg=null;
buildManageVariables();
}
function do_login(){
var cell = $("divBeraterButtons");
if(cell){
cell=createElement("div",{"class":"link beraterButtonIcon hoverBgBlue","mouseOverText":getText("manageVariables")+" ("+getText("automat")+")"},cell);
createElement("img",{"src":IMAGES["floppyDisk"],"style":"position:relative;top:3px;left:3px;;width:24px;height:24px;"},cell);
cell.addEventListener("click",manageVariables,false);
}
cell=null;
}
function do_relogin(time){
var newdiv=$("automatDoRelogin");
if(document.getElementsByTagName("div").length>10){
if(newdiv){ removeElement(newdiv); }
}else{
if(time>0){
if(!newdiv){ newdiv=createElement("div",{"id":"automatDoRelogin","class":"alertbubble tbig link"},document.body); }
newdiv.innerHTML="Relogin in "+getTimeStr(time);
newdiv=null;
window.setTimeout(do_relogin,1000,--time);
}else if(GAMEPAGES[top.unsafeData.COUNTRY]){
location.href="http://www."+GAMEPAGES[top.unsafeData.COUNTRY];
}
}
newdiv=null;
}
function start_script(){
try{
COUNTRY=top.unsafeData.COUNTRY;
LANGUAGE=top.unsafeData.LANGUAGE;
PAGE=location.pathname.replace(/^\//,"").replace(/\.php.*$/,"");
// **************************************************
// ChangeData Global
// -->> add var to delete also to resetVariables
var err_trace="ChangeData Global";
var help,help2;
try{
var changedata = GM_getValue("automatChangedata",0);
switch(changedata){
case 0:{
help=cloneInto(GM_listValues(), unsafeWindow);
for(var v=help.length-1;v>=0;v--){
if(help2=/^([a-z]{2})(_.*)$/.exec(help[v])){
GM_setValue(help2[1].toUpperCase()+help2[2],GM_getValue(help[v]));
GM_deleteValue(help[v]);
}
}
}
}
if(changedata<1){ GM_setValue("automatChangedata",1); }
}catch(err){GM_logError("changedata global\n"+err);}
// **************************************************
// ChangeData Country
err_trace="ChangeData Country";
try{
var changedata = GM_getValue(COUNTRY+"_automatChangedata",0);
switch(changedata){
case 0:{
help=settings.get("country","pauseShort");
if(help2=GM_getValue(COUNTRY+"_tmin")){
help[0]=help2;
GM_deleteValue(COUNTRY+"_tmin");
}
if(help2=GM_getValue(COUNTRY+"_tmax")){
help[1]=help2;
GM_deleteValue(COUNTRY+"_tmax");
}
settings.set("country","pauseShort",help);
help=settings.get("country","pause");
if(help2=GM_getValue(COUNTRY+"_tmin2")){
help[0]=help2;
GM_deleteValue(COUNTRY+"_tmin2");
}
if(help2=GM_getValue(COUNTRY+"_tmax2")){
help[1]=help2;
GM_deleteValue(COUNTRY+"_tmax2");
}
settings.set("country","pause",help);
}
}
if(changedata<1){ GM_setValue(COUNTRY+"_automatChangedata",1); }
}catch(err){GM_logError("changedata country\n"+err);}
// **************************************************
// Multilingual
texte=top.unsafeData.texte;
if(texte["de"]["automat"]==undefined){
texte["de"]["automat"] = "Automat";
texte["de"]["automat_planting"] = "Pflanze...";
texte["de"]["automat_waiting"] = "Warte...";
texte["de"]["automat_watering"] = "Gie"+sz+"e...";
texte["de"]["automat_feeding"] = "F"+u_dots+"ttere...";
texte["de"]["automat_automatPlanting"] = "Pflanzautomat";
texte["de"]["automat_automatFeeding"] = "Futterautomat...";
texte["de"]["automat_automatFactory"] = "Fabrikautomat...";
texte["de"]["automat_automatWindmill"] = "M"+u_dots+"hlenautomat...";
texte["de"]["automat_botStart"] = "Automat-Bot starten";
texte["de"]["automat_botStop"] = "Automat-Bot stoppen";
texte["de"]["automat_settings_botErrorBehaviour"] = "Verhalten des Automaten im Fall eines Fehlers";
texte["de"]["automat_settings_pageReload"] = "Neu Laden der Seite";
texte["de"]["automat_settings_botRestart"] = "Neu Starten des Bots";
texte["de"]["automat_zonePairing"] = "Zone pairing";
texte["de"]["automat_debugInfo"] = "Debug Info";
texte["de"]["automat_windmill"] = "windmill";
texte["de"]["automat_timing"] = "Timing";
texte["de"]["automat_general"] = "General";
texte["de"]["automat_development"] = "Development";
texte["de"]["automat_confirmChangelogVersion"]="Du hast eine neue Version des Automat-Scriptes installiert.<br>Die Version %1% beinhaltet folgende "+A_dots+"nderungen:";
texte["de"]["automat_shouldUpdateAdviser"] = "Du solltest das Berater-Script aktualisieren!<br>Der Automat wird nicht ordnungsgem"+a_dots+sz+" arbeiten.";
texte["de"]["automat_settings_autoPlant"] = "Soll der Pflanz-Automat angezeigt werden?";
texte["de"]["automat_settings_autoWater"] = "Sollen die "+A_dots+"cker gegossen werden?";
texte["de"]["automat_settings_autoFeed"] = "Soll der Futter-Automat angezeigt werden?";
texte["de"]["automat_settings_botUse"] = "Verwende Bot";
texte["de"]["automat_settings_disableCropFields"]="Block the cropping of sleeping fields.";
texte["de"]["automat_settings_pauseShortMin"] = "Minimale Klickzeit der Automaten";
texte["de"]["automat_settings_pauseShortMax"] = "Maximale Klickzeit der Automaten";
texte["de"]["automat_settings_pauseMin"] = "Minimale Wartezeiten der Automaten";
texte["de"]["automat_settings_pauseMax"] = "Maximale Wartezeiten der Automaten";
texte["de"]["automat_settings_maxDurationBotRun"] = "Maximale Laufzeit des Automaten";
texte["de"]["automat_settings_maxDurationBotStep"] = "Maximale Laufzeit eines Schrittes des Automaten";
texte["de"]["automat_setToDefault"] = "Standard setzen";
texte["de"]["automat_settings_seedWaitForCrop"] = "Das Pflanzen wartet, falls innerhalb dieser Zeit geerntet werden kann.";
texte["de"]["automat_emergencyPlants"] = "Notfall-Pflanzen. Diese werden zuerst genommen, falls die ben"+o_dots+"tigte Pflanze nicht verf"+u_dots+"gbar oder passend ist.";
texte["de"]["automat_settings_useQueueList"] = "Benutze Queue-Listen f"+u_dots+"r die "+A_dots+"cker";
texte["de"]["automat_set12a"] = "L"+o_dots+"sche \n alle zone Queue\n Daten";
texte["de"]["automat_set12b"] = "Gel"+o_dots+"scht.";
texte["de"]["automat_settings_showQueueTime"] = "Zeige berechnete Zeiten in der Queue-Liste.";
texte["de"]["automat_set18a"] = "L"+o_dots+"sche alle Daten der M"+u_dots+"hlen-Queue";
texte["de"]["automat_set18b"] = "L"+o_dots+"schen erfolgreich";
texte["de"]["automat_settings_powerUpActivate"] = "Aktiviere Produkt-Powerups";
texte["de"]["automat_settings_lotteryActivate"] = "Aktiviere das t"+a_dots+"gliche Lotterie-Los";
texte["de"]["automat_settings_lotteryDailyLot"] = "Behalte das t"+a_dots+"gliche Lotterie-Los";
texte["de"]["automat_settings_questActivate"] = "Aktiviere den Quest to quest:";
texte["de"]["automat_settings_questSolving"] = "Erf"+u_dots+"lle den Quest to quest:";
texte["de"]["automat_settings_farmiReject"] = "Auto-Ablehnung Farmi unter";
texte["de"]["automat_settings_farmiAccept"] = "Auto-Annahme Farmi "+u_dots+"ber";
texte["de"]["automat_settings_farmiAcceptBelowMinValue"] = "Nimm Farmi an, der ein Produkt verlangt unter minimalem Lagerbestand";
texte["de"]["automat_settings_farmiRemoveMissing"] = "Entferne Farmi mit fehlenden Produkten und wenigstem Gewinn. Schwelle:";
texte["de"]["automat_fields"] = A_dots+"cker";
texte["de"]["automat_titleGeneral"] = "Allgemein-Queue";
texte["de"]["automat_titleQueue"] = "Queue";
texte["de"]["automat_QueCopyTextHeader"] = "Kopiere Queue";
texte["de"]["automat_QueCopyTextHeaderFrom"] = "Kopiere von:";
texte["de"]["automat_QueCopyTextHeaderTo"] = "Kopiere nach:";
texte["de"]["automat_QueAddText"] = "Eine weitere Pflanze an die Liste anh"+a_dots+"ngen"; //Add product
texte["de"]["automat_QueAddAboveText"] = "Eine weitere Pflanze in die Liste schieben";
texte["de"]["automat_QueDeleteText"] = "Diese Pflanze l"+o_dots+"schen";
texte["de"]["automat_QueClose"] = "Men"+u_dots+" schlie"+sz+"en";
texte["de"]["automat_QueCloseAll"] = "Alle ge"+o_dots+"ffneten Queue-Fenster schlie"+sz+"en";
texte["de"]["automat_QueMin"] = "Weniger";
texte["de"]["automat_QuePlus"] = "Mehr";
texte["de"]["automat_QueBehaviourF"] = "Klick um in den Lager-Modus zu schalten";
texte["de"]["automat_QueBehaviourR"] = "Klick um in den Felder-Modus zu schalten";
texte["de"]["automat_QueUpButton"] = "Fr"+u_dots+"her";
texte["de"]["automat_QueDownButton"] = "Sp"+a_dots+"ter";
texte["de"]["automat_buttonTimeLine"] = "Zeige Felder-Zeitverlauf";
texte["de"]["automat_buttonOverview"] = "Zeige Automaten-"+U_dots+"bersicht";
texte["de"]["automat_repeat_on"] = "Wiederholung AN";
texte["de"]["automat_repeat_off"] = "Wiederholung AUS";
texte["de"]["automat_shuffle_on"] = "Zufall AN";
texte["de"]["automat_shuffle_off"] = "Zufall AUS";
texte["de"]["automat_rotate"] = "Rotieren";
texte["de"]["automat_stop"] = "STOPP";
texte["de"]["automat_week"] = "Wochen";
texte["de"]["automat_inftext"] = "L"+a_dots+"uft ohne Ende";
texte["de"]["automat_removeAllWeed"] = "Entferne alle %AMOUNT% %PROD%<br>St"+u_dots+"ck = %COST%<br>Total = %TCOST%";
texte["de"]["automat_usedFarmFieldsReadyAt"] = "Benutzte Felder sind fertig um:";
texte["de"]["automat_CloseWindowTimer"] = "Closing screen in :%1%";
texte["de"]["automat_CloseWindowTimerClick"] = "Click to reset timer!";
//%PRODNAME% = product name, %FLDFROM% = field nr from, %FLDTO% = field nr until,
texte["de"]["automat_QueDoWork"] = "Zone wird vom Bot bearbeitet";
texte["de"]["automat_QueDontWork"] = "Zone wird vom Bot ignoriert";
texte["de"]["automat_QueueStoped"] = "Diese %PRODNAME% werden nicht gepflanzt, da vorher gestoppt wird.";
texte["de"]["automat_QueStop0"] = "Das automatische Pflanzen wird gestoppt.";
texte["de"]["automat_QueStop1"] = "Nach Pflanzen von %FLDFROM% Feld wird gestoppt.";
texte["de"]["automat_QueStopX"] = "Nach Pflanzen von %FLDFROM% Feldern wird gestoppt.";
texte["de"]["automat_QueRepeat"] = "(Wiederholung)";
texte["de"]["automat_QueShuffle"] = "(Zufall)";
texte["de"]["automat_QueRepeatShuffle"] = "(Zufallswiederholung)";
texte["de"]["automat_QueFieldInRow1"] = "(Nr. %FLDFROM%)";
texte["de"]["automat_QueFieldInRowX"] = "(Nr. %FLDFROM% bis %FLDTO%)";
texte["de"]["automat_QueRoundDoneR"] = "These fields %PRODNAME% are already cultured and will be skiped";
texte["de"]["automat_QueRoundDone1"] = "%PRODNAME% ist diese Runde bereits gepflanzt <br/>und wird erneut geplanzt.";
texte["de"]["automat_QueRoundDoneX"] = "%PRODNAME% sind diese Runde bereits gepflanzt <br/>und werden erneut geplanzt.";
texte["de"]["automat_QueFieldMake"] = "Total:";
texte["de"]["automat_QueFieldToGo"] = "Noch:";
texte["de"]["automat_QueRoundMake"] = "Jede Runde:";
texte["de"]["automat_QueRoundMade"] = "Erledigt:";
texte["de"]["automat_QueRoundToGo"] = "Noch:";
texte["de"]["automat_QueUses"] = "Benutzt:";
texte["de"]["automat_QueGives"] = "Ertrag:";
texte["de"]["automat_QueFutter"] = "Zeitersparnis:";
texte["de"]["automat_QueTimeThis"] = "Wachstumszeit:";
texte["de"]["automat_QueTimeToGo"] = "Verbleibende Wachstumszeit:";
texte["de"]["automat_QueTimeReady"] = "Fertig um:";
texte["de"]["automat_QueTimeFirstReady"] = "Erstes fertig:";
texte["de"]["automat_QueTimeNextReady"] = "N"+a_dots+"chstes fertig:";
texte["de"]["automat_QueTimeRound"] = "Durchschnitt jede Runde:";
texte["de"]["automat_QueRackMode"]="(Regal Modus)";
texte["de"]["automat_queueshow"]="Klick zum "+A_dots+"ndern der Queue";
//For the Mill
//%PRODNAME% = product name, %FLDFROM% = field nr from, %FLDTO% = field nr until,
texte["de"]["automat_MillQueue"] = "M"+u_dots+"hlen-Queue";
texte["de"]["automat_MillDoWork"] = "Windm"+u_dots+"hle wird automatisch bearbeitet.";
texte["de"]["automat_MillDontWork"] = "Windm"+u_dots+"hle wird ignoriert. Manuelle Bedienung.";
texte["de"]["automat_MillClearAddAll"] = "L"+o_dots+"sche Windm"+u_dots+"hlen-Queue und nehme dann alle Rezepte auf";
texte["de"]["automat_MillShuffle"] = "(Zufallsmodus)";
texte["de"]["automat_MillInRow1"] = "(Nr. %FLDFROM%)";
texte["de"]["automat_MillInRowX"] = "(Nr. %FLDFROM% bis %FLDTO%)";
texte["de"]["automat_MillTimeTotal"] = "Total Backzeit:";
texte["de"]["automat_MillTimeReady"] = "Fertig:";
texte["de"]["automat_MillStoped"] = "Es ist ein Stopp in der Liste. %PRODNAME% wird nicht gebacken.";
texte["de"]["automat_MillStop0"] = "Der automatische Prozess wird gestoppt.";
texte["de"]["automat_MillStop1"] = "Nach %FLDFROM% Rezept wird der automatische Prozess gestoppt.";
texte["de"]["automat_MillStopX"] = "Nach %FLDFROM% Rezepten wird der automatische Prozess gestoppt.";
try{
texte["de"]["automat_MillTimeThis"] = top.window.wrappedJSObject.windmill_bakeingtime;
texte["de"]["automat_MillPowerUpText_0"] = top.window.wrappedJSObject.powerup_bonustext1;
texte["de"]["automat_MillPowerUpText_1"] = top.window.wrappedJSObject.powerup_bonustext2;
texte["de"]["automat_MillPowerUpText_2"] = top.window.wrappedJSObject.powerup_bonustext3;
texte["de"]["automat_MillIngredients"] = top.window.wrappedJSObject.windmill_zutaten;
}catch(err){GM_logError("texte Mill from game missing \n"+err);}
texte["de"]["automat_number"] = "Anzahl";
texte["de"]["automat_lack"] = "Fehlend";
texte["de"]["automat_MillRecipesBought"] = "Total gekaufte Rezepte: ";
texte["de"]["automat_MillRecipesUsed"] = "Total benutzte Rezepte: ";
texte["de"]["automat_MillRecipesBake"] = "Max zu backende Rezepte: ";
//title
texte["de"]["automat_title_on_general"] = "Zeige nur Allgemein-Queue<br>+Strg: Zeige Allgemein-Queue";
texte["de"]["automat_title_off_general"] = "Zeige nur Allgemein-Queue<br>+Strg: Verstecke Allgemein-Queue";
texte["de"]["automat_title_on_farm1"] = "Zeige nur 1. Farm<br>+Strg: Zeige 1. Farm";
texte["de"]["automat_title_off_farm1"] = "Zeige nur 1. Farm<br>+Strg: Verstecke 1. Farm";
texte["de"]["automat_title_on_farm2"] = "Zeige nur 2. Farm<br>+Strg: Zeige 2. Farm";
texte["de"]["automat_title_off_farm2"] = "Zeige nur 2. Farm<br>+Strg: Verstecke 2. Farm";
texte["de"]["automat_title_on_farm3"] = "Zeige nur 3. Farm<br>+Strg: Zeige 3. Farm";
texte["de"]["automat_title_off_farm3"] = "Zeige nur 3. Farm<br>+Strg: Verstecke 3. Farm";
texte["de"]["automat_title_on_farm4"] = "Zeige nur 4. Farm<br>+Strg: Zeige 4. Farm";
texte["de"]["automat_title_off_farm4"] = "Zeige nur 4. Farm<br>+Strg: Verstecke 4. Farm";
texte["de"]["automat_title_on_farmersmarket"] = "Zeige nur Bauernmarkt<br>+Strg: Zeige Bauernmarkt";
texte["de"]["automat_title_off_farmersmarket"] = "Zeige nur Bauernmarkt<br>+Strg: Verstecke Bauernmarkt";
texte["de"]["automat_title_on_city"] = "Zeige nur Stadt<br>+Strg: Zeige Stadt";
texte["de"]["automat_title_off_city"] = "Zeige nur Stadt<br>+Strg: Verstecke Stadt";
texte["de"]["automat_title_on_forestry"] = "Zeige nur Baumerei<br>+Strg: Zeige Baumerei";
texte["de"]["automat_title_off_forestry"] = "Zeige nur Baumerei<br>+Strg: Verstecke Baumerei";
texte["de"]["automat_title_on_foodworld"] = "Zeige nur Picknickarea<br>+Strg: Zeige Picknickarea";
texte["de"]["automat_title_off_foodworld"] = "Zeige nur Picknickarea<br>+Strg: Verstecke Picknickarea";
texte["de"]["automat_title_on_type1"] = "Zeige nur "+A_dots+"cker<br>+Strg: Zeige "+A_dots+"cker";
texte["de"]["automat_title_off_type1"] = "Zeige nur "+A_dots+"cker<br>+Strg: Verstecke "+A_dots+"cker";
texte["de"]["automat_title_on_type2"] = "Zeige nur St"+a_dots+"lle<br>+Strg: Zeige St"+a_dots+"lle";
texte["de"]["automat_title_off_type2"] = "Zeige nur St"+a_dots+"lle<br>+Strg: Verstecke St"+a_dots+"lle";
texte["de"]["automat_title_on_type3"] = "Zeige nur Fabriken<br>+Strg: Zeige Fabriken";
texte["de"]["automat_title_off_type3"] = "Zeige nur Fabriken<br>+Strg: Verstecke Fabriken";
texte["de"]["automat_title_on_all"] = "Show all farm queues";
texte["de"]["automat_title_off_all"] = "Hide all farm queues";
//help
texte["de"]["automat_help_0"] = [,"This script can be used to add automation to the cultivation process."];
texte["de"]["automat_help_1"] = ["How it works","If you click the \""+texte["de"]["automat_botStart"]+"\" button at the bottom of the page the automation process will be started.<br>You even can continue gaming as long as nothing is ready. Then the bot begins to simulate the clicks a user does. During that period you shouldn't interact."];
texte["de"]["automat_help_2"] = ["Field","At the bottom of every zone an icon is displayed. If the icon shows <div class = \"kp"+PRODSTOP+"\" style = \"display:inline-block;\"> </div> the automation process is stopped or will be stopped at the next culture moment. There will not be any culturing for this garden until you select an other product. When a product icon is displayed this product is cultured next at the field."];
texte["de"]["automat_help_3"] = ["Queue","If in the option menu of the Automat the queue checkbox is checked, clicking the product culturing icon of a zone will display a queue where multiple products can be queued. If the background of a queue item is red this item will not be cultered because a production stop item is added somewhere before in the list."];
texte["de"]["automat_help_4"] = ["Repeat","Enabling the \"Repeat\" check box will enable the \"loop\" feature of the queue."];
texte["de"]["automat_help_5"] = ["Shuffle","Enabling the \"Shuffle\" check box will randomly culture a product from the list."];
texte["de"]["automat_help_6"] = ["Stables","At the bottom of every zone with a stable an icon is displayed. If the icon shows <div class = \"kp"+PRODSTOP+"\" style = \"display:inline-block;\"> </div> the automation process is stopped or will be stopped at the next culture moment. When a product is displayed this product will be used to feed the stable. Click this icon to choose the feed amount through the slider or change the feed product by selecting the product."];
texte["de"]["automat_help_7"] = ["Factories","At the bottom of every zone with a factory an icon is displayed. If the icon shows <div class = \"kp"+PRODSTOP+"\" style = \"display:inline-block;\"> </div> the automation process is stopped or will be stopped at the next culture moment. When a product is displayed this will be the produced product of this factory."];
texte["de"]["automat_help_8"] = [texte["de"]["automat_zonePairing"],"In the \""+texte["de"]["automat_zonePairing"]+"\" menu of the Automat the radio-buttons controle the pairing of the zones. Also the general queue is extended to allow multiple general queues."];
texte["de"]["automat_help_9"] = ["Windmill","The windmill queue works the same as the zone queue but instead of products recipes are baked.<br>As extra the mill queue has a <div class = \"queueButtonAddAll\"> </div> button which can be used to clear and refill the queue with all available recipes that were bought and where there are enough ingredients in the rack to bake them.<br>If the background of a queue item is yellow then there are not enough products to bake all these recipes.<br><br><b>Note: </b>For first time user that have already bought recipes. Go to the miller or the trading lady screen so the bought recipes can be stored into the system."];
}
if(texte["en"]["automat"]==undefined){
texte["en"]["automat"] = "Automaton";
texte["en"]["automat_planting"] = "Planting...";
texte["en"]["automat_waiting"] = "Waiting...";
texte["en"]["automat_watering"] = "Watering...";
texte["en"]["automat_feeding"] = "Feeding...";
texte["en"]["automat_automatPlanting"] = "Seedingmachine";
texte["en"]["automat_automatFeeding"] = "Feedingmachine...";
texte["en"]["automat_automatFactory"] = "Factorymachine...";
texte["en"]["automat_automatWindmill"] = "Millmachine...";
texte["en"]["automat_botStart"] = "Start Automaton-Bot";
texte["en"]["automat_botStop"] = "Stop Automaton-Bot";
texte["en"]["automat_settings_botErrorBehaviour"] = "Behaviour of Automaton in case of errors";
texte["en"]["automat_settings_pageReload"] = "Reload of page";
texte["en"]["automat_settings_botRestart"] = "Restart bot";
texte["en"]["automat_zonePairing"] = "Zone pairing";
texte["en"]["automat_debugInfo"] = "Debug Info";
texte["en"]["automat_windmill"] = "windmill";
texte["en"]["automat_timing"] = "Timing";
texte["en"]["automat_general"] = "General";
texte["en"]["automat_development"] = "Development";
texte["en"]["automat_confirmChangelogVersion"]="You have installed a new version of the Automaton script.<br>The version %1% contains the following changes:";
texte["en"]["automat_msgUpdate"] = "There is a new script version of the automaton. Install?";
texte["en"]["automat_shouldUpdateAdviser"] = "You should update the script of the Adviser!<br>The Automaton will not run properly.";
texte["en"]["automat_settings_autoPlant"] = "Shall the planting machine be displayed?";
texte["en"]["automat_settings_autoWater"] = "Shall the fields be watered?";
texte["en"]["automat_settings_autoFeed"] = "Shall the feeding machine be displayed?";
texte["en"]["automat_settings_botUse"] = "Use bot";
texte["en"]["automat_settings_disableCropFields"]="Block the cropping of sleeping fields.";
texte["en"]["automat_settings_pauseShortMin"] = "Minimal clicking delay of the automaton";
texte["en"]["automat_settings_pauseShortMax"] = "Maximal clicking delay of the automaton";
texte["en"]["automat_settings_pauseMin"] = "Minimal waiting delay of the automaton";
texte["en"]["automat_settings_pauseMax"] = "Maximal waiting delay of the automaton";
texte["en"]["automat_settings_maxDurationBotRun"] = "Maximal running time of the automaton";
texte["en"]["automat_settings_maxDurationBotStep"] = "Maximal running time for a step of the automaton";
texte["en"]["automat_setToDefault"] = "Set to default";
texte["en"]["automat_settings_seedWaitForCrop"] = "Wait planting if next cropping time is less than";
texte["en"]["automat_emergencyPlants"] = "Emergency Plants. They are taken first if the needed plant is not available or fitting.";
texte["en"]["automat_settings_useQueueList"] = "Use queue for the fields.";
texte["en"]["automat_set12a"] = "Delete \n all zone queue\n data";
texte["en"]["automat_set12b"] = "Delete Completed.";
texte["en"]["automat_settings_showQueueTime"] = "Show calculated product ready time in the queue.";
texte["en"]["automat_set18a"] = "Delete all mill queue data";
texte["en"]["automat_set18b"] = "Delete Completed";
texte["en"]["automat_settings_powerUpActivate"] = "Activate powerups for products";
texte["en"]["automat_settings_lotteryActivate"] = "Activate the daily lottery automatically";
texte["en"]["automat_settings_lotteryDailyLot"] = "Choose to keep the daily lot";
texte["en"]["automat_settings_questActivate"] = "Activate the Quest automatically to quest:";
texte["en"]["automat_settings_questSolving"] = "Solve the Quest automatically to quest:";
texte["en"]["automat_settings_farmiReject"] = "Auto reject farmi below:";
texte["en"]["automat_settings_farmiAccept"] = "Auto accept farmi above:";
texte["en"]["automat_settings_farmiAcceptBelowMinValue"] = "Accept a farmi with an product item that is below the minimal product amount in the rack.";
texte["en"]["automat_settings_farmiRemoveMissing"] = "Remove a farmi with missing products and the lowest yield. Threshold:";
texte["en"]["automat_fields"] = "Fields";
texte["en"]["automat_titleGeneral"] = "General queue";
texte["en"]["automat_titleQueue"] = "Queue";
texte["en"]["automat_QueCopyTextHeader"] = "Copy queue";
texte["en"]["automat_QueCopyTextHeaderFrom"] = "Copy from:";
texte["en"]["automat_QueCopyTextHeaderTo"] = "Copy to:";
texte["en"]["automat_QueAddText"] = "Click to add a product to the list."; //Add product
texte["en"]["automat_QueAddAboveText"] = "Click to add a product to the list before this product";
texte["en"]["automat_QueDeleteText"] = "Delete this product from the list.";
texte["en"]["automat_QueClose"] = "Close this menu";
texte["en"]["automat_QueCloseAll"] = "Close all open Queue windows.";
texte["en"]["automat_QueMin"] = "Lower value";
texte["en"]["automat_QuePlus"] = "Increase value";
texte["en"]["automat_QueBehaviourF"] = "Click to switch to rack-mode";
texte["en"]["automat_QueBehaviourR"] = "Click to switch to field-mode";
texte["en"]["automat_QueUpButton"] = "Move Up";
texte["en"]["automat_QueDownButton"] = "Move Down";
texte["en"]["automat_buttonTimeLine"] = "Show field timelines";
texte["en"]["automat_buttonOverview"] = "Show overview of automatons";
texte["en"]["automat_repeat_on"] = "Repeat list is ON, press to turn off repeat.";
texte["en"]["automat_repeat_off"] = "Repeat list is OFF, press to turn on repeat.";
texte["en"]["automat_shuffle_on"] = "Shuffle list is ON, press to turn off shuffle.";
texte["en"]["automat_shuffle_off"] = "Shuffle list is OFF, press to turn on shuffle.";
texte["en"]["automat_rotate"] = "Rotate: place first entry after the last entry";
texte["en"]["automat_stop"] = "STOP";
texte["en"]["automat_week"] = "week";
texte["en"]["automat_inftext"] = "Runs indefinitely";
texte["en"]["automat_removeAllWeed"] = "Remove all %AMOUNT% %PROD%<br>a piece = %COST%<br>total = %TCOST%";
texte["en"]["automat_usedFarmFieldsReadyAt"] = "Used farm fields are ready at:";
texte["en"]["automat_CloseWindowTimer"] = "Closing screen in :%1%";
texte["en"]["automat_CloseWindowTimerClick"] = "Click to reset timer!";
//%PRODNAME% = product name, %FLDFROM% = field nr from, %FLDTO% = field nr until,
texte["en"]["automat_QueDoWork"] = "Zone is done by bot";
texte["en"]["automat_QueDontWork"] = "Zone is ignored by bot";
texte["en"]["automat_QueueStoped"] = "A culture stop is detected these %PRODNAME% will not be cultured.";
texte["en"]["automat_QueStop0"] = "The automatic culturing process will be stopped";
texte["en"]["automat_QueStop1"] = "After culturing %FLDFROM% field the automatic process will be stopped.";
texte["en"]["automat_QueStopX"] = "After culturing %FLDFROM% fields the automatic process will be stopped.";
texte["en"]["automat_QueRepeat"] = "(Repeat mode)";
texte["en"]["automat_QueShuffle"] = "(Shuffle mode)";
texte["en"]["automat_QueRepeatShuffle"] = "(Shuffle repeat mode)";
texte["en"]["automat_QueFieldInRow1"] = "(Nr. %FLDFROM%)";
texte["en"]["automat_QueFieldInRowX"] = "(Nr. %FLDFROM% to %FLDTO%)";
texte["en"]["automat_QueRoundDoneR"] = "These fields %PRODNAME% are already cultured and will be skipped";
texte["en"]["automat_QueRoundDone1"] = "This field %PRODNAME% s already cultured in this turn, <br/>next turn it will be cultured again.";
texte["en"]["automat_QueRoundDoneX"] = "These fields %PRODNAME% are already cultured in this turn, <br/>next turn they will be cultured again.";
texte["en"]["automat_QueFieldMake"] = "Total:";
texte["en"]["automat_QueFieldToGo"] = "To go:";
texte["en"]["automat_QueRoundMake"] = "Each turn: ";
texte["en"]["automat_QueRoundMade"] = "Made:";
texte["en"]["automat_QueRoundToGo"] = "To do:";
texte["en"]["automat_QueUses"] = "Uses:";
texte["en"]["automat_QueGives"] = "Yield:";
texte["en"]["automat_QueFutter"] = "Time discount:";
texte["en"]["automat_QueTimeThis"] = "Production time:";
texte["en"]["automat_QueTimeToGo"] = "Culture time to go:";
texte["en"]["automat_QueTimeReady"] = "Ready at:";
texte["en"]["automat_QueTimeFirstReady"] = "First is ready at:";
texte["en"]["automat_QueTimeNextReady"] = "Next is ready at:";
texte["en"]["automat_QueTimeRound"] = "Average each turn:";
texte["en"]["automat_QueRackMode"]="(Rack mode)";
texte["en"]["automat_queueshow"]="Click to edit the queue";
//For the Mill
//%PRODNAME% = product name, %FLDFROM% = field nr from, %FLDTO% = field nr until,
texte["en"]["automat_MillQueue"] = "Mill Queue";
texte["en"]["automat_MillDoWork"] = "The windmill is automatically maintained.";
texte["en"]["automat_MillDontWork"] = "The windmill is ignored. Manual maintenance is required.";
texte["en"]["automat_MillClearAddAll"] = "Clear mill list then add all recieps";
texte["en"]["automat_MillShuffle"] = "(Shuffle mode)";
texte["en"]["automat_MillInRow1"] = "(Nr. %FLDFROM%)";
texte["en"]["automat_MillInRowX"] = "(Nr. %FLDFROM% to %FLDTO%)";
texte["en"]["automat_MillTimeTotal"] = "Total Bakeing time:";
texte["en"]["automat_MillTimeReady"] = "Ready:";
texte["en"]["automat_MillStoped"] = "There is a stop added to the queue this %PRODNAME% will not be bakeed";
texte["en"]["automat_MillStop0"] = "The automatic bakeing process will be stopped";
texte["en"]["automat_MillStop1"] = "After %FLDFROM% recipe the automatic bakeing process will be stopped.";
texte["en"]["automat_MillStopX"] = "After %FLDFROM% recipes the automatic bakeing process will be stopped.";
try{
texte["en"]["automat_MillTimeThis"] = top.window.wrappedJSObject.windmill_bakeingtime;
texte["en"]["automat_MillPowerUpText_0"] = top.window.wrappedJSObject.powerup_bonustext1;
texte["en"]["automat_MillPowerUpText_1"] = top.window.wrappedJSObject.powerup_bonustext2;
texte["en"]["automat_MillPowerUpText_2"] = top.window.wrappedJSObject.powerup_bonustext3;
texte["en"]["automat_MillIngredients"] = top.window.wrappedJSObject.windmill_zutaten;
}catch(err){GM_log("Mill from game missing \n"+err);}
texte["en"]["automat_number"] = "Number";
texte["en"]["automat_lack"] = "Lack";
texte["en"]["automat_MillRecipesBought"] = "Total recipes bought: ";
texte["en"]["automat_MillRecipesUsed"] = "Total recipes used: ";
texte["en"]["automat_MillRecipesBake"] = "Max recipes to bake: ";
//title
texte["en"]["automat_title_on_general"] = "Show general queue only<br>+Ctrl: Show general queue";
texte["en"]["automat_title_off_general"] = "Show general queue only<br>+Ctrl: Hide general queue";
texte["en"]["automat_title_on_farm1"] = "Show first farm only<br>+Ctrl: Show first farm";
texte["en"]["automat_title_off_farm1"] = "Show first farm only<br>+Ctrl: Hide first farm";
texte["en"]["automat_title_on_farm2"] = "Show second farm only<br>+Ctrl: Show second farm";
texte["en"]["automat_title_off_farm2"] = "Show second farm only<br>+Ctrl: Hide second farm";
texte["en"]["automat_title_on_farm3"] = "Show third farm only<br>+Ctrl: Show third farm";
texte["en"]["automat_title_off_farm3"] = "Show third farm only<br>+Ctrl: Hide third farm";
texte["en"]["automat_title_on_farm4"] = "Show fourth farm only<br>+Ctrl: Show fourth farm";
texte["en"]["automat_title_off_farm4"] = "Show fourth farm only<br>+Ctrl: Hide fourth farm";
texte["en"]["automat_title_on_farmersmarket"] = "Show farmersmarket only<br>+Ctrl: Show farmersmarket";
texte["en"]["automat_title_off_farmersmarket"] = "Show farmersmarket only<br>+Ctrl: Hide farmersmarket";
texte["en"]["automat_title_on_city"] = "Show city only<br>+Ctrl: Show city";
texte["en"]["automat_title_off_city"] = "Show city only<br>+Ctrl: Hide city";
texte["en"]["automat_title_on_forestry"] = "Show forestry only<br>+Ctrl: Show forestry";
texte["en"]["automat_title_off_forestry"] = "Show forestry only<br>+Ctrl: Hide forestry";
texte["en"]["automat_title_on_foodworld"] = "Show picnic area only<br>+Ctrl: Show picnic area";
texte["en"]["automat_title_off_foodworld"] = "Show picnic area only<br>+Ctrl: Hide picnic area";
texte["en"]["automat_title_on_type1"] = "Show fields only<br>+Ctrl: Show fields";
texte["en"]["automat_title_off_type1"] = "Show fields only<br>+Ctrl: Hide fields";
texte["en"]["automat_title_on_type2"] = "Show stables only<br>+Ctrl: Show stables";
texte["en"]["automat_title_off_type2"] = "Show stables only<br>+Ctrl: Hide stables";
texte["en"]["automat_title_on_type3"] = "Show factories only<br>+Ctrl: Show factories";
texte["en"]["automat_title_off_type3"] = "Show factories only<br>+Ctrl: Hide factories";
texte["en"]["automat_title_on_all"] = "Show all farm queues";
texte["en"]["automat_title_off_all"] = "Hide all farm queues";
//help
texte["en"]["automat_help_0"] = [,"This script can be used to add automation to the cultivation process."];
texte["en"]["automat_help_1"] = ["How it works","If you click the \""+texte["en"]["automat_botStart"]+"\" button at the bottom of the page the automation process will be started.<br>You even can continue gaming as long as nothing is ready. Then the bot begins to simulate the clicks a user does. During that period you shouldn't interact."];
texte["en"]["automat_help_2"] = ["Field","At the bottom of every zone an icon is displayed. If the icon shows <div class = \"kp"+PRODSTOP+"\" style = \"display:inline-block;\"> </div> the automation process is stopped or will be stopped at the next culture moment. There will not be any culturing for this garden until you select an other product. When a product icon is displayed this product is cultured next at the field."];
texte["en"]["automat_help_3"] = ["Queue","If in the option menu of the Automat the queue checkbox is checked, clicking the product culturing icon of a zone will display a queue where multiple products can be queued. If the background of a queue item is red this item will not be cultered because a production stop item is added somewhere before in the list."];
texte["en"]["automat_help_4"] = ["Repeat","Enabling the \"Repeat\" check box will enable the \"loop\" feature of the queue."];
texte["en"]["automat_help_5"] = ["Shuffle","Enabling the \"Shuffle\" check box will randomly culture a product from the list."];
texte["en"]["automat_help_6"] = ["Stables","At the bottom of every zone with a stable an icon is displayed. If the icon shows <div class = \"kp"+PRODSTOP+"\" style = \"display:inline-block;\"> </div> the automation process is stopped or will be stopped at the next culture moment. When a product is displayed this product will be used to feed the stable. Click this icon to choose the feed amount through the slider or change the feed product by selecting the product."];
texte["en"]["automat_help_7"] = ["Factories","At the bottom of every zone with a factory an icon is displayed. If the icon shows <div class = \"kp"+PRODSTOP+"\" style = \"display:inline-block;\"> </div> the automation process is stopped or will be stopped at the next culture moment. When a product is displayed this will be the produced product of this factory."];
texte["en"]["automat_help_8"] = [texte["en"]["automat_zonePairing"],"In the \""+texte["en"]["automat_zonePairing"]+"\" menu of the Automat the radio-buttons controle the pairing of the zones. Also the general queue is extended to allow multiple general queues."];
texte["en"]["automat_help_9"] = ["Windmill","The windmill queue works the same as the zone queue but instead of products recipes are baked.<br>As extra the mill queue has a <div class = \"queueButtonAddAll\"> </div> button which can be used to clear and refill the queue with all available recipes that were bought and where there are enough ingredients in the rack to bake them.<br>If the background of a queue item is yellow then there are not enough products to bake all these recipes.<br><br><b>Note: </b>For first time user that have already bought recipes. Go to the miller or the trading lady screen so the bought recipes can be stored into the system."];
}
delimThou=top.unsafeData.delimThou;
regDelimThou=new RegExp(top.unsafeData.regDelimThou,"g");
delimDeci=top.unsafeData.delimDeci;
regDelimDeci=new RegExp(top.unsafeData.regDelimDeci);
window.setInterval(function (){
now=Math.floor((new Date()).getTime()/1000);
},1000);
GM_registerMenuCommand(getText("automat")+" "+"Update", function(){
location.href=GM_Source;
});
GM_registerMenuCommand(getText("automat")+" "+getText("scriptHomepage"), function(){
window.open(GM_Home);
});
// Version check
err_trace="Version check";
if((!unsafeData.beraterVersion)||(compareVersions(neededVersionBerater,unsafeData.beraterVersion)>0)){
alert2(getText("automat_shouldUpdateAdviser"),getText("ok"));
}
var loc=new RegExp("s(\\d+)\\."+GAMEPAGES[COUNTRY].replace(/\./g,"\\."),"i").exec(location.hostname);
if(loc){
SERVER=loc[1];
USERNAME=unsafeData.username.slice();
settings.init();
// **************************************************
// ChangeData Server
err_trace="ChangeData Server";
try{
var changedata = GM_getValue(COUNTRY+"_"+SERVER+"_automatChangedata",0);
switch(changedata){
case 0:{
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_valBot")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_valBot");
settings.set("server","botActive",help);
}
}
}
if(changedata<1){ GM_setValue(COUNTRY+"_"+SERVER+"_automatChangedata",1); }
}catch(err){GM_logError("changedata server\n"+err);}
// **************************************************
// ChangeData User
err_trace="ChangeData Server";
try{
var changedata = GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_automatChangedata",0);
switch(changedata){
case 0:{
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valAutoPflanz")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valAutoPflanz");
settings.set("account","autoPlant",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valAutoFutter")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valAutoFutter");
settings.set("account","autoFeed",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valUseQueueList")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valUseQueueList");
settings.set("account","useQueueList",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valSeedWaitForCrop")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valSeedWaitForCrop");
settings.set("account","seedWaitForCrop",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valDisableCropFields")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valDisableCropFields");
settings.set("account","disableCropFields",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valShowQueueTime")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valShowQueueTime");
settings.set("account","showQueueTime",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valPowerUpActivate")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valPowerUpActivate");
settings.set("account","powerUpActivate",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valLotteryActivate")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valLotteryActivate");
settings.set("account","lotteryActivate",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valLotteryDailyLot")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valLotteryDailyLot");
settings.set("account","lotteryDailyLot",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiReject")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiReject");
settings.set("account","farmiReject",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiRejectUntilNr")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiRejectUntilNr");
settings.set("account","farmiRejectUntilNr",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiAccept")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiAccept");
settings.set("account","farmiAccept",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiAcceptAboveNr")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiAcceptAboveNr");
settings.set("account","farmiAcceptAboveNr",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiAcceptBelowMinValue")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiAcceptBelowMinValue");
settings.set("account","farmiAcceptBelowMinValue",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiRemoveMissing")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiRemoveMissing");
settings.set("account","farmiRemoveMissing",help);
}
if(help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiRemoveMissingAboveNr")){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valFarmiRemoveMissingAboveNr");
settings.set("account","farmiRemoveMissingAboveNr",help);
}
if((help=GM_getValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valUseBot"))&&(help=explode(help,"changedata country/valUseBot"))){
GM_deleteValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_valUseBot");
for(var i in help){
if(!help.hasOwnProperty(i)){ continue; }
settings.set("account","botUse"+i.toTitleCase(),!!help[i]);
}
}
}
}
if(changedata<1){ GM_setValue(COUNTRY+"_"+SERVER+"_"+USERNAME+"_automatChangedata",1); }
}catch(err){GM_logError("changedata user\n"+err);}
// **************************************************
switch (PAGE){
//case "dbfehler":
//case "wartung": break;
case "main": do_main();break;
case "hilfe": do_hilfe();break;
}
} else {
settings.init();
do_login();
}
GM_log("Userscript \"MyFreeFarm Automat\" has started\nPage="+location.href);
unsafeData.automatStarted=automatStarted=true;
}catch(err){GM_logError("start_script ("+err_trace+")\n"+err);}
}
window.addEventListener("load",function(){
if(self==top){ do_relogin(60); }
if(unsafeData.beraterDone){
start_script();
}else{
document.addEventListener("beraterDone",function(){
start_script();
document.removeEventListener("beraterDone",arguments.callee,false);
},false);
}
},false);
Donate for the site OpenUserJS
Are you sure you want to go to an external site to donate a monetary value?
WARNING: Some countries laws may supersede the payment processors policy such as the GDPR and PayPal. While it is highly appreciated to donate, please check with your countries privacy and identity laws regarding privacy of information first. Use at your utmost discretion.