„Popup.js” változatai közötti eltérés
Nincs szerkesztési összefoglaló |
Nincs szerkesztési összefoglaló |
||
(12 közbenső módosítás, amit 4 másik szerkesztő végzett, nincs mutatva) | |||
1. sor: | 1. sor: | ||
westui = { | westui = { | ||
lang: { | |||
input_level: "Szinted", | input_level: "Szinted", | ||
input_search: "Keresés", | |||
damages: "Sebzés", | |||
per_level: "Szintenként", | |||
speed: "Sebesség", | |||
level: "Szint", | |||
unsalable: "Nem eladható", | |||
auction: "Aukciózható", | |||
not_auction: "Nem aukciózható", | |||
not_upgrade: "Nem fejleszthető", | |||
upgrade: "Fejleszthető", | |||
total: "Összesen", | |||
popup: { | |||
dmg: { | |||
dmglvl: '<p class="popup_dmg">+ #1 Sebzés#2</p>' | |||
}, | |||
skills: { | |||
str: '<p class="popup_attribute">+ #1 Erő#2</p>', | |||
mob: '<p class="popup_attribute">+ #1 Mozgékonyság#2</p>', | |||
dex: '<p class="popup_attribute">+ #1 Ügyesség#2</p>', | |||
cha: '<p class="popup_attribute">+ #1 Karizma#2</p>', | |||
con: '<p class="popup_skill">+ #1 Építés#2</p>', | |||
vig: '<p class="popup_skill">+ #1 Ütőerő#2</p>', | |||
tou: '<p class="popup_skill">+ #1 Szívósság#2</p>', | |||
sta: '<p class="popup_skill">+ #1 Kitartás#2</p>', | |||
hea: '<p class="popup_skill">+ #1 Életerő pont#2</p>', | |||
rid: '<p class="popup_skill">+ #1 Lovaglás#2</p>', | |||
ref: '<p class="popup_skill">+ #1 Reflex#2</p>', | |||
dod: '<p class="popup_skill">+ #1 Kitérés#2</p>', | |||
hid: '<p class="popup_skill">+ #1 Rejtőzés#2</p>', | |||
swi: '<p class="popup_skill">+ #1 Úszás#2</p>', | |||
aim: '<p class="popup_skill">+ #1 Célzás#2</p>', | |||
sho: '<p class="popup_skill">+ #1 Lövés#2</p>', | |||
pit: '<p class="popup_skill">+ #1 Csapdaállítás#2</p>', | |||
fin: '<p class="popup_skill">+ #1 Kézügyesség#2</p>', | |||
rep: '<p class="popup_skill">+ #1 Javítás#2</p>', | |||
lea: '<p class="popup_skill">+ #1 Irányítás#2</p>', | |||
tac: '<p class="popup_skill">+ #1 Taktika#2</p>', | |||
tra: '<p class="popup_skill">+ #1 Kereskedelem#2</p>', | |||
ani: '<p class="popup_skill">+ #1 Állati ösztön#2</p>', | |||
app: '<p class="popup_skill">+ #1 Fellépés#2</p>' | |||
}, | |||
fb: { | |||
fbdef: '<p class="popup_fb">+ #1 <b>Védekezés</b> (Erődharc bónusz)#2</p>', | |||
fboff: '<p class="popup_fb">+ #1 <b>Támadás</b> (Erődharc bónusz)#2</p>', | |||
fbres: '<p class="popup_fb">+ #1 <b>Ellenállás</b> (Erődharc bónusz)#2</p>', | |||
fbdefs: '<p class="popup_fb">+ #1 <b>Védekezés</b> (Erődharc szektorbónusz)#2</p>', | |||
fboffs: '<p class="popup_fb">+ #1 <b>Támadás</b> (Erődharc szektorbónusz)#2</p>', | |||
fbdmgs: '<p class="popup_fb">+ #1 <b>Sebzés</b> (Erődharc szektorbónusz)#2</p>' | |||
}, | |||
special: { | |||
xp: '<p class="popup_txtgreen">+ #1% tapasztalat a munkákból, párbajokból és az erődharcokból#2</p>', | |||
money: '<p class="popup_txtgreen">+ #1% Fizetség munkákból és párbajokból#2</p>', | |||
luck: '<p class="popup_txtgreen">+ #1% Szerencse#2</p>', | |||
regen: '<p class="popup_txtgreen">+ #1% Regeneráció#2</p>', | |||
drop: '<p class="popup_txtgreen">+ #1% Találati esély#2</p>', | |||
labor_pts: '<p class="popup_txtgreen">+ #1 munkapont#2</p>', | |||
building_pts: '<p class="popup_txtgreen">+ #1 munkapont erre: Építkezés#2</p>', | |||
spd: '<p class="popup_txtgreen">+ #1% Sebesség#2</p>' | |||
} | |||
} | |||
}, | |||
config: { | |||
enable_set_calc: true, | |||
plain_popup: true, | |||
redirect_on_dblclick: false, | |||
link_on_dblclick:true, | |||
enable_sorting:true, | |||
cdn: "https://westzz.innogamescdn.com", | |||
img_buyprice: "/images/5/57/Buy_price.png", | |||
img_sellprice: "/images/f/fc/Sell_price.png", | |||
img_male: "/images/c/c5/Gender_m.png", | |||
img_female: "/images/4/41/Gender_f.png", | |||
set_bonus: { | |||
str: { | |||
name: "Erő", | |||
img: "/images/f/f4/Erő.png" | |||
}, | |||
mob: { | |||
name: "Mozgékonyság", | |||
img: "/images/c/c0/Mozgékonyság.png" | |||
}, | |||
dex: { | |||
name: "Ügyesség", | |||
img: "/images/f/fe/Ügyesség.png" | |||
}, | |||
cha: { | |||
name: "Karizma", | |||
img: "/images/2/2e/Karizma.png" | |||
}, | |||
con: { | |||
name: "Építés", | |||
img: "/images/2/2a/Építés.png" | |||
}, | |||
vig: { | |||
name: "Ütőerő", | |||
img: "/images/1/1a/Ütőerő.png" | |||
}, | |||
tou: { | |||
name: "Szívósság", | |||
img: "/images/7/71/Szívósság.png" | |||
}, | |||
sta: { | |||
name: "Kitartás", | |||
img: "/images/3/3a/Kitartás.png" | |||
}, | |||
hea: { | |||
name: "Életerő pont", | |||
img: "/images/a/a9/Életerő_pont.png" | |||
}, | |||
rid: { | |||
name: "Lovaglás", | |||
img: "/images/2/21/Lovaglás.png" | |||
}, | |||
ref: { | |||
name: "Reflex", | |||
img: "/images/b/b2/Reflex.png" | |||
}, | |||
dod: { | |||
name: "Kitérés", | |||
img: "/images/d/d3/Kitérés.png" | |||
}, | |||
hid: { | |||
name: "Rejtőzés", | |||
img: "/images/f/f3/Rejtőzés.png" | |||
}, | |||
swi: { | |||
name: "Úszás", | |||
img: "/images/6/69/Úszás.png" | |||
}, | |||
aim: { | |||
name: "Célzás", | |||
img: "/images/2/22/Célzás.png" | |||
}, | |||
sho: { | |||
name: "Lövés", | |||
img: "/images/0/07/Lövés.png" | |||
}, | |||
pit: { | |||
name: "Csapdaállítás", | |||
img: "/images/4/41/Csapdaállítás.png" | |||
}, | |||
fin: { | |||
name: "Kézügyesség", | |||
img: "/images/3/32/Kézügyesség.png" | |||
}, | |||
rep: { | |||
name: "Javítás", | |||
img: "/images/6/64/Javítás.png" | |||
}, | |||
lea: { | |||
name: "Irányítás", | |||
img: "/images/a/ad/Irányítás.png" | |||
}, | |||
tac: { | |||
name: "Taktika", | |||
img: "/images/4/41/Taktika.png" | |||
}, | |||
tra: { | |||
name: "Kereskedelem", | |||
img: "/images/c/c5/Kereskedelem_képesség.png" | |||
}, | |||
ani: { | |||
name: "Állati ösztön", | |||
img: "/images/7/7c/Állati_ösztön.png" | |||
}, | |||
app: { | |||
name: "Fellépés", | |||
img: "/images/1/1a/Fellépés.png" | |||
}, | |||
fbdef: { | |||
name: "<b>Védekezés</b> (Erődharc bónusz)", | |||
img: "/images/a/a5/Védekezés.png" | |||
}, | |||
fboff: { | |||
name: "<b>Támadás</b> (Erődharc bónusz)", | |||
img: "/images/6/6f/Támadás.png" | |||
}, | |||
fbres: { | |||
name: "<b>Ellenállás</b> (Erődharc bónusz)", | |||
img: "/images/8/80/Ellenállás_képesség.png" | |||
}, | |||
fbdefs: { | |||
name: "<b>Védelem</b> (Erődharc szektorbónusz)", | |||
img: "/images/b/b9/Védekezés%28szek%29.png" | |||
}, | |||
fboffs: { | |||
name: "<b>Támadás</b> (Erődharc szektorbónusz)", | |||
img: "/images/9/92/Támadás%28szek%29.png" | |||
}, | |||
fbdmgs: { | |||
name: "<b>Sebzés</b> (Erődharc szektorbónusz)", | |||
img: "/images/7/78/Sebzés%28szek%29.png" | |||
}, | |||
xp: { | |||
name: "tapasztalat munkákból, párbajokból és az erődharcokból (%)", | |||
img: "/images/2/26/TPM.png" | |||
}, | |||
money: { | |||
name: "Pénz munkákból és párbajokból (%)", | |||
img: "/images/8/84/Pénz.png" | |||
}, | |||
luck: { | |||
name: "Szerencse", | |||
img: "/images/8/8a/Szerencse.png" | |||
}, | |||
regen: { | |||
name: "Regeneráció", | |||
img: "/images/5/58/Regeneráció.png", | |||
}, | |||
drop: { | |||
name: "Találati esély", | |||
img: "/images/5/59/Találati_esély.png" | |||
}, | |||
spd: { | |||
name: "Sebesség", | |||
img: "/images/2/25/Sebesség.png" | |||
}, | |||
building_pts: { | |||
name: "Munkapont erre: Építkezés", | |||
img: "/images/2/2c/Building_pts.png" | |||
} | |||
}, | |||
sorting: { | |||
'Erő':'{"str":1}', | |||
'Mozgékonyság':'{"mob":1}', | |||
'Ügyesség':'{"dex":1}', | |||
'Karizma':'{"cha":1}', | |||
'Építés':'{"str":1,"con":1}', | |||
'Ütőerő':'{"str":1,"vig":1}', | |||
'Szívósság':'{"str":1,"tou":1}', | |||
'Kitartás':'{"str":1,"sta":1}', | |||
'Életerő pont':'{"str":1,"hea":1}', | |||
'Lovaglás':'{"mob":1,"rid":1}', | |||
'Reflex':'{"mob":1,"ref":1}', | |||
'Kitérés':'{"mob":1,"dod":1}', | |||
'Rejtőzés':'{"mob":1,"hid":1}', | |||
'Úszás':'{"mob":1,"swi":1}', | |||
'Célzás':'{"dex":1,"aim":1}', | |||
'Lövés':'{"dex":1,"sho":1}', | |||
'Csapdaállítás':'{"dex":1,"pit":1}', | |||
'Kézügyesség':'{"dex":1,"fin":1}', | |||
'Javítás':'{"dex":1,"rep":1}', | |||
'Irányítás':'{"cha":1,"lea":1}', | |||
'Taktika':'{"cha":1,"tac":1}', | |||
'Kereskedelem':'{"cha":1,"tra":1}', | |||
'Állati ösztön':'{"cha":1,"ani":1}', | |||
'Fellépés':'{"cha":1,"app":1}', | |||
'Városépítés':'{"str":3,"con":3,"dex":1,"rep":1,"cha":1,"lea":1}', | |||
'Tapasztalat a munkákból, párbajokból és az erődharcokból(%)':'{"xp":1}', | |||
'Pénz munkákból és párbajokból (%)':'{"money":1}', | |||
'Szerencse (%)':'{"luck":1}', | |||
'Regeneráció(%)':'{"regen":1}', | |||
'Találati esély(%)':'{"drop":1}', | |||
'Sebesség (%)':'{"spd":1,"hspd":1,"mob":1,"rid":1}', | |||
'Átlag sebzés':'{"dmg_min":0.5,"dmg_max":0.5,"dmglvl":1}', | |||
'Maximum sebzés':'{"dmg_max":1,"dmglvl":1}', | |||
} | |||
}, | |||
initPage: function () { | |||
//Append input level | |||
if ($("#input_level").length === 1) { | |||
var input_level = $('<input type="number" style="width:80px;" class="west" placeholder="' + westui.lang.input_level + '" min="0" max="250">').bind("propertychange keyup input paste", function () { | |||
if (this.value > 250) { | |||
this.value = 250; | |||
} else if (this.value < 0) { | |||
this.value = 0; | |||
} | |||
$(".calc").each(function () { | |||
if (input_level.val() == 0) { | |||
$(this).html(this.id); | |||
$('.per_level_off').addClass('per_level').removeClass('per_level_off'); | |||
} else { | |||
$(this).html(Math.ceil(Number(this.id) * input_level.val())); | |||
$('.per_level').addClass('per_level_off').removeClass('per_level'); | |||
} | |||
}); | |||
}).appendTo($("#input_level")); | |||
} | |||
//Search | |||
if ($("#input_search").length === 1) { | |||
var input_search = $('<input type="search" class="west" placeholder="' + westui.lang.input_search + '">').bind("propertychange keyup input paste", function () { | |||
var val = this.value.toLowerCase(); | |||
if (val === '') { | |||
$('.item_container').show(); | |||
} else { | |||
$('.item_container').hide(); | |||
$('.item_container').filter(function () { | |||
return $(this).attr('data-popup').toLowerCase().indexOf(val) > -1; | |||
}).show(); | |||
} | |||
}).appendTo($("#input_search")); | |||
} | |||
//Switch weapons | |||
if ($("#switch").length === 1) { | |||
$("#fire").hide(); | |||
$("#switch").on("click", function () { | |||
$('#melee, #fire').toggle(); | |||
}); | |||
} | |||
//Switch products | |||
if ($("#switch_prod").length === 1) { | |||
$("#prod2").hide(); | |||
$("#switch_prod").on("click", function () { | |||
$('#prod, #prod2').toggle(); | |||
}); | |||
} | |||
//Show a "plain text" popup in the template | |||
if (westui.config.plain_popup && (new RegExp(mw.config.get('wgFormattedNamespaces')[10] + '\:Item\_*').test(mw.config.get('wgPageName'))) && ($('.item_container').length === 1)) { | |||
$('#mw-content-text').append('<center><div id="popup_plain" class="popup_window"><div class="popup_front"><div class="tw_bg_tl"></div><div class="tw_bg_tr"></div><div class="tw_bg_bl"></div><div class="tw_bg_br"></div></div><div id="popup_plain_contents" class="popup_contents"></div></div></center>'); | |||
$('#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(); | |||
} | |||
//On dbl click on item, redirect the user to the template | |||
if (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 / 1000; | |||
}); | |||
} | |||
if (westui.config.link_on_dblclick) { | |||
$('.item_container img').on('dblclick', function () { | |||
window.location = '/wiki/' + $(this).parent().attr('data-link'); | |||
}); | |||
} | |||
}, | |||
popup: { | |||
content: "", | |||
delay: 200, | |||
active: false, | |||
show: function (obj) { | |||
westui.popup.content = westui.popup.createPopup($(obj).attr('data-popup'), $(obj).attr('data-cdn-cat'), $(obj).attr('data-cdn-img'), parseInt($(obj).attr('data-lvl'))); | |||
westui.popup.active = true; | |||
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 = false; | |||
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 () { | |||
if (westui.popup.timer) window.clearTimeout(westui.popup.timer); | |||
}, | |||
getEl: function () { | |||
return $('#popup_window'); | |||
}, | |||
getContainer: function () { | |||
return $('#popup_contents'); | |||
}, | |||
createPopup: function (data, cdn_cat, cdn_name, lvl) { | |||
data = JSON.parse(data); | |||
var html = '<div class="popup_image"><img src="' + westui.config.cdn + '/images/items/' + data.cdn_cat + '/' + data.cdn_img + '.png' + '"/></div><div class="popup_divider"></div><p class="popup_name">' + data.name + '</p><p class="popup_type">' + data.type + '</p><br/>'; | |||
var upgraded = false; | |||
if ((lvl >= 1) && (lvl <= 5)) { | |||
upgraded = true; | |||
data.auc = false; | |||
} | |||
if (data.dmg_min && data.dmg_max) { | |||
if (upgraded) { | |||
data.dmg_min += Math.round(Math.max(1, data.dmg_min * 0.1 * lvl)); | |||
data.dmg_max += Math.round(Math.max(1, data.dmg_max * 0.1 * lvl)); | |||
} | |||
html += '<p class="popup_dmg">' + data.dmg_min + '-' + data.dmg_max + ' ' + westui.lang.damages + '</p>'; | |||
} | |||
if (data.text) { | |||
for (var i = 0; i < data.text.length; i++) { | |||
html += '<p class="popup_text">' + data.text[i] + '</p>'; | |||
} | |||
html += '<br/>'; | |||
} | |||
for (var cat in westui.lang.popup) { | |||
var cnt = 0; | |||
for (var key in westui.lang.popup[cat]) { | |||
if (data.hasOwnProperty(key)) { | |||
cnt++; | |||
var per_level = ""; | |||
if (data[key] < 0) { | |||
if ($('#input_level input').val() > 0) { | |||
data[key] = Math.ceil($('#input_level input').val() * -data[key]); | |||
if (upgraded) { | |||
data[key] += Math.round(Math.max(1, data[key] * 0.1 * lvl)); | |||
} | |||
} else { | |||
data[key] = -data[key]; | |||
per_level = " (" + westui.lang.per_level + ")"; | |||
if (upgraded) { | |||
data[key] = Math.round(1e6 * (data[key] * 1 + Math.round(Math.max(1, data[key] * 1000 * lvl)) / 10000)) / 1e6; | |||
} | |||
} | |||
} else if (upgraded) { | |||
if (data[key] < 1) { | |||
data[key] = Math.round(1e6 * (data[key] * 1 + Math.round(Math.max(1, data[key] * 1000 * lvl)) / 10000)) / 1e6; | |||
} else { | |||
data[key] += Math.round(Math.max(1, data[key] * 0.1 * lvl)); | |||
} | |||
} | |||
html += westui.lang.popup[cat][key].replace('#1', data[key]).replace('#2', per_level); | |||
} | |||
} | |||
if (cnt > 0) { | |||
html += '<br/>'; | |||
} | |||
} | |||
if (data.textjob) { | |||
for (var i = 0; i < data.textjob.length; i++) { | |||
html += '<p class="popup_txtgreen">' + data.textjob[i] + '</p>'; | |||
} | |||
html += '<br/>'; | |||
} | |||
if (data.bonus) { | |||
for (var i = 0; i < data.bonus.length; i++) { | |||
html += '<p class="popup_bonus">' + data.bonus[i] + '</p>'; | |||
} | |||
html += '<br/>'; | |||
} | |||
if (data.jobs) { | |||
html += '<div style="text-align:center;"><table class="popup_job">'; | |||
for (var i = 0; i < data.jobs.length; i++) { | |||
html += '<tr><td><img src="' + westui.config.cdn + '/images/jobs/' + data.jobs[i][1] + '.png"/></td><td><span> ' + data.jobs[i][0] + '</span></td></tr>'; | |||
} | |||
html += '</table></div>'; | |||
} | |||
if (data.craft) { | |||
html += '<div style="text-align:center;"><table class="popup_crafteditem"><tr><td><img src="' + westui.config.cdn + '/images/crafting/profsymbol_' + data.craft.id + '_small.png"/></td><td><table><tr>'; | |||
for (var i = 0; i < data.craft.req.length; i++) { | |||
html += '<td><img style="width:36px;height:36px;" src="' + westui.config.cdn + '/images/items/yield/' + data.craft.req[i][0] + '.png"/></td>'; | |||
} | |||
html += '</tr><tr>'; | |||
for (var i = 0; i < data.craft.req.length; i++) { | |||
html += '<td><span>x' + data.craft.req[i][1] + '</span></td>'; | |||
} | |||
html += '</tr></table></td></tr></table></div>'; | |||
} | |||
html += '<div class="popup_infos">'; | |||
if (data.hspd) { | |||
if (upgraded) { | |||
data.hspd += Math.round(Math.max(1, data.hspd * 0.1 * lvl)); | |||
} | |||
html += '<p class="popup_speed">' + westui.lang.speed + ': +' + data.hspd + '%</p><br/>'; | |||
} | |||
if (data.set) html += '<p><a class="popup_set" href="/wiki/' + data.set + '">' + data.set + '</a></p><br/>'; | |||
if (data.sp) { | |||
html += '<img src="' + westui.config.img_buyprice + '"/>' + data.bp + ' <img src="' + westui.config.img_sellprice + '"/> ' + data.sp + '<br/><br/>'; | |||
} else { | |||
html += '<i>' + westui.lang.unsalable + '</i><br/><br/>'; | |||
} | |||
if (data.lvl) html += westui.lang.level + ' <b>' + data.lvl + '</b><br/>'; | |||
if (data.sex) { | |||
if (data.sex == 0) { | |||
html += '<img src="' + westui.config.img_male + '"/> '; | |||
} else { | |||
html += '<img src="' + westui.config.img_female + '"/> '; | |||
} | |||
} | |||
if (data.auc == 1) { | |||
html += '<span class="popup_txtgreen">' + westui.lang.auction + '</span><br/>'; | |||
} else { | |||
html += '<span class="popup_txtred">' + westui.lang.not_auction + '</span><br/>'; | |||
} | |||
if (data.upg == 0) { | |||
html += '<span class="popup_txtred">' + westui.lang.not_upgrade + '</span><br/>'; | |||
} else { | |||
html += '<span class="popup_txtgreen">' + westui.lang.upgrade + '</span><br/>'; | |||
} | |||
html += '<br/><p class="popup_id">[item=<b>' + data.id + '</b>]</p></div>'; | |||
return html; | |||
}, | |||
setPosition: function (e) { | |||
var window_width = $(window).width(); | |||
var window_height = $(window).height(); | |||
var popup_width = westui.popup.getEl().outerWidth(); | |||
var popup_height = westui.popup.getEl().outerHeight(); | |||
var pos_x = e.clientX; | |||
var pos_y = e.clientY; | |||
var top; | |||
var left; | |||
var margin_top = 20; | |||
var margin_left = 20; | |||
if (pos_x + popup_width + margin_left > window_width) { | |||
left = pos_x - popup_width - margin_left + (e.pageX - e.clientX); | |||
} else { | |||
left = pos_x + margin_left + (e.pageX - e.clientX); | |||
} | |||
if (pos_y + popup_height + margin_top > window_height) { | |||
top = window_height - popup_height + (e.pageY - e.clientY); | |||
} else { | |||
top = pos_y + margin_top + (e.pageY - e.clientY); | |||
} | |||
westui.popup.getEl().css({ | |||
top: top, | |||
left: left | |||
}); | |||
}, | |||
init: function () { | |||
//Append popup container | |||
$('body').append('<div id="popup_window" class="popup_window"><div class="popup_front"><div class="tw_bg_tl"></div><div class="tw_bg_tr"></div><div class="tw_bg_bl"></div><div class="tw_bg_br"></div></div><div id="popup_contents" class="popup_contents"></div></div>'); | |||
//Set events | |||
$(document).on('mouseenter', '.item_container', function (e) { | |||
westui.popup.show(this); | |||
westui.popup.setPosition(e); | |||
}); | |||
$(document).on('mouseleave', '.item_container', function () { | |||
westui.popup.hide(); | |||
}); | |||
$(document).on('mousemove', '.item_container', function (e) { | |||
westui.popup.setPosition(e); | |||
}); | |||
$('.item_level').mousedown(function (e) { | |||
e.preventDefault(); | |||
}); | |||
$(document).on('click', '.upgrade', function () { | |||
var container = $(this).closest('.item_container'); | |||
var lvl = parseInt(container.attr('data-lvl')); | |||
if (lvl !== 5) { | |||
container.attr('data-lvl', lvl + 1); | |||
container.find('.level').html(lvl + 1); | |||
} | |||
westui.popup.show(container[0]); | |||
}); | |||
$(document).on('click', '.downgrade', function () { | |||
var container = $(this).closest('.item_container'); | |||
var lvl = parseInt(container.attr('data-lvl')); | |||
if (lvl !== 0) { | |||
container.attr('data-lvl', lvl - 1); | |||
container.find('.level').html(lvl - 1); | |||
} | |||
westui.popup.show(container[0]); | |||
}); | |||
} | |||
}, | |||
set_calc: { | |||
bonus: { | |||
//If there are any other "special" bonuses, they will be dynamically retrieved and stored there | |||
extra_set_bonus: {} | |||
}, | |||
//Bonuses from all sets / items : | |||
data: {}, | |||
//Status of all items (item lvl, activated or not) | |||
itemStatus: {}, | |||
getData: function () { | |||
$('.set_container').each(function () { | |||
var set_id = $(this).attr('data-set-id'); | |||
westui.set_calc.itemStatus[set_id] = {}; | |||
westui.set_calc.data[set_id] = { | |||
items: {}, | |||
set: {} | |||
}; | |||
}); | |||
//Get bonuses from all sets | |||
$('.infoSet').each(function () { | |||
var set_id = $(this).attr('data-set-id'); | |||
$(this).find('.infosetatt').each(function () { | |||
var nb = $(this).attr('data-nb'); | |||
westui.set_calc.data[set_id].set[nb] = {}; | |||
$(this).find('.set_bonus').each(function () { | |||
key = $(this).attr('data-type'); | |||
if ($(this).find('.calc').length !== 0) { | |||
westui.set_calc.data[set_id].set[nb][key] = -parseFloat($(this).find('.calc').attr('id')); | |||
} else { | |||
westui.set_calc.data[set_id].set[nb][key] = parseFloat($(this).find('.val').text()); | |||
} | |||
if (!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() | |||
}; | |||
} | |||
}); | |||
}); | |||
}); | |||
//Get bonuses from all item sets | |||
$('.set_container').each(function () { | |||
var set_id = $(this).attr('data-set-id'); | |||
$(this).find('.item_container').each(function () { | |||
var json = JSON.parse($(this).attr('data-popup')); | |||
if ($(this).is(":hidden")) { | |||
westui.set_calc.itemStatus[set_id][json.id] = false; | |||
} else { | |||
westui.set_calc.itemStatus[set_id][json.id] = 0; | |||
} | |||
for (var prop in json) { | |||
if (json.hasOwnProperty(prop) && (westui.config.set_bonus.hasOwnProperty(prop) || westui.set_calc.bonus.extra_set_bonus.hasOwnProperty(prop))) { | |||
if (!westui.set_calc.data[set_id].items[prop]) { | |||
westui.set_calc.data[set_id].items[prop] = {}; | |||
} | |||
westui.set_calc.data[set_id].items[prop][json.id] = json[prop]; | |||
} | |||
} | |||
}); | |||
}); | |||
}, | |||
calc: function () { | |||
//Only calc if a player level is provided | |||
if ($('#input_level').length === 0 | $('#input_level input').val() !== "") { | |||
var level = parseInt($('#input_level input').val()); | |||
total = {}; | |||
for (var set_id in westui.set_calc.data) { | |||
for (var key in westui.set_calc.data[set_id].items) { | |||
for (var item_id in westui.set_calc.data[set_id].items[key]) { | |||
if (westui.set_calc.itemStatus[set_id][item_id] !== false) { | |||
lvl = westui.set_calc.itemStatus[set_id][item_id]; | |||
if (!total[key]) { | |||
total[key] = 0; | |||
} | |||
var value = westui.set_calc.data[set_id].items[key][item_id]; | |||
if (westui.set_calc.data[set_id].items[key][item_id] < 0) { | |||
//If bonus (per Level) | |||
value = -value; | |||
if (westui.set_calc.itemStatus[set_id][item_id] > 0) { | |||
//If item upgraded | |||
total[key] += Math.ceil(value * level) + Math.round(Math.max(1, Math.ceil(value * level) * 0.1 * lvl)); | |||
} else { | |||
total[key] += Math.ceil(value * level); | |||
} | |||
} else { | |||
if (westui.set_calc.itemStatus[set_id][item_id] > 0) { | |||
if (value < 1) { | |||
total[key] += Math.round(1e6 * (value * 1 + Math.round(Math.max(1, value * 1000 * lvl)) / 10000)) / 1e6; | |||
} else { | |||
total[key] += value + Math.round(Math.max(1, value * 0.1 * lvl)); | |||
} | |||
} else { | |||
total[key] += value; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
var item_nb = 0; | |||
for (var item_id in westui.set_calc.itemStatus[set_id]) { | |||
if (westui.set_calc.itemStatus[set_id][item_id] !== false) { | |||
item_nb++; | |||
} | |||
} | |||
for (var key in westui.set_calc.data[set_id].set[item_nb]) { | |||
if (!total[key]) { | |||
total[key] = 0; | |||
} | |||
if (westui.set_calc.data[set_id].set[item_nb][key] < 0) { | |||
total[key] += Math.ceil(-westui.set_calc.data[set_id].set[item_nb][key] * level); | |||
} else { | |||
total[key] += westui.set_calc.data[set_id].set[item_nb][key]; | |||
} | |||
} | |||
} | |||
//Create the html table | |||
var html = '<center><table class="infoSet"><caption><br><big><b>' + westui.lang.total + '</b></big></caption><tbody><tr><td></center>'; | |||
for (var key in westui.config.set_bonus) { | |||
if (total.hasOwnProperty(key)) { | |||
html += '<div class="set_bonus tooltip_container"><img src="' + westui.config.set_bonus[key].img + '"><b>+' + total[key] + (['xp', 'money', 'luck', 'spd', 'regen', 'drop'].indexOf(key) !== -1 ? "%" : "") + '</b><div class="tooltip_outer"><div class="tooltip"><div class="tt_bg_tl"></div><div class="tt_bg_tr"></div><div class="tt_bg_bl"></div><div class="tt_bg_br"></div><div id="tooltip_content">' + westui.config.set_bonus[key].name + '</div></div></div></div>'; | |||
} | |||
} | |||
for (var key in westui.set_calc.bonus.extra_set_bonus) { | |||
if (total.hasOwnProperty(key)) { | |||
html += '<div class="set_bonus tooltip_container"><img src="' + westui.set_calc.bonus.extra_set_bonus[key].img + '"><b>+' + total[key] + (['xp', 'money', 'luck', 'spd', 'regen', 'drop'].indexOf(key) !== -1 ? "%" : "") + '</b><div class="tooltip_outer"><div class="tooltip"><div class="tt_bg_tl"></div><div class="tt_bg_tr"></div><div class="tt_bg_bl"></div><div class="tt_bg_br"></div><div id="tooltip_content">' + westui.set_calc.bonus.extra_set_bonus[key].name + '</div></div></div></div>'; | |||
} | |||
} | |||
//Display the result at the bottom of the page | |||
$('#set_calc').html(html); | |||
} else { | |||
$('#set_calc').html(""); | |||
} | |||
}, | |||
initEvents: function () { | |||
//Deactivate / activate item on click | |||
$('.item_container > img').on('click', function () { | |||
var item_container = $(this).closest('.item_container'); | |||
item_container.toggleClass('item_off'); | |||
var set_id = item_container.closest('.set_container').attr('data-set-id'); | |||
var item_id = JSON.parse(item_container.attr('data-popup')).id; | |||
if (item_container.hasClass('item_off') || item_container.is(":hidden")) { | |||
westui.set_calc.itemStatus[set_id][item_id] = false; | |||
} else { | |||
westui.set_calc.itemStatus[set_id][item_id] = parseInt(item_container.attr('data-lvl')); | |||
} | |||
westui.set_calc.calc(); | |||
}); | |||
//Update item level on upgrade / downgrade | |||
$(document).on('click', '.upgrade, .downgrade', function () { | |||
var item = $(this).closest('.item_container'); | |||
var set_id = item.closest('.set_container').attr('data-set-id'); | |||
if (!item.hasClass('item_off') && !item.is(":hidden")) { | |||
westui.set_calc.itemStatus[set_id][JSON.parse(item.attr('data-popup')).id] = parseInt(item.attr('data-lvl')); | |||
westui.set_calc.calc(); | |||
} | |||
}); | |||
//Calc again when player level changes | |||
$("#input_level").bind("propertychange keyup input paste", function () { | |||
westui.set_calc.calc(); | |||
}); | |||
//Activate/deactivate melee/fire weapon when the switch btn is clicked | |||
$("#switch").on('click', function () { | |||
$('#melee, #fire').each(function () { | |||
var item = $(this).find('.item_container'); | |||
var set_id = $(this).closest('.set_container').attr('data-set-id'); | |||
if ($(this).is(":hidden")) { | |||
westui.set_calc.itemStatus[set_id][JSON.parse(item.attr('data-popup')).id] = false; | |||
} else { | |||
westui.set_calc.itemStatus[set_id][JSON.parse(item.attr('data-popup')).id] = parseInt(item.attr('data-lvl')); | |||
} | |||
}); | |||
westui.set_calc.calc(); | |||
}); | |||
}, | |||
init: function () { | |||
westui.set_calc.initEvents(); | |||
westui.set_calc.getData(); | |||
$('#mw-content-text').append('<div id="set_calc"></div>'); | |||
if ($('#input_level').length === 0) | |||
westui.set_calc.calc(); | |||
} | |||
}, | |||
sorting: { | |||
sortItems: function(param){ | |||
$('.item_container').removeAttr('data-sort'); | |||
function calcSortVal(el){ | |||
var data = JSON.parse($(el).attr('data-popup')); | |||
var val = 0; | |||
for (var prop in param){ | |||
if (data[prop]){ | |||
if (data[prop]<0){ | |||
val+=Math.ceil(-data[prop]*($('#input_level input').val()?$('#input_level input').val():150))*param[prop]; | |||
} else { | |||
val+=data[prop]*param[prop]; | |||
} | |||
} | |||
} | |||
$(el).attr('data-sort',val); | |||
if ($(el).find('p.number').length!==0){ | |||
$(el).find('p.number').html(val); | |||
} else { | |||
$(el).append('<p class="number">'+val+'</p>'); | |||
} | |||
} | |||
$('#mw-content-text').find('.sorting_hidden').hide(); | |||
$('#mw-content-text').find('.item_container').sort(function(a, b) { | |||
if (!$(a).attr('data-sort')){calcSortVal(a);} | |||
if (!$(b).attr('data-sort')){calcSortVal(b);} | |||
return $(b).attr('data-sort') - $(a).attr('data-sort'); | |||
}).appendTo('#mw-content-text'); | |||
}, | |||
init:function(){ | |||
if ($('div#sort_items').length===1){ | |||
var html = "<div id='input_search'><select id='sort_items' class='west'><option selected disabled>Rendezés :</option>"; | |||
for (var prop in westui.config.sorting){ | |||
html+= "<option value='"+westui.config.sorting[prop]+"'>"+prop+"</option>"; | |||
} | |||
html += "</select></div>"; | |||
$('div#sort_items').html(html); | |||
$('select#sort_items').on('change',function(){ | |||
westui.sorting.sortItems(JSON.parse($(this).find("option:selected").attr('value'))); | |||
}); | |||
} | |||
} | |||
}, | |||
init: function () { | |||
westui.initPage(); | |||
westui.popup.init(); | |||
if (westui.config.enable_sorting) | |||
westui.sorting.init(); | |||
if (westui.config.enable_set_calc && $('.infoSet').length !== 0) { | |||
westui.set_calc.init(); | |||
} | |||
} | |||
}; | |||
westui.init(); |
A lap jelenlegi, 2023. október 25., 21:02-kori változata
westui = {
lang: { input_level: "Szinted", input_search: "Keresés", damages: "Sebzés", per_level: "Szintenként", speed: "Sebesség", level: "Szint", unsalable: "Nem eladható", auction: "Aukciózható", not_auction: "Nem aukciózható", not_upgrade: "Nem fejleszthető", upgrade: "Fejleszthető", total: "Összesen", popup: { dmg: {
dmglvl: '
+ #1 Sebzés#2
'
}, skills: {
str: '
+ #1 Erő#2
', mob: '
+ #1 Mozgékonyság#2
', dex: '
+ #1 Ügyesség#2
', cha: '
+ #1 Karizma#2
', con: '
+ #1 Építés#2
', vig: '
+ #1 Ütőerő#2
', tou: '
+ #1 Szívósság#2
', sta: '
+ #1 Kitartás#2
', hea: '
+ #1 Életerő pont#2
', rid: '
+ #1 Lovaglás#2
', ref: '
+ #1 Reflex#2
', dod: '
+ #1 Kitérés#2
', hid: '
+ #1 Rejtőzés#2
', swi: '
+ #1 Úszás#2
', aim: '
+ #1 Célzás#2
', sho: '
+ #1 Lövés#2
', pit: '
+ #1 Csapdaállítás#2
', fin: '
+ #1 Kézügyesség#2
', rep: '
+ #1 Javítás#2
', lea: '
+ #1 Irányítás#2
', tac: '
+ #1 Taktika#2
', tra: '
+ #1 Kereskedelem#2
', ani: '
+ #1 Állati ösztön#2
', app: '
+ #1 Fellépés#2
'
}, fb: {
fbdef: '
+ #1 Védekezés (Erődharc bónusz)#2
', fboff: '
+ #1 Támadás (Erődharc bónusz)#2
', fbres: '
+ #1 Ellenállás (Erődharc bónusz)#2
', fbdefs: '
+ #1 Védekezés (Erődharc szektorbónusz)#2
', fboffs: '
+ #1 Támadás (Erődharc szektorbónusz)#2
', fbdmgs: '
+ #1 Sebzés (Erődharc szektorbónusz)#2
'
}, special: {
xp: '
+ #1% tapasztalat a munkákból, párbajokból és az erődharcokból#2
', money: '
+ #1% Fizetség munkákból és párbajokból#2
', luck: '
+ #1% Szerencse#2
', regen: '
+ #1% Regeneráció#2
', drop: '
+ #1% Találati esély#2
', labor_pts: '
+ #1 munkapont#2
', building_pts: '
+ #1 munkapont erre: Építkezés#2
', spd: '
+ #1% Sebesség#2
'
} } }, config: { enable_set_calc: true, plain_popup: true, redirect_on_dblclick: false, link_on_dblclick:true, enable_sorting:true, cdn: "https://westzz.innogamescdn.com", img_buyprice: "/images/5/57/Buy_price.png", img_sellprice: "/images/f/fc/Sell_price.png", img_male: "/images/c/c5/Gender_m.png", img_female: "/images/4/41/Gender_f.png", set_bonus: { str: { name: "Erő", img: "/images/f/f4/Erő.png" }, mob: { name: "Mozgékonyság", img: "/images/c/c0/Mozgékonyság.png" }, dex: { name: "Ügyesség", img: "/images/f/fe/Ügyesség.png" }, cha: { name: "Karizma", img: "/images/2/2e/Karizma.png" }, con: { name: "Építés", img: "/images/2/2a/Építés.png" }, vig: { name: "Ütőerő", img: "/images/1/1a/Ütőerő.png" }, tou: { name: "Szívósság", img: "/images/7/71/Szívósság.png" }, sta: { name: "Kitartás", img: "/images/3/3a/Kitartás.png" }, hea: { name: "Életerő pont", img: "/images/a/a9/Életerő_pont.png" }, rid: { name: "Lovaglás", img: "/images/2/21/Lovaglás.png" }, ref: { name: "Reflex", img: "/images/b/b2/Reflex.png" }, dod: { name: "Kitérés", img: "/images/d/d3/Kitérés.png" }, hid: { name: "Rejtőzés", img: "/images/f/f3/Rejtőzés.png" }, swi: { name: "Úszás", img: "/images/6/69/Úszás.png" }, aim: { name: "Célzás", img: "/images/2/22/Célzás.png" }, sho: { name: "Lövés", img: "/images/0/07/Lövés.png" }, pit: { name: "Csapdaállítás", img: "/images/4/41/Csapdaállítás.png" }, fin: { name: "Kézügyesség", img: "/images/3/32/Kézügyesség.png" }, rep: { name: "Javítás", img: "/images/6/64/Javítás.png" }, lea: { name: "Irányítás", img: "/images/a/ad/Irányítás.png" }, tac: { name: "Taktika", img: "/images/4/41/Taktika.png" }, tra: { name: "Kereskedelem", img: "/images/c/c5/Kereskedelem_képesség.png" }, ani: { name: "Állati ösztön", img: "/images/7/7c/Állati_ösztön.png" }, app: { name: "Fellépés", img: "/images/1/1a/Fellépés.png" }, fbdef: { name: "Védekezés (Erődharc bónusz)", img: "/images/a/a5/Védekezés.png" }, fboff: { name: "Támadás (Erődharc bónusz)", img: "/images/6/6f/Támadás.png" }, fbres: { name: "Ellenállás (Erődharc bónusz)", img: "/images/8/80/Ellenállás_képesség.png" }, fbdefs: { name: "Védelem (Erődharc szektorbónusz)", img: "/images/b/b9/Védekezés%28szek%29.png" }, fboffs: { name: "Támadás (Erődharc szektorbónusz)", img: "/images/9/92/Támadás%28szek%29.png" }, fbdmgs: { name: "Sebzés (Erődharc szektorbónusz)", img: "/images/7/78/Sebzés%28szek%29.png" }, xp: { name: "tapasztalat munkákból, párbajokból és az erődharcokból (%)", img: "/images/2/26/TPM.png" }, money: { name: "Pénz munkákból és párbajokból (%)", img: "/images/8/84/Pénz.png" }, luck: { name: "Szerencse", img: "/images/8/8a/Szerencse.png" }, regen: { name: "Regeneráció", img: "/images/5/58/Regeneráció.png", }, drop: { name: "Találati esély", img: "/images/5/59/Találati_esély.png" }, spd: { name: "Sebesség", img: "/images/2/25/Sebesség.png" }, building_pts: { name: "Munkapont erre: Építkezés", img: "/images/2/2c/Building_pts.png" } }, sorting: { 'Erő':'{"str":1}', 'Mozgékonyság':'{"mob":1}', 'Ügyesség':'{"dex":1}', 'Karizma':'{"cha":1}', 'Építés':'{"str":1,"con":1}', 'Ütőerő':'{"str":1,"vig":1}', 'Szívósság':'{"str":1,"tou":1}', 'Kitartás':'{"str":1,"sta":1}', 'Életerő pont':'{"str":1,"hea":1}', 'Lovaglás':'{"mob":1,"rid":1}', 'Reflex':'{"mob":1,"ref":1}', 'Kitérés':'{"mob":1,"dod":1}', 'Rejtőzés':'{"mob":1,"hid":1}', 'Úszás':'{"mob":1,"swi":1}', 'Célzás':'{"dex":1,"aim":1}', 'Lövés':'{"dex":1,"sho":1}', 'Csapdaállítás':'{"dex":1,"pit":1}', 'Kézügyesség':'{"dex":1,"fin":1}', 'Javítás':'{"dex":1,"rep":1}', 'Irányítás':'{"cha":1,"lea":1}', 'Taktika':'{"cha":1,"tac":1}', 'Kereskedelem':'{"cha":1,"tra":1}', 'Állati ösztön':'{"cha":1,"ani":1}', 'Fellépés':'{"cha":1,"app":1}', 'Városépítés':'{"str":3,"con":3,"dex":1,"rep":1,"cha":1,"lea":1}', 'Tapasztalat a munkákból, párbajokból és az erődharcokból(%)':'{"xp":1}', 'Pénz munkákból és párbajokból (%)':'{"money":1}', 'Szerencse (%)':'{"luck":1}', 'Regeneráció(%)':'{"regen":1}', 'Találati esély(%)':'{"drop":1}', 'Sebesség (%)':'{"spd":1,"hspd":1,"mob":1,"rid":1}', 'Átlag sebzés':'{"dmg_min":0.5,"dmg_max":0.5,"dmglvl":1}', 'Maximum sebzés':'{"dmg_max":1,"dmglvl":1}', } }, initPage: function () { //Append input level if ($("#input_level").length === 1) { var input_level = $('<input type="number" style="width:80px;" class="west" placeholder="' + westui.lang.input_level + '" min="0" max="250">').bind("propertychange keyup input paste", function () { if (this.value > 250) { this.value = 250; } else if (this.value < 0) { this.value = 0; } $(".calc").each(function () { if (input_level.val() == 0) { $(this).html(this.id); $('.per_level_off').addClass('per_level').removeClass('per_level_off'); } else { $(this).html(Math.ceil(Number(this.id) * input_level.val())); $('.per_level').addClass('per_level_off').removeClass('per_level'); } }); }).appendTo($("#input_level")); }
//Search if ($("#input_search").length === 1) { var input_search = $('<input type="search" class="west" placeholder="' + westui.lang.input_search + '">').bind("propertychange keyup input paste", function () { var val = this.value.toLowerCase(); if (val === ) { $('.item_container').show(); } else { $('.item_container').hide(); $('.item_container').filter(function () { return $(this).attr('data-popup').toLowerCase().indexOf(val) > -1; }).show(); } }).appendTo($("#input_search")); }
//Switch weapons if ($("#switch").length === 1) { $("#fire").hide(); $("#switch").on("click", function () { $('#melee, #fire').toggle(); }); }
//Switch products if ($("#switch_prod").length === 1) { $("#prod2").hide(); $("#switch_prod").on("click", function () { $('#prod, #prod2').toggle(); }); }
//Show a "plain text" popup in the template if (westui.config.plain_popup && (new RegExp(mw.config.get('wgFormattedNamespaces')[10] + '\:Item\_*').test(mw.config.get('wgPageName'))) && ($('.item_container').length === 1)) {
$('#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(); }
//On dbl click on item, redirect the user to the template if (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 / 1000; }); } if (westui.config.link_on_dblclick) { $('.item_container img').on('dblclick', function () { window.location = '/wiki/' + $(this).parent().attr('data-link'); }); }
}, popup: { content: "", delay: 200, active: false, show: function (obj) { westui.popup.content = westui.popup.createPopup($(obj).attr('data-popup'), $(obj).attr('data-cdn-cat'), $(obj).attr('data-cdn-img'), parseInt($(obj).attr('data-lvl'))); westui.popup.active = true; 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 = false; 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 () { if (westui.popup.timer) window.clearTimeout(westui.popup.timer); }, getEl: function () { return $('#popup_window'); }, getContainer: function () { return $('#popup_contents'); }, createPopup: function (data, cdn_cat, cdn_name, lvl) { data = JSON.parse(data);
var html = '
' + data.name + '
' + data.type + '
';
var upgraded = false; if ((lvl >= 1) && (lvl <= 5)) { upgraded = true; data.auc = false; } if (data.dmg_min && data.dmg_max) { if (upgraded) { data.dmg_min += Math.round(Math.max(1, data.dmg_min * 0.1 * lvl)); data.dmg_max += Math.round(Math.max(1, data.dmg_max * 0.1 * lvl)); }
html += '
' + data.dmg_min + '-' + data.dmg_max + ' ' + westui.lang.damages + '
';
} if (data.text) { for (var i = 0; i < data.text.length; i++) {
html += '
' + data.text[i] + '
';
} html += '
'; } for (var cat in westui.lang.popup) { var cnt = 0; for (var key in westui.lang.popup[cat]) { if (data.hasOwnProperty(key)) { cnt++; var per_level = ""; if (data[key] < 0) { if ($('#input_level input').val() > 0) { data[key] = Math.ceil($('#input_level input').val() * -data[key]); if (upgraded) { data[key] += Math.round(Math.max(1, data[key] * 0.1 * lvl)); } } else { data[key] = -data[key]; per_level = " (" + westui.lang.per_level + ")"; if (upgraded) { data[key] = Math.round(1e6 * (data[key] * 1 + Math.round(Math.max(1, data[key] * 1000 * lvl)) / 10000)) / 1e6; } } } else if (upgraded) { if (data[key] < 1) { data[key] = Math.round(1e6 * (data[key] * 1 + Math.round(Math.max(1, data[key] * 1000 * lvl)) / 10000)) / 1e6; } else { data[key] += Math.round(Math.max(1, data[key] * 0.1 * lvl)); } } html += westui.lang.popup[cat][key].replace('#1', data[key]).replace('#2', per_level); } } if (cnt > 0) { html += '
'; } } if (data.textjob) { for (var i = 0; i < data.textjob.length; i++) {
html += '
' + data.textjob[i] + '
';
} html += '
'; } if (data.bonus) { for (var i = 0; i < data.bonus.length; i++) {
html += '
' + data.bonus[i] + '
';
} html += '
'; } if (data.jobs) {
html += '
for (var i = 0; i < data.jobs.length; i++) {html += '';
}html += '
<img src="' + westui.config.cdn + '/images/jobs/' + data.jobs[i][1] + '.png"/> | ' + data.jobs[i][0] + ' |
';
} if (data.craft) {
html += '
<img src="' + westui.config.cdn + '/images/crafting/profsymbol_' + data.craft.id + '_small.png"/> | ';
for (var i = 0; i < data.craft.req.length; i++) {html += ''; }html += ''; for (var i = 0; i < data.craft.req.length; i++) { html += ''; }html += '
|
';
}
html += '
if (data.hspd) { if (upgraded) { data.hspd += Math.round(Math.max(1, data.hspd * 0.1 * lvl)); }html += '
' + westui.lang.speed + ': +' + data.hspd + '%
';
}if (data.set) html += '
<a class="popup_set" href="/wiki/' + data.set + '">' + data.set + '</a>
';
if (data.sp) { html += '<img src="' + westui.config.img_buyprice + '"/>' + data.bp + ' <img src="' + westui.config.img_sellprice + '"/> ' + data.sp + 'html += '
'; } else { html += '' + westui.lang.unsalable + '
'; } if (data.lvl) html += westui.lang.level + ' ' + data.lvl + '
'; if (data.sex) { if (data.sex == 0) { html += '<img src="' + westui.config.img_male + '"/> '; } else { html += '<img src="' + westui.config.img_female + '"/> '; } } if (data.auc == 1) { html += '' + westui.lang.auction + '
'; } else { html += '' + westui.lang.not_auction + '
'; } if (data.upg == 0) { html += '' + westui.lang.not_upgrade + '
'; } else { html += '' + westui.lang.upgrade + '
'; }
[item=' + data.id + ']
';
return html; }, setPosition: function (e) { var window_width = $(window).width(); var window_height = $(window).height(); var popup_width = westui.popup.getEl().outerWidth(); var popup_height = westui.popup.getEl().outerHeight(); var pos_x = e.clientX; var pos_y = e.clientY; var top; var left; var margin_top = 20; var margin_left = 20; if (pos_x + popup_width + margin_left > window_width) { left = pos_x - popup_width - margin_left + (e.pageX - e.clientX); } else { left = pos_x + margin_left + (e.pageX - e.clientX); } if (pos_y + popup_height + margin_top > window_height) { top = window_height - popup_height + (e.pageY - e.clientY); } else { top = pos_y + margin_top + (e.pageY - e.clientY); } westui.popup.getEl().css({ top: top, left: left }); }, init: function () {
//Append popup container
$('body').append('
');
//Set events $(document).on('mouseenter', '.item_container', function (e) { westui.popup.show(this); westui.popup.setPosition(e); }); $(document).on('mouseleave', '.item_container', function () { westui.popup.hide(); }); $(document).on('mousemove', '.item_container', function (e) { westui.popup.setPosition(e); });
$('.item_level').mousedown(function (e) { e.preventDefault(); }); $(document).on('click', '.upgrade', function () { var container = $(this).closest('.item_container'); var lvl = parseInt(container.attr('data-lvl')); if (lvl !== 5) { container.attr('data-lvl', lvl + 1); container.find('.level').html(lvl + 1); } westui.popup.show(container[0]); }); $(document).on('click', '.downgrade', function () { var container = $(this).closest('.item_container'); var lvl = parseInt(container.attr('data-lvl')); if (lvl !== 0) { container.attr('data-lvl', lvl - 1); container.find('.level').html(lvl - 1); } westui.popup.show(container[0]); }); } }, set_calc: { bonus: { //If there are any other "special" bonuses, they will be dynamically retrieved and stored there extra_set_bonus: {} }, //Bonuses from all sets / items : data: {}, //Status of all items (item lvl, activated or not) itemStatus: {}, getData: function () { $('.set_container').each(function () { var set_id = $(this).attr('data-set-id'); westui.set_calc.itemStatus[set_id] = {}; westui.set_calc.data[set_id] = { items: {}, set: {} }; }); //Get bonuses from all sets $('.infoSet').each(function () { var set_id = $(this).attr('data-set-id'); $(this).find('.infosetatt').each(function () { var nb = $(this).attr('data-nb'); westui.set_calc.data[set_id].set[nb] = {}; $(this).find('.set_bonus').each(function () { key = $(this).attr('data-type'); if ($(this).find('.calc').length !== 0) { westui.set_calc.data[set_id].set[nb][key] = -parseFloat($(this).find('.calc').attr('id')); } else { westui.set_calc.data[set_id].set[nb][key] = parseFloat($(this).find('.val').text()); } if (!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() }; } }); }); }); //Get bonuses from all item sets $('.set_container').each(function () { var set_id = $(this).attr('data-set-id'); $(this).find('.item_container').each(function () { var json = JSON.parse($(this).attr('data-popup')); if ($(this).is(":hidden")) { westui.set_calc.itemStatus[set_id][json.id] = false; } else { westui.set_calc.itemStatus[set_id][json.id] = 0; } for (var prop in json) { if (json.hasOwnProperty(prop) && (westui.config.set_bonus.hasOwnProperty(prop) || westui.set_calc.bonus.extra_set_bonus.hasOwnProperty(prop))) { if (!westui.set_calc.data[set_id].items[prop]) { westui.set_calc.data[set_id].items[prop] = {}; } westui.set_calc.data[set_id].items[prop][json.id] = json[prop]; } } }); }); }, calc: function () { //Only calc if a player level is provided if ($('#input_level').length === 0 | $('#input_level input').val() !== "") { var level = parseInt($('#input_level input').val()); total = {}; for (var set_id in westui.set_calc.data) { for (var key in westui.set_calc.data[set_id].items) { for (var item_id in westui.set_calc.data[set_id].items[key]) { if (westui.set_calc.itemStatus[set_id][item_id] !== false) { lvl = westui.set_calc.itemStatus[set_id][item_id]; if (!total[key]) { total[key] = 0; } var value = westui.set_calc.data[set_id].items[key][item_id];
if (westui.set_calc.data[set_id].items[key][item_id] < 0) { //If bonus (per Level) value = -value;
if (westui.set_calc.itemStatus[set_id][item_id] > 0) { //If item upgraded total[key] += Math.ceil(value * level) + Math.round(Math.max(1, Math.ceil(value * level) * 0.1 * lvl)); } else { total[key] += Math.ceil(value * level); } } else { if (westui.set_calc.itemStatus[set_id][item_id] > 0) { if (value < 1) { total[key] += Math.round(1e6 * (value * 1 + Math.round(Math.max(1, value * 1000 * lvl)) / 10000)) / 1e6; } else { total[key] += value + Math.round(Math.max(1, value * 0.1 * lvl)); } } else { total[key] += value; } } } } } var item_nb = 0; for (var item_id in westui.set_calc.itemStatus[set_id]) { if (westui.set_calc.itemStatus[set_id][item_id] !== false) { item_nb++; } } for (var key in westui.set_calc.data[set_id].set[item_nb]) { if (!total[key]) { total[key] = 0; } if (westui.set_calc.data[set_id].set[item_nb][key] < 0) { total[key] += Math.ceil(-westui.set_calc.data[set_id].set[item_nb][key] * level); } else { total[key] += westui.set_calc.data[set_id].set[item_nb][key]; } } } //Create the html table
var html = '
';
for (var key in westui.config.set_bonus) { if (total.hasOwnProperty(key)) {html += ' <img src="' + westui.config.set_bonus[key].img + '">+' + total[key] + (['xp', 'money', 'luck', 'spd', 'regen', 'drop'].indexOf(key) !== -1 ? "%" : "") + ' ';
' + westui.config.set_bonus[key].name + ' } } for (var key in westui.set_calc.bonus.extra_set_bonus) { if (total.hasOwnProperty(key)) {html += ' <img src="' + westui.set_calc.bonus.extra_set_bonus[key].img + '">+' + total[key] + (['xp', 'money', 'luck', 'spd', 'regen', 'drop'].indexOf(key) !== -1 ? "%" : "") + ' ';
' + westui.set_calc.bonus.extra_set_bonus[key].name + ' } } //Display the result at the bottom of the page $('#set_calc').html(html); } else { $('#set_calc').html(""); } }, initEvents: function () { //Deactivate / activate item on click $('.item_container > img').on('click', function () { var item_container = $(this).closest('.item_container'); item_container.toggleClass('item_off'); var set_id = item_container.closest('.set_container').attr('data-set-id'); var item_id = JSON.parse(item_container.attr('data-popup')).id; if (item_container.hasClass('item_off') || item_container.is(":hidden")) { westui.set_calc.itemStatus[set_id][item_id] = false; } else { westui.set_calc.itemStatus[set_id][item_id] = parseInt(item_container.attr('data-lvl')); } westui.set_calc.calc(); }); //Update item level on upgrade / downgrade $(document).on('click', '.upgrade, .downgrade', function () { var item = $(this).closest('.item_container'); var set_id = item.closest('.set_container').attr('data-set-id'); if (!item.hasClass('item_off') && !item.is(":hidden")) { westui.set_calc.itemStatus[set_id][JSON.parse(item.attr('data-popup')).id] = parseInt(item.attr('data-lvl')); westui.set_calc.calc(); } }); //Calc again when player level changes $("#input_level").bind("propertychange keyup input paste", function () { westui.set_calc.calc(); }); //Activate/deactivate melee/fire weapon when the switch btn is clicked $("#switch").on('click', function () { $('#melee, #fire').each(function () { var item = $(this).find('.item_container'); var set_id = $(this).closest('.set_container').attr('data-set-id'); if ($(this).is(":hidden")) { westui.set_calc.itemStatus[set_id][JSON.parse(item.attr('data-popup')).id] = false; } else { westui.set_calc.itemStatus[set_id][JSON.parse(item.attr('data-popup')).id] = parseInt(item.attr('data-lvl')); } }); westui.set_calc.calc(); }); }, init: function () { westui.set_calc.initEvents(); westui.set_calc.getData();$('#mw-content-text').append(''); if ($('#input_level').length === 0) westui.set_calc.calc(); } }, sorting: { sortItems: function(param){ $('.item_container').removeAttr('data-sort'); function calcSortVal(el){ var data = JSON.parse($(el).attr('data-popup')); var val = 0; for (var prop in param){ if (data[prop]){ if (data[prop]<0){ val+=Math.ceil(-data[prop]*($('#input_level input').val()?$('#input_level input').val():150))*param[prop]; } else { val+=data[prop]*param[prop]; } } } $(el).attr('data-sort',val); if ($(el).find('p.number').length!==0){ $(el).find('p.number').html(val); } else {$(el).append(' '+val+' ');} } $('#mw-content-text').find('.sorting_hidden').hide(); $('#mw-content-text').find('.item_container').sort(function(a, b) { if (!$(a).attr('data-sort')){calcSortVal(a);} if (!$(b).attr('data-sort')){calcSortVal(b);} return $(b).attr('data-sort') - $(a).attr('data-sort'); }).appendTo('#mw-content-text'); }, init:function(){ if ($('div#sort_items').length===1){var html = " <select id='sort_items' class='west'><option selected disabled>Rendezés :</option>";
";
for (var prop in westui.config.sorting){ html+= "<option value='"+westui.config.sorting[prop]+"'>"+prop+"</option>"; }html += "</select> $('div#sort_items').html(html); $('select#sort_items').on('change',function(){ westui.sorting.sortItems(JSON.parse($(this).find("option:selected").attr('value'))); }); } } }, init: function () { westui.initPage(); westui.popup.init(); if (westui.config.enable_sorting) westui.sorting.init(); if (westui.config.enable_set_calc && $('.infoSet').length !== 0) { westui.set_calc.init(); } } }; westui.init(); |