Popup.js: Διαφορά μεταξύ των αναθεωρήσεων
Χωρίς σύνοψη επεξεργασίας |
Χωρίς σύνοψη επεξεργασίας |
||
Γραμμή 1: | Γραμμή 1: | ||
westui |
Αναθεώρηση της 05:19, 24 Μαρτίου 2022
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:{},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(t,e){var s=this.img_job[t],i=s?["/images/"+s[0]+"/Job_",s[1]+(e||"")]:[this.cdn+"/images/jobs/",e];return i[0]+=t+".png",i}},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"));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,s,i){t=JSON.parse(t);var a=westui.lang,p=westui.config,n='
'+(0==t.sex?'<img height="16" src="'+p.img_male+'"/>':1==t.sex?'<img height="16" src="'+p.img_female+'"/> ':"")+t.name+"
",o=!1;d=t.dmg&&t.dmg.split("-");var l=0;if(t.ico&&(n+='
<a href="/wiki/'+t.event+'"><img src="'+p.media_cdn+"/"+t.ico+'.png"/>',n+=""),t.event){for(c=0;c<t.event.length;c++);n+=''+t.event+"</a>
",n+=""}if(t.typeW){for(c=0;c<t.typeW.length;c++);n+='
'+t.typeW+"
",n+=""}if(t.type){for(c=0;c<t.type.length;c++);n+='
'+t.type+"
",n+=""}if(t.unique?n+='
'+t.unique+"
":n+="
",i>=1&&i<=5&&(o=!0,t.auc=!1),t.text){for(var c=0;c<t.text.length;c++)n+='
'+t.text[c]+"
";n+=""}for(var r in(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&&a.popup)&&(n+="
"),i>=1&&i<=5&&(o=!0,t.auc=!1),d&&(l=1)&&(o&&(d[0]=1*d[0]+Math.round(Math.max(1,.1*d[0]*i)),d[1]=1*d[1]+Math.round(Math.max(1,.1*d[1]*i))),n+='
'+d[0]+"-"+d[1]+' ('+Math.round((Number(d[0])+Number(d[1]))/2+(t.dmglvl?Math.round($("#input_level input").val()*-t.dmglvl):""))+") "+a.damages+"
")&&(t.dmglvl?n+="":n+="
"),i>=1&&i<=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*i)),t.dmg_max=1*t.dmg_max+Math.round(Math.max(1,.1*t.dmg_max*i))),n+='
'+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):""))+") "+a.damages+"
")&&(t.dmglvl?n+="":n+="
"),a.popup){l=0;for(var u in a.popup[r])if(t.hasOwnProperty(u)){l++;var _="";t[u]<0?$("#input_level input").val()>0?(t[u]=Math.ceil($("#input_level input").val()*-t[u]),o&&(t[u]+=Math.round(Math.max(1,.1*t[u]*i)))):(t[u]=-t[u],_=" ("+a.per_level+")",o&&(t[u]=Math.round(1e6*(1*t[u]+Math.round(Math.max(1,1e3*t[u]*i))/1e4))/1e6)):o&&(t[u]<1?t[u]=Math.round(1e6*(1*t[u]+Math.round(Math.max(1,1e3*t[u]*i))/1e4))/1e6:t[u]+=Math.round(Math.max(1,.1*t[u]*i))),n+=a.popup[r][u].replace("#1",t[u]).replace("#2",_)}l>0&&(n+="
")}if(t.textjob){for(c=0;c<t.textjob.length;c++)n+='
'+t.textjob[c]+"
";n+="
"}if(t.bonus){for(n+='
Επίδραση:
',c=0;c<t.bonus.length;c++)n+='
'+t.bonus[c]+"
";n+="
"}if(t.jobs){for(o in n+='
Από την εργασία:
',t.jobs)if("req"==o){for(var m of(n+='"}else{var g=p.jobIcon(o,t.jobs[o]);n+='"}n+="',t.jobs[o]))n+=' <img src="'+p.cdn+"/images/items/"+(m[0].includes("/")?"":"yield/")+m[0]+'.png">'+("eqp"==m[2]?"":' ";n+="'+m[1]+" ")+" | |
<img src="'+g[0]+'"> | '+g[1]+" |
"}if(t.craft){for(n+='
Χρειάζονται για την Δημιουργία:
<img src="/images/'+p.img_prof[t.craft.id]+"/Profsymbol_"+t.craft.id+'.png" width="36px" height="36px"/> | ',c=0;c<t.craft.req.length;c++)n+=' <img src="'+p.cdn+"/images/items/yield/"+t.craft.req[c][0]+'.png"> ";n+="'+t.craft.req[c][1]+" |
"}var v=i,h=Math.pow(3,v),b=(Math.pow(3,Number(v)+Number(1))-3-2*v)/4,f=(t.bp*(h+b)).toString().replace(/\B(?=(\d{3})+(?!\d))/g,".");return n+='
'+a.speed+": +"+t.hspd+"%
"),t.set&&(n+='
<a class="popup_set" href="/wiki/'+t.set+'">'+t.set+"</a>
"),t.sp?n+='<img src="'+p.img_buyprice+'"/>'+t.bp+' <img src="'+p.img_sellprice+'"/> '+t.sp+"
":n+=""+a.unsalable+"
",t.blding?n+='
'+t.blding+"
":n+="",n+=1<=v?"Έξοδα αναβάθμισης: $"+f+"
":"
",t.lvl||t.cat?n+='
Χρειάζεται:
':n+="",t.lvl&&t.cat?n+='- '+a.level+" "+t.lvl+"
":0<t.lvl?n+='- '+a.level+" "+t.lvl+"
":n+="","Εργάτης"==t.cat?n+=p.cat_img+p.worker+" "+t.cat+"</a>
":"Μονομάχος"==t.cat?n+=p.cat_img+p.dueller+" "+t.cat+"</a>
":"Στρατιώτης"==t.cat?n+=p.cat_img+p.soldier+" "+t.cat+"</a>
":"Τυχοδιώκτης"==t.cat?n+=p.cat_img+p.adventurer+" "+t.cat+"</a>
":"Πρωτάρης"==t.cat?n+=p.cat_img+p.greenhorn+" "+t.cat+"</a>
":n+="",1==t.auc?n+='
'+a.auction+"
":n+=''+a.not_auction+"
",0==t.upg?n+=''+a.not_upgrade+"
":n+=''+a.upgrade+"
",n+"";for(var s in westui.config.set_bonus)total.hasOwnProperty(s)&&(n+=' <img src="'+westui.config.set_bonus[s].img+'">+'+total[s]+' ");for(var s in westui.set_calc.bonus.extra_set_bonus)total.hasOwnProperty(s)&&(n+=''+westui.config.set_bonus[s].name+" <img src="'+westui.set_calc.bonus.extra_set_bonus[s].img+'">+'+total[s]+(-1!==["xp","money","luck","spd","regen","drop"].indexOf(s)?"%":"")+' ");$("#set_calc").html(n)}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"),s=JSON.parse(t.attr("data-popup")).id;t.hasClass("item_off")||t.is(":hidden")?westui.set_calc.itemStatus[e][s]=!1:westui.set_calc.itemStatus[e][s]=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(t){function e(e){var s=JSON.parse($(e).attr("data-popup")),i=$("#input_level input").val();i=i||150;var a=-1!==Object.keys(t).indexOf("id")||t.bool&&!0===t.bool,p=0;if(t.bool&&!0===t.bool)for(var n in p=1,t)"bool"!==n&&s[n]!==t[n]&&(p=0);else for(var n in t)"id"===n?p-=s[n]:(!s.lvl||s.lvl<=i)&&s[n]&&(s[n]<0?p+=Math.round(Math.round(-s[n]*i)*t[n]):p+=Math.round(Math.round(s[n])*t[n]));$(e).attr("data-sort",p),0==p&&$(e).hide(),0!==$(e).find(".sortval").length?a?$(e).find(".sortval").html(""):$(e).find(".sortval").html(p):a||$(e).append(''+westui.set_calc.bonus.extra_set_bonus[s].name+" '+p+" ")}$(".item_container").removeAttr("data-sort").show(),$("#mw-content-text").find(".sorting_hidden").hide(),$(".sorting_container").each(function(){$(this).find(".item_container").sort(function(t,s){return $(t).attr("data-sort")||e(t),$(s).attr("data-sort")||e(s),$(s).attr("data-sort")-$(t).attr("data-sort")}).appendTo($(this))})},init:function(){if(1===$("div#sort_items").length){var t="<select id='sort_items' class='west'><option selected disabled>Ταξινόμηση κατά:</option>";for(var e in westui.config.sorting)t+="<option value='"+westui.config.sorting[e]+"'>"+e+"</option>";t+="</select> ",$("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(); |