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

Από Wiki The-West GR
Jump to navigation
Χωρίς σύνοψη επεξεργασίας
Χωρίς σύνοψη επεξεργασίας
Γραμμή 1: Γραμμή 1:
westui = {
westui
    lang: {
        input_level: "Your level",
        input_search: "Search",
        damages: "Damages",
        per_level: "per Level",
        speed: "Speed",
        level: "Level",
        unsalable: "Unsalable",
        auction: "Auctionable",
        not_auction: "Not auctionable",
        not_upgrade: "Not upgradeable",
        upgrade: "Upgradeable",
        total: "Total",
        popup: {
            dmg: {
                dmglvl: '<p class="popup_dmg">+ #1 Damages#2</p>'
            },
            skills: {
                str: '<p class="popup_attribute">+ #1 Strength#2</p>',
                mob: '<p class="popup_attribute">+ #1 Mobility#2</p>',
                dex: '<p class="popup_attribute">+ #1 Dexterity#2</p>',
                cha: '<p class="popup_attribute">+ #1 Charisma#2</p>',
                con: '<p class="popup_skill">+ #1 Construction#2</p>',
                vig: '<p class="popup_skill">+ #1 Vigor#2</p>',
                tou: '<p class="popup_skill">+ #1 Toughness#2</p>',
                sta: '<p class="popup_skill">+ #1 Stamina#2</p>',
                hea: '<p class="popup_skill">+ #1 Health Points#2</p>',
                rid: '<p class="popup_skill">+ #1 Horseback Riding#2</p>',
                ref: '<p class="popup_skill">+ #1 Reflex#2</p>',
                dod: '<p class="popup_skill">+ #1 Dodging#2</p>',
                hid: '<p class="popup_skill">+ #1 Hiding#2</p>',
                swi: '<p class="popup_skill">+ #1 Swimming#2</p>',
                aim: '<p class="popup_skill">+ #1 Aiming#2</p>',
                sho: '<p class="popup_skill">+ #1 Shooting#2</p>',
                pit: '<p class="popup_skill">+ #1 Setting traps#2</p>',
                fin: '<p class="popup_skill">+ #1 Fine Motor Skills#2</p>',
                rep: '<p class="popup_skill">+ #1 Repairing#2</p>',
                lea: '<p class="popup_skill">+ #1 Leadership#2</p>',
                tac: '<p class="popup_skill">+ #1 Tactics#2</p>',
                tra: '<p class="popup_skill">+

Αναθεώρηση της 16:52, 18 Ιουνίου 2018

westui={lang:{input_level:"Το επίπεδό σου",input_search:"Αναζήτηση",damages:"Ζημιά",per_level:"ανά επίπεδο",speed:"Ταχύτητα",level:"Επίπεδο",unsalable:"Μη εμπορεύσιμο",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:'

'},fb:{fbdef:'

',fboff:'

',fbres:'

',fbdefs:'

',fboffs:'

',fbdmgs:'

'},special:{xp:'

',money:'

',luck:'

',regen:'

',drop:'

',labor_pts:'

'}}},config:{enable_set_calc:!0,plain_popup:!0,redirect_on_dblclick:!1,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:"Δύναμη",img:"/images/thumb/8/8b/Strength.png/40px-Strength.png"},mob:{name:"Κινητικότητα",img:"/images/thumb/5/5a/Mobility.png/40px-Mobility.png"},dex:{name:"Επιδεξιότητα",img:"/images/thumb/0/0d/Dexterity.png/40px-Dexterity.png"},cha:{name:"Χαρισματικότητα",img:"/images/thumb/c/c9/Charisma.png/40px-Charisma.png"},con:{name:"Κατασκευή",img:"/images/thumb/3/37/Construction.png/40px-Construction.png"},vig:{name:"Σθένος",img:"/images/thumb/9/90/Skill_Punch.png/40px-Skill_Punch.png"},tou:{name:"Ανθεκτικότητα",img:"/images/thumb/f/f8/Skill_Tough.png/40px-Skill_Tough.png"},sta:{name:"Αντοχή",img:"/images/thumb/8/8d/Stamina.png/40px-Stamina.png"},hea:{name:"Πόντοι υγείας",img:"/images/thumb/9/94/Health.png/40px-Health.png"},rid:{name:"Ιππασία",img:"/images/thumb/7/78/Hbr.png/40px-Hbr.png"},ref:{name:"Αντανακλαστικά",img:"/images/thumb/e/e9/Skill_Reflex.png/40px-Skill_Reflex.png"},dod:{name:"Αποφυγή",img:"/images/thumb/0/07/Skill_Dodge.png/40px-Skill_Dodge.png"},hid:{name:"Κρύψιμο",img:"/images/thumb/9/97/Hiding.png/40px-Hiding.png"},swi:{name:"Κολύμπι",img:"/images/thumb/f/f4/Swimming.png/40px-Swimming.png"},aim:{name:"Στόχευση",img:"/images/thumb/5/53/Skill_Aim.png/40px-Skill_Aim.png"},sho:{name:"Σημάδι",img:"/images/thumb/7/73/Skill_Shot.png/40px-Skill_Shot.png"},pit:{name:"Στήσιμο παγίδων",img:"/images/thumb/e/e1/Trapping.png/40px-Trapping.png"},fin:{name:"Εξαιρετικές κινητικές ικανότητες",img:"/images/thumb/1/18/Fms.png/40px-Fms.png"},rep:{name:"Επιδιόρθωση",img:"/images/thumb/d/d5/Repairing.png/40px-Repairing.png"},lea:{name:"Ηγεσία",img:"/images/thumb/4/44/Leadership.png/40px-Leadership.png"},tac:{name:"Τακτικές",img:"/images/thumb/9/91/Skill_Tactic.png/40px-Skill_Tactic.png"},tra:{name:"Εμπόριο",img:"/images/thumb/f/f3/Skill_Trading.png/40px-Skill_Trading.png"},ani:{name:"Ζώωες ένστικτο",img:"/images/thumb/9/9d/AnimalInstinct.png/40px-AnimalInstinct.png"},app:{name:"Εμφάνιση",img:"/images/thumb/4/4c/Skill_Appearance.png/40px-Skill_Appearance.png"},fbdef:{name:"Άμυνα (Fort battle bonus)",img:"/images/8/82/Set_Fb_defense.png"},fboff:{name:"Επίθεση (Fort battle bonus)",img:"/images/3/30/Set_Fb_offense.png"},fbres:{name:"Αντίσταση (Fort battle bonus)",img:"/images/4/4b/Resistance.png"},fbdefs:{name:"Άμυνα (Fort battle sector bonus)",img:"/images/1/1a/Set_Fb_defense_sec.png"},fboffs:{name:"Επίθεση (Fort battle sector bonus)",img:"/images/f/fe/Set_Fb_offense_sec.png"},fbdmgs:{name:"Ζημιά (Fort battle sector bonus)",img:"/images/b/b3/Damages_sector.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/thumb/b/b8/Drop.png/40px-Drop.png"},labor_pts:{name:"Πόντοι εργασίας",img:"/images/5/5e/Labor_pts.png"}}},initPage:function(){if(1===$("#input_level").length)var t=$('<input type="number" style="width:80px;" 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 s='


",p=!1;if(a>=1&&a<=5&&(p=!0,t.auc=!1),t.dmg_min&&t.dmg_max&&(p&&(t.dmg_min+=Math.round(Math.max(1,.1*t.dmg_min*a)),t.dmg_max+=Math.round(Math.max(1,.1*t.dmg_max*a))),s+='

"),t.text){for(var n=0;n<t.text.length;n++)s+='

";s+="
"}for(var o in westui.lang.popup){var l=0;for(var c in westui.lang.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=" ("+westui.lang.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+=westui.lang.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+='

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

";s+="
"}if(t.jobs){s+='

';for(n=0;n<t.jobs.length;n++)s+='";s+="

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

"}return 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+20>a?o-p-20+(t.pageX-t.clientX):o+20+(t.pageX-t.clientX),e=l+n+20>s?s-n+(t.pageY-t.clientY):l+20+(t.pageY-t.clientY),westui.popup.getEl().css({top:e,left:i})},init:function(){$("body").append('

'),$(document).on("mouseenter",".item_container",function(t){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:{}},$(this).find(".item_container").each(function(){var e=JSON.parse($(this).attr("data-popup"));$(this).is(":hidden")?westui.set_calc.itemStatus[t][e.id]=!1:westui.set_calc.itemStatus[t][e.id]=0;for(var i in e)e.hasOwnProperty(i)&&westui.config.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])})}),$(".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()})})})})},calc:function(){if(0===$("#input_level").length|""!==$("#input_level input").val()){var t=parseInt($("#input_level input").val());total={};for(var e in 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:Math.round(Math.max(1,.1*s*lvl)):total[i]+=s}var p=0;for(var a in westui.set_calc.itemStatus[e])!1!==westui.set_calc.itemStatus[e][a]&&p++;for(var i in westui.set_calc.data[e].set[p])total[i]||(total[i]=0),westui.set_calc.data[e].set[p][i]<0?total[i]+=Math.ceil(-westui.set_calc.data[e].set[p][i]*t):total[i]+=westui.set_calc.data[e].set[p][i]}var n='

<tbody>

'+westui.lang.total+"
";for(var i in westui.config.set_bonus)total.hasOwnProperty(i)&&(n+='
<img src="'+westui.config.set_bonus[i].img+'">+'+total[i]+'
'+westui.config.set_bonus[i].name+"
");for(var i in westui.set_calc.bonus.extra_set_bonus)total.hasOwnProperty(i)&&(n+='
<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(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"),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()}},init:function(){westui.initPage(),westui.popup.init(),westui.config.enable_set_calc&&0!==$(".infoSet").length&&westui.set_calc.init()}},westui.init();