// ==UserScript==
// @name The West - tw-db.info Cloth Calc [ro]
// @version 0.44 Rev. 3
// @description The West Script: Cloth Calculation for game version 1.34 or higher
// @author Bluep, scoobydoo, Dun, Petee [tw-db.info]
// @namespace http://tw-db.info
// @grant none
// @website http://tw-db.info
// @include http://*.the-west.*/game.php*
// @include https://*.the-west.*/game.php*
// @include http://*.tw.innogames.*/game.php*
// @include https://*.tw.innogames.*/game.php*
// @downloadURL none
// ==/UserScript==
(function (f) {
var d = document, s = d.createElement('script');
s.setAttribute('type', 'application/javascript');
s.textContent = '(' + f.toString() + ')()';
(d.body || d.head || d.documentElement).appendChild(s);
s.parentNode.removeChild(s)
})(function () {
if (isDefined(window.TWDB)) {
new west.gui.Dialog(TWDB.script.name, '
Script-ul CloathCalc este instalat de două ori, cu două versiuni lingvistice diferite. Va trebui să dezinstalați una dintre ele pentru script-ul să funcționeze corect!
vă rugăm să mergeţi la TW-db.info pentru a obţine fragmentele de cod pentru a le introduce aici tw-db.info Calculator
');
var o = new west.gui.Dialog(s + "Îndemânări selectate", o);
o.addButton("ok", function () {
return n.editConfig(e, true)
});
o.addButton("cancel");
o.show()
} else {
var u = function (e) {
(new UserMessage("inserările făcute sunt incorecte: " + e, UserMessage.TYPE_ERROR)).show();
return false
};
if (this.parent.gui.custom.name.getValue() == "") {
return u("gol Nume")
}
if (this.parent.gui.custom.code.getValue() == "") {
return u("gol Cod [1]")
}
if (this.parent.gui.custom.name.getValue() == this.tmp.name && this.parent.gui.custom.code.getValue() == this.tmp.code) {
return true
}
try {
var i = jQuery.parseJSON(this.parent.gui.custom.code.getValue())
} catch (a) {
return u("greşit Cod [2]")
}
if (typeof i.type == "undefined" || typeof i.para == "undefined") {
return u("greşit Cod [3]")
}
var f = 0;
for (var l in i.para) {
f++
}
switch (i.type) {
case"speed":
case"regen":
if (f !== 0) {
return u("greşit Cod [4]")
}
break;
case"fort":
if (typeof i.para.type == "undefined" || typeof i.para.att == "undefined" || typeof i.para.def == "undefined" || typeof i.para.health == "undefined") {
return u("greşit Cod [5]")
}
if (i.para.type !== 1 && i.para.type !== 0) {
return u("greşit Cod [6]")
}
if (!jQuery.isNumeric(i.para.att) || i.para.att < 0) {
return u("greşit Cod [7]")
}
if (!jQuery.isNumeric(i.para.def) || i.para.def < 0) {
return u("greşit Cod [8]")
}
if (!jQuery.isNumeric(i.para.health) || i.para.health < 0) {
return u("greşit Cod [9]")
}
break;
case"duel":
case"custom":
if (f <= 0) {
return u("greşit Cod [10]")
}
break;
default:
return u("greşit Cod [11]")
}
delete this.tmp;
this.parent.data.custom[e] = {
id: Number(e),
type: i.type,
para: i.para,
name: this.htmlEscape(this.parent.gui.custom.name.getValue())
};
this.parent.gui.custom.config.hide();
this.showConfig();
TWDB.Settings.set("custom", this.parent.data.custom)
}
}, deleteConfig: function (e, t) {
if (typeof t == "undefined") {
var n = this;
var r = new west.gui.Dialog("şterge - Îndemânări selectate", "şterge: " + this.parent.data.custom[e].name + "?");
r.addButton("ok", function () {
n.deleteConfig(e, true)
});
r.addButton("cancel");
r.show()
} else {
var i = this.parent.data.custom;
delete i[e];
this.parent.data.custom = {};
var s = 0;
for (var e in i) {
s++;
this.parent.data.custom[s] = i[e];
this.parent.data.custom[s].id = s
}
this.parent.gui.custom.config.hide();
this.showConfig();
TWDB.Settings.set("custom", this.parent.data.custom)
}
}
},
getSkillImg: function (e, t) {
var n = 1;
var r = 1;
var i = 0;
switch (e) {
case"build":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
r = 2;
break;
case"punch":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
i = 1;
r = 2;
break;
case"tough":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
i = 2;
r = 2;
break;
case"endurance":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
i = 3;
r = 2;
break;
case"health":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
i = 4;
r = 2;
break;
case"ride":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
r = 2;
break;
case"reflex":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
i = 1;
r = 2;
break;
case"dodge":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
i = 2;
r = 2;
break;
case"hide":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
i = 3;
r = 2;
break;
case"swim":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
i = 4;
r = 2;
break;
case"aim":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
r = 2;
break;
case"shot":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
i = 1;
r = 2;
break;
case"pitfall":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
i = 2;
r = 2;
break;
case"finger_dexterity":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
i = 3;
r = 2;
break;
case"repair":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
i = 4;
r = 2;
break;
case"leadership":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
r = 2;
break;
case"tactic":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
i = 1;
r = 2;
break;
case"trade":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
i = 2;
r = 2;
break;
case"animal":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
i = 3;
r = 2;
break;
case"appearance":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
i = 4;
r = 2;
break;
case"strength":
var s = Game.cdnURL + "/images/window/skills/circle_strength.png";
break;
case"flexibility":
var s = Game.cdnURL + "/images/window/skills/circle_flexibility.png";
break;
case"dexterity":
var s = Game.cdnURL + "/images/window/skills/circle_dexterity.png";
break;
case"charisma":
var s = Game.cdnURL + "/images/window/skills/circle_charisma.png";
break;
case"attacker":
var s = TWDB.images.attacker;
break;
case"defender":
var s = TWDB.images.defender;
break;
default:
return jQuery("")
}
var o = "";
if (typeof CharacterSkills.skills[e] !== "undefined") {
var o = CharacterSkills.skills[e].name
} else if (typeof CharacterSkills.attributes[e] !== "undefined") {
var o = CharacterSkills.attributes[e].name
}
s = '';
s = jQuery(s);
var u = '';
u = jQuery(u);
return u.append(s)
},
bag: {
stack: {}, interval: false, setParent: function (e) {
this.parent = e
}, showItems: function (e, t) {
this.parent.gui.bag.children().remove();
this.items = {};
var n = this, r = false, i = function (e) {
var r = (new tw2widget.InventoryItem(ItemManager.get(e))).setCharacter(Character);
var i = r.getMainDiv();
var s = function (e) {
return function () {
n.click(r, e, t)
}
}(e);
jQuery(i).removeAttr("id").children(".TWDBbuyTip, .TWDBsellTip, .TWDBcollector").remove().end().children("img:first-child").removeAttr("id").end().click(s).appendTo(n.parent.gui.bag);
n.items[e] = jQuery(i)
}, s, o;
for (s in e) {
if (typeof s === "function") {
break
}
o = e[s].id;
i(o);
r = r || ItemManager.get(o).type === "animal"
}
this.parent.gui.bag.append(jQuery((new west.gui.Button(Inventory.guiElements.instantWearButton.caption.text, n.autoEquip, n, null)).getMainDiv()).css({
position: "absolute",
right: "8px",
bottom: "5px"
}));
var u = TWDB.DataManager.getAnimals();
if (!r && u.length > 0) {
i(u[0]["id"])
}
this.wear()
}, autoEquip: function () {
var e;
for (e in this.items) {
if (this.items.hasOwnProperty(e)) {
jQuery(this.items[e]).click()
}
}
}, click: function (e, t, n) {
if (Bag.getItemByItemId(t) === undefined) {
return false
}
Wear.carry(e);
this.stack[t] = e;
var r = this, i;
if (this.interval === false) {
switch (n) {
case"jobs":
i = function () {
r.wear();
r.parent.jobs.update();
r.parent.joblist.update()
};
break;
case"custom":
i = function () {
r.wear();
r.parent.customs.showSkill()
};
break
}
TWDB.Eventer.set("carryChecker", i, 1);
this.interval = setInterval(function () {
r.carry()
}, 100)
}
}, carry: function () {
var e = 0, t, n;
for (t in this.stack) {
n = this.stack[t];
if (n === undefined || n.getImgEl().css("opacity") === "1") {
delete this.stack[t]
} else {
e++
}
}
if (e === 0) {
clearInterval(this.interval);
this.interval = false;
TWDB.Eventer.trigger("carryChecker")
}
}, wear: function () {
var e, t;
for (e in Wear.wear) {
t = Wear.wear[e].getId();
if (typeof this.items[t] !== "undefined") {
this.items[t].css("opacity", "0.5")
}
}
}
},
setUsedItems: function () {
for (var e in this.calcdata.jobs) {
for (var t in this.calcdata.jobs[e].cloth) {
var n = this.calcdata.jobs[e].cloth[t].id;
if (typeof (this.calcdata.used[n] == "undefined")) {
this.calcdata.used[n] = 1
} else {
this.calcdata.used[n]++
}
}
}
for (var r in this.calcdata.custom) {
for (var t in this.calcdata.custom[r].cloth) {
var n = this.calcdata.custom[r].cloth[t].id;
if (typeof (this.calcdata.used[n] == "undefined")) {
this.calcdata.used[n] = 1
} else {
this.calcdata.used[n]++
}
}
}
},
jobSearch: function () {
var e = this;
if (this.jobs.selected == 0) {
return
}
if (this.gui.job.searchDiv.parent().length) {
this.jobs.switchJob(this.jobs.selected);
return
}
this.gui.bag.children().remove();
var t = TWDB.Map.getNearestJob(this.jobs.selected);
var n = 4;
var r = jQuery("
");
for (var i = 0; i < t.length; i++) {
if (i === n) {
break
}
var s = t[i];
var o = "rotate(" + s.angle + "deg);";
var u = jQuery("
");
u.append('
' + s.time.formatDuration() + "
");
u.append(jQuery('
').append(jQuery('').click(function (e, t) {
return function () {
Map.center(e, t)
}
}(s.x, s.y))));
var a = jQuery("
");
var f = new west.gui.Button("Deschide", function (e, t, n) {
return function () {
TWDB.Jobs.openJob(e, t, n)
}
}(e.jobs.selected, s.x, s.y));
jQuery(f.divMain).css({"min-width": "50px", "max-width": "80px"});
jQuery(f.divMain).find(".textart_title").css({overflow: "hidden"});
f.appendTo(a);
u.append(a);
if (Premium.hasBonus("automation")) {
var a = jQuery("
");
var f = new west.gui.Button("default", function (t, n, r) {
return function () {
TWDB.Jobs.startJob(t, n, r, Number(e.jobs.basetime))
}
}(e.jobs.selected, s.x, s.y));
jQuery(f.divMain).css({"min-width": "50px", "max-width": "80px"});
jQuery(f.divMain).find(".textart_title").css({overflow: "hidden"});
f.appendTo(a);
u.append(a)
}
r.append(u)
}
this.gui.job.searchDiv.children().remove();
this.gui.job.searchDiv.append(r);
this.gui.bag.append(this.gui.job.searchDiv)
},
isUsedItem: function (e) {
if (this.calcdata.used[e]) {
return true
} else {
return false
}
},
getClothForJob: function (e) {
if (!isDefined(this.calcdata.jobs[e]) || !isDefined(this.calcdata.jobs[e].cloth)) {
return null
}
return this.calcdata.jobs[e].cloth
},
getLPForJob: function (e) {
if (!isDefined(this.calcdata.jobs[e]) || !isDefined(this.calcdata.jobs[e].laborpoints)) {
return null
}
return this.calcdata.jobs[e].laborpoints
},
getSelectedJob: function () {
return this.jobs.selected
},
isLoaded: function () {
if (isDefined(this.calcdata.loaded)) {
return this.calcdata.loaded
}
return false
}
};
(function ($) {
var _base = TWDB;
var w = window;
var Images = _base.images;
var Script = _base.script;
var ClothCalc = _base.ClothCalc;
var Debugger = function (e) {
var t = {};
return t
}($);
_base.Debugger = Debugger;
var Error = function (e) {
var t = {};
var n = "twdb_error";
var r = [];
var i = true;
t.report = function (e, t) {
if (!isDefined(e.message)) {
r.push({msg: "failed to add error", e: t})
} else {
r.push({msg: t + " " + (e.stack && (e.stack.match(/:\d+:\d+/) || [])[0] || ""), e: e.message})
}
if (i) {
i = false;
WestUi.NotiBar.add(new OnGoingPermanentEntry(function () {
s()
}, "tw-db.info: an error occured", "tip"))
}
};
var s = function () {
var t = new west.gui.Scrollpane;
e(t.getMainDiv()).css("height", "370px");
e(t.getMainDiv()).find(".tw2gui_scrollpane_clipper_contentpane").addClass("selectable");
var i = '
';
for (var s = r.length - 1; s >= 0; s--) {
i += "
" + s + "
" + r[s].msg + "
" + r[s].e + "
"
}
i += "
";
t.appendContent(i);
var o = wman.open(n, null, "noreload").setMiniTitle("TWDB Errorlog").setTitle("tw-db.info Errorlog").appendToContentPane(t.getMainDiv())
};
return t
}($);
_base.Error = Error;
Debugger.Error = Error;
var Loader = function (e) {
var t = {};
var n = [];
var r = {};
var i = {};
var s;
var o = false;
var u = false;
var a = false;
var f = 0;
t.add = function (e, t, r, i) {
var s = {ready: false};
n.push({key: e, txt: t, call: r, dep: i || {}, ready: s, count: 0});
return s
};
t.init = function () {
if (s) {
return
}
s = w.setInterval(function () {
l()
}, 500)
};
var l = function () {
if (u) {
return
}
u = true;
if (o === false) {
if (!c()) {
u = false;
return
}
TWDB.Cache.init();
r.Cache = true;
try {
Updater.query();
h()
} catch (e) {
Error.report(e, "");
(new UserMessage("a eşuat în a înregistra scriptul tw-db.info pe TheWestApi", UserMessage.TYPE_FATAL)).show();
return d()
}
if (TWDB.Util.isNewIDsystem()) {
TWDB.Util.wrapBetaGetItem()
}
if (TWDB.Util.isNewIDsystem() && window.location.href.indexOf(".beta.the-west.net") === -1 && !TWDB.Util.idMigrationDone()) {
try {
TWDB.Util.backupData()
} catch (e) {
}
try {
TWDB.Util.idMigrator();
(new UserMessage("Converting TW-DB data to new item ID system successful.", UserMessage.TYPE_SUCCESS)).show();
TWDB.Util.simpleRestore(true)
} catch (e) {
Error.report(e, "Item ID conversion failed.");
(new UserMessage("Item ID conversion failed. Do not use the ANALYSERS if you want to save your data!", UserMessage.TYPE_FATAL)).show();
TWDB.Util.simpleRestore()
}
}
return p()
}
if (isDefined(i[o.key])) {
return p()
}
if (o.ready.ready) {
r[o.key] = true;
a = false;
return p()
}
u = false
};
var c = function () {
if (!isDefined(w.jQuery) || !isDefined(w.TheWestApi) || !isDefined(w.TheWestApi.version) || w.ItemManager.get(2e3) === undefined || !isDefined(w.Character) || w.Character.playerId === 0 || !w.Bag.loaded) {
return false
} else {
return true
}
};
var h = function () {
var t = w.TheWestApi.register("twdb_clothcalc", "tw-db.info Cloth Calc", "2.04", String(Script.gameversion), "scoobydoo, Dun, Petee, Bluep, Tom Robert [tw-db.info]", "https://tw-db.info");
var n = '
';
var r = e("").append("Script-ul ClathCalc este un proiect creat de echipa TW-DB.info. El oferă o mulţime de caracteristici şi extensii ce vă va oferi o experienţă de joc îmbunătăţită - economisind timpul şi optimizând câteva din activităţile dumneavoastră. ", n, "Vă mulțumim!");
t.setGui(r);
if (t.isOutdated()) {
w.TheWestApi.displayOutdated()
}
};
var p = function () {
if (n.length === 0) {
return d()
}
o = n.shift();
o.count++;
if (o.count > f) {
if (a) {
Error.report({message: "deadlock detected"}, "failed to load module: " + o.key);
i[o.key] = true;
return p()
}
f++;
a = true
}
for (var e in o.dep) {
if (!isDefined(r[e])) {
if (TWDB.script.isDev()) {
console.log(o.key, "needs ", e)
}
n.push(o);
return p()
}
}
try {
o.call()
} catch (t) {
Error.report(t, "failed to load module: " + o.key);
i[o.key] = true;
return p()
}
u = false;
l()
};
var d = function () {
w.clearInterval(s);
w.setTimeout(function () {
delete t
}, 1e3)
};
t.stack = n;
t.loaded = r;
t.failed = i;
t.current = o;
return t
}($);
Debugger.Loader = Loader;
var Cache = function (e) {
var t = {};
var n = {};
var r = "";
var i = {};
var s = function (e) {
if (!i[e]) {
i[e] = true;
t.save("keys", i)
}
};
var o = function () {
if (n.ready) {
return
}
r = "twdb_" + Character.playerId + "_";
i = t.load("keys");
if (!i) {
i = {keys: true}
}
n.ready = true
};
t.load = function (n) {
s(n);
try {
return e.parseJSON(decodeURIComponent(localStorage.getItem(r + n)))
} catch (i) {
Error.report(i, "load " + n + " from cache");
t.save(n, null);
return null
}
};
t.save = function (e, n) {
s(e);
try {
localStorage.setItem(r + e, encodeURIComponent(JSON.stringify(n)));
return true
} catch (i) {
Error.report(i, "save " + e + " to cache");
t.save(e, null);
return false
}
};
t.reset = function (n, s) {
try {
if (n) {
if (isDefined(s)) {
localStorage.removeItem(s)
} else {
for (var o in i) {
localStorage.removeItem(r + o)
}
}
(new UserMessage("Reset Done, page will now be reloaded", UserMessage.TYPE_SUCCESS)).show();
location.href = location.href.replace(location.hash || "#", "")
} else {
var u = e("
Ești sigur ca vrei sa-ți resetezi cache-ul?
");
var a = (new west.gui.Textfield("twdb_cache_key")).setSize(40).setLabel("Key:");
u.append(a.getMainDiv());
var f = (new west.gui.Checkbox("all Keys")).setSelected(true);
f.setCallback(function (e) {
if (e) {
a.setValue("")
}
});
e(a.getMainDiv()).find("span").css("font-size", "12px");
e(a.getMainDiv()).find("input").keyup(function () {
f.setSelected(false)
});
u.append(e('').append(f.getMainDiv()));
(new west.gui.Dialog("tw-db Cache Reset", u, west.gui.Dialog.SYS_QUESTION)).addButton("ok", function () {
if (f.isSelected()) {
t.reset(true)
} else {
t.reset(true, a.getValue())
}
}).addButton("cancel").show()
}
} catch (l) {
Error.report(l, "cache reset")
}
};
t.init = o;
return t
}($);
_base.Cache = Cache;
Debugger.Cache = Cache;
var Worker = function (e) {
var t = {};
var n = [];
var r = false;
var i = false;
t.add = function (e) {
n.push(e);
if (r) {
return
}
r = w.setInterval(function () {
s()
}, 100)
};
var s = function () {
if (i) {
return
}
i = true;
var e = n.shift();
try {
e()
} catch (t) {
Error.report(t, "Worker")
}
if (n.length == 0) {
w.clearInterval(r);
r = false
}
i = false
};
return t
}($);
Debugger.Worker = Worker;
var Jobs = function (e) {
var t = {};
var n = {};
var r = [];
var i = {};
var s = {};
var o = [1828e3, 1829e3, 183e4, 2e6, 2003e3, 2006e3, 2009e3];
var u;
var a = {};
var f = function () {
if (n.ready) {
return
}
var t = 0;
var f = 0;
var c = {};
while (true) {
t++;
var h = w.JobList.getJobById(t);
if (!h) {
f++;
if (f > 5) {
break
}
continue
}
f = 0;
r.push(h.id);
i[h.name.toLowerCase()] = h.id;
s[h.shortname.toLowerCase()] = h.id;
for (var p in h.yields) {
if (isNaN(p) || c[p]) {
continue
}
c[p] = true;
o.push(Number(p))
}
}
u = function (e) {
var t = {
description: "",
duration: 1800,
energy: 6,
groupid: null,
id: 255,
malus: 0,
name: "Construcţie",
randomyields: [],
shortname: "construction",
skills: {build: 3, repair: 1, leadership: 1},
yields: {},
calcJobPoints: function () {
return 0
},
canDo: function () {
return true
}
};
return t
}(e);
r.push(255);
i[u.name.toLowerCase()] = 255;
s[u.shortname.toLowerCase()] = 255;
var d = function (e, t) {
var n = e === 255 ? u : w.JobList.getJobById(e);
var r = t === 255 ? u : w.JobList.getJobById(t);
return n.name > r.name
};
r.sort(d);
o.sort();
a = Cache.load("jobdata");
if (a === null || typeof a !== "object") {
a = {}
}
Eventer.set("TWDBdataLoaded", function () {
l()
});
n.ready = true
};
n = Loader.add("Jobs", "tw-db Jobsystem", f, {Cache: true});
var l = function () {
a = {};
Cache.save("jobdata", a)
};
t.getJobByName = function (n) {
n = e.trim(n).toLowerCase();
if (!isDefined(i[n])) {
return null
}
return t.getJobById(i[n])
};
t.getJobByShortname = function (n) {
n = e.trim(n).toLowerCase();
if (!isDefined(s[n])) {
return null
}
return t.getJobById(s[n])
};
t.getJobById = function (t) {
var n;
if (t === 255) {
n = u
} else {
n = w.JobList.getJobById(t);
if (!n) {
return n
}
}
var r = e.extend(true, {}, n);
var i = 1;
if (w.Character.charClass == "adventurer") {
if (w.Premium.hasBonus("character")) {
i *= 1.2
} else {
i *= 1.1
}
}
if (w.Premium.hasBonus("money")) {
i *= 1.5
}
for (var s = 0; s < r.randomyields.length; s++) {
r.randomyields[s] = (r.randomyields[s] * i).round(2)
}
if (typeof r.yields.length == "undefined") {
for (var o in r.yields) {
r.yields[o].prop = (r.yields[o].prop * i).round(2)
}
}
return r
};
t.openJob = function (e, t, n) {
w.JobWindow.open(e, t, n)
};
t.startJob = function (e, t, n, r) {
w.JobWindow.startJob(e, t, n, Number(r) || 3600)
};
t.getAllJobs = function () {
return r
};
t.isProduct = function (t) {
return e.inArray(Number(t), o)
};
t.getPopup = function (e, n) {
var r = '
';
var i = t.getJobById(e);
if (isDefined(i)) {
r += '' + i.name + "" + '
' + "" + '' + "
"
}
return r += "
"
};
return t
}($);
_base.Jobs = Jobs;
Debugger.Jobs = Jobs;
var Window = function (e) {
var t = {};
var n = "twdb_window";
var r = null;
var i = null;
var s = {};
var o = {};
var u = function () {
if (o.ready) {
return
}
var t = e('').css("background-image", "url(" + Images.button + ")").mouseenter(function () {
e(this).css("background-position", "-25px 0px")
}).mouseleave(function () {
e(this).css("background-position", "0px 0px")
}).click(function () {
a()
});
e("#ui_menubar").append(e('').append(t).append(''));
ready = true;
o.ready = true
};
o = Loader.add("Window", "tw-db Scriptwindow", u);
t.open = function (e) {
a(e)
};
var a = function (t) {
r = wman.open(n, null).setMiniTitle("tw-db.info").setTitle("tw-db.info");
r.appendToContentPane(e('
"));
r.appendToContentPane(e('').append('').click(function () {
Support.open()
}));
var o;
for (var u in s) {
if (!isDefined(o)) {
o = u
}
if (t == u) {
o = u
}
r.addTab(s[u].name, u, function (e, t) {
f(t)
});
s[u].gui.children().remove();
r.appendToContentPane(s[u].gui)
}
if (isDefined(o)) {
i = s[o].gui;
f(o)
}
};
var f = function (e) {
i.hide();
r.showLoader();
r.activateTab(e);
if (!isDefined(s[e])) {
return
}
if (s[e].title !== "") {
r.setTitle("tw-db.info " + s[e].title)
} else {
r.setTitle("")
}
i = s[e].gui;
i.show();
w.setTimeout(s[e].callback, 10)
};
t.addTab = function (t, n, r, i) {
s[t] = {title: r, name: n, callback: i, gui: null};
s[t].gui = e('').hide();
return s[t].gui
};
t.hideLoader = function () {
r.hideLoader()
};
return t
}($);
Debugger.Window = Window;
var Support = function (e) {
var t = {};
var n = "twdb_support";
var r = {};
t.addKey = function (e, t) {
r[e] = t
};
t.open = function () {
var t = e('
Please include the text displayed below in a bug report sent using our contact form and also try to describe how to reproduce this error (what did you do when it occured). Thanks!
');
var i = e('');
var s = "[CODE]";
for (var o in r) {
s += String(o) + "\n";
s += String(r[o]) + "\n";
s += "----------" + "\n"
}
s += "[/CODE]";
i.append((new west.gui.Textarea).setContent(s).setWidth(600).setHeight(250).setReadonly().getMainDiv());
wman.open(n, null).setMiniTitle("tw-db.info Support").setTitle("tw-db.info Support").appendToContentPane(t).appendToContentPane(i)
};
return t
}($);
Debugger.Support = Support;
var Timer = function (e) {
var t = {};
var n = 0;
var r = 0;
var i = 0;
t.getTimeout = function () {
var e = (new Date).getTime();
if (e - n < 2e3) {
r++
} else {
r = 0
}
if (e - n < 6e4) {
i++
} else {
i = 0
}
n = e;
var t = 0;
if (i > 50) {
t = 6e4
}
if (r < 20) {
return t + 200
}
return t + 2e3
};
return t
}($);
Debugger.Timer = Timer;
var Eventer = function (e) {
var t = {};
var n = {};
t.set = function (e, t, r) {
if (!isDefined(n[e])) {
n[e] = {}
}
if (!isDefined(r)) {
var r = false
}
var i = Number((new Date).getTime());
while (n[e][i])i++;
n[e][i] = {id: i, call: t, count: r};
return i
};
t.trigger = function (e) {
if (!isDefined(n[e])) {
return
}
var t = 0;
for (var r in n[e]) {
if (!isDefined(n[e][r].id)) {
continue
}
w.setTimeout(n[e][r].call, 10);
if (n[e][r].count == false) {
t++;
continue
}
n[e][r].count--;
if (n[e][r].count > 0) {
t++;
continue
}
}
if (t == 0) {
delete n[e]
}
};
t.remove = function (e, t) {
if (!isDefined(n[e]) || !isDefined(n[e][t])) {
return false
}
delete n[e][t]
};
return t
}($);
_base.Eventer = Eventer;
Debugger.Eventer = Eventer;
var Calc = function (e) {
var t = {};
var n = false;
var r = {sets: {}};
var i = {sets: {}, items: {}};
var s = {};
var o = function (e) {
for (set in e) {
var t = e[set];
var n = {};
var i = {}, s = {}, o = {};
var u = 0;
for (level in t.bonus) {
if (!t.bonus.hasOwnProperty(level))continue;
n[level] = {jobs: {}, attributes: [], skills: []};
if (u > 0) {
for (var a = parseInt(u, 10) + 1; a <= level; ++a) {
n[a] = JSON.parse(JSON.stringify(n[u]))
}
}
for (bonus in t.bonus[level]) {
if (!t.bonus[level].hasOwnProperty(bonus))continue;
var f = t.bonus[level][bonus];
var l = TWDB.ClothCalc._skill2id[f.name];
switch (f.type) {
case"job":
if (!isDefined(n[level]["jobs"][f.job]))n[level]["jobs"][f.job] = 0;
n[level]["jobs"][f.job] += f.value;
break;
case"attribute":
if (!isDefined(i[l]))i[l] = 0;
i[l] += f.value;
n[level]["attributes"][l] = i[l];
for (iT = 0; iT < TWDB.ClothCalc._sk4attr[f.name].length; iT++) {
var c = TWDB.ClothCalc._sk4attr[f.name][iT];
if (!isDefined(s[c]))s[c] = 0;
s[c] += f.value;
n[level]["skills"][c] = s[c]
}
break;
case"skill":
if (!isDefined(s[l]))s[l] = 0;
s[l] += f.value;
n[level]["skills"][l] = s[l];
break;
case"character":
if (f.bonus && f.key === "level") {
var h = f.roundingMethod;
if (f.bonus.type === "skill") {
var p = TWDB.ClothCalc._skill2id[f.bonus.name];
if (!isDefined(s[p]))s[p] = 0;
s[p] += Math[h](Character.level * f.bonus.value);
n[level]["skills"][p] = s[p]
} else if (f.bonus.type == "attribute") {
for (iT = 0; iT < TWDB.ClothCalc._sk4attr[f.bonus.name].length; iT++) {
var c = TWDB.ClothCalc._sk4attr[f.bonus.name][iT];
if (!isDefined(s[c]))s[c] = 0;
s[c] += Math[h](Character.level * f.bonus.value);
n[level]["skills"][c] = s[c]
}
} else if (f.bonus.type == "job") {
if (!isDefined(n[level]["jobs"][f.bonus.job]))n[level]["jobs"][f.bonus.job] = 0;
n[level]["jobs"][f.bonus.job] += Math[h](Character.level * f.bonus.value)
}
}
break;
default:
break
}
}
u = level
}
r.sets[set] = n
}
return r.sets
};
var u = function () {
if (s.ready) {
return
}
Worker.add(function () {
return function () {
r = o(west.storage.ItemSetManager._setList);
s.ready = true;
n = true
}
}())
};
s = Loader.add("Calc", "tw-db Calculator", u, {});
t.getCcCache = function () {
return i
};
t.getSetCache = function () {
return r
};
t.getSetBonusForJob = function (e, t, n) {
if (isDefined(i.sets[e]) && isDefined(i.sets[e][t]) && isDefined(i.sets[e][t][n])) {
return i.sets[e][t][n]
}
try {
return a(e, t, n)
} catch (r) {
Error.report(r, "calcSetBonusForJob (" + e + " " + t + " " + n + ")")
}
return 0
};
t.getItemBonusForJob = function (e, t) {
try {
if (isDefined(i) && isDefined(i.items) && isDefined(i.items[e]) && isDefined(i.items[e][t])) {
return i.items[e][t]
}
return f(e, t)
} catch (n) {
Error.report(n, "calcItemBonusForJob (" + e + " " + t + ")")
}
return 0
};
t.isCached = function (e, t) {
if (isDefined(i.items[e]) && isDefined(i.items[e][t])) {
return true
} else {
return false
}
};
var a = function (e, t, n) {
if (!isDefined(r[e])) {
console.log({message: "unknown set " + e}, "calcSetBonusForJob");
return 0
}
if (!isDefined(r[e][t])) {
return 0
}
var s = r[e][t];
var o = Jobs.getJobById(n);
if (!o) {
return 0
}
var u = 0;
if (isDefined(s.jobs["all"])) {
u += s.jobs["all"]
}
if (isDefined(s.jobs[n])) {
u += s.jobs[n]
}
for (var a in o.skills) {
var f = o.skills[a];
if (isDefined(s.skills[TWDB.ClothCalc._skill2id[a]])) {
u += s.skills[TWDB.ClothCalc._skill2id[a]] * f
}
}
if (!isDefined(i.sets[e])) {
i.sets[e] = {}
}
if (!isDefined(i.sets[e][t])) {
i.sets[e][t] = {}
}
i.sets[e][t][n] = u;
return u
};
var f = function (e, t) {
var n = ItemManager.get(e);
if (!n) {
return 0
}
var r = Jobs.getJobById(t);
if (!r) {
return 0
}
var s = n.getValue(r.skills, t);
if (!isDefined(i.items[e])) {
i.items[e] = {}
}
i.items[e][t] = s;
return s
};
return t
}($);
_base.Calc = Calc;
Debugger.Calc = Calc;
var Importer = function (e) {
var t = {};
var n = {};
t.div = null;
var r = function () {
if (n.ready) {
return
}
t.div = Window.addTab("importer", "Importer", "", function () {
i()
});
n.ready = true
};
n = Loader.add("Importer", "tw-db Importersystem", r, {Window: true});
var i = function () {
t.div.children().remove();
Window.hideLoader();
e.getScript(Script.protocol + "://" + Script.url + "/cache/js/sDoImport_" + Script.lang + ".js")
};
return t
}($);
_base.Importer = Importer;
Debugger.Importer = Importer;
var Settings = function (e) {
var t = {};
var n = {};
var r = null;
var i = {};
var s = function () {
if (i.ready) {
return
}
var e = Cache.load("settings");
if (typeof e === "object" && e !== null) {
n = e
} else {
n = {}
}
TWDB.Util.addCss("span.twdb_sett_capt { font-size: 115%; font-weight: bold; font-style: italic; display: inline-block; margin-top: 8px; text-shadow: 2px 1px 2px #643; }");
r = Window.addTab("settings", "setări", "setări", o);
i.ready = true
};
i = Loader.add("Settings", "tw-db Settingssystem", s, {Cache: true, Window: true});
var o = function () {
r.children().remove();
var i = new west.gui.Scrollpane;
e(i.getMainDiv()).css("height", "300px");
r.append(i.getMainDiv());
var s = [[9, "", "Inventar", false], [0, "jobBoniTooltip", "arată informaţii despre punctele de muncă în fereastra inventarului pentru munca selectată", false], [0, "collector", "marchează obiectele de la negustor şi piaţă pe care nu le ai", false], [0, "buyTip", "arată opţiunea de cumpărare la negustor", false], [0, "sellTip", "arată opţiunea de vânzare în fereastra inventarului", false], [0, "sellTip1", "Vinde obiectele care le deții de mai multe ori", "Setări pentru sfaturi de vânzare"], [0, "sellTip2", "Vinde obiectele care nu le folosești la nicio muncă", "Setări pentru sfaturi de vânzare"], [0, "sellTip3", "Nu vindeți niciodată obiectele cu aură! ", "Setări pentru sfaturi de vânzare"], [0, "sellTip4", "Nu vindeți niciodată obiectele care pot fi obținute doar muncind", "Setări pentru sfaturi de vânzare"], [0, "sellTip5", "Nu vindeți obiecte ce fac parte dintr-un set. ", "Setări pentru sfaturi de vânzare"], [0, "pinitems", "Activează fixarea obiectelor în secțiunea "Utilizat recent" din Inventar", false], [0, "collectorsell", "Adaugă un buton la negustorul ambulant care vinde toate obiectele (excepție un obiect) din cele selectate", false], [9, "", "Misiuni", false], [0, "questwiki", "Include tw-db și ClothCalc in fereastra pentru misiuni ", false], [0, "questcancle", "Când anulaţi o misiune veţi primi o întrebare dacă într-adevăr vrei să faceţi asta", false], [0, "qbswitch", "Activează comutarea între introducerea şi completarea textului în cartea de misiuni", false], [0, "qfulltext", "Afişează întotdeauna tot textul misiunii", false], [9, "", "Piaţă", false], [0, "marketmap", "Foloseşte harta pieţei", false], [0, "marketreminder", "Adaugă un memento pentru licitaţiile de la piata", false], [0, "marketselldialog", "Îmbunătăţeşte caseta de dialog al vânzării pe piaţă", false], [9, "", "Munci", false], [0, "jobwin_ccbutton", "Adaugă ClothCalc la fereastra muncii", false], [0, "jobwin_showlp", "Arată punctele de muncă în fereastra muncii", false], [9, "", "Listă cu sarcini", false], [0, "tasklistpoints", "Arată indicaţii despre punctele de muncă in lista de comenzi", false], [9, "", "GUI", false], [0, "duelmotivation", "Adaugă un indicator pentru motivaţia de duel", false], [0, "directsleep", "Afişează un buton care te trimite direct la hotel sau cazarmă", false], [0, "deposit", "Adauga un buton pentru depozitarea banilor la bancă", false], [0, "noshopsale", "Dezactivează notificarea pentru reducerile din magazin", false], [0, "expbarvalues", "Arată valorile pe bara de experienţă; Credite & mulţumiri Leones/Slygoxx", false], [0, "mini_chatgui", "Permite ca interfața chat-ului să fie minimizată", false], [0, "customcounterpos", "Repoziționați contoarele de evenimente (ouă, inimi, artificii, etc.) pe ecrane late", false], [0, "noscrollbars", "Dezactiveză barele de derulare pe ecrane mici sau când mişti ferestrele prea departe", false], [9, "", "Mini-hartă", false], [0, "showbonusjobs", "Arată muncile bonus pe hartă", false], [0, "showscrollto", "Adaugă o listă pentru a coordona câmpul de introducere din mini-hartă", false], [9, "", "Fort", false], [0, "fortrecruitment", "Arată prezentarea generală a recrutării la fort", false], [0, "enhancedfortrecruitment", "Arată jucătorii de lângă fort", false], [9, "", "Diverse", false], [0, "chat", "foloseşte chatul intensiv", false], [0, "notes", "Folosește Notițele. ", false], [0, "forumlastpage", "Adaugă un buton pe forum pentru a te direcţiona la ultima postare", false], [0, "fastskillchange", "Activează schimbarea rapidă de indemanari (Țineți apăsat click stânga pe mouse) ", false], [0, "autodeposit", "Primeşte un mesaj pentru a depozita banii dacă ajungi în oraş", false], [0, "chestanalyser", "Creează o statistică pentru cuferele deschise", false], [0, "weeklycrafting", "Fi anunțat când expiră perioada de așteptare a meseriilor.", false], [0, "noworkqueuepa", "Scoate sfaturile pentru optiunea de Automatizare (CP)", "Setări premium"], [0, "nofetchallpa", "Dezactivați solicitarea premium când preluaţi toate obiectele de pe piață", "Setări premium"], [0, "nowofnuggets", "Nu utilizați pepite ca plată implicită pentru evenimente (dacă este disponibil)", "Setări premium"], [0, "instanthotel", "Add a hotel button to town signs", false], [0, "telegramsource", "Adaugă un buton pentru comutarea textului neformatat din telegrame", false], [8, "clothPos"], [0, "wear_openmin", "Deschide fereastra cu echipament minimizată la deschiderea ClothCalc", false]];
var o = {};
var a = e("
");
var f = {};
for (var l = 0; l < s.length; l++) {
var c = s[l][1];
o[c] = t.get(c);
var h = e("
");
if (s[l][0] === 9) {
h.append(e('
').append(e('').text((s[l][2] + "").twdb_twiceHTMLUnescape())));
a.append(h);
continue
}
if (s[l][0] === 8) {
h.addClass("placeholder_" + s[l][1]);
a.append(h);
continue
}
switch (s[l][0]) {
case 0:
var p = function (e) {
return function () {
o[e] = !o[e]
}
}(c);
var d = new west.gui.Checkbox("", !o[c] ? "" : "tw2gui_checkbox_checked", p);
h.append(e('
').append(d.getMainDiv()));
break
}
h.append(e("
").text((s[l][2] + "").twdb_twiceHTMLUnescape()));
if (s[l][3]) {
var v = s[l][3];
if (!isDefined(f[v])) {
f[v] = e("
"));
var g = new west.gui.Button("Salvează", function () {
switch (m.getValue()) {
case"left":
n["clothPos"] = "left";
break;
case"right":
n["clothPos"] = "right";
break;
default:
n["clothPos"] = "custom";
break
}
u(o)
});
var y = e('').append(e('').click(function () {
Cache.reset()
}));
i.appendContent(a);
r.append(g.getMainDiv()).append(y);
Window.hideLoader()
};
t.get = function (e, r) {
if (!isDefined(n[e])) {
t.set(e, r);
return r
}
return n[e]
};
t.set = function (e, t) {
n[e] = t;
Cache.save("settings", n)
};
var u = function (e) {
for (var t in e) {
n[t] = e[t]
}
if (Cache.save("settings", n)) {
(new UserMessage("Salvat cu succes", UserMessage.TYPE_SUCCESS)).show()
} else {
(new UserMessage("?save_error", UserMessage.TYPE_ERROR)).show()
}
};
return t
}($);
_base.Settings = Settings;
Debugger.Settings = Settings;
var JobWindowCC = function (e) {
var t = {};
var n = {};
var r = function () {
if (n.ready) {
return
}
if (Settings.get("jobwin_ccbutton", true)) {
i()
}
if (Settings.get("jobwin_showlp", true)) {
s()
}
n.ready = true
};
var i = function () {
try {
JobWindow.prototype.__twdb__getBestWearButton = JobWindow.prototype.__twdb__getBestWearButton || JobWindow.prototype.getBestWearButton;
JobWindow.prototype.getBestWearButton = function () {
var t = JobWindow.prototype.__twdb__getBestWearButton.apply(this, arguments);
var n = this;
return t.append(e('
').click(function (e) {
e.stopImmediatePropagation();
TWDB.ClothCalc.open(n.job.id, "job")
}))
};
var t = "div.job_bestwearbutton {left: 15px!important; width: 210px;}\n" + "div.twdb_bestwear {background: url('" + TWDB.images.bestwear + "') no-repeat top; " + "height: 55px; width: 55px; position: relative; left: 195px; top: -15px;}\n" + "div.job_bestwearbutton:hover .twdb_bestwear {background-position: bottom;}";
TWDB.Util.addCss(t, "bestwear")
} catch (n) {
Error.report(n, "manipulate JobWindow.prototype.getBestWearButton")
}
};
var s = function () {
try {
JobWindow.prototype.__twdb__initView = JobWindow.prototype.__twdb__initView || JobWindow.prototype.initView;
JobWindow.prototype.initView = function () {
var t = JobWindow.prototype.__twdb__initView.apply(this, arguments);
var n = " (" + (this.currSkillpoints - this.job.workpoints) + " PM)";
e("div.tw2gui_inner_window_title > .textart_title", this.window.divMain).append(n);
return t
}
} catch (t) {
Error.report(t, "manipulate JobWindow.prototype.initView")
}
};
n = Loader.add("JobWindowCC", "tw-db Job window", r, {Settings: true, ClothCalc: true});
return t
}($);
var Tools = function (e) {
var t = {};
var n = {};
var r;
var i = function () {
if (n.ready) {
return
}
r = Window.addTab("tools", "Tools", "", function () {
s()
});
n.ready = true
};
n = Loader.add("Tools", "tw-db Toolsystem", i, {Window: true});
var s = function () {
r.children().remove();
(new west.gui.Button("open Tool", function () {
w.open("https://" + Script.url + "/?strana=politic_map&world=" + location.hostname.split(".")[0])
})).appendTo(r);
var t = new west.gui.Button;
t.setCaption("Alliance Import".escapeHTML()).click(function () {
t.disable();
e.getScript(Script.protocol + "://" + Script.url + "/js/sDoAllianceImport.js")
}).appendTo(r);
Window.hideLoader()
};
return t
}($);
Debugger.Tools = Tools;
var Updater = function (e) {
var t = {};
var n = {};
var r;
var i = false;
var s = function () {
if (n.ready) {
return
}
r = Window.addTab("notes", "Release Notes", "Release Notes", function () {
u()
});
if (Cache.load("version") && Script.version + " " + Script.revision !== Cache.load("version")) {
Cache.save("version", Script.version + " " + Script.revision);
i = true;
var e = "Scriptul a fost updatat";
var t = '
Script-ul =1= a fost actualizat. Vrei să vezi ce s-a modificat?
';
t = t.replace("=1=", "" + Script.name + "");
(new west.gui.Dialog(e, t, west.gui.Dialog.SYS_WARNING)).addButton("no").addButton("yes", function () {
Window.open("notes")
}).show()
}
n.ready = true
};
n = Loader.add("Updater", "tw-db Updater", s, {Cache: true, Window: true});
var o = function (t, n) {
var r = "Scriptul are nevoie de update";
var i = '
Pentru script =1= este o nouă versiune disponibilă, va rog apăsaţi OK pentru a actualiza scriptul
';
i = i.replace("=1=", "" + Script.name + "");
i += "
current version: " + Script.version / 100 + " revision " + Script.revision + " new version: " + t / 100 + " revision " + n + "
";
var s = Script.protocol + "://" + Script.update;
if (e.browser.webkit) {
s += "?" + Script.version + Script.revision
}
var o = function () {
try {
location.href = s
} catch (e) {
}
(new west.gui.Dialog(Script.name, "Vă rugăm reîncărcaţi fereastra după instalare.", west.gui.Dialog.SYS_WARNING)).setModal(true, false, true).show()
};
(new west.gui.Dialog(r, i, west.gui.Dialog.SYS_WARNING)).addButton("Nu acum").addButton("ok", o).show()
};
t.wasUpdated = function () {
return i
};
var u = function () {
r.children().remove();
var t = new west.gui.Scrollpane;
e(t.getMainDiv()).css("height", "335px");
var n = false;
for (var i = 0; i < Script.notes.length; i++) {
var s = e("
").css("border-bottom", "1px solid black").click(function () {
e(this).next().toggle()
});
var o = e("
" + Script.notes[i].notes + "
");
t.appendContent(s).appendContent(o);
if (n) {
o.hide()
}
n = true
}
r.append(t.getMainDiv());
Window.hideLoader()
};
t.query = function () {
setTimeout(function () {
e.getScript(Script.protocol + "://" + Script.check + "?" + (new Date).getTime())
}, 500)
};
t.check = function (e, t, n) {
if (Script.version !== e || Script.revision !== t) {
o(e, t)
}
};
return t
}($);
_base.Updater = Updater;
Debugger.Updater = Updater;
var Sleep = function (e) {
var t = {};
var n = null;
var r = [];
var i = [];
var s = {};
var o = 1;
var u = false;
var a = {};
var f = function () {
if (a.ready) {
return
}
if (Settings.get("directsleep", true)) {
var e = "ul.tw2gui_selectbox_content.twdb_sleepmenu {max-width: 320px!important; white-space: nowrap; overflow-y: auto; overflow-x: hidden;}" + "ul.tw2gui_selectbox_content.twdb_sleepmenu > div.tw2gui_scrollpane {width: 320px!important}" + "ul.tw2gui_selectbox_content.twdb_sleepmenu > li {padding-right: 20px!important;}";
TWDB.Util.addCss(e);
s = Cache.load("barracks");
if (s == null || typeof s !== "object") {
s = {}
}
if (Character.homeTown.town_id !== 0) {
l();
d()
}
}
a.ready = true
};
a = Loader.add("Sleep", "tw-db DirectSleep", f, {Cache: true, Settings: true});
var l = function () {
n = GameInject.CharacterButton.add(Images.buttonSleep);
n.addMousePopup("Somn").click(function (e) {
if (w.Character.homeTown.town_id !== 0 && r.length == 0) {
h()
} else {
c(e)
}
})
};
var c = function (t) {
if (r.length == 0) {
return
}
var n = Map.getLastPosition();
n.x = n[0];
n.y = n[1];
for (var i = 0; i < r.length; i++) {
r[i].distance = w.Map.calcWayTime(n, r[i])
}
r.sort(function (e, t) {
return e.distance == t.distance ? 0 : e.distance > t.distance ? 1 : -1
});
var s = (new west.gui.Selectbox(true)).addListener(function (e) {
switch (e) {
case 0:
h();
break;
default:
p(e);
break
}
}).addItem(0, "Hotel " + w.Map.calcWayTime(n, w.Character.homeTown).formatDuration());
for (var i = 0; i < r.length; i++) {
if (r[i].stage !== 0) {
s.addItem(r[i].id, "Etapă " + r[i].stage + " " + r[i].distance.formatDuration() + " | " + r[i].name)
}
}
e(s.elContent).addClass("twdb_sleepmenu");
s.show(t)
};
var h = function () {
Ajax.remoteCallMode("building_hotel", "get_data", {town_id: w.Character.homeTown.town_id}, function (e) {
if (e.error) {
(new UserMessage(e.error, UserMessage.TYPE_ERROR)).show();
return
}
var t = "";
for (var n in e.rooms) {
if (e.rooms[n].available) {
t = n
}
}
w.TaskQueue.add(new TaskSleep(w.Character.homeTown.town_id, t))
})
};
var p = function (e) {
if (isDefined(s[e])) {
w.TaskQueue.add(new TaskFortSleep(e, s[e].x, s[e].y))
}
};
var d = function () {
if (w.Character.homeTown.alliance_id == 0) {
return
}
Ajax.remoteCallMode("alliance", "get_data", {alliance_id: w.Character.homeTown.alliance_id}, function (e) {
if (e.error) {
(new UserMessage(e.error, UserMessage.TYPE_ERROR)).show();
return
}
i = e.data.forts;
if (i.length > 0) {
w.setTimeout(function () {
v()
}, Timer.getTimeout())
}
})
};
var v = function () {
try {
if (i.length <= 0) {
return
}
var t = i.pop();
var n = t.fort_id;
if (!isDefined(s[n])) {
s[n] = {time: 0, stage: 0}
}
e.extend(s[n], {id: n, x: t.x, y: t.y, name: t.name, type: t.type});
if (s[n].stage !== 5 && s[n].time + o * 86400 > (new Date).getTime() / 1e3) {
r.push(s[n]);
if (i.length > 0) {
w.setTimeout(function () {
v()
}, Timer.getTimeout())
} else {
Cache.save("barracks", s)
}
return
}
Ajax.remoteCallMode("fort_building_barracks", "index", {fort_id: n}, function (e) {
if (e.error) {
(new UserMessage(e.error, UserMessage.TYPE_ERROR)).show()
} else {
s[n].time = Number((new Date).getTime() / 1e3).round(0);
if (isDefined(e.barrackStage)) {
s[n].stage = e.barrackStage
}
}
r.push(s[n]);
if (i.length > 0) {
w.setTimeout(function () {
v()
}, Timer.getTimeout())
} else {
Cache.save("barracks", s)
}
})
} catch (u) {
Error.report(u, "getFortData")
}
};
return t
}($);
Debugger.Sleep = Sleep;
var Analyser = function ($) {
var _self = {};
var ready = false;
var statistic = null;
var backup = null;
var locked = false;
var reports = [];
var failedReports = [];
var lastPage = 0;
var gui = {};
var sorting = {};
_self.extra = false;
var loader = {};
var init = function () {
if (loader.ready) {
return
}
TWDB.Util.addCss(".messages-analyser-job .item img.tw_item { width: 30px; height: 27px; }" + ".messages-analyser-job .item .count { bottom: -4px; }" + ".messages-analyser-job .item span.usable { display: none; }" + "div.tw2gui_window .messages-analyser-job div.fancytable .row > div { display: none; vertical-align: top; }" + ".messages-analyser-job.view-rewards div.fancytable .row > div.view-rewards { display: inline-block; }" + ".messages-analyser-job.view-items div.fancytable .row > div.view-items { display: inline-block; }" + "div.tw2gui_window .messages-analyser-job div.fancytable div.trows div.tbody div.row { height: auto; }");
var e = Cache.load("statistic");
if (typeof e == "object" && e !== null) {
statistic = e
} else {
reset("all", true)
}
if (!statistic.ver) {
reset("all", true)
}
switch (statistic.ver) {
case 1:
reset("job", true, 1);
reset("duel", true, 1);
statistic.ver = 2;
case 2:
reset("job", true, 1);
reset("duel", true, 1);
statistic.ver = 3;
case 3:
reset("chest", true, 1);
statistic.ver = 4
}
backup = $.extend(true, {}, statistic);
GameInject.addTabOnMessagesWindow("Analizator de munci", "analyser-job", function () {
show("job")
});
if (Settings.get("chestanalyser", true)) {
GameInject.ItemUse(Chest.add);
GameInject.addTabOnMessagesWindow("Analizator de cufere", "analyser-chest", function () {
Chest.show()
})
}
loader.ready = true
};
loader = Loader.add("Analyser", "tw-db Job-Analyser", init, {Cache: true, Settings: true, Jobs: true});
_self.restore = function () {
statistic = $.extend(true, {}, backup)
};
_self.debug = function () {
console.log(statistic);
console.log(sorting)
};
var reset = function (e, t, n) {
if (t == true) {
if (!n) {
var n = 0
} else {
var r = /\[report=([0-9]+)([A-Fa-f0-9]{10})\]/;
var i = String(n).match(r);
if (i) {
var n = i[1]
}
}
if (isNaN(parseInt(n, 10))) {
var s = 0
} else {
var s = parseInt(n, 10) - 1
}
switch (e) {
case"job":
statistic[e] = {last: s, items: {last: 0}};
break;
case"duel":
statistic[e] = {last: s};
break;
case"chest":
statistic[e] = {};
break;
case"all":
statistic = {ver: 4};
reset("job", true, s + 1);
reset("duel", true, s + 1);
reset("chest", true, s + 1);
break
}
} else {
var o = $('
Do you really want to reset the ReportAnalyser statistics?
Give Report-Link of first Report which should be read after Reset
');
var u = (new west.gui.Textfield("twdb_analyser_last")).setSize(40);
u.setLabel("Report-Link:");
o.append(u.getMainDiv());
var a = new west.gui.Checkbox("or use all reports ");
var f = new west.gui.Checkbox("or use only future reports");
a.setCallback(function (e) {
if (e) {
f.setSelected(false);
u.setValue("")
}
});
f.setCallback(function (e) {
if (e) {
a.setSelected(false);
u.setValue("")
}
});
$(u.getMainDiv()).find("span").css("font-size", "12px");
$(u.getMainDiv()).find("input").keyup(function () {
a.setSelected(false);
f.setSelected(false)
});
o.append($('').append(a.getMainDiv()).append(f.getMainDiv()));
var l = new west.gui.Dialog("ReportAnalyser - Resetare", o);
l.addButton("ok", function () {
if (a.isSelected()) {
reset(e, true)
} else if (f.isSelected()) {
reset(e, true, statistic[e].last + 1)
} else {
reset(e, true, u.getValue())
}
l.hide();
MessagesWindow.open("analyser-" + e)
});
l.addButton("cancel");
l.show()
}
};
var Chest = function (e) {
var t = {};
t.add = function (e, t) {
var n = false;
for (i = 0; i < t.msg.effects.length; i += 1) {
var r = t.msg.effects[i];
if (r.type == "lottery" || r.type == "content") {
if (!isDefined(statistic.chest[e])) {
statistic.chest[e] = {count: 0, items: {}}
}
var s = statistic.chest[e];
if (!n) {
s.count++;
n = true
}
r.items.each(function (e) {
if (!isDefined(s.items[e.item_id])) {
s.items[e.item_id] = 0
}
s.items[e.item_id] += e.count
})
}
}
Cache.save("statistic", statistic)
};
t.show = function () {
if (!MessagesWindow.window) {
return
}
var t = e(MessagesWindow.window.getContentPane()).find(".messages-analyser-chest");
MessagesWindow.window.showLoader();
t.children().remove();
var n = new west.gui.Scrollpane;
e(n.getMainDiv()).css("height", "385px");
t.append(n.getMainDiv());
for (var r in statistic.chest) {
var i = statistic.chest[r];
var s = (new tw2widget.Item(ItemManager.get(r), "item_inventory")).setCount(i.count);
s.getImgEl().addClass("item_inventory_img");
n.appendContent(e('').append(s.getMainDiv()));
var o = 0;
var u = e('');
for (var a in i.items) {
o++;
var s = (new tw2widget.Item(ItemManager.get(a), "item_inventory")).setCount(i.items[a]);
s.getImgEl().addClass("item_inventory_img");
u.append(s.getMainDiv())
}
u.css("height", (parseInt(o / 10, 10) + 1) * 61 + "px");
n.appendContent('');
n.appendContent(u);
n.appendContent('')
}
MessagesWindow.window.hideLoader()
};
return t
}($);
var analyse = function (e) {
if (locked) {
return
}
locked = true;
reports = [];
queryReports(e)
};
var queryReports = function (e, t) {
if (!t) {
t = 1
}
lastPage = t;
Ajax.remoteCall("reports", "get_reports", {page: t, folder: e}, function (t) {
readReports(e, t)
})
};
var readReports = function (e, t) {
var n = true;
if (typeof t.reports !== "object") {
t.reports = [];
n = false
}
if (typeof t.page == "undefined" || lastPage !== t.page) {
t.reports = [];
n = false
}
for (var r = 0; r < t.reports.length; r++) {
var i = t.reports[r];
if (i.report_id <= statistic[e].last) {
n = false;
break
}
reports.push({id: i.report_id, hash: i.hash, type: e})
}
gui.bar.setMaxValue(reports.length);
if (n) {
window.setTimeout(function () {
queryReports(e, lastPage + 1)
}, Timer.getTimeout())
} else {
analyseReports(e)
}
};
var analyseReports = function (e) {
if (reports.length > 0) {
gui.bar.setValue(gui.bar.getValue() + 1);
queryReport(reports.pop())
} else {
Cache.save("statistic", statistic);
locked = false;
show(e, true)
}
};
var queryReport = function (e) {
$.post("game.php?window=reports&mode=show_report", {
flash: null,
hash: e.hash,
report_id: e.id
}, function (t) {
readReport(e.type, t)
}, "json")
};
var readReport = function (e, t) {
if (!t || !t.report_id || !t.publishHash) {
(new UserMessage("empty Server Response", UserMessage.TYPE_ERROR)).show();
return false
}
if (typeof t.page !== "string" || typeof t.title !== "string" || typeof t.js !== "string") {
failedReports.push(t.report_id)
} else {
switch (e) {
case"job":
analyseJobReport(t);
break;
case"duel":
analyseDuelReport(t);
break
}
statistic[e].last = t.report_id
}
window.setTimeout(function () {
analyseReports(e)
}, Timer.getTimeout())
};
var analyseDuelReport = function (e) {
};
var analyseJobReport = function (json) {
try {
data = {
id: null,
hash: null,
job: null,
motivation: null,
duration: null,
wage: null,
bond: null,
experience: null,
injury: 0,
killed: false,
date_received: null,
items: {}
};
data.id = json.report_id;
data.hash = json.publishHash;
var job = Jobs.getJobByName(json.title.slice(json.title.indexOf(":") + 1));
if (!job) {
failedReports.push(data.id);
return false
}
data.job = job.id;
data.date_received = json.date_received;
var tmp = $(json.page);
tmp.find(".rp_row_jobdata").each(function (index) {
var str = $.trim($(this).children("span:last-child").html());
str = str.split(" ").join(" ");
switch (index) {
case 0:
data.motivation = parseInt(str.slice(0, str.indexOf(" ")), 10);
break;
case 1:
var tmp = str.replace("h", " * 3600 + ");
tmp = tmp.replace("m", " * 60 + ");
tmp = tmp.replace("s", " * 1 + ");
tmp += "0";
try {
data.duration = parseInt(eval(tmp), 10)
} catch (e) {
throw{message: "unrecognized time on report: " + str}
}
break;
case 2:
data.wage = parseInt(str.slice(str.indexOf(" ") + 1), 10);
break;
case 3:
data.bond = parseInt(str, 10);
break;
case 4:
data.experience = parseInt(str.slice(0, str.indexOf(" ")), 10);
break
}
});
tmp.find(".rp_hurtmessage_text").each(function () {
var e = new RegExp("[0-9]+");
data.injury = Number(e.exec($(this).html()))
});
tmp.find(".rp_row_killmessage").each(function () {
data.killed = true
});
var tmp = json.js.split(";");
$(tmp).each(function () {
var e = new RegExp(/\s*ItemManager\.get\(([0-9]+)\)\s*\)\.setCount\(([0-9]+)\)/m);
var t = e.exec(this);
if (t) {
data.items[Number(t[1])] = Number(t[2])
}
});
if (!statistic.job[data.job]) {
statistic.job[data.job] = {count: 0, products: {}}
}
var jobstats = statistic.job[data.job];
jobstats.count++;
if (!jobstats[data.motivation]) {
jobstats[data.motivation] = {
count: 0,
duration: 0,
wage: 0,
bond: 0,
experience: 0,
injury: {},
killed: 0,
items: {},
extraitems: {}
}
}
var stats = jobstats[data.motivation];
if (!isDefined(stats.duration)) {
stats.duration = 0
}
stats.count++;
stats.duration += data.duration;
stats.wage += data.wage;
stats.bond += data.bond;
stats.experience += data.experience;
if (!stats.injury[data.injury]) {
stats.injury[data.injury] = 0
}
stats.injury[data.injury]++;
if (data.killed) {
stats.killed++
}
for (var key in data.items) {
var id = Number(key);
var geronimoID = TWDB.Util.isNewIDsystem() ? 138e3 : 138;
if (id === geronimoID) {
if (!isDefined(statistic.extra)) {
statistic.extra = {count: 0};
_self.extra = true
}
statistic.extra.count++;
statistic.extra[statistic.extra.count] = data
}
var count = data.items[id];
var item = ItemManager.get(id);
if (Jobs.isProduct(id) !== -1) {
if (!jobstats.products[id]) {
jobstats.products[id] = {last: 0}
}
var tmp = jobstats.products[id];
for (var i = 0; i < count; i++) {
var last = jobstats.count - tmp.last;
tmp.last = jobstats.count;
if (!tmp[last]) {
tmp[last] = 0
}
tmp[last]++
}
} else if (item.price == 0) {
if (!stats.extraitems[id]) {
stats.extraitems[id] = 0
}
stats.extraitems[id]++
} else {
luck = true;
if (!stats.items[id]) {
stats.items[id] = 0
}
stats.items[id]++
}
}
} catch (e) {
failedReports.push(data.id);
return false
}
};
var show = function (e, t) {
if (!MessagesWindow.window) {
return
}
gui.window = $(MessagesWindow.window.getContentPane()).find(".messages-analyser-" + e);
if (typeof t == "undefined") {
MessagesWindow.window.showLoader();
gui.bar = new west.gui.Progressbar(0, reports.length);
gui.window.children().remove();
gui.window.append(gui.bar.getMainDiv());
analyse(e)
} else {
switch (e) {
case"job":
var n = showJobs();
break;
case"duel":
var n = showDuels();
break
}
gui.window.children().remove();
gui.window.append(n);
sort();
switchAvg();
sort();
MessagesWindow.window.hideLoader()
}
};
var sort = function (e) {
try {
if (typeof e != "undefined") {
if (sorting.type == e) {
sorting.ord *= -1
} else {
sorting.ord = 1;
sorting.type = e
}
} else {
var e = sorting.type
}
var t = sorting.ord;
var n = function (n, r) {
var i = $(n).find(".cell_" + e).html();
var s = $(r).find(".cell_" + e).html();
if (Number(i) == i) {
return i * 1 > s * 1 ? t : -t
} else {
return i > s ? t : -t
}
};
gui.rows.sort(n);
for (var r = 0; r < gui.rows.length; r++) {
gui.bodyscroll.appendContent(gui.rows[r])
}
} catch (i) {
Error.report(i, "Analyser sort")
}
};
var switchAvg = function () {
switch (sorting.avg) {
case"avg":
sorting.avg = "sum";
break;
case"sum":
sorting.avg = "avg";
break
}
$(gui.window).find("div.row div").each(function (e) {
var t = $(this).data(String(sorting.avg));
var n = $(this).data(String(sorting.avg) + "-t");
$(this).html(t).attr("title", n)
})
};
var showJobs = function () {
gui.window.addClass("view-rewards");
sorting = {ord: 1, type: 0, avg: "avg"};
var e = $('
' + '' + '' + '' + '' + '
' + '
' + '
' + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + '
' + '' + '' + "" + "
" + "
" + "
" + '
' + '' + '' + "
" + '
' + '' + "
" + "
" + "
");
e.find(".row_head > div").each(function () {
var e = $(this).attr("class").match(/cell_(\d+|reset)/)[1], t = $(this).find("img");
if (e == "reset") {
$(this).click(function () {
reset("job")
})
} else {
$(this).click(function (e) {
return function () {
sort(e)
}
}(e * 1))
}
});
e.find(".row_head").find("img").css("cursor", "pointer");
var t = 0;
var n = {
jobs: 0,
count: 0,
duration: 0,
experience: 0,
wage: 0,
bond: 0,
motivation: 0,
injury: 0,
killed: 0,
products: 0,
items: 0,
luck: 0
};
var r = statistic.job;
var i = $();
gui.rows = [];
for (var s in r) {
var o = Jobs.getJobById(s);
if (!o) {
continue
}
var u = {
count: 0,
duration: 0,
experience: 0,
wage: 0,
bond: 0,
motivation: 0,
injury: 0,
killed: 0,
products: 0,
items: 0,
luck: 0,
all_products: {},
all_items: {}
};
var a = r[s];
u.count = a.count;
var f = 0;
for (var t = 0; t < o.randomyields.length; t++) {
f += o.randomyields[t]
}
if (typeof o.yields.length == "undefined") {
for (var l in o.yields) {
f += o.yields[l].prop
}
}
for (var l in a.products) {
for (var c in a.products[l]) {
if (c == "last") {
continue
}
var h = ItemManager.get(l);
u.products += Number(a.products[l][c]);
u.luck += Number(h.price * a.products[l][c]);
u.all_products[l] = (u.all_products[l] || 0) + a.products[l][c]
}
}
for (var p in a) {
if (p == "count" || p == "products") {
continue
}
var c = a[p];
u.motivation += p * c.count;
u.bond += c.bond;
u.duration += c.duration || 0;
u.experience += c.experience;
for (var d in c.injury) {
u.injury += d * c.injury[d]
}
for (var l in c.items) {
var h = ItemManager.get(l);
u.items += Number(c.items[l]);
u.luck += Number(h.price * c.items[l]);
u.all_items[l] = (u.all_items[l] || 0) + c.items[l]
}
u.killed += c.killed;
u.wage += c.wage
}
var v = $('');
var c = $('');
c.data("sum", o.name);
c.data("sum-t", o.name);
c.data("avg", o.name);
c.data("avg-t", o.name);
v.append(c);
n.jobs++;
var c = $('');
c.data("sum", u.count);
c.data("sum-t", u.count);
c.data("avg", u.count);
c.data("avg-t", u.count);
v.append(c);
n.count += u.count;
var c = $('');
c.data("sum", (u.duration / 3600).round(2));
c.data("sum-t", String((u.duration / 3600).round(2)) + " ore");
c.data("avg", (u.duration / (3600 * u.count)).round(2));
c.data("avg-t", "Ø " + String((u.duration / (3600 * u.count)).round(2)) + " ore");
v.append(c);
n.duration += u.duration;
var c = $('');
c.data("sum", u.experience);
c.data("sum-t", String(u.experience));
c.data("avg", (u.experience / u.count).round(2));
c.data("avg-t", "Ø " + String((u.experience / u.count).round(2)));
v.append(c);
n.experience += u.experience;
var c = $('');
c.data("sum", u.wage);
c.data("sum-t", "$" + String(u.wage));
c.data("avg", (u.wage / u.count).round(2));
c.data("avg-t", "Ø $" + String((u.wage / u.count).round(2)));
v.append(c);
n.wage += u.wage;
var c = $('');
c.data("sum", u.bond);
c.data("sum-t", String(u.bond));
c.data("avg", (u.bond / u.count * 100).round(2));
c.data("avg-t", "Ø " + String((u.bond / u.count * 100).round(2)) + "%");
v.append(c);
n.bond += u.bond;
var c = $('');
c.data("sum", u.motivation);
c.data("sum-t", String(u.motivation) + "%");
c.data("avg", (u.motivation / u.count).round(2));
c.data("avg-t", "Ø " + String((u.motivation / u.count).round(2)) + "%");
v.append(c);
n.motivation += u.motivation;
var c = $('');
c.data("sum", u.injury);
c.data("sum-t", String(u.injury));
c.data("avg", (u.injury / u.count).round(2));
c.data("avg-t", "Ø " + String((u.injury / u.count).round(2)));
v.append(c);
n.injury += u.injury;
var c = $('');
c.data("sum", u.killed);
c.data("sum-t", String(u.killed));
c.data("avg", (u.killed / u.count * 100).round(2));
c.data("avg-t", "Ø " + String((u.killed / u.count * 100).round(2)) + "%");
v.append(c);
n.killed += u.killed;
var c = $('');
c.data("sum", u.products);
c.data("sum-t", String(u.products));
c.data("avg", (u.products / u.count * 100).round(2));
c.data("avg-t", "Ø " + String((u.products / u.count * 100).round(2)) + "% [" + f * 100 + "%]");
v.append(c);
n.products += u.products;
var c = $('');
var m = $.map(u.all_products, function (e, t) {
return (new tw2widget.Item(ItemManager.get(t))).setCount(e).getMainDiv()
});
c.data("sum", m);
c.data("avg", m);
v.append(c);
var c = $('');
c.data("sum", u.items);
c.data("sum-t", String(u.items));
c.data("avg", (u.items / u.count * 100).round(2));
c.data("avg-t", "Ø " + String((u.items / u.count * 100).round(2)) + "%");
v.append(c);
n.items += u.items;
var c = $('');
var m = $.map(u.all_items, function (e, t) {
return (new tw2widget.Item(ItemManager.get(t))).setCount(e).getMainDiv()
});
c.data("sum", m);
c.data("avg", m);
v.append(c);
var c = $('');
c.data("sum", u.luck);
c.data("sum-t", "$" + String(u.luck));
c.data("avg", (u.luck / u.count).round(2));
c.data("avg-t", "Ø $" + String((u.luck / u.count).round(2)));
v.append(c);
n.luck += u.luck;
gui.rows.push(v);
v.click(function () {
detail($(this).children(".cell_0").html())
});
t++
}
gui.bodyscroll = new west.gui.Scrollpane;
$(gui.bodyscroll.getMainDiv()).css("height", "300px");
e.find(".tbody").append(gui.bodyscroll.getMainDiv());
gui.footer = e.find(".row_foot");
var c = $('');
c.data("sum", n.jobs);
c.data("sum-t", n.jobs + " Munci");
c.data("avg", n.jobs);
c.data("avg-t", n.jobs + " Munci");
gui.footer.append(c);
var c = $('');
c.mouseenter(function () {
$(this).css("color", "#888")
}).mouseleave(function () {
$(this).css("color", "#444")
});
c.click(function () {
switchAvg()
});
c.data("sum", "∑");
c.data("sum-t", "schimbă în Ø");
c.data("avg", "Ø");
c.data("avg-t", "schimbă în ∑");
gui.footer.append(c);
var c = $('');
c.data("sum", n.count);
c.data("sum-t", n.count);
c.data("avg", n.count);
c.data("avg-t", n.count);
gui.footer.append(c);
var c = $('');
c.data("sum", (n.duration / 3600).round(2));
c.data("sum-t", String((n.duration / 3600).round(2)) + "ore");
c.data("avg", (n.duration / (3600 * n.count)).round(2));
c.data("avg-t", "Ø " + String((n.duration / (3600 * n.count)).round(2)) + "ore");
gui.footer.append(c);
var c = $('');
c.data("sum", n.experience);
c.data("sum-t", String(n.experience));
c.data("avg", (n.experience / n.count).round(2));
c.data("avg-t", "Ø " + String((n.experience / n.count).round(2)));
gui.footer.append(c);
var c = $('');
c.data("sum", n.wage);
c.data("sum-t", "$" + String(n.wage));
c.data("avg", (n.wage / n.count).round(2));
c.data("avg-t", "Ø $" + String((n.wage / n.count).round(2)));
gui.footer.append(c);
var c = $('');
c.data("sum", n.bond);
c.data("sum-t", String(n.bond));
c.data("avg", (n.bond / n.count * 100).round(2));
c.data("avg-t", "Ø " + String((n.bond / n.count * 100).round(2)) + "%");
gui.footer.append(c);
var c = $('');
c.data("sum", n.motivation);
c.data("sum-t", String(n.motivation) + "%");
c.data("avg", (n.motivation / n.count).round(2));
c.data("avg-t", "Ø " + String((n.motivation / n.count).round(2)) + "%");
gui.footer.append(c);
var c = $('');
c.data("sum", n.injury);
c.data("sum-t", String(n.injury));
c.data("avg", (n.injury / n.count).round(2));
c.data("avg-t", "Ø " + String((n.injury / n.count).round(2)));
gui.footer.append(c);
var c = $('');
c.data("sum", n.killed);
c.data("sum-t", String(n.killed));
c.data("avg", (n.killed / n.count * 100).round(2));
c.data("avg-t", "Ø " + String((n.killed / n.count * 100).round(2)) + "%");
gui.footer.append(c);
var c = $('');
c.data("sum", n.products);
c.data("sum-t", String(n.products));
c.data("avg", (n.products / n.count * 100).round(2));
c.data("avg-t", "Ø " + String((n.products / n.count * 100).round(2)) + "%");
gui.footer.append(c);
var c = $('');
c.data("sum", n.products);
c.data("sum-t", String(n.products));
c.data("avg", (n.products / n.count * 100).round(2));
c.data("avg-t", "Ø " + String((n.products / n.count * 100).round(2)) + "%");
gui.footer.append(c);
var c = $('');
c.data("sum", n.items);
c.data("sum-t", String(n.items));
c.data("avg", (n.items / n.count * 100).round(2));
c.data("avg-t", "Ø " + String((n.items / n.count * 100).round(2)) + "%");
gui.footer.append(c);
var c = $('');
c.data("sum", n.items);
c.data("sum-t", String(n.items));
c.data("avg", (n.items / n.count * 100).round(2));
c.data("avg-t", "Ø " + String((n.items / n.count * 100).round(2)) + "%");
gui.footer.append(c);
var c = $('');
c.data("sum", n.luck);
c.data("sum-t", "$" + String(n.luck));
c.data("avg", (n.luck / n.count).round(2));
c.data("avg-t", "Ø $" + String((n.luck / n.count).round(2)));
gui.footer.append(c);
var i = $('').append($('Schimbă între recompense şi obiecte găsite').css({
marginTop: "-8px",
display: "block",
textAlign: "center"
}).click(function () {
$(".messages-analyser-job").toggleClass("view-rewards view-items")
})).append(e);
return i
};
var detail = function (e) {
};
_self.getExtra = function () {
if (isDefined(statistic.extra)) {
return statistic.extra
}
return null
};
return _self
}($);
Debugger.Analyser = Analyser;
var Notes = function (e) {
var t = {};
var n = null;
var r = {};
var i = function () {
if (r.ready) {
return
}
if (r.ready) {
return
}
if (Settings.get("notes", true)) {
GameInject.addTabOnMessagesWindow("Notițe", "notes", function () {
s()
})
}
r.ready = true
};
r = Loader.add("Notes", "tw-db Notes", i, {Cache: true, Settings: true});
var s = function () {
if (!w.MessagesWindow.window) {
return
}
n = e(w.MessagesWindow.window.getContentPane()).find(".messages-notes");
n.css("width", "680px").css("margin", "0 auto").css("position", "relative").css("top", "0");
a(Cache.load("notes"))
};
var o = function (e) {
Cache.save("notes", e);
(new UserMessage("Salvat cu succes", UserMessage.TYPE_SUCCESS)).show()
};
var u = function (t) {
n.children().remove();
w.MessagesWindow.window.showLoader();
var r = (new west.gui.Textarea).setWidth(660).setHeight(300).setContent(t);
n.append(e('').append((new west.gui.Bbcodes(r)).getMainDiv())).append(r.getMainDiv()).append(e('').append((new west.gui.Button("Salvează".escapeHTML(), function () {
o(r.getContent());
a(r.getContent())
})).getMainDiv()).append((new west.gui.Button("Previzualizează".escapeHTML(), function () {
a(r.getContent())
})).getMainDiv()));
w.MessagesWindow.window.hideLoader()
};
var a = function (t) {
n.children().remove();
var r = new west.gui.Scrollpane;
e(r.getMainDiv()).css("height", "324px");
e(r.getMainDiv()).find(".tw2gui_scrollpane_clipper_contentpane").addClass("selectable");
n.append(e('').append(r.getMainDiv())).append(e('').append((new west.gui.Button("Salvează".escapeHTML(), function () {
o(t)
})).getMainDiv()).append((new west.gui.Button("editează".escapeHTML(), function () {
u(t)
})).getMainDiv()));
if (t) {
w.MessagesWindow.window.showLoader();
Ajax.remoteCall("settings", "get_parsed_text", {text: t}, function (e) {
r.appendContent(w.Game.TextHandler.parse(e.parsed_text));
w.MessagesWindow.window.hideLoader()
})
}
};
return t
}($);
Debugger.Notes = Notes;
var Map = function (e) {
var t = {};
var n = false;
var r = 181;
var i = 79;
var s = 0;
var o = 0;
var u = {};
var a = {};
var f = null;
var l = null;
var c = {};
var h = function () {
if (c.ready) {
return
}
if (Settings.get("showscrollto", true)) {
d()
}
Ajax.get("map", "get_minimap", {}, function (e) {
if (e.error) {
c.failed = true;
return (new UserMessage(e.msg)).show()
}
u = e.job_groups;
c.ready = true
})
};
c = Loader.add("Map", "tw-db Map", h, {Settings: true});
t.getNearestJob = function (e) {
var n = JobList.getJobById(e);
var r = u[n.groupid];
if (!r) {
return []
}
var i = [];
var s = t.getLastPosition();
for (var o = 0; o < r.length; o++) {
var a = r[o][0] - s[0];
var f = r[o][1] - s[1];
var l = Math.sqrt(a * a + f * f);
var c = window.Map.calcWayTime({x: r[o][0], y: r[o][1]}, {x: s[0], y: s[1]});
var h = Number(Math.atan(f / a) * 180 / Math.PI).round(0);
if (a < 0) {
h -= 180
}
i.push({dist: l, time: c, x: r[o][0], y: r[o][1], angle: h})
}
var p = function (e, t) {
return e.dist * 1 > t.dist * 1 ? 1 : -1
};
i.sort(p);
return i
};
t.getLastPosition = function () {
var e = Character.position.x;
var t = Character.position.y;
var n = TaskQueue.queue;
for (var r = 0; r < n.length; r++) {
var i = n[r].wayData;
if (i.x) {
e = i.x;
t = i.y
}
}
return [e, t]
};
t.setMinimapJob = function (t) {
if (f) {
window.clearInterval(l);
window.clearInterval(f)
}
var n = function (t) {
if (!MinimapWindow.window || e(MinimapWindow.window.divMain).find(".tw2gui_jobsearch_string").length == 0 || !e(MinimapWindow.window.divMain).find(".tw2gui_jobsearch_string").is(":visible")) {
return
}
window.clearInterval(f);
window.clearInterval(l);
f = null;
l = null;
MinimapWindow.resetSearchContext();
e("input.tw2gui_jobsearch_string", MinimapWindow.DOM).val(t).keyup()
};
l = setInterval(function () {
window.clearInterval(f);
window.clearInterval(l);
f = null;
l = null
}, 3e5);
f = setInterval(function () {
n(t)
}, 200)
};
var p = function (e) {
var n = false;
var u = 0;
var e = [];
var a = s;
var f = o;
for (var a = s; a <= r; a++) {
for (var f = o; f <= i; f++) {
u++;
e.push([a, f]);
if (u > 299) {
n = true;
break
}
}
if (n) {
break
}
o = 0
}
s = a;
o = f + 1;
if (e.length > 0) {
window.Map.Data.Loader.load(e, function () {
setTimeout(function () {
t.loadMap()
}, Timer.getTimeout())
})
}
};
t.loadMap = function () {
p()
};
var d = function () {
var t = "div#mmap_twdb_coords {position: absolute; bottom: 35px; left: 1px; display: block;}\n" + "div#mmap_twdb_coords > img {cursor:pointer; opacity:0.5; position:relative;}";
TWDB.Util.addCss(t, "minimap");
var n = function () {
var t = e('');
var n = new west.gui.Textfield;
var r = new west.gui.Textfield;
var i = "";
var s = "";
n.setWidth(45);
r.setWidth(45).setMaxLength(5);
var o = function () {
var e = Number(n.getValue());
var t = Number(r.getValue());
window.Map.center(e, t);
n.setValue("");
r.setValue("")
};
e(n.getMainDiv()).find("input").keyup(function (t) {
window.setTimeout(function () {
var u;
if (t.ctrlKey && t.keyCode === 86 && !t.altKey) {
u = (new RegExp("^([0-9]{1,5})([^0-9]+)([0-9]{1,5})$")).exec(e.trim(n.getValue()));
if (u) {
n.setValue(u[1]);
r.setValue(u[3]);
e(r.getMainDiv()).find("input").focus();
i = n.getValue();
s = r.getValue();
return
}
u = (new RegExp("^([0-9]{1,5})$")).exec(e.trim(n.getValue()));
if (u) {
n.setValue(u[1]);
e(r.getMainDiv()).find("input").focus();
i = n.getValue();
return
}
n.setValue(i)
}
if (t.keyCode === 13) {
return o()
}
if (String(e.trim(n.getValue())).length === 0) {
i = n.getValue();
return
}
u = (new RegExp("^([0-9]{1,5})$")).exec(e.trim(n.getValue()));
if (u) {
n.setValue(u[1]);
if (String(u[1]).length === 5) {
e(r.getMainDiv()).find("input").focus()
}
i = n.getValue();
return
}
n.setValue(i)
}, 100)
});
e(r.getMainDiv()).find("input").keyup(function (t) {
window.setTimeout(function () {
if (t.ctrlKey && t.keyCode == 86 && !t.altKey) {
var n = (new RegExp("^([0-9]{1,5})$")).exec(e.trim(r.getValue()));
if (n) {
r.setValue(n[1]);
e(r.getMainDiv()).find("input").focus();
s = r.getValue();
return
}
r.setValue(s)
}
if (t.keyCode == 13) {
o();
return
}
if (String(e.trim(r.getValue())).length == 0) {
s = r.getValue();
return
}
var n = (new RegExp("^([0-9]{1,5})$")).exec(e.trim(r.getValue()));
if (n) {
r.setValue(n[1]);
if (String(n[1]).length == 5) {
e(r.getMainDiv()).find("input").focus()
}
s = r.getValue();
return
}
r.setValue(s)
}, 100)
});
var u = (new west.gui.Button("Ok", function () {
o()
}, null, null, "Centrează harta pe coordonatele date ")).setWidth("48");
var a = e('').click(function () {
if (e(this).css("opacity") === 1) {
e(this).css("opacity", "0.5");
window.Map.hideCoords()
} else {
e(this).css("opacity", "1");
window.Map.showCoords()
}
});
t.append(a, n.getMainDiv(), "|", r.getMainDiv(), e(u.getMainDiv()).css("top", "6px"));
e(".minimap-right", MinimapWindow.window.divMain).append(t)
};
GameInject.injectMinimap(function () {
n()
})
};
return t
}($);
_base.Map = Map;
Debugger.Map = Map;
var BonusJobs = function (e) {
var t = {}, n, r = {}, i = {gold: false, silver: false}, s = function () {
if (r.ready) {
return
}
if (!Settings.get("showbonusjobs", true)) {
r.ready = true;
return
}
var e, t, s, a, f, l, c;
n = Cache.load("bonusjobs") || {};
i = Cache.load("bonusdisplay") || {gold: false, silver: false};
for (e in n) {
if (!n.hasOwnProperty(e)) {
continue
}
t = n[e];
s = 0;
for (a in t) {
if (!t.hasOwnProperty(a)) {
continue
}
if (t[a].gold) {
s++;
continue
}
var f = new Date;
var l = new Date;
l.setHours(2);
l.setMinutes(15);
l.setSeconds(0);
l.setMilliseconds(0);
var c = l.getTime();
if (f.getHours() < 2 || f.getHours() == 2 && f.getMinutes() < 15) {
c -= 24 * 60 * 60 * 1e3
}
if (t[a].time > c) {
s++
} else {
delete t[a]
}
}
if (s == 0) {
delete n[e]
}
}
u();
o();
r.ready = true
};
r = Loader.add("BonusJobs", "tw-db BonusJobs", s, {Settings: true, Cache: true, Jobs: true});
var o = function () {
var e = function (e) {
var t = window.Map.Helper.getPosition(e.parent);
if (!isDefined(t) || !isDefined(t.x) || !isDefined(t.y)) {
return
}
if (!isDefined(window.Map.JobHandler.Featured[t.x + "-" + t.y])) {
if (isDefined(n[t.x + "-" + t.y])) {
delete n[t.x + "-" + t.y];
Cache.save("bonusjobs", n)
}
return
}
var r = window.Map.JobHandler.Featured[t.x + "-" + t.y], i;
n[t.x + "-" + t.y] = {};
for (i in r) {
if (!r.hasOwnProperty(i)) {
continue
}
n[t.x + "-" + t.y][i] = r[i];
n[t.x + "-" + t.y][i]["time"] = (new Date).getTime()
}
Cache.save("bonusjobs", n)
};
GameInject.injectRadialmenu(function (t) {
e(t)
})
};
var u = function () {
var t = "div#mmap_twdb_bonusjobs {position:absolute; top:40px; right:10px;}\n" + 'div#mmap_twdb_bonusjobs > input[type="checkbox"] {margin-left:6px; cursor:pointer;}\n' + "div#mmap_twdb_bonusjobs > div {position:relative; display:inline-block; height:9px; width:9px; margin:1px;}\n" + "div#mmap_twdb_bonusjobs > img {margin-left:3px; cursor:pointer; position:relative; display:inline-block; height:16px; width:16px; top:-4px;}";
TWDB.Util.addCss(t, "minimap");
var n = function () {
var t = e('').append(e('").change(function () {
i.gold = e(this).attr("checked");
a()
})).append('').append(e('").change(function () {
i.silver = e(this).attr("checked");
a()
})).append('').append(e('').click(function () {
f()
})).append(e('').click(function () {
l()
})).append(e('').click(function () {
c()
}));
e(MinimapWindow.window.divMain).find(".minimap-right").append(t);
a()
};
GameInject.injectMinimap(function () {
n()
})
};
var a = function () {
Cache.save("bonusdisplay", i);
e("#minimap_worldmap > div.TWDBbonusjob", MinimapWindow.window.divMain).remove();
var t = function (t, n, r, i, s) {
var o = .00513;
var u = parseInt(t * o, 10) - 3;
var a = parseInt(n * o, 10) + 2;
var f = "";
if (i > 1) {
f = "-moz-transform:rotate(45deg);-webkit-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);"
}
var l = e('').click(function (e, t) {
return function () {
window.Map.center(e, t)
}
}(t, n)).addMousePopup('
' + s.join('') + "
");
e(MinimapWindow.window.divMain).find("#minimap_worldmap").append(l)
};
var r = n;
for (key in r) {
if (!r.hasOwnProperty(key)) {
continue
}
var s = r[key];
var o = false;
var u = 0;
var a = [];
for (var f in s) {
if (!s.hasOwnProperty(f)) {
continue
}
if (s[f].gold) {
if (!i.gold) {
continue
}
o = true;
u++
}
if (s[f].silver) {
if (!i.silver) {
continue
}
u++
}
var l = s[f].x;
var c = s[f].y;
job = JobList.getJobById(s[f].job_id);
a.push(Jobs.getPopup(s[f].job_id, s[f].gold ? "gold" : "silver"))
}
if (u > 0) {
t(l, c, o, u, a)
}
}
};
var f = function () {
var t = [];
for (var r in n) {
if (!n.hasOwnProperty(r)) {
continue
}
var i = n[r];
for (var s in i) {
if (!i.hasOwnProperty(s)) {
continue
}
var o = Jobs.getJobById(s);
var u = Math.ceil(i[s].x / 6635) + (i[s].y > 10176 ? 7 : 0);
t.push({
name: o.name,
bonus: i[s].gold ? "gold" : "silver",
country: u,
x: i[s].x,
y: i[s].y,
id: s
})
}
}
var a = e("").css({
width: "500px",
height: "200px",
"background-color": "transparent",
"border-width": "0px"
}).click(function () {
this.select()
});
var f = "";
var l = 1;
var c = function (e) {
if (f !== e) {
f = e;
l = 1
} else {
l *= -1
}
var n = function (e, t) {
return e[f] > t[f] ? l : -1 * l
};
t.sort(n);
var r = "";
var i = "";
for (var s = 0; s < t.length; s++) {
var o = t[s];
if (f == "country" && i !== o.country) {
i = o.country;
r += "-- ?country " + i + " --" + "\n"
}
r += o.name + "; " + o.bonus + "; " + o.x + "-" + o.y + "; " + o.id + "\n"
}
a.val(r)
};
c("name");
var h = e("").css({
width: "500px",
height: "22px",
position: "relative",
display: "block"
}).append(e('').click(function () {
c("name")
})).append(e('').click(function () {
c("country")
}));
(new west.gui.Dialog("Munci bonus Exportă", e("").append(h).append(a))).addButton("ok").show()
};
var l = function () {
var t = e("").css({width: "400px", height: "100px"});
var r = function () {
var r = t.val(), i = r.split(/[\n,\r,\r\n]/), s, o, u, f, l, c;
for (s = 0; s < i.length; s++) {
o = i[s].split(";", 4);
if (o.length !== 4 || !e.isNumeric(o[3]) || !Jobs.getJobById(Number(o[3]))) {
continue
}
u = String(o[2]).split("-", 2);
if (u.length !== 2 || !e.isNumeric(u[0]) || !e.isNumeric(u[1])) {
continue
}
f = Number(o[3]);
l = {
gold: e.trim(o[1]) == "gold" ? true : false,
group_id: Jobs.getJobById(f).groupid,
job_id: f,
silver: e.trim(o[1]) == "gold" ? false : true,
x: Number(u[0]),
y: Number(u[1]),
time: (new Date).getTime()
};
c = Number(u[0]) + "-" + Number(u[1]);
if (!isDefined(n[c])) {
n[c] = {}
}
n[c][f] = l
}
Cache.save("bonusjobs", n);
a()
};
(new west.gui.Dialog("Munci bonus Importă", t)).addButton("ok", r).addButton("cancel").show()
};
var c = function (e) {
try {
if (e) {
for (var t in n) {
if (!n.hasOwnProperty(t)) {
continue
}
var r = n[t];
var i = 0;
for (var s in r) {
if (!r.hasOwnProperty(s)) {
continue
}
if (e == "gold" && r[s].gold) {
i++;
continue
}
if (e == "silver" && r[s].silver) {
i++;
continue
}
delete r[s]
}
if (i == 0) {
delete n[t]
}
}
Cache.save("bonusjobs", n);
a();
(new UserMessage("Munci bonus Resetare", UserMessage.TYPE_SUCCESS)).show()
} else {
var o = "tw-db Munci bonus Resetare";
var u = '
Munci bonus Resetare
';
(new west.gui.Dialog(o, u, west.gui.Dialog.SYS_QUESTION)).addButton("Totul", function () {
c("all")
}).addButton("Munci de aur", function () {
c("silver")
}).addButton("Munci de argint", function () {
c("gold")
}).addButton("cancel").show()
}
} catch (f) {
Error.report(f, "bonusjob reset")
}
};
return t
}($);
Debugger.BonusJobs = BonusJobs;
var Chat = function (e) {
var t = {};
var n = false;
var i = {
":/": "sore",
"=:)": "invader",
">:(": "angry",
":'(": "cry",
":)": "smile",
":D": "grin",
":(": "frown",
";)": "smirk",
":P": "tongue",
":o": "ohmy",
":x": "muted",
":|": "silent",
">.<": "palm",
"-.-": "nc",
"o.O": "oo",
"O.o": "oo",
"^_^": "happy",
o_O: "oo",
"x.x": "xx",
"T.T": "cry",
"el pollo diablo!": "elpollodiablo",
"!el pollo diablo": "elpollodiablo_mirror",
"el pollo diablo?!": "elpollodiablo_front",
"add me": "sheep.gif",
"add me!": "sheep_rainbow.gif"
};
var s = [];
var o = {};
var u = function () {
if (o.ready) {
return
}
if (Settings.get("chat", true)) {
GameInject.ChatLayout(function (e) {
f(e)
});
GameInject.ChatSend(function (e) {
a(e)
});
var e = Cache.load("chathistory");
if (typeof e == "object" && e !== null) {
if (e.color) {
e = e.color;
Cache.save("chathistory", e)
}
s = e
}
if ($("div.tw2gui_window.chat.nominimize div.tw2gui_window_buttons_close").click().length > 0) {
ChatWindow.open()
}
}
o.ready = true
};
o = Loader.add("Chat", "tw-db Chat Enhancement", u, {Settings: true, Cache: true});
var a = function (e) {
var t = e.input.val();
if (!t) {
return
}
var n = function (t) {
if (e._caps) {
t = t.toUpperCase()
}
if (e._bold) {
t = t.replace(/\*/g, "~");
t = "*" + t + "*"
}
return t
};
if (t.substr(0, 1) == "/") {
r = new RegExp("^\\/(tell|msg)\\s+([^:]+):(.+)$");
v = t.match(r);
if (v) {
if (e._color) {
t = "/tell " + v[2] + ":/" + e._color + n(v[3])
} else {
t = "/tell " + v[2] + ":" + n(v[3])
}
}
e.input.val(t);
return
}
t = n(t);
if (e._color) {
t = "/" + e._color + t
}
e.input.val(t);
return
};
var f = function (e) {
var t = e.mainDiv.find(".TWDBchat");
if (t.length == 0) {
e.mainDiv.find(".chat_input").find(".cbg").css("left", "38px").addClass(".TWDBchat");
e._color = null;
e._bold = false;
e._caps = false;
l(e);
m(e)
}
};
var l = function (t) {
var n;
var r = e('');
for (var s in i) {
n = i[s].indexOf(".gif") === -1 ? i[s] + ".png" : i[s];
r.append(e('').click(function (e) {
return function () {
t.input.val(t.input.val() + " " + e + " ");
t.input.focus();
r.hide()
}
}(s)))
}
var o = false;
t.mainDiv.find(".chat_input").append(e('').append(e('')).append(r).hover(function () {
o = true;
r.show()
}, function () {
o = false;
setTimeout(function () {
if (!o) {
r.hide()
}
}, 200)
}))
};
var c = function (e) {
var t = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
if (t) {
return String(parseInt(t[1] * 9 / 255 + .5, 10)) + String(parseInt(t[2] * 9 / 255 + .5, 10)) + String(parseInt(t[3] * 9 / 255 + .5, 10))
} else {
return "000"
}
};
var h = function (e) {
return "rgb(" + parseInt(e[0] * 255 / 9, 10) + "," + parseInt(e[1] * 255 / 9, 10) + "," + parseInt(e[2] * 255 / 9, 10) + ")"
};
var p = function (e, t) {
if (isDefined(t.color)) {
var n = c(t.color);
var r = s.length;
for (var i = 0; i < r; i++) {
var o = s.shift();
if (o !== n) {
s.push(o)
}
}
s.push(n);
if (s.length > 5) {
s.shift()
}
Cache.save("chathistory", s);
e._color = n
}
if (t.color === null) {
e._color = null
}
if (isDefined(t.bold)) {
e._bold = t.bold
}
if (isDefined(t.caps)) {
e._caps = t.caps
}
if (e._bold) {
e.mainDiv.find(".TWDBtext").css("font-weight", "bold")
} else {
e.mainDiv.find(".TWDBtext").css("font-weight", "normal")
}
if (e._caps) {
e.mainDiv.find(".TWDBtext").html("A")
} else {
e.mainDiv.find(".TWDBtext").html("a")
}
if (e._color) {
e.mainDiv.find(".TWDBcolor").children("div").children("div").css("background-color", h(e._color));
if (e._color[1] >= 4) {
e.mainDiv.find(".TWDBtext").css("color", "#000")
} else {
e.mainDiv.find(".TWDBtext").css("color", "#fff")
}
} else {
e.mainDiv.find(".TWDBcolor").children("div").children("div").css("background-color", "#e0e2e0");
e.mainDiv.find(".TWDBtext").css("color", "#000")
}
e.input.focus()
};
var d = function (t) {
return e('').append(e('')).append(e('')).append(e('')).append(e('')).append(e('')).append(e('')).append(e('')).append(e('')).append(e('')).append(e('')).append(e('')).append(e('')).append(e(''))
};
var m = function (t) {
try {
var n = e('');
n.append('');
var r = ["black", "red", "blue", "yellow", "green", "brown", "magenta", "gray"];
n.append(e('').append(d("#e0e2e0")).append(e('
')).append(n).hover(function () {
s = true;
n.show()
}, function () {
s = false;
setTimeout(function () {
if (!s) {
n.hide()
}
}, 200)
}))
} catch (o) {
Error.report(o, "injectColor")
}
};
var g = function (t) {
var n = t.mainDiv.find(".TWDBcolor").children("div").children("div");
var r = c(n.css("background-color"));
var i = {};
i.customColor = e('');
i.customColor.css("background-color", h(c(n.css("background-color"))));
var o = function (e, t) {
if (t && r[e] == 9 || !t && r[e] == 0) {
return
}
var n = [Number(r[0]), Number(r[1]), Number(r[2])];
n[e] += t ? 1 : -1;
r = String(n[0]) + String(n[1]) + String(n[2]);
i.input.val(r);
if (r[e] == 0) {
i.plusminus[e].children(".butMinus").css("opacity", .3)
} else {
i.plusminus[e].children(".butMinus").css("opacity", 1)
}
if (r[e] == 9) {
i.plusminus[e].children(".butPlus").css("opacity", .3)
} else {
i.plusminus[e].children(".butPlus").css("opacity", 1)
}
i.customColor.css("background-color", h(r))
};
var u = e('');
i.plusminus = [];
for (var a = 0; a < 3; a++) {
switch (a) {
case 0:
var f = "#f00";
break;
case 1:
var f = "#0f0";
break;
case 2:
var f = "#00f";
break
}
i.plusminus[a] = e('
');
i.plusminus[a].children(".butMinus").click(function (e) {
return function () {
o(e, false)
}
}(a));
i.plusminus[a].children(".butPlus").click(function (e) {
return function () {
o(e, true)
}
}(a));
if (r[a] == 0) {
i.plusminus[a].children(".butMinus").css("opacity", .3)
}
if (r[a] == 9) {
i.plusminus[a].children(".butPlus").css("opacity", .3)
}
u.append(i.plusminus[a])
}
u.append(i.plusminus[0]).append(i.plusminus[1]).append(i.plusminus[2]);
i.input = e('');
i.input.keyup(function () {
var e = i.input.val();
if (e.length < 3) {
return
}
if (!e.match(/(\d){3}/)) {
i.input.val(r);
return
}
r = e;
for (var t = 0; t < 3; t++) {
if (r[t] == 0) {
i.plusminus[t].children(".butMinus").css("opacity", .3)
} else {
i.plusminus[t].children(".butMinus").css("opacity", 1)
}
if (r[t] == 9) {
i.plusminus[t].children(".butPlus").css("opacity", .3)
} else {
i.plusminus[t].children(".butPlus").css("opacity", 1)
}
}
i.customColor.css("background-color", h(r));
i.input.attr("value", r)
});
u.append(i.input);
var l = {bold: t._bold, caps: t._caps};
var d = e('');
var v = new west.gui.Checkbox("*reliefat*", l.bold ? "tw2gui_checkbox_checked" : "", function () {
l.bold = l.bold ? false : true
});
e(v.getMainDiv()).css("display", "block").css("margin-bottom", "5px");
d.append(v.getMainDiv());
var v = new west.gui.Checkbox("Valorifică", l.caps ? "tw2gui_checkbox_checked" : "", function () {
l.caps = l.caps ? false : true
});
d.append(v.getMainDiv());
var m = e('');
m.append('istorie');
for (var a = 0; a < s.length; a++) {
var g = e('');
g.click(function () {
p(t, {color: e(this).css("background-color"), bold: l.bold, caps: l.caps});
i.colorBox.hide()
});
m.append(g)
}
var y = e("").append(i.customColor).append(u).append(d).append(m);
i.colorBox = new west.gui.Dialog("Culoare", y);
i.colorBox.addButton("ok", function () {
p(t, {color: e(i.customColor).css("background-color"), bold: l.bold, caps: l.caps})
});
i.colorBox.addButton("cancel");
i.colorBox.show()
};
return t
}(jQuery);
Debugger.Chat = Chat;
var SellTip = function (e) {
var t = {};
var n = false;
var r = {};
var i = function () {
if (r.ready) {
return
}
if (Settings.get("sellTip", true)) {
GameInject.injectItem("Inventory", "sellTip", function (e) {
setTimeout(function () {
return s(e)
}, 0)
})
}
r.ready = true
};
r = Loader.add("sellTip", "tw-db sellTip", i, {Settings: true, ClothCalc: true});
var s = function (e) {
var t = e.obj.item_id;
var n = w.ItemManager.get(t);
var r = false;
var i = "";
if (!n.sellable && !n.auctionable) {
return
}
if (Settings.get("sellTip1", true)) {
var s = w.Bag.getItemByItemId(n.item_id);
var o = w.Wear.wear[n.type];
if (s || o && o.obj.item_id == n.item_id) {
var u = (s !== undefined ? s.count : 0) + (o !== undefined && o.obj.item_id == n.item_id ? 1 : 0);
if (u > 1) {
r = true;
i = "Deții acest obiect de mai multe ori".escapeHTML()
}
}
}
if (Settings.get("sellTip2", true) && ClothCalc.isLoaded()) {
if (!ClothCalc.isUsedItem(n.item_id)) {
r = true;
i = "Acest obiect nu este folosit pentru nicio muncă sau pentru o activitate predefinită (ClothCalc)".escapeHTML()
}
}
if (Settings.get("sellTip3", true)) {
if (n.named) {
r = false
}
}
if (Settings.get("sellTip4", true)) {
if (n.traderlevel === null || n.traderlevel > 20) {
r = false
}
}
if (Settings.get("sellTip5", true)) {
if (n.set) {
r = false
}
}
e.divMain.find(".TWDBsellTip").remove();
if (r) {
e.divMain.append('')
}
};
return t
}($);
Debugger.SellTip = SellTip;
var Collector = function (e) {
var t = {};
var n = false;
var r = {};
var i = function () {
if (r.ready) {
return
}
if (Settings.get("collector", true)) {
GameInject.injectItem("Trader", "collector", function (e) {
return s(e)
});
GameInject.injectTrader("collector", function (e) {
if (t.isNewItem(e.item_id)) {
var n = '';
return n
}
return ""
});
GameInject.injectMarket("collector", function (e) {
return o(e)
});
GameInject.injectGetBids()
}
r.ready = true
};
r = Loader.add("Collector", "tw-db Collector", i, {Settings: true});
t.isNewItem = function (e) {
var t = w.ItemManager.get(e);
var n = w.Bag.getItemsIdsByBaseItemId(t.item_base_id);
var r = w.Wear.wear[t.type];
var i = r && r.obj.item_base_id == t.item_base_id;
var s = TWDB.ClothCalc.bids[t.item_id];
if (n.length || i || s) {
return false
} else {
return true
}
};
var s = function (e) {
e.divMain.find(".TWDBcollector").remove();
if (t.isNewItem(e.obj.item_id)) {
e.divMain.append('')
}
};
var o = function (e) {
if (t.isNewItem(e)) {
return ''
} else {
return ""
}
};
return t
}($);
Debugger.Collector = Collector;
var BuyTip = function (e) {
var t = {};
var n = false;
var r = {};
var i = 0;
var s = {};
var o = {};
var u = function () {
if (o.ready) {
return
}
if (Settings.get("buyTip", true)) {
GameInject.injectItem("Trader", "buytip", function (e) {
return f(e, "trader")
});
GameInject.injectTrader("buytip", function (e) {
return a(e)
});
GameInject.injectMarket("buytip", function (e) {
return f(e, "market")
})
}
Eventer.set("TWDBdataLoaded", function () {
t.reset()
});
if (!Updater.wasUpdated()) {
r = Cache.load("betteritems");
if (r == null || typeof r !== "object") {
r = {}
}
}
o.ready = true
};
o = Loader.add("BuyTip", "tw-db BuyTip", u, {
Settings: true,
Cache: true,
Collector: true,
ClothCalc: true,
Calc: true
});
t.reset = function () {
r = {};
Cache.save("betteritems", r)
};
var a = function (e) {
n = e.item_id;
if (!Collector.isNewItem(n) || isDefined(r[n]) && r[n].length == 0) {
return ""
}
if (isDefined(r[n])) {
var t = h(n);
if (isDefined(t)) {
t.css({bottom: "45px", right: "11px"})
}
return t
}
l(n);
var t = h(n);
if (isDefined(t)) {
t.css({bottom: "45px", right: "11px"})
}
return t
};
var f = function (e, t) {
if (t == "shop") {
n = e.item_id
} else {
n = t == "market" ? e : e.obj.item_id
}
if (!Collector.isNewItem(n) || isDefined(r[n]) && r[n].length == 0) {
return ""
}
if (t == "market") {
if (isDefined(r[n])) {
return c(n)
}
i++;
Worker.add(function (e, t) {
return function () {
l(t);
var n = w.MarketWindow.DOM.find("#TWDBbuyTip" + e);
n.after(c(t));
n.remove()
}
}(i, n));
return ''
}
if (isDefined(r[n])) {
if (t == "shop") {
var s = h(n);
s.css({bottom: "45px", right: "11px"});
return s
} else {
e.divMain.find(".TWDBbuyTip").remove();
e.divMain.append(h(n))
}
return
}
if (isDefined(e.divMain)) {
e.divMain.find(".TWDBbuyTip").remove()
}
e.divMain.append('');
Worker.add(function (e, t) {
return function () {
l(t);
if (t == "shop") {
var n = h(t);
n.css({bottom: "45px", right: "11px"});
return n
} else {
e.divMain.find(".TWDBbuyTip").remove();
e.divMain.append(h(t))
}
}
}(e, n))
};
var l = function (e) {
if (!ClothCalc.isLoaded()) {
return
}
if (!ClothCalc.isItemUsable(e, true)) {
return
}
if (isDefined(r[e])) {
return
}
r[e] = [];
var t = ItemManager.get(e);
var n = Jobs.getAllJobs();
for (var i = 0; i < n.length; i++) {
var s = n[i];
var o = ClothCalc.getClothForJob(s);
if (!isDefined(o)) {
continue
}
var u = 0;
var a = Calc.getItemBonusForJob(e, s);
if (isDefined(o[TWDB.ClothCalc._type2id[t.type]])) {
var f = ItemManager.get(o[TWDB.ClothCalc._type2id[t.type]].id);
u += Calc.getItemBonusForJob(f.item_id, s)
}
if (isDefined(f) && isDefined(f.set) || isDefined(t.set)) {
var l = isDefined(f) && isDefined(f.set) ? f.set : null;
var c = isDefined(t.set) ? t.set : null;
var h = {};
h[l] = 0;
h[c] = 0;
for (var p in o) {
var d = ItemManager.get(o[p].id);
if (!isDefined(d)) {
continue
}
if (d.set) {
if (d.set == l) {
h[l]++
}
if (d.set == c && l !== c) {
h[c]++
}
}
}
if (l) {
u += Calc.getSetBonusForJob(l, h[l], s);
u -= Calc.getSetBonusForJob(l, h[l] - 1, s)
}
if (c) {
a += Calc.getSetBonusForJob(c, h[c] + 1, s);
a -= Calc.getSetBonusForJob(c, h[c], s)
}
}
if (a > u) {
var v = ClothCalc.getLPForJob(s);
if (isDefined(v)) {
var m = v.sum - u + a;
r[e].push({job: s, newlp: m, more: m - v.sum})
} else {
r[e].push({job: s, newlp: a, more: a})
}
}
}
Cache.save("betteritems", r)
};
var c = function (e) {
if (!isDefined(r[e])) {
return ""
}
if (r[e].length == 0) {
return ""
}
s[e] = false;
var t = p(e).escapeHTML();
return "'
};
var h = function (t) {
if (!isDefined(r[t])) {
return
}
if (r[t].length == 0) {
return
}
s[t] = false;
var n = p(t);
return e('')
};
var p = function (e) {
if (!isDefined(r[e])) {
return ""
}
var t = '
';
if (!ClothCalc.isItemUsable(e)) {
var n = ItemManager.get(e);
t += '
Nivel ' + n.level + "
"
}
for (var i = 0; i < r[e].length; i++) {
var o = r[e][i];
var u = Jobs.getJobById(o.job);
var a = " +" + o.more + " " + u.name.escapeHTML() + " [" + o.newlp + "]";
if (o.job == ClothCalc.getSelectedJob()) {
a = "" + a + "";
s[e] = true
}
if (o.newlp < 0) {
var f = "#FF0000"
} else {
if (o.newlp - o.more < 0) {
var f = "#0000FF"
} else {
var f = "#008000"
}
}
t += '
' + a + "
";
if (i % 2) {
t += "
"
}
}
if (i % 2) {
t += "
"
} else {
t = t.substring(0, t.length - 4)
}
t += "
";
return t
};
return t
}($);
Debugger.BuyTip = BuyTip;
var LpInfo = function (e) {
var t = {};
var n = false;
var r = {};
var i = function () {
if (r.ready) {
return
}
if (Settings.get("jobBoniTooltip", true)) {
GameInject.injectItem("Inventory", "lpInfo", function (e) {
return s(e)
})
}
r.ready = true
};
r = Loader.add("LpInfo", "tw-db LpInfo", i, {Settings: true, Jobs: true, Calc: true});
var s = function (e) {
e.divMain.find(".TWDBlpInfo").remove();
var t = ClothCalc.getSelectedJob();
if (!isDefined(t)) {
return
}
var n = e.obj.item_id;
e.divMain.find(".TWDBlpInfo").remove();
if (Calc.isCached(n, t)) {
e.divMain.append(o(n, t))
} else {
Worker.add(function (e, t, n) {
return function () {
e.divMain.find(".TWDBlpInfo").remove();
e.divMain.append(o(t, n))
}
}(e, n, t))
}
};
var o = function (e, t) {
var n = Calc.getItemBonusForJob(e, t);
if (isNaN(n) || n <= 0) {
return
}
var t = Jobs.getJobById(t);
return ''
};
return t
}($);
Debugger.LpInfo = LpInfo;
var Snippets = function ($) {
var _self = {};
var timeout = null;
var interval = null;
var loader = {};
var init = function () {
if (loader.ready) {
return
}
trustTWDB();
if (Settings.get("collectorsell", true)) {
GameInject.injectWanderingTraderSellDialog()
}
if (Settings.get("customcounterpos", true)) {
repositionEventCounters()
}
if (Settings.get("noscrollbars", false)) {
disableScrollbars()
}
if (Settings.get("instanthotel", true)) {
InstantHotel()
}
if (Settings.get("qbswitch", true)) {
QuestbookSwitch()
}
if (Settings.get("qfulltext", false)) {
QuestFullText()
}
if (Settings.get("fastskillchange", true)) {
fastSkillChange()
}
if (Settings.get("fortrecruitment", true)) {
activateFortRecruitment()
}
if (Settings.get("noworkqueuepa", true)) {
removeWorkQueuePA()
}
if (Settings.get("nofetchallpa", false)) {
removeVariousPA()
}
if (Settings.get("nowofnuggets", false)) {
changeWofNuggets()
}
if (Settings.get("marketselldialog", true)) {
enhanceMarketSellDialog()
}
if (Settings.get("weeklycrafting", false)) {
weeklyCrafting()
}
if (Settings.get("pinitems", true)) {
GameInject.injectInventoryAddItemsPinItems();
GameInject.injectInventoryAddItemDivToInvPinItems()
}
if (Settings.get("telegramsource", true))GameInject.injectTelegramWindowAppendTelegramDisplaySource();
if (Settings.get("noshopsale", false)) {
supressOnGoingEntries()
}
if (Settings.get("expbarvalues", true)) {
expBarValues()
}
if (Settings.get("mini_chatgui", true)) {
allowChatGuiMinimize()
}
if (Settings.get("tasklistpoints", true)) {
addTaskJobsHints();
GameInject.injectTaskJobs()
}
loader.ready = true
};
loader = Loader.add("Snippets", "tw-db code Snippets", init, {Settings: true});
var trustTWDB = function () {
try {
var str = showlink.toString();
str = str.replace("the-west", "tw-db|the-west");
str = str.replace("|com|", "|com|info|");
eval("showlink = " + str)
} catch (e) {
}
};
var repositionEventCounters = function () {
TWDB.Util.addCss("@media (min-width: 1320px) { .custom_unit_counter {top: -1px!important; margin-left: 310px!important;} #hiro_friends_container {top: -1px!important; margin-right: 304px!important;} }")
};
var disableScrollbars = function () {
$("body").css({overflow: "hidden"})
};
var allowChatGuiMinimize = function () {
TWDB.Util.addCss("div#ui_bottomleft { width: auto; overflow: hidden; }" + "div#ui_chat { margin-top: 12px; }" + "div#ui_chat div#toggleMinChat { position: absolute; top: -14px; left: 5px; width: 27px; display: block; background-size: 108px 42px; border: 0px solid rgba(0, 0, 0, 0); background-clip: content-box; }" + "div#ui_chat.minchat div#toggleMinChat { background-position: 0px 0px; border-width: 0px 8px 34px 0px; }" + "div#ui_chat.minchat div#servertime { display: none; }" + "div#ui_chat.minchat > div.tabs div { display: none; }" + "div#ui_chat.minchat div.container div.friend { display: none!important; }" + "div#ui_chat.minchat div.container div.general { display: block!important; }" + "div#ui_chat.minchat div.container div.vertical_divider { display: none; }" + "div#ui_chat.minchat img.leave_channel { display: none!important; }" + "div#ui_chat div.minchat_tabr { display: none; }" + 'div#ui_chat.minchat div.minchat_tabr { display: block; position: absolute; left: 32px; top: 0px; width: 8px; height: 34px; background: url("' + to_cdn("images/interface/chat/chat-top.png?1") + '") top right; }' + "div#ui_chat.minchat { position: relative; left: -10px; top: 4px; width: 39px; }" + 'div#ui_chat.minchat > div.tabs { width: 32px; background: url("' + to_cdn("images/interface/chat/chat-top.png?1") + '"); }' + "div#ui_chat.minchat div.chat_channel { width: 24px; }" + "div#ui_chat.minchat div.chat_channel .new_message { left: 2px; top: 0px; }" + "div#ui_chat.minchat div.chat_channel div.online_count { background: none; position: absolute; right: 0px; top: -1px; width: auto; height: auto; line-height: normal; padding: 0px; font-size: 8pt; font-weight: bold; text-align: right; text-shadow: -1px 1px 1px #FFF, 0px 0px 2px #FFF; cursor: default; }" + "div#ui_chat.minchat div.container { width: 40px; background-position-x: right; }" + "div#ui_chat.minchat div.row_title { left: 5px; width: 32px; opacity: 0; }" + "div#ui_chat.minchat div.tw2gui_scrollpane { width: 50px; }", "minchat");
$("div#ui_chat").append('').toggleClass("minchat", Settings.get("mini_chatgui_min", true)).children(".tabs").first().append($('').on("click", function (e) {
e.stopPropagation();
Settings.set("mini_chatgui_min", $("div#ui_chat").toggleClass("minchat").hasClass("minchat"));
return false
}))
};
var addTaskJobsHints = function () {
var e = "div#ui_workcontainer div.twdb_lp_hint { position: absolute; left: 2px; width: 18px; height: 18px; background-color: #432; border: 2px ridge #976; border-radius: 11px; background-blend-mode: soft-light; }" + "div.twdb_lp_hint > img { position: absolute; left: 1px; top: 1px; }";
TWDB.Util.addCss(e);
var t = function () {
if (TaskQueue.queue.length) {
var e, t = $("div#ui_workcontainer"), n, r;
for (e = 0; e < TaskQueue.queue.length; e++) {
if (TaskQueue.queue[e].type === "job") {
n = null;
r = TWDB.ClothCalc.calcdata.loaded && TaskQueue.queue[e].data.job_points < TWDB.ClothCalc.calcdata.jobs[TaskQueue.queue[e].data.job.id].laborpoints.sum - 5;
if (TaskQueue.queue[e].data.job_points < 0) {
n = west.gui.Icon.get("exclamation-priority-3", "Puncte de muncă negative")
} else if (TaskQueue.queue[e].data.job_points < TaskQueue.queue[e].data.job.malus / 5) {
n = west.gui.Icon.get("exclamation-priority-2", "Puncte de muncă foarte puține")
} else if (r) {
n = west.gui.Icon.get("exclamation-priority-1", "Puncte de muncă reduse")
}
if (n !== null) {
$(".task-queuePos-" + e + " > div.icon", t).children(".twdb_lp_hint").remove().end().append($('').toggleClass("tw2gui-iconset tw2gui-icon-star", !r).append(n))
}
}
}
}
};
EventHandler.listen(["taskqueue-updated", "taskqueue-ready"], t)
};
var expBarValues = function () {
if (isDefined(w.SlySuite)) {
TWDB.Settings.set("expbarvalues", false);
return
}
TWDB.Util.addCss("div#ui_experience_bar .label {text-shadow: 3px 1px 1px #000, 3px -1px 1px #000, -2px 1px 1px #000, -2px 0px 0px #000;}");
var e = function (e) {
if (Math.abs(e) >= 1e4) {
return Math.round(e / 1e3) + "k"
} else {
return e
}
};
var t = function () {
var t = $("#ui_experience_bar"), n = undefined === Character.getTrackingAchievement() ? WestUi.updateTrackXp(t) : WestUi.updateTrackAchievement(t);
$(".label", t).off("hover");
$(".label span", t).show();
xpString = "";
if (Character.level < 150) {
xpString = n.percent + "% - " + e(n.current) + " / " + e(n.required);
xpString += " (" + e(n.required - n.current) + ")"
} else xpString = Character.experience.toLocaleString();
$(".label span", t).html(xpString)
};
EventHandler.listen("character_exp_changed", t);
EventHandler.listen("character_tracking_achievement_changed", t);
t()
};
var supressOnGoingEntries = function () {
var e = ["shop_sale"];
var t = function (e) {
if ($.isArray(e)) {
for (var n = 0; n < e.length; n++) {
t(e[n])
}
} else if (typeof e === "string") {
var r = WestUi.NotiBar.main.list;
for (var n = 0; n < r.length; n++) {
if ($(r[n].element).children().is("div.image." + e)) {
WestUi.NotiBar.remove(r[n])
}
}
}
};
var n = function (e) {
try {
WestUi.NotiBar.__twdb__add = WestUi.NotiBar.__twdb__add || WestUi.NotiBar.add;
WestUi.NotiBar.add = function (t) {
var n = $(".image", t.element);
for (var r = 0; r < e.length; r++) {
if (n.hasClass(e[r])) {
return
}
}
WestUi.NotiBar.__twdb__add.apply(this, arguments)
}
} catch (t) {
Error.report(t, "manipulate WestUi.NotiBar.add")
}
};
n(e);
t(e)
};
var InstantHotel = function () {
try {
w.Map.Component.Town.prototype.__twdb__getContent = w.Map.Component.Town.prototype.__twdb__getContent || w.Map.Component.Town.prototype.getContent;
w.Map.Component.Town.prototype.getContent = function () {
var e = this.__twdb__getContent();
if (e === "") {
return e
} else {
return e.replace(/\<\/div\>$/, "
")
}
};
w.Map.Draw.__twdb__checkDouble = w.Map.Draw.__twdb__checkDouble || w.Map.Draw.checkDouble;
w.Map.Draw.checkDouble = function () {
$("#map div.instanthotel.needslistener").each(function (e, t) {
var n = $(t);
var r = parseInt(n.attr("tid"), 10);
n.click(function (e) {
e.stopPropagation();
HotelWindow.open(r);
return false
}).removeClass("needslistener").removeAttr("tid")
});
return w.Map.Draw.__twdb__checkDouble()
};
var e = "div.instanthotel { background-image: url('" + TWDB.images.instanthotel + "'); width: 20px; height: 20px; " + "position: absolute; right: 10px; top: -8px; cursor: pointer; display: none; }\n" + "div.townname:hover .instanthotel { z-index: 2; display: block; }";
TWDB.Util.addCss(e);
w.Map.refresh(true)
} catch (t) {
Error.report(t, "manipulate town signs")
}
};
var fastSkillChange = function () {
try {
west.gui.Plusminusfield.prototype.__twdb__init = west.gui.Plusminusfield.prototype.init;
west.gui.Plusminusfield.prototype.init = function (e, t, n, r, i, s, o, u) {
this.__twdb__init.apply(this, arguments);
var a = this;
var f = {minus: $("span.butMinus", a.divMain), plus: $("span.butPlus", a.divMain)};
$(this.divMain).off("mousewheel").on("mousewheel", function (e, t) {
f[t < 0 ? "minus" : "plus"].click();
e.stopPropagation();
return false
});
$.each(f, function (e, t) {
var n = 400, r = -1, i = function () {
n = Math.max(Math.round(n * (n / 200 + 1) / (n / 133 + 1)), 5);
t.click();
r = setTimeout(i, n)
}, s = function () {
r = setTimeout(i, n)
}, o = function (e) {
if (r !== -1) {
clearTimeout(r);
r = -1
}
n = 400
};
t.css("cursor", "pointer").mousedown(s).mouseup(o).mouseout(o)
})
}
} catch (e) {
Error.report(e, "manipulate Plusminusfield")
}
};
var QuestbookSwitch = function () {
try {
QuestGroupWindowView.cc_showSolvedQuest = QuestGroupWindowView.showSolvedQuest;
QuestGroupWindowView.showSolvedQuest = function (e) {
QuestGroupWindowView.cc_showSolvedQuest(e);
var t = $("div.window-quest_group div.quest_description_container span").slice(1).hide();
var n = $(" " + e.description + "");
$("div.window-quest_group div.quest_description_container").append(n);
var r = $(' Arată textul de completare ').addClass("introshown").click(function () {
var e = $(this), r = e.hasClass("introshown");
t.toggle(r);
n.toggle(!r);
e.text(r ? " Arată textul de introducere " : " Arată textul de completare ");
e.toggleClass("introshown")
});
$("div.window-quest_group div.solved_text_container").append($("
").append(r))
}
} catch (e) {
Error.report(e, "manipulate showSolvedQuest")
}
};
var QuestFullText = function () {
try {
QuestWindowView.cc_showQuest = QuestWindowView.showQuest;
QuestWindowView.showQuest = function (e) {
QuestWindowView.cc_showQuest(e);
$("div.quest_description_container div#quest_shortd").hide();
$("div.quest_description_container div#quest_fulld").show()
};
QuestEmployerView.cc_showQuest = QuestEmployerView.showQuest;
QuestEmployerView.showQuest = function (e) {
QuestEmployerView.cc_showQuest(e);
$("div.quest_description_container div#quest_shortd").hide();
$("div.quest_description_container div#quest_fulld").show()
}
} catch (e) {
Error.report(e, "manipulate showQuest")
}
};
var removeWorkQueuePA = function () {
try {
TWDB.Util.addCss("#queuedTasks .buyPremiumTask {background: none!important}");
Premium.checkForAutomationPremium = function (e, t) {
if (typeof t !== "undefined")return t()
}
} catch (e) {
Error.report(e, "manipulate removeWorkQueuePA")
}
};
var changeWofNuggets = function () {
try {
west.gui.payHandler.prototype.__twdb__addPayOption = west.gui.payHandler.prototype.addPayOption;
west.gui.payHandler.prototype.addPayOption = function (e) {
this.__twdb__addPayOption.apply(this, arguments);
if (false === e || "nugget" === e) {
return this
}
this.setSelectedPayId(e.id);
return this
}
} catch (e) {
Error.report(e, "manipulate changeWofNuggets")
}
};
var removeVariousPA = function () {
var e = [], t;
if (Settings.get("nofetchallpa", false))e.push("marketdelivery all");
if (!e.length)return;
t = new RegExp(e.join("|"));
try {
Premium.twdb_confirmUse = Premium.confirmUse;
Premium.confirmUse = function (e, n, r, i, s, o, u, a) {
if (t.test(e)) {
if (typeof u !== "undefined")return u()
} else {
return Premium.twdb_confirmUse(e, n, r, i, s, o, u, a)
}
}
} catch (n) {
Error.report(n, "manipulate removeVariousPA")
}
};
var activateFortRecruitment = function () {
try {
FortBattleWindow.__twdb__getInfoArea = FortBattleWindow.__twdb__getInfoArea || FortBattleWindow.getInfoArea;
FortBattleWindow.getInfoArea = function () {
this.preBattle.battleData.canSetPrivilege = true;
return FortBattleWindow.__twdb__getInfoArea.apply(this, arguments)
}
} catch (e) {
Error.report(e, "manipulate FortBattleWindow.getInfoArea")
}
};
var enhanceMarketSellDialog = function () {
var e;
var t = TWDB.Cache.load("msdsettings");
if (typeof t !== "object" || t == null) {
t = {cb: {}}
} else if (typeof t.cb !== "object" || t.cb == null) {
t.cb = {}
}
try {
if (!isDefined(west.gui.Dialog.prototype.__twdb__show)) {
west.gui.Dialog.prototype.__twdb__show = west.gui.Dialog.prototype.show
}
if (TWDB.script.isDev()) {
west.gui.Dialog.prototype.show = function () {
if (this.divMain.attr("id") === "market_createoffer_window") {
var e = this.__twdb__show();
w.setTimeout(function () {
MarketWindow.TWDB_touchUpSellDialog(e)
}, 25);
return e
}
var t = ["div#equip_manager_list", "span.twdb_banking"].join(", ");
if ($(this.divMain).find(t).addBack().is(t)) {
return this.setModal(false).setBlockGame(false).setDraggable(true).__twdb__show()
}
return this.__twdb__show()
}
} else {
west.gui.Dialog.prototype.show = function () {
if (this.divMain.attr("id") === "market_createoffer_window") {
var e = this.__twdb__show();
w.setTimeout(function () {
MarketWindow.TWDB_touchUpSellDialog(e)
}, 25);
return e
}
return this.__twdb__show()
}
}
if (!isDefined(MarketWindow.TWDB_createMarketOffer)) {
MarketWindow.TWDB_createMarketOffer = MarketWindow.createMarketOffer
}
MarketWindow.createMarketOffer = function (t) {
var n = typeof t == "number" ? t : $(t).data("itemId");
if (n === undefined) {
var r = $(this).data("dnd_droppedObj");
n = r.data("itemId")
}
e = w.ItemManager.get(n);
return MarketWindow.TWDB_createMarketOffer(n)
}
} catch (n) {
Error.report(n, "manipulate market sell dialog")
}
MarketWindow.TWDB_touchUpSellDialog = function (n) {
if (n.divMain.attr("id") !== "market_createoffer_window") {
return
}
var r = $("div.tw2gui_dialog_content", n.divMain);
if (r.find("#auction_item_slot", r).html() == "")return w.setTimeout(function () {
MarketWindow.TWDB_touchUpSellDialog(n)
}, 25);
$("div.tw2gui_dialog_framefix").css({left: "50%", top: "50%", width: "1px", height: "1px"});
$("textarea#auction_description", r).css("width", "270px").closest("tr").append("
");
var i = $("table:nth-child(2)", r);
$("tr:first-child", i).after($("
');
var s = function () {
n.divMain.css({
"margin-top": "-" + n.divMain.height() / 2 + "px",
"margin-left": "-" + n.divMain.width() / 2 + "px"
})
};
var o = function () {
var e, n = this.groupClass;
$("div.tw2gui_checkbox." + n).not(this.divMain).removeClass("tw2gui_checkbox_checked");
if (this.isSelected()) {
e = this.getValue();
this.divMain.next().click()
} else {
e = 0
}
t.cb[n] = e;
TWDB.Cache.save("msdsettings", t);
(new UserMessage("Salvat cu succes", UserMessage.TYPE_SUCCESS)).show();
return this
};
var u = function (e, n) {
t[e] = n;
TWDB.Cache.save("msdsettings", t);
(new UserMessage("Salvat cu succes", UserMessage.TYPE_SUCCESS)).show()
};
var a = function () {
var e, n;
for (e in t.cb) {
if (!t.cb.hasOwnProperty(e))continue;
$("div.tw2gui_checkbox." + e).each(function () {
n = $(this).guiElement();
if (n.getValue() === t.cb[e]) {
n.setSelected(true, true);
$(this).next().click()
}
})
}
$("textarea#auction_description", r).val(t.description || "");
$("span#market_days.tw2gui_combobox", r).guiElement().select(t.duration || 1);
$("span#market_rights.tw2gui_combobox", r).guiElement().select(isDefined(t.rights) ? t.rights : 2)
};
$("#twdb_msd_desc_cc", r).append($('