Popup.js: Διαφορά μεταξύ των αναθεωρήσεων

Από Wiki The-West GR
Jump to navigation
Χωρίς σύνοψη επεξεργασίας
Ετικέτα: Χειροκίνητη αναστροφή
Χωρίς σύνοψη επεξεργασίας
Γραμμή 1: Γραμμή 1:
westui
westui

Αναθεώρηση της 20:55, 30 Νοεμβρίου 2023

westui={lang:{input_level:"Το επίπεδό σου",input_search:"Αναζήτηση: ID, Σετ ή Όνομα",damages:"Ζημιά",per_level:"ανά επίπεδο",speed:"Ταχύτητα",level:"Επίπεδο",unsalable:"Μη εμπορεύσιμο",useable:"(Χρησιμοποιήσιμο)",auction:"Με δυνατότητα δημοπρασίας",not_auction:"Χωρίς δυνατότητα δημοπρασίας",not_upgrade:"Χωρίς δυνατότητα αναβάθμισης",upgrade:"Με δυνατότητα αναβάθμισης",total:"Σύνολο",popup:{dmg:{dmglvl:'

'},skills:{str:'

',mob:'

',dex:'

',cha:'

',con:'

',vig:'

',tou:'

',sta:'

',hea:'

',rid:'

',ref:'

',dod:'

',hid:'

',swi:'

',aim:'

',sho:'

',pit:'

',fin:'

',rep:'

',lea:'

',tac:'

',tra:'

',ani:'

',app:'

',cpattr:'

',cnattr:'

',cpskill:'

',cnskill:'

',pray:'

',spd:'

',xp:'

',money:'

',luck:'

',drop:'

',regen:'

',labor_pts:'

'},fb:{fbdef:'

',fboff:'

',fbres:'

',fbdmgs:'

',fbdefs:'

',fboffs:'

',ddmg:'

'}}},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:"//media.innogamescdn.com/com_WEST_GR/wiki/event_offers",wiki:"wiki.the-west.gr/",twcalc:"tw-calc",events:{1:["xmas","Χριστούγεννα"],2:["valentine","Αγ. Βαλεντίνος"],3:["easter","Πάσχα"],4:["independence","Ημέρα Ανεξαρτησίας"],5:["octoberfest","Οκτόμπερφεστ"],6:["dotd","Ημέρα των Νεκρών"],9:["cs","Πώληση"]},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_recipe:["b/b8","e/ec","7/77","b/b4","b/b4"],img_job:{all:["d/d1","Οποιαδήποτε εργασία"]},cat_img:'

'),$("#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,s){t=JSON.parse(t);var p=westui.lang,a=westui.config,l=t.id+"00"+(s>=0?s:"0"),n=n=t.id?'

Shift+κλικ για αντιγραφή [item='+l+"]

":"",o=!1,c=t.dmg&&t.dmg.split("-"),r=0,d=Math.ceil($("#input_level input").val()*(-t.dmglvl+.1*(s||0)*-t.dmglvl));t.cdn_img&&(n+='

'),t.id&&(n+='

'),t.name&&(n+='

"),1==t.useable?n+='

":n+="";for(const e in eventSets)for(const i in eventSets[e])eventSets[e][i].includes(t.set)&&(n+=`

`);if(t.ico&&(n+='

"}if(t.typeW){for(u=0;u<t.typeW.length;u++);n+='

"}if(t.type){for(u=0;u<t.type.length;u++);n+='

"}if(t.unique&&(n+='

"),s>=1&&s<=5&&(o=!0,t.auc=!1),t.text){(t.unique||"Προϊόν"!=t.type)&&(n+="
");for(var u=0;u<t.text.length;u++)n+='

";n+=""}for(var _ in t.type||t.typeW||t.useable||t.text||t.unique?n+="
":n+="",s>=1&&s<=5&&(o=!0,t.auc=!1),c&&(r=1)&&(o&&(c[0]=1*c[0]+Math.round(Math.max(1,.1*c[0]*s)),c[1]=1*c[1]+Math.round(Math.max(1,.1*c[1]*s))),n+='

")&&!t.dmglvl&&c[0]&&(n+="
"),s>=1&&s<=5&&(o=!0,t.auc=!1),t.dmg_min&&t.dmg_max&&(o&&(t.dmg_min=1*t.dmg_min+Math.round(Math.max(1,.1*t.dmg_min*s)),t.dmg_max=1*t.dmg_max+Math.round(Math.max(1,.1*t.dmg_max*s))),n+='

")&&!t.dmglvl&&t.dmg_min&&(n+="
"),p.popup){r=0;for(var m in p.popup[_])if(t.hasOwnProperty(m)){r++;var b="";t[m]<0?$("#input_level input").val()>0?(t[m]=Math.ceil($("#input_level input").val()*-t[m]),o&&(t[m]+=Math.round(Math.max(1,.1*t[m]*s)))):(t[m]=-t[m],b=" ("+p.per_level+")",o&&(t[m]=Math.round(1e6*(1*t[m]+Math.round(Math.max(1,1e3*t[m]*s))/1e4))/1e6)):o&&(t[m]<1?t[m]=Math.round(1e6*(1*t[m]+Math.round(Math.max(1,1e3*t[m]*s))/1e4))/1e6:t[m]+=Math.round(Math.max(1,.1*t[m]*s))),n+=$("#input_level input").val()>0&&"dmg"===_?p.popup[_][m].replace(/.*/,b):p.popup[_][m].replace("#1",t[m]).replace("#2",b)}r>0&&(n+="
")}if(t.textjob){for(u=0;u<t.textjob.length;u++)n+='

";n+="
"}if(t.bonus){for(n+='

',u=0;u<t.bonus.length;u++)n+='

";n+="
"}if(t.jobs){for(o in n+='

Από την εργασία:

',t.jobs)if("req"==o){for(var g of(n+='"}else{var v=a.jobIcon(o,t.jobs[o]);n+='"}n+="


"}if(t.craft){for(n+='

Χρειάζονται για την Δημιουργία:

"}if(t.recipe?n+="":t.craft?n+="
":n+="",t.recipe){for(n+='

"}var f=s,h=Math.pow(3,f),k=(Math.pow(3,Number(f)+Number(1))-3-2*f)/4,w=(t.bp*(h+k)).toString().replace(/\B(?=(\d{3})+(?!\d))/g,".");return t.hspd||t.set||t.sp||t.bp||t.blding||t.lvl||t.cat||t.auc||t.upg?n+='":n+="",n+=""},setPosition:function(t){var e,i,s=$(window).width(),p=$(window).height(),a=westui.popup.getEl().outerWidth(),l=westui.popup.getEl().outerHeight(),n=t.clientX,o=t.clientY;i=n+a+10>s?n-a-10+(t.pageX-t.clientX):n+10+(t.pageX-t.clientX),e=o+l+10>p?p-l+(t.pageY-t.clientY):o+10+(t.pageY-t.clientY),westui.popup.getEl().css({top:e,left:i})},copyToClipboard:function(t){var e=$("<input>");$("body").append(e),e.val($(t).text()).select(),document.execCommand("copy"),e.remove()},init:function(){var t=westui.popup,e=westui.config;$("body").append(''),$(document).on("mouseenter",".item_container",(function(e){t.show(this),t.setPosition(e)})),$(document).on("click",".item_container",(function(i){if(i.shiftKey&&t.copyToClipboard(".popup_id"),i.altKey){var s="https://"+e.wiki+"index.php?title=Πρότυπο:"+$(".popup_id").text().slice(0,-2).replace(/[\[\]]/gi,"")+"0&action=edit";window.open(s,"_blank")}if(i.ctrlKey){s="https://"+e.twcalc+".net/item/"+$(".popup_id").text().slice(0,-2).replace(/[A-Za-z\=\[\]]/gi,"")+"0";window.open(s,"_blank")}})),$(document).on("mouseleave",".item_container",(function(){t.hide()})),$(document).on("mousemove",".item_container",(function(e){t.setPosition(e)})),$(".item_level").mousedown((function(t){t.preventDefault()})),$(document).on("click",".upgrade",(function(){var e=$(this).closest(".item_container"),i=parseInt(e.attr("data-lvl"));5!==i&&(e.attr("data-lvl",i+1),e.find(".level").html(i+1)),t.show(e[0])})),$(document).on("click",".downgrade",(function(){var e=$(this).closest(".item_container"),i=parseInt(e.attr("data-lvl"));0!==i&&(e.attr("data-lvl",i-1),e.find(".level").html(i-1)),t.show(e[0])}))}},set_calc:{bonus:{extra_set_bonus:{}},data:{},itemStatus:{},getData:function(){var t=westui.set_calc,e=westui.config;$(".set_container").each((function(){var e=$(this).attr("data-set-id");t.itemStatus[e]={},t.data[e]={items:{},set:{}}})),$(".infoSet").each((function(){var i=$(this).attr("data-set-id");$(this).find(".infosetatt").each((function(){var s=$(this).attr("data-nb");t.data[i].set[s]={},$(this).find(".set_bonus").each((function(){key=$(this).attr("data-type"),0!==$(this).find(".calc").length?t.data[i].set[s][key]=-parseFloat($(this).find(".calc").attr("id")):t.data[i].set[s][key]=parseFloat($(this).find(".val").text()),e.set_bonus.hasOwnProperty(key)||(t.bonus.extra_set_bonus[key]={img:$(this).find("img").attr("src"),name:$(this).find("#tooltip_content").text()})}))}))})),$(".set_container").each((function(){var i=$(this).attr("data-set-id");$(this).find(".item_container").each((function(){var s=JSON.parse($(this).attr("data-popup"));for(var p in $(this).is(":hidden")?t.itemStatus[i][s.id]=!1:t.itemStatus[i][s.id]=0,s)if("dmg"!=p){var a=p.startsWith("Job_");s.hasOwnProperty(p)&&(e.set_bonus.hasOwnProperty(p)||t.bonus.extra_set_bonus.hasOwnProperty(p)||a&&(t.bonus.extra_set_bonus[p]={img:e.jobIcon(p.replace("Job_",""))[0],name:s[p][1]}))&&(t.data[i].items[p]||(t.data[i].items[p]={}),t.data[i].items[p][s.id]=a?s[p][0]:s[p])}}))}))},calc:function(){var t=westui.set_calc,e=westui.config;if(0===$("#input_level").length|""!==$("#input_level input").val()){var i=parseInt($("#input_level input").val());for(var s in total={},t.data){for(var p in t.data[s].items)for(var a in t.data[s].items[p])if(!1!==t.itemStatus[s][a]){lvl=t.itemStatus[s][a],total[p]||(total[p]=0);var l=t.data[s].items[p][a];t.data[s].items[p][a]<0?(l=-l,t.itemStatus[s][a]>0?total[p]+=Math.ceil(l*i)+Math.round(Math.max(1,.1*Math.ceil(l*i)*lvl)):total[p]+=Math.ceil(l*i)):t.itemStatus[s][a]>0?total[p]+=l<1?Math.round(1e6*(1*l+Math.round(Math.max(1,1e3*l*lvl))/1e4))/1e6:l+Math.round(Math.max(1,.1*l*lvl)):total[p]+=l}var n=0;for(var a in t.itemStatus[s])!1!==t.itemStatus[s][a]&&n++;for(var p in t.data[s].set[n])total[p]||(total[p]=0),t.data[s].set[n][p]<0?total[p]+=Math.ceil(-t.data[s].set[n][p]*i):total[p]+=t.data[s].set[n][p]}var o='
<tbody>

'+westui.lang.total+"
";for(var p in e.set_bonus)total.hasOwnProperty(p)&&(o+='
<img src="/images/'+e.set_bonus[p].img+'.png" width="40px">
+'+total[p]+(-1!==["xp","money","luck","spd","regen","drop"].indexOf(p)?"%":"")+'
'+(e.set_bonus[p].icon?'<img src="/images/'+e.set_bonus[p].icon+'.png"> ':"")+e.set_bonus[p].name+"
");for(var c in t.bonus.extra_set_bonus)total.hasOwnProperty(c)&&(o+='
<img src="'+t.bonus.extra_set_bonus[c].img+'" width="40px">
+'+total[c]+(-1!==["xp","money","luck","spd","regen","drop"].indexOf(c)?"%":"")+'
'+(t.bonus.extra_set_bonus[c].icon?'<img src="/images/'+t.bonus.extra_set_bonus[c].icon+'.png"> ':"")+t.bonus.extra_set_bonus[c].name+"
");$("#set_calc").html(o)}else $("#set_calc").html("")},initEvents:function(){var t=westui.set_calc;$(".item_container > img").on("click",(function(){var e=$(this).closest(".item_container");e.toggleClass("item_off");var i=e.closest(".set_container").attr("data-set-id"),s=JSON.parse(e.attr("data-popup")).id;e.hasClass("item_off")||e.is(":hidden")?t.itemStatus[i][s]=!1:westui.set_calc.itemStatus[i][s]=parseInt(e.attr("data-lvl")),t.calc()})),$(document).on("click",".upgrade, .downgrade",(function(){var e=$(this).closest(".item_container"),i=e.closest(".set_container").attr("data-set-id");e.hasClass("item_off")||e.is(":hidden")||(t.itemStatus[i][JSON.parse(e.attr("data-popup")).id]=parseInt(e.attr("data-lvl")),t.calc())})),$("#input_level").bind("propertychange keyup input paste",(function(){t.calc()})),$("#switch").on("click",(function(){$("#melee, #fire").each((function(){var e=$(this).find(".item_container"),i=$(this).closest(".set_container").attr("data-set-id");$(this).is(":hidden")?t.itemStatus[i][JSON.parse(e.attr("data-popup")).id]=!1:t.itemStatus[i][JSON.parse(e.attr("data-popup")).id]=parseInt(e.attr("data-lvl"))})),t.calc()}))},init:function(){var t=westui.set_calc;t.initEvents(),t.getData(),$("#mw-content-text").append('
'),0===$("#input_level").length&&t.calc()}},sorting:{sortItems:function(t){function e(e){var i=JSON.parse($(e).attr("data-popup")),s=$("#input_level input").val();s=s||250;var p=-1!==Object.keys(t).indexOf("id")||t.bool&&!0===t.bool,a=0;if(t.bool&&!0===t.bool)for(var l in a=1,t)"bool"!==l&&i[l]!==t[l]&&(a=0);else for(var l in t)"id"===l?a-=i[l]:(!i.lvl||i.lvl<=s)&&i[l]&&(i[l]<0?a+=Math.ceil(-i[l]*s)*t[l]:a+=i[l]*t[l]);$(e).attr("data-sort",a),0==a&&$(e).hide(),0!==$(e).find(".sortval").length?p?$(e).find(".sortval").html(""):$(e).find(".sortval").html(a):p||$(e).append('

'+a+"

")}$(".item_container").removeAttr("data-sort").show(),$("#mw-content-text").find(".sorting_hidden").hide(),$(".sorting_container").each((function(){$(this).find(".item_container").sort((function(t,i){return $(t).attr("data-sort")||e(t),$(i).attr("data-sort")||e(i),$(i).attr("data-sort")-$(t).attr("data-sort")})).appendTo($(this))}))},init:function(){if(1===$("div#sort_items").length){var t="",$("div#sort_items").html(t),$("select#sort_items").on("change",(function(){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();