Popup.js
westui = {
lang: { input_level: "Το επίπεδό σου", input_search: "Αναζήτηση: ID, Σετ ή Όνομα", damages: "Ζημιά", per_level: "ανά επίπεδο", speed: "Ταχύτητα", level: "Επίπεδο", unsalable: "Μη εμπορεύσιμο", auction: "Με δυνατότητα δημοπρασίας", not_auction: "Χωρίς δυνατότητα δημοπρασίας", not_upgrade: "Χωρίς δυνατότητα αναβάθμισης", upgrade: "Με δυνατότητα αναβάθμισης", total: "Σύνολο", popup: { dmg: {
dmglvl: '
+ #1 Ζημιά#2
'
}, skills: {
str: '
+ #1 Δύναμη#2
', mob: '
+ #1 Κινητικότητα#2
', dex: '
+ #1 Επιδεξιότητα#2
', cha: '
+ #1 Χαρισματικότητα#2
', con: '
+ #1 Κατασκευή#2
', vig: '
+ #1 Σθένος#2
', tou: '
+ #1 Ανθεκτικότητα#2
', sta: '
+ #1 Αντοχή#2
', hea: '
+ #1 Πόντοι Υγείας#2
', rid: '
+ #1 Ιππασία#2
', ref: '
+ #1 Αντανακλαστικά#2
', dod: '
+ #1 Αποφυγή#2
', hid: '
+ #1 Κρύψιμο#2
', swi: '
+ #1 Κολύμπι#2
', aim: '
+ #1 Στόχευση#2
', sho: '
+ #1 Σημάδι#2
', pit: '
+ #1 Στήσιμο Παγίδων#2
', fin: '
+ #1 Εξαιρετικές Κινητικές Ικανότητες#2
', rep: '
+ #1 Επιδιόρθωση#2
', lea: '
+ #1 Ηγεσία#2
', tac: '
+ #1 Τακτικές#2
', tra: '
+ #1 Εμπόριο#2
', ani: '
+ #1 Ζωώδες Ένστικτο#2
', app: '
+ #1 Εμφάνιση#2
'
}, fb: {
fbdef: '
+ #1 Άμυνα (Μπόνους μάχης οχυρού)#2
', fboff: '
+ #1 Επίθεση (Μπόνους μάχης οχυρού)#2
', fbres: '
+ #1 Αντίσταση (Μπόνους μάχης οχυρού)#2
', fbdmgs: '
+ #1 Ζημιά (Μπόνους τομέα μάχης οχυρού)#2
', fbdefs: '
+ #1 Άμυνα (Μπόνους τομέα μάχης οχυρού)#2
', fboffs: '
+ #1 Επίθεση (Μπόνους τομέα μάχης οχυρού)#2
'
}, special: {
pray: '
+ #1 Προσευχή#2
', labor_pts: '
+ #1 Πόντοι εργασίας#2
', spd: '
+ #1% Ταχύτητα#2
', regen: '
+ #1% Επαναφορά#2
', xp: '
+ #1% Εμπειρία από δουλειές, μονομαχίες και μάχες οχυρού#2
', money: '
+ #1% Χρήματα από δουλειές και μονομαχίες#2
', luck: '
+ #1% Αυξημένη τύχη#2
', drop: '
+ #1% Βελτιωμένη πιθανότητα εύρεσης#2
'
} } }, config: { enable_set_calc: !0, plain_popup: !0, redirect_on_dblclick: !1, link_on_dblclick: !1, enable_sorting: !0, cdn: "//westgr.innogamescdn.com", media_cdn: "https://media.innogamescdn.com/com_WEST_GR/wiki/event_offers", img_buyprice: "/images/5/57/Buy_price.png", img_sellprice: "/images/f/fc/Sell_price.png", img_male: "/images/e/ed/Ανδρικό.png", img_female: "/images/b/b5/Γυναικείο.png", img_prof: ['c/c0','c/c3','2/2d','9/9a','f/fc'], img_job: { all: ['d/d1', 'Οποιαδήποτε εργασία'] },
cat_img: '
- Κατηγορία: <a src="/wiki/Κατηγορίες Χαρακτήρα"><img src="/images/', adventurer: 'f/fe/Τυχοδιώκτης.png"/>', dueller: '0/0f/Μονομάχος.png"/>', worker: '0/0e/Εργάτης.png"/>', soldier: '0/0e/Στρατιώτης.png"/>', greenhorn: 'f/f7/Πρωτάρης.png"/>', set_bonus: { str:{name:"Δύναμη",img:"/images/1/17/Δύναμη.png"}, mob:{name:"Κινητικότητα",img:"/images/5/5a/Mobility.png"}, dex:{name:"Επιδεξιότητα",img:"/images/0/0d/Dexterity.png"}, cha:{name:"Χαρισματικότητα",img:"/images/c/c9/Charisma.png"}, con:{name:"Κατασκευή",img:"/images/3/37/Construction.png"}, vig:{name:"Σθένος",img:"/images/9/90/Skill_Punch.png"}, tou:{name:"Ανθεκτικότητα",img:"/images/f/f8/Skill_Tough.png"}, sta:{name:"Αντοχή",img:"/images/8/8d/Stamina.png"}, hea:{name:"Πόντοι υγείας",img:"/images/9/94/Health.png"}, rid:{name:"Ιππασία",img:"/images/7/78/Hbr.png"}, ref:{name:"Αντανακλαστικά",img:"/images/e/e9/Skill_Reflex.png"}, dod:{name:"Αποφυγή",img:"/images/0/07/Skill_Dodge.png"}, hid:{name:"Κρύψιμο",img:"/images/9/97/Hiding.png"}, swi:{name:"Κολύμπι",img:"/images/f/f4/Swimming.png"}, aim:{name:"Στόχευση",img:"/images/5/53/Skill_Aim.png"}, sho:{name:"Σημάδι",img:"/images/7/73/Skill_Shot.png"}, pit:{name:"Στήσιμο παγίδων",img:"/images/e/e1/Trapping.png"}, fin:{name:"Εξαιρετικές κινητικές ικανότητες",img:"/images/1/18/Fms.png"}, rep:{name:"Επιδιόρθωση",img:"/images/d/d5/Repairing.png"}, lea:{name:"Ηγεσία",img:"/images/4/44/Leadership.png"}, tac:{name:"Τακτικές",img:"/images/9/91/Skill_Tactic.png"}, tra:{name:"Εμπόριο",img:"/images/f/f3/Skill_Trading.png"}, ani:{name:"Ζώωες ένστικτο",img:"/images/9/9d/AnimalInstinct.png"}, app:{name:"Εμφάνιση",img:"/images/4/4c/Skill_Appearance.png"}, fbdef:{name:"Άμυνα (Μπόνους μάχης οχυρού)",img:"/images/8/82/Set_Fb_defense.png"}, fboff:{name:"Επίθεση (Μπόνους μάχης οχυρού)",img:"/images/3/30/Set_Fb_offense.png"}, fbres:{name:"Αντίσταση (Μπόνους μάχης οχυρού)",img:"/images/4/4b/Resistance.png"}, fbdmgs:{name:"Ζημιά (Μπόνους τομέα μάχης οχυρού)",img:"/images/b/b3/Damages_sector.png"}, fbdefs:{name:"Άμυνα (Μπόνους τομέα μάχης οχυρού)",img:"/images/1/1a/Set_Fb_defense_sec.png"}, fboffs:{name:"Επίθεση (Μπόνους τομέα μάχης οχυρού)",img:"/images/f/fe/Set_Fb_offense_sec.png"}, xp:{name:"Εμπειρία από δουλειές, μονομαχίες και μάχες οχυρού (%)",img:"/images/7/71/Set_xp.png"}, money:{name:"Χρήματα από δουλειές και μονομαχίες (%)",img:"/images/d/df/Set_money.png"}, luck:{name:"Αυξημένη τύχη",img:"/images/c/c1/Set_luck.png"}, regen:{name:"Επαναφορά",img:"/images/5/53/Regeneration.png"}, drop:{name:"Βελτιωμένη πιθανότητα εύρεσης",img:"/images/b/b8/Drop.png"}, labor_pts:{name:"Πόντοι εργασίας",img:"/images/5/5e/Labor_pts.png"} }, sorting: { "Καμία ταξινόμηση": '{"id":1}', "Δύναμη": '{"str":1}', "Κινητικότητα": '{"mob":1}', "Επιδεξιότητα": '{"dex":1}', "Χαρισματικότητα": '{"cha":1}', "Κατασκευή": '{"str":1,"con":1}', "Σθένος": '{"str":1,"vig":1}', "Ανθεκτικότητα": '{"str":1,"tou":1}', "Αντοχή": '{"str":1,"sta":1}', "Πόντοι Υγείας": '{"str":1,"hea":1}', "Ιππασία": '{"mob":1,"rid":1}', "Αντανακλαστικά": '{"mob":1,"ref":1}', "Αποφυγή": '{"mob":1,"dod":1}', "Κρύψιμο": '{"mob":1,"hid":1}', "Κολύμπι": '{"mob":1,"swi":1}', "Στόχευση": '{"dex":1,"aim":1}', "Σημάδι": '{"dex":1,"sho":1}', "Στήσιμο Παγίδων": '{"dex":1,"pit":1}', "Εξαιρετικές Κινητικές Ικανότητες": '{"dex":1,"fin":1}', "Επιδιόρθωση": '{"dex":1,"rep":1}', "Ηγεσία": '{"cha":1,"lea":1}', "Τακτικές": '{"cha":1,"tac":1}', "Εμπόριο": '{"cha":1,"tra":1}', "Ζωώδες Ένστικτο": '{"cha":1,"ani":1}', "Εμφάνιση": '{"cha":1,"app":1}', "Κατασκευή κτηρίων": '{"str":3,"con":3,"dex":1,"rep":1,"cha":1,"lea":1}', "Εμπειρία από δουλειές, μονομαχίες και μάχες οχυρού (%)": '{"xp":1}', "Χρήματα από δουλειές και μονομαχίες (%)": '{"money":1}', "Αυξημένη τύχη (%)": '{"luck":1}', "Επαναφορά (%)": '{"regen":1}', "Βελτιωμένη πιθανότητα εύρεσης (%)": '{"drop":1}', "Ταχύτητα (%)": '{"spd":1,"hspd":1,"mob":1,"rid":1}', "Μέσος όρος ζημιάς": '{"dmg_min":0.5,"dmg_max":0.5,"dmglvl":1}', "Μέγιστη ζημιά": '{"dmg_max":1,"dmglvl":1}', "Με δυνατότητα αναβάθμισης": '{"bool":true,"upg":1}', "Χωρίς δυνατότητα αναβάθμισης": '{"bool":true,"upg":0}', "Με δυνατότητα δημοπρασίας": '{"bool":true,"auc":1}', "Χωρίς δυνατότητα δημοπρασίας": '{"bool":true,"auc":0}', "Με δυνατότητα εύρεσης από εργασίες": '{"bool":true,"dropable":1}', "Διαθέσιμα στα καταστήματα πόλης": '{"bool":true,"shop":1}', "Ευγενή αντικείμενα": '{"bool":true,"shop":0,"dropable":1}' }, jobIcon: function ( p, q ){ var wip = this.img_job[ p ], ji = wip ? [ '/images/' + wip[ 0 ] + '/Job_', wip[ 1 ] + ( q || ) ] : [ this.cdn + '/images/jobs/', q ]; ji[ 0 ] += p + '.png'; return ji; } }, initPage: function() { if (1 === $("#input_level").length) var t = $('<input type="number" style="width:110px;" class="west" placeholder="' + westui.lang.input_level + '" min="0" max="150">').bind("propertychange keyup input paste", function() { this.value > 150 ? this.value = 150 : this.value < 0 && (this.value = 0), $(".calc").each(function() { 0 == t.val() ? ($(this).html(this.id), $(".per_level_off").addClass("per_level").removeClass("per_level_off")) : ($(this).html(Math.ceil(Number(this.id) * t.val())), $(".per_level").addClass("per_level_off").removeClass("per_level")) }) }).appendTo($("#input_level")); if (1 === $("#input_search").length) $('<input type="search" class="west" placeholder="' + westui.lang.input_search + '">').bind("propertychange keyup input paste", function() { var t = this.value.toLowerCase(); "" === t ? $(".item_container").show() : ($(".item_container").hide(), $(".item_container").filter(function() { return $(this).attr("data-popup").toLowerCase().indexOf(t) > -1 }).show()) }).appendTo($("#input_search")); 1 === $("#switch").length && ($("#fire").hide(), $("#switch").on("click", function() { $("#melee, #fire").toggle() })), 1 === $("#switch_prod").length && ($("#prod2").hide(), $("#switch_prod").on("click", function() { $("#prod, #prod2").toggle() })), westui.config.plain_popup && new RegExp(mw.config.get("wgFormattedNamespaces")[10] + ":Item=*").test(mw.config.get("wgPageName")) && 1 === $(".item_container").length && ($("#mw-content-text").append('
'), $("#popup_plain").hide(), $("#popup_plain_contents").append(westui.popup.createPopup($(".item_container").attr("data-popup"), $(".item_container").attr("data-cdn-cat"), $(".item_container").attr("data-cdn-img"), 0)), $("#popup_plain").slideDown()), westui.config.redirect_on_dblclick && $(".item_container img").on("dblclick", function() {
window.location = "/wiki/" + mw.config.get("wgFormattedNamespaces")[10] + ":Item=" + JSON.parse($(this).parent().attr("data-popup")).id / 1e3 }) }, popup: { content: "", delay: 200, active: !1, show: function(t) { westui.popup.content = westui.popup.createPopup($(t).attr("data-popup"), $(t).attr("data-cdn-cat"), $(t).attr("data-cdn-img"), parseInt($(t).attr("data-lvl"))), westui.popup.active = !0, westui.popup.setTimeout(), westui.popup.getContainer().html(westui.popup.content) }, hide: function() { westui.popup.getEl().css({ display: "none", top: 0, left: 0 }), westui.popup.active = !1, westui.popup.clearTimeout() }, setTimeout: function() { westui.popup.clearTimeout(), westui.popup.timer = window.setTimeout(function() { westui.popup.getEl().css("display", "block") }, westui.popup.delay) }, clearTimeout: function() { westui.popup.timer && window.clearTimeout(westui.popup.timer) }, getEl: function() { return $("#popup_window") }, getContainer: function() { return $("#popup_contents") }, createPopup: function(t, e, i, a) { t = JSON.parse(t); var wl = westui.lang, wc = westui.config,
s = '
' + (0 == t.sex ? '<img height="16" src="' + wc.img_male + '"/>' : (1 == t.sex ? '<img height="16" src="' + wc.img_female + '"/> ' : )) + t.name + '
',
p = !1; d = t.dmg && t.dmg.split( '-' ); var l = 0; if (t.ico) {
s += '
<a href="/wiki/' + t.event + '"><img src="' + wc.media_cdn + "/" + t.ico + '.png"/>'; s += "" } if (t.event) { for (n = 0; n < t.event.length; n++); s += '' + t.event + "</a>
";
s += "" } if (t.typeW) { for (n = 0; n < t.typeW.length; n++);
s += '
' + t.typeW + "
";
s += "" } if (t.type) { for (n = 0; n < t.type.length; n++);
s += '
' + t.type + "
";
s += "" }
t.unique ? s += '
' + t.unique + '
' : s += "
";
if (a >= 1 && a <= 5 && (p = !0, t.auc = !1), t.text) {
for (var n = 0; n < t.text.length; n++) s += '
' + t.text[n] + "
";
s += "" } if ((t.text && t.unique) || (t.text && t.dmg_max) || (t.text && t.textjob) || (t.text && t.bonus) || (t.text && t.jobs) || (t.text && t.craft) || (t.text && wl.popup)) { s += "
" }
if (a >= 1 && a <= 5 && (p = !0, t.auc = !1), d && ( l = 1 ) && ( p && ( d[ 0 ] = d[ 0 ] * 1 + Math.round( Math.max( 1, .1 * d[ 0 ] * a ) ), d[ 1 ] = d[ 1 ] * 1 + Math.round( Math.max( 1, .1 * d[ 1 ] * a ) ) ), s += '
' + d[ 0 ] + "-" + d[ 1 ] + ' (' + (Math.round(((Number(d[ 0 ]) + Number(d[ 1 ])) / 2) + (t.dmglvl ? Math.round($("#input_level input").val() * (-t.dmglvl)) : ""))) + ') ' + wl.damages + '
' )) {
t.dmglvl ? s += "" : s += "
" }
if (a >= 1 && a <= 5 && (p = !0, t.auc = !1), t.dmg_min && t.dmg_max && (p && (t.dmg_min = t.dmg_min *1 + Math.round(Math.max(1, .1 * t.dmg_min * a)), t.dmg_max = t.dmg_max *1 + Math.round(Math.max(1, .1 * t.dmg_max * a))), s += '
' + t.dmg_min + "-" + t.dmg_max + ' (' + (Math.round(((t.dmg_min + t.dmg_max) / 2) + (t.dmglvl ? Math.round($("#input_level input").val() * (-t.dmglvl)) : ""))) + ') ' + wl.damages + "
")) {
t.dmglvl ? s += "" : s += "
" } for (var o in wl.popup) { var l = 0; for (var c in wl.popup[o]) if (t.hasOwnProperty(c)) { l++; var u = ""; t[c] < 0 ? $("#input_level input").val() > 0 ? (t[c] = Math.ceil($("#input_level input").val() * -t[c]), p && (t[c] += Math.round(Math.max(1, .1 * t[c] * a)))) : (t[c] = -t[c], u = " (" + wl.per_level + ")", p && (t[c] = Math.round(1e6 * (1 * t[c] + Math.round(Math.max(1, 1e3 * t[c] * a)) / 1e4)) / 1e6)) : p && (t[c] < 1 ? t[c] = Math.round(1e6 * (1 * t[c] + Math.round(Math.max(1, 1e3 * t[c] * a)) / 1e4)) / 1e6 : t[c] += Math.round(Math.max(1, .1 * t[c] * a))), s += wl.popup[o][c].replace("#1", t[c]).replace("#2", u) } l > 0 && (s += "
") } if (t.textjob) {
for (n = 0; n < t.textjob.length; n++) s += '
' + t.textjob[n] + "
";
s += "
" } if (t.bonus) {
s += '
Επίδραση:
'; for (n = 0; n < t.bonus.length; n++) s += '
' + t.bonus[n] + "
";
s += "
" } if (t.jobs) {
s += '
Από την εργασία:
';for (p in t.jobs){ if (p == 'req'){s += ''; } else{ var ji = wc.jobIcon( p, t.jobs[ p ] ); s += '";
} }s += "
';
for (var q of t.jobs[p]){ q = q.split( ',' );s += ' <img src="' + wc.cdn + '/images/items/' + ( q[ 0 ].includes( '/' ) ? : 'yield/' ) + q[ 0 ] + '.png">' + ( q[ 2 ] == 'eqp' ? : ' ';
' + q[ 1 ] + ' ' ) + '}s += ' | |
<img src="' + ji[ 0 ] + '"> | ' + ji[ 1 ] + " |
"
} if (t.craft) {
s += '
Χρειάζονται για την Δημιουργία:
<img src="/images/' + wc.img_prof[ t.craft.id ] + '/Profsymbol_' + t.craft.id + '.png" width="36px" height="36px"/> | ';
for (n = 0; n < t.craft.req.length; n++) {s += ' <img src="' + wc.cdn + "/images/items/yield/" + t.craft.req[n][0] + '.png"> '
' + t.craft.req[n][1] + ' }s += " |
"
}
var upgLvL = a, upgItems = Math.pow(3, upgLvL), upgFees = (Math.pow(3, Number(upgLvL) + Number(1)) - 3 - 2 * upgLvL) / 4, upgTotal = t.bp * (upgItems + upgFees), upgPrice = upgTotal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");return s += '
' + wl.speed + ": +" + t.hspd + "%
"), t.set && (s += '
<a class="popup_set" href="/wiki/' + t.set + '">' + t.set + "</a>
"), t.sp ? s += '<img src="' + wc.img_buyprice + '"/>' + t.bp + ' <img src="' + wc.img_sellprice + '"/> ' + t.sp + "
" : s += "" + wl.unsalable + "
", t.blding ? s += '
' + t.blding + '
' : s += "", 1 <= upgLvL ? s += 'Έξοδα αναβάθμισης: $' + upgPrice + '
' : s += "
", (t.lvl || t.cat) ? s += '
Χρειάζεται:
' : s += "", t.lvl && t.cat ? s += '- ' + wl.level + " " + t.lvl + "
" : 0 < t.lvl ? s += '- ' + wl.level + " " + t.lvl + "
" : s += "", "Εργάτης" == t.cat ? s += wc.cat_img + wc.worker + " " + t.cat + "</a>
" : "Μονομάχος" == t.cat ? s += wc.cat_img + wc.dueller + " " + t.cat + "</a>
" : "Στρατιώτης" == t.cat ? s += wc.cat_img + wc.soldier + " " + t.cat + "</a>
" : "Τυχοδιώκτης" == t.cat ? s += wc.cat_img + wc.adventurer + " " + t.cat + "</a>
" : "Πρωτάρης" == t.cat ? s += wc.cat_img + wc.greenhorn + " " + t.cat + "</a>
" : s += "", 1 == t.auc ? s += '
' + wl.auction + "
" : s += '' + wl.not_auction + "
", 0 == t.upg ? s += '' + wl.not_upgrade + "
" : s += '' + wl.upgrade + "
", s += '}, setPosition: function(t) { var e, i, a = $(window).width(), s = $(window).height(), p = westui.popup.getEl().outerWidth(), n = westui.popup.getEl().outerHeight(), o = t.clientX, l = t.clientY; i = o + p + 10 > a ? o - p - 10 + (t.pageX - t.clientX) : o + 10 + (t.pageX - t.clientX), e = l + n + 10 > s ? s - n + (t.pageY - t.clientY) : l + 10 + (t.pageY - t.clientY), westui.popup.getEl().css({ top: e, left: i }) }, init: function() {$("body").append('
westui.popup.show(this), westui.popup.setPosition(t) }), $(document).on("mouseleave", ".item_container", function() { westui.popup.hide() }), $(document).on("mousemove", ".item_container", function(t) { westui.popup.setPosition(t) }), $(".item_level").mousedown(function(t) { t.preventDefault() }), $(document).on("click", ".upgrade", function() { var t = $(this).closest(".item_container"), e = parseInt(t.attr("data-lvl")); 5 !== e && (t.attr("data-lvl", e + 1), t.find(".level").html(e + 1)), westui.popup.show(t[0]) }), $(document).on("click", ".downgrade", function() { var t = $(this).closest(".item_container"), e = parseInt(t.attr("data-lvl")); 0 !== e && (t.attr("data-lvl", e - 1), t.find(".level").html(e - 1)), westui.popup.show(t[0]) }) } }, set_calc: { bonus: { extra_set_bonus: {} }, data: {}, itemStatus: {}, getData: function() { $(".set_container").each(function() { var t = $(this).attr("data-set-id"); westui.set_calc.itemStatus[t] = {}, westui.set_calc.data[t] = { items: {}, set: {} } }), $(".infoSet").each(function() { var t = $(this).attr("data-set-id"); $(this).find(".infosetatt").each(function() { var e = $(this).attr("data-nb"); westui.set_calc.data[t].set[e] = {}, $(this).find(".set_bonus").each(function() { key = $(this).attr("data-type"), 0 !== $(this).find(".calc").length ? westui.set_calc.data[t].set[e][key] = -parseFloat($(this).find(".calc").attr("id")) : westui.set_calc.data[t].set[e][key] = parseFloat($(this).find(".val").text()), westui.config.set_bonus.hasOwnProperty(key) || (westui.set_calc.bonus.extra_set_bonus[key] = { img: $(this).find("img").attr("src"), name: $(this).find("#tooltip_content").text() }) }) }) }), $(".set_container").each(function() { var t = $(this).attr("data-set-id"); $(this).find(".item_container").each(function() { var e = JSON.parse($(this).attr("data-popup")); for (var i in $(this).is(":hidden") ? westui.set_calc.itemStatus[t][e.id] = !1 : westui.set_calc.itemStatus[t][e.id] = 0, e) e.hasOwnProperty(i) && (westui.config.set_bonus.hasOwnProperty(i) || westui.set_calc.bonus.extra_set_bonus.hasOwnProperty(i)) && (westui.set_calc.data[t].items[i] || (westui.set_calc.data[t].items[i] = {}), westui.set_calc.data[t].items[i][e.id] = e[i]) }) }) }, calc: function() { if (0 === $("#input_level").length | "" !== $("#input_level input").val()) { var t = parseInt($("#input_level input").val()); for (var e in total = {}, westui.set_calc.data) { for (var i in westui.set_calc.data[e].items) for (var a in westui.set_calc.data[e].items[i]) if (!1 !== westui.set_calc.itemStatus[e][a]) { lvl = westui.set_calc.itemStatus[e][a], total[i] || (total[i] = 0); var s = westui.set_calc.data[e].items[i][a]; westui.set_calc.data[e].items[i][a] < 0 ? (s = -s, westui.set_calc.itemStatus[e][a] > 0 ? total[i] += Math.ceil(s * t) + Math.round(Math.max(1, .1 * Math.ceil(s * t) * lvl)) : total[i] += Math.ceil(s * t)) : westui.set_calc.itemStatus[e][a] > 0 ? total[i] += s < 1 ? Math.round(1e6 * (1 * s + Math.round(Math.max(1, 1e3 * s * lvl)) / 1e4)) / 1e6 : s + Math.round(Math.max(1, .1 * s * lvl)) : total[i] += s } var n = 0; for (var a in westui.set_calc.itemStatus[e]) !1 !== westui.set_calc.itemStatus[e][a] && n++; for (var i in westui.set_calc.data[e].set[n]) total[i] || (total[i] = 0), westui.set_calc.data[e].set[n][i] < 0 ? total[i] += Math.ceil(-westui.set_calc.data[e].set[n][i] * t) : total[i] += westui.set_calc.data[e].set[n][i] }var p = '
";
for (var i in westui.config.set_bonus) total.hasOwnProperty(i) && (p += ' <img src="' + westui.config.set_bonus[i].img + '">+' + total[i] + (-1 !== ["xp", "money", "luck", "spd", "regen", "drop"].indexOf(i) ? "%" : "") + ' ");
for (var i in westui.set_calc.bonus.extra_set_bonus) total.hasOwnProperty(i) && (p += '' + westui.config.set_bonus[i].name + " <img src="' + westui.set_calc.bonus.extra_set_bonus[i].img + '">+' + total[i] + (-1 !== ["xp", "money", "luck", "spd", "regen", "drop"].indexOf(i) ? "%" : "") + ' ");
' + westui.set_calc.bonus.extra_set_bonus[i].name + " $("#set_calc").html(p) } else $("#set_calc").html("") }, initEvents: function() { $(".item_container > img").on("click", function() { var t = $(this).closest(".item_container"); t.toggleClass("item_off"); var e = t.closest(".set_container").attr("data-set-id"), i = JSON.parse(t.attr("data-popup")).id; t.hasClass("item_off") || t.is(":hidden") ? westui.set_calc.itemStatus[e][i] = !1 : westui.set_calc.itemStatus[e][i] = parseInt(t.attr("data-lvl")), westui.set_calc.calc() }), $(document).on("click", ".upgrade, .downgrade", function() { var t = $(this).closest(".item_container"), e = t.closest(".set_container").attr("data-set-id"); t.hasClass("item_off") || t.is(":hidden") || (westui.set_calc.itemStatus[e][JSON.parse(t.attr("data-popup")).id] = parseInt(t.attr("data-lvl")), westui.set_calc.calc()) }), $("#input_level").bind("propertychange keyup input paste", function() { westui.set_calc.calc() }), $("#switch").on("click", function() { $("#melee, #fire").each(function() { var t = $(this).find(".item_container"), e = $(this).closest(".set_container").attr("data-set-id"); $(this).is(":hidden") ? westui.set_calc.itemStatus[e][JSON.parse(t.attr("data-popup")).id] = !1 : westui.set_calc.itemStatus[e][JSON.parse(t.attr("data-popup")).id] = parseInt(t.attr("data-lvl")) }), westui.set_calc.calc() }) }, init: function() {westui.set_calc.initEvents(), westui.set_calc.getData(), $("#mw-content-text").append(''), 0 === $("#input_level").length && westui.set_calc.calc() } }, sorting: { sortItems: function(e) { function t(t) { var a = JSON.parse($(t).attr("data-popup")), i = $("#input_level input").val(); i = i || 150; var s = -1 !== Object.keys(e).indexOf("id") || e.bool && !0 === e.bool, p = 0; if (e.bool && !0 === e.bool) for (var n in p = 1, e) "bool" !== n && a[n] !== e[n] && (p = 0); else for (var n in e) "id" === n ? p -= a[n] : (!a.lvl || a.lvl <= i) && a[n] && (a[n] < 0 ? p += Math.round(Math.round(-a[n] * i) * e[n]) : p += Math.round(Math.round(a[n]) * e[n]));$(t).attr("data-sort", p), 0 == p && $(t).hide(), 0 !== $(t).find(".sortval").length ? s ? $(t).find(".sortval").html("") : $(t).find(".sortval").html(p) : s || $(t).append(' ' + p + " ")
} $(".item_container").removeAttr("data-sort").show(), $("#mw-content-text").find(".sorting_hidden").hide(), $(".sorting_container").each(function() { $(this).find(".item_container").sort(function(e, a) { return $(e).attr("data-sort") || t(e), $(a).attr("data-sort") || t(a), $(a).attr("data-sort") - $(e).attr("data-sort") }).appendTo($(this)) }) }, init: function() { if (1 === $("div#sort_items").length) {var e = " <select id='sort_items' class='west'><option selected disabled>Ταξινόμηση κατά:</option>";
", $("div#sort_items").html(e), $("select#sort_items").on("change", function() {
for (var t in westui.config.sorting) e += "<option value='" + westui.config.sorting[t] + "'>" + t + "</option>";e += "</select> westui.sorting.sortItems(JSON.parse($(this).find("option:selected").attr("value"))) }) } } }, init: function() { westui.initPage(), westui.popup.init(), westui.config.enable_sorting && westui.sorting.init(), westui.config.enable_set_calc && 0 !== $(".infoSet").length && westui.set_calc.init() } }, westui.init(); |