MediaWiki:Common.js: differenze tra le versioni

Da Wiki The-West IT.
Vai alla navigazione
Nessun oggetto della modifica
Nessun oggetto della modifica
 
(97 versioni intermedie di 3 utenti non mostrate)
Riga 1: Riga 1:
/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti. */
/* Any JavaScript here will be loaded for all users on every page load. */
$('.tbbox-logo').wrap('<a href="/wiki/Pagina_principale"></a>');
if ($('.item_container').length!==0) {
    $('.item_container').each(function() {
        $(this).append('<img src="https://westzz.innogamescdn.com/images/items/' + $(this).attr('data-url') + '">');
    });
    $.getScript("https://wiki.the-west.it/wiki/Popup.js?action=raw");
}
 
$(window).scroll(function() {
    if ($(this).scrollTop() > 100) {
        $('#back-top').fadeIn();
    } else {
        $('#back-top').fadeOut();
    }
});
// Scroll body to top on click
$('#back-top a').click(function() {
    $('body,html').animate({
        scrollTop: 0
    }, 800);
    return false;
});
// Embed youtube videos
if ($('.youtube_video').length !== 0) {
    $('.youtube_video').each(function() {
        $(this).html('<iframe width="100%" height="100%" src="https://www.youtube.com/embed/' + $(this).attr('data-id') + '?cc_load_policy=1&cc_lang_pref=' + $(this).attr('data-subtitles') + '" frameborder="0" allowfullscreen></iframe>');
    });
}
 
//Let's generate an input box - Criminus
$('.target_input p').each(function() {
var id = $(this).attr('id');
var phrase = $(this).text();
var newInput="<input type='number' name='input_nou' value='"+phrase+"' class='target' max='999' min='1' />";
$(this).replaceWith(newInput);
});
 
$("input[name=input_nou]").on("click", function() {
    if ($(this).val() == "1")
        $(this).val("")
});
 
$(function () {
  $("input[name=input_nou]").keydown(function () {
    // Save old value.
    if (!$(this).val() || (parseInt($(this).val()) <= 9999 && parseInt($(this).val()) >= 0))
    $(this).data("old", $(this).val());
  });
  $("input[name=input_nou]").keyup(function () {
    // Check correct, else revert back to old value.
    if (!$(this).val() || (parseInt($(this).val()) <= 9999 && parseInt($(this).val()) >= 0))
      ;
    else
      $(this).val($(this).data("old"));
  });
});
 
(function($) {
    $(document).ready(function() {
        var multiplierValue = 1;
        var currentAmountsArray = [];
        $('.item_number').each(function(index) {
            currentAmountsArray[index] = parseInt($(this).text());
        });
        if ($("input[name='input_nou']").length > 0) {
            $("input[name='input_nou']").change(function() {
                multiplierValue = $(this).val();
                $('.item_number').each(function(index) {
                    $(this).text(currentAmountsArray[index] * multiplierValue);
                });
                $('.craft_extra').show();
                $('.craft_extra .item_container').each(function() {
                    $(this).children().addClass('OverlayItem');
                });


var tooltips = {
            });
    debug: true,
            $("input[name='input_nou']").keyup(function() {
                multiplierValue = $(this).val();
    api: false,
                $('.item_number').each(function(index) {
    types: [],
                    $(this).text(currentAmountsArray[index] * multiplierValue);
    classes: ['basic-tooltip', 'advanced-tooltip'],
                });
    advancedCounter: 1,
                $('.craft_extra').show();
                $('.craft_extra .item_container').each(function() {
    events: [],
                    $(this).children().addClass('OverlayItem');
    timeouts: [],
                });
             });
    offsetX: 20,
    offsetY: 20,
    waitForImages: false,
    init: function() {
        if(location.search.search('ttdebug=true') != -1 || (typeof tooltips_debug != 'undefined' && tooltips_debug)) tooltips.debug = true;
        var href = $('link[rel="canonical"]').attr('href')
        if(typeof href == 'undefined' || !href) {
            console.log('Tooltips: script couldn\'t find required  link[rel="canonical"]  tag');
            tooltips.disabled = true;
             return false;
         }
         }
        href = href.split('/wiki/');
    });
        tooltips.api = href[0]+'/api.php?format=json&action=parse&disablepp=true&prop=text&title='+href[1];
})(jQuery);
        if(mw.util.getParamValue('uselang')) tooltips.api += '&uselang='+mw.util.getParamValue('uselang');
 
         tooltips.api += '&text=';
//Live search through craft items - Criminus
$('.search_craft p').each(function() {
        tooltips.types['basic-tooltip'] = {};
var id = $(this).attr('id');
        tooltips.types['advanced-tooltip'] = {};
var phrase = $(this).text();
var newInput="<input type='text' id='live_search' name='craft_search' value='"+phrase+"' class='craft_search' />";
        if(!tooltips.config()) {
$(this).replaceWith(newInput);
            console.log('Tooltips: missing config');
});
             tooltips.disabled = true;
 
             return false;
$("#live_search").on("keyup", function() {
    var value = $(this).val();
    $("table tr").each(function(index) {
         if (index !== 0) {
            $row = $(this);
            var id = $.map($row.find('td .item_container'), function(element) {
                return $(element).attr("data-popup")
            }).join(' ');
            if (id.toLowerCase().indexOf(value.toLowerCase()) < 0) {
                $row.hide();
             } else {
                $row.show();
             }
         }
         }
    });
        var content = $('#WikiaMainContent')
});
        if(!content.length) content = $('#mw-content-text')
 
$("#live_search").on("click", function() {
        if($('#tooltip-wrapper').length == 0) $('<div id="tooltip-wrapper" class="WikiaArticle"></div>').appendTo(content);
    if ($(this).val() == "Nome o ID")
        if($('#tooltip-storage').length == 0) $('<div id="tooltip-storage" class="WikiaArticle"></div>').append('<div class="main-tooltip tt-basic-tooltip" id="tooltip-basic-tooltip">Lorem ipsum dolor sit amet</div>').appendTo(content);
        $(this).val("")
});
         $('#tooltip-wrapper')
 
            .css({'margin':'0px','position':'fixed','height':'auto','min-height':'0'})
(function($) {
            .hide()
    $(document).ready(function() {
$('.radioButtonsHere').replaceWith('<center><input id="normal" type="radio" value="0" class="selectRadio" name="selectRadio"/> Semplice <input id="silver" type="radio" value="50" class="selectRadio" name="selectRadio"/> Argento <input id="aura" type="radio" value="100" class="selectRadio" name="selectRadio"/> Oro</center>');
         $('#tooltip-storage')
         var multiplierValue = 1;
            .css({'height':'0px','min-height':'0','visibility':'hidden','overflow':'hidden','position':'static'})
         var currentXPArray = [];
var currentCashArray = [];
         $('.xp').each(function(index) {
         $('#tooltip-basic-tooltip').data('type', 'basic-tooltip');
             currentXPArray[index] = parseInt($(this).text());
        tooltips.applyTooltips(document)
        mw.hook('wikipage.content').add(function(elem) {
             tooltips.applyTooltips($(elem));
         });
         });
         $('.money').each(function(index) {
         if(typeof tooltips.events == 'string') tooltips.events = [tooltips.events]
             var getNumber = $(this).text().replace(/[^0-9]/gi, '');
        for(var x=0; x<tooltips.events.length; x++) { $(window).on(tooltips.events[x], function(ev, elem) { tooltips.applyTooltips(elem || this) }) }
             currentCashArray[index] = parseFloat(getNumber, 10);
        if(tooltips.debug) {
            $('#tooltip-wrapper').css({'background-color':'rgba(255,0,0,0.2)'})
            $('#tooltip-storage').css({'background-color':'rgba(0,255,0,0.2)','height':'500px','overflow-y':'scroll','visibility':'visible'})
        }
    },
    config: function() {
        if(typeof tooltips_list != 'undefined') {
            $(tooltips_list).each(function(i, v) { tooltips.addType(v) });
        }
        if(typeof tooltips_config == 'object') {
             tooltips.offsetX = tooltips_config.offsetX || tooltips.offsetX;
            tooltips.offsetY = tooltips_config.offsetY || tooltips.offsetY;
            tooltips.waitForImages = (tooltips_config.waitForImages || tooltips.waitForImages) && true;
            tooltips.events = tooltips_config.events || tooltips.events;
        }
        return true
    },
    applyTooltips: function(elem) {
        $(elem).find('.'+tooltips.classes.join(', .')).each(function() {
            $this = $(this)
            if($this.hasClass('tooltips-init-complete')) return;
            $this.find('*').removeAttr('title');
            $this.mouseover(tooltips.handlers.mouseOver);
            $this.mouseout(tooltips.handlers.mouseOut);
            $this.mousemove(tooltips.handlers.mouseMove);
            $this.data('tooltip-contents', $(this).attr('title'));
             $this.removeAttr('title');
            tooltips.advancedTooltip($this);
            $(this).addClass('tooltips-init-complete');
         });
         });
    },
         $("input[name='selectRadio']").change(function() {
    advancedTooltip: function(elem) {
             multiplierValue = $(this).val();
         elem = $(elem)
             $('.xp').each(function(index) {
        if(!elem.hasClass('advanced-tooltip')) return;
var finalXP = currentXPArray[index] + (currentXPArray[index] * (multiplierValue / 100));
        var tips = elem.find('.tooltip-contents')
                $(this).text(Math.round(finalXP));
        if(!tips.length) return;
$(this).css({ 'font-weight': 'bold' });
        var tip = $('<div class="main-tooltip tt-advanced-tooltip"></div>').attr('id', 'tooltip-advanced-tooltip-'+tooltips.advancedCounter).appendTo('#tooltip-storage').data('type', 'advanced-tooltip').append($(tips[0]).contents()).each(tooltips.calcSize);
        tips.remove();
        elem.data('tooltip-id-advanced-tooltip', tooltips.advancedCounter);
        tooltips.advancedCounter++;
    },
    addType: function(tt) {
        if(typeof tooltips.types[tt.classname] == 'undefined') {
            var obj = {}
            if(typeof tt.parse == 'string' || typeof tt.parse == 'function') var parse = tt.parse; else var parse = false;
            if(typeof tt.text == 'string' || typeof tt.text == 'function') var text = tt.text; else var text = false;
            if(parse) {
                obj.text = parse;
                obj.parse = true;
            } else if(text) {
                obj.text = text;
                obj.parse = false;
            } else return;
            if(typeof obj.text == 'string') obj.parameters = tooltips.getParameters(obj.text); else obj.parameters = [];
            if(typeof tt.delay == 'string' || typeof tt.delay == 'number') obj.delay = parseInt(tt.delay); else obj.delay = false;
            if(typeof tt.onParsed == 'function') obj.onParsed = tt.onParsed;
            if(typeof tt.onShow == 'function') obj.onShow = tt.onShow;
            if(typeof tt.onHide == 'function') obj.onHide = tt.onHide;
            tooltips.types[tt.classname] = obj;
            if(tooltips.classes.indexOf(tt.classname) == -1) tooltips.classes.push(tt.classname)
        } else {
            if(typeof tt.delay == 'string' || typeof tt.delay == 'number') tooltips.types[tt.classname].delay = parseInt(tt.delay);
            if(typeof tt.onParsed == 'function') tooltips.types[tt.classname].onParsed = tt.onParsed;
            if(typeof tt.onShow == 'function') tooltips.types[tt.classname].onShow = tt.onShow;
            if(typeof tt.onHide == 'function') tooltips.types[tt.classname].onHide = tt.onHide;
        }
    },
    getParameters: function(text) {
        var list = []
        var matches = text.match(/<#\s*[a-z0-9_\-]+?\s*#>/gi)
        if(matches) {
            for(var x=0; x<matches.length; x++) {
                list.push(/<#\s*([a-z0-9_\-]+?)\s*#>/i.exec(matches[x])[1])
            }
        }
        return list
    },
    getAPI: function(text) {
        return tooltips.api+encodeURIComponent(text)
    },
    getText: function(type, elem) {
        if(typeof tooltips.types[type].text == 'function') {
            var text = tooltips.types[type].text($(elem)[0])
        } else {
            var text = tooltips.types[type].text
            for(var x=0; x<tooltips.types[type].parameters.length; x++) {
                var param = tooltips.types[type].parameters[x]
                var value = $(elem).data(param)
                if(typeof value == 'undefined') value = ''
                var rx = new RegExp('<#\\s*'+param.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")+'\\s*#>', 'g')
                text = text.replace(rx, value)
            }
        }
        return text
    },
    getTooltip: function(type, elem) {
        elem = $(elem)
        if(elem.data('tooltip-id-'+type)) return $('#tooltip-'+type+'-'+elem.data('tooltip-id-'+type))
        var text = tooltips.getText(type, elem)
        var id = tooltips.hash(text)
        elem.data('tooltip-id-'+type, id)
        var tip = $('#tooltip-'+type+'-'+elem.data('tooltip-id-'+type))
        if(tip.length) return tip;
        tip = $('<div class="main-tooltip"></div>').attr('id', 'tooltip-'+type+'-'+id).appendTo('#tooltip-storage').data('type', type).addClass('tt-'+type)
        tooltips.wrapperPosition(tooltips.lastKnownMousePos[0], tooltips.lastKnownMousePos[1])
        tooltips.sameWidth()
        if(!tooltips.types[type].parse) {
             tip.html(text).each(tooltips.calcSize)
            tooltips.wrapperPosition(tooltips.lastKnownMousePos[0], tooltips.lastKnownMousePos[1])
            tooltips.sameWidth()
        } else {
            tip.addClass('tooltip-loading')
            var api = tooltips.getAPI(text)
            if(tooltips.debug) tip.html('<pre style="padding:2px 3px;font-size:11px;">'+api+'</pre>')
            tip.attr('title', api)
            $.ajax({
                url: api,
                dataType: 'json',
                context: tip,
                success: function(data, textStatus, jqXHR) {
                    $(this).html(data['parse']['text']['*']).each(tooltips.calcSize)
                    tooltips.wrapperPosition(tooltips.lastKnownMousePos[0], tooltips.lastKnownMousePos[1])
                    tooltips.sameWidth()
                    var images = $(this).find('img')
                    images.fadeTo(0, 0).one('load', function() {
                        if(tooltips.waitForImages) {
                            $(this).fadeTo(0,1);
                            $(this).addClass('image-loaded')
                            tip = $(this).closest('.main-tooltip')
                            if(tip.find('img').length == tip.find('img.image-loaded').length) {
                                tip.removeClass('tooltip-loading').each(tooltips.calcSize)
                                tooltips.wrapperPosition(tooltips.lastKnownMousePos[0], tooltips.lastKnownMousePos[1])
                                tooltips.sameWidth()
                            }
                        } else $(this).fadeTo(100,1);
                    })
                    if(tooltips.waitForImages) {
                        if(images.length == 0) {
                            $(this).removeClass('tooltip-loading').each(tooltips.calcSize)
                        }
                    } else {
                        $(this).removeClass('tooltip-loading').each(tooltips.calcSize)
                    }
                    var type = $(this).data('type') || false
                    if(type && typeof tooltips.types[type].onParsed == 'function') {
                        tooltips.types[type].onParsed.call(this);
                        tip.each(tooltips.calcSize)
                    }
                    if($(this).find('a.new').length > 0) $(this).addClass('has-redlinks')
                    tooltips.wrapperPosition(tooltips.lastKnownMousePos[0], tooltips.lastKnownMousePos[1])
                    tooltips.sameWidth()
                }
             });
        }
        return tip
    },
    getBasicTooltip: function(elem) {
        return $("#tooltip-basic-tooltip").html($(elem).data('tooltip-contents').replace(/\\n/g,'<br />')).each(tooltips.calcSize);
    },
    getAdvancedTooltip: function(elem) {
        return $("#tooltip-advanced-tooltip-"+$(elem).data('tooltip-id-advanced-tooltip'));
    },
    getTooltips: function(elem) {
        elem = $(elem)
        var classes = elem.attr('class').split(' ')
        var tips = []
        for(var i=0;i<classes.length;i++) {
            var tip = false;
            if(classes[i] == 'advanced-tooltip') tip = tooltips.getAdvancedTooltip(elem);
            else if(classes[i] == 'basic-tooltip') tip = tooltips.getBasicTooltip(elem);
            else if(typeof tooltips.types[classes[i]] != 'undefined') tip = tooltips.getTooltip(classes[i], elem);
            if(tip) tips.push(tip[0]);
        }
        return $(tips)
    },
    setOwnWidth: function() {
        $this = $(this)
        if(typeof $this.data('width') != 'undefined') $this.css('width', $this.data('width')+'px')
        else $this.css('width', '')
    },
    calcSize: function() {
        $this = $(this)
        $this.css('position', 'absolute')
        var temp = $this.css('width')
        $this.css('width', '')
        $this.data('width', $this.width());
        $this.data('height', $this.height());
        $this.data('outerwidth', $this.outerWidth(true));
        $this.data('outerheight', $this.outerHeight(true));
        $this.css('width', $this.data('width')+'px')
        $this.css('position', '')
        $this.css('width', temp)
    },
    sameWidth: function() {
        if($("#tooltip-wrapper").find('.main-tooltip').length == 1) {
            $("#tooltip-wrapper").find('.main-tooltip').each(tooltips.setOwnWidth)
        } else {
            var width = 0;
            $("#tooltip-wrapper").find('.main-tooltip').each(function() { width = Math.max(width, $(this).data('width') || 0); });
            $("#tooltip-wrapper").find('.main-tooltip').each(function() { $(this).css('width', width+'px'); });
        }
    },
    wrapperPosition: function(mouseX, mouseY) {
        var tipH = parseInt($("#tooltip-wrapper").css('padding-top')) + parseInt($("#tooltip-wrapper").css('padding-bottom'));
        var tipW = 0;
        $("#tooltip-wrapper").find('.main-tooltip').each( function(){ if(typeof $(this).data('outerheight') != 'undefined') tipH += $(this).data('outerheight'); });
        $("#tooltip-wrapper").find('.main-tooltip').each( function(){ if(typeof $(this).data('outerwidth') != 'undefined') tipW = Math.max(tipW, $(this).data('outerwidth') + parseInt($("#tooltip-wrapper").css('padding-left')) + parseInt($("#tooltip-wrapper").css('padding-right'))); });
        var coordX = tooltips.offsetX+mouseX;
        var coordY = tooltips.offsetY+mouseY;
        var toRight = $(window).width()-coordX;
        if ($("#tooltip-wrapper").css('position') == 'fixed') {
            coordX = coordX-$(window).scrollLeft();
            coordY = coordY-$(window).scrollTop();
            coordY = Math.min(coordY, $(window).height()-tipH-$('#WikiaBarWrapper').height());
        } else {
            coordY = Math.min(coordY, $(window).height()-tipH-$('#WikiaBarWrapper').height()+$(window).scrollTop());
        }
        if(toRight >= tipW) $("#tooltip-wrapper").css({left: coordX + 'px', top: coordY + 'px'});
        else $("#tooltip-wrapper").css({left: coordX-tipW-tooltips.offsetX*2 + 'px', top: coordY + 'px'});
    },
    handlers: {
        mouseOver: function(e) {
            tooltips.lastKnownMousePos = [e.pageX, e.pageY]
            tooltips.wrapperPosition(e.pageX, e.pageY)
            var tips = tooltips.getTooltips(this)
            $("#tooltip-wrapper").prepend(tips).show();
            tooltips.sameWidth()
            var handle = this
            tips.each(function() {
                var $this = $(this);
                var type = $(this).data('type') || false;
                $this.show();
                if(type && typeof tooltips.types[type] != 'undefined' && tooltips.types[type].delay) {
                    $this.hide()
                    tooltips.timeouts[$(this).attr('id')] = setTimeout(function(){
                        $this.show();
                        if(type && typeof tooltips.types[type].onShow == 'function') tooltips.types[type].onShow.call($this[0], handle);
                    }, tooltips.types[type].delay)
                } else if(type && typeof tooltips.types[type].onShow == 'function') tooltips.types[type].onShow.call(this, handle);
             });
             });
        },
             $('.money').each(function(index) {
        mouseOut: function(e) {
var finalCash = currentCashArray[index] + (currentCashArray[index] * (multiplierValue / 100));
            tooltips.lastKnownMousePos = [e.pageX, e.pageY]
var cashSymbol = "$ ";
            tooltips.wrapperPosition(e.pageX, e.pageY)
                 $(this).text(cashSymbol + Math.round(finalCash));
$(this).css({ 'font-weight': 'bold' });
            var handle = this
             $("#tooltip-wrapper").hide()
            $("#tooltip-wrapper").find('.main-tooltip').appendTo('#tooltip-storage').each(function() {
                var type = $(this).data('type') || false;
                if(type && typeof tooltips.types[type].onHide == 'function') tooltips.types[type].onHide.call(this, handle);
                 $(this).show()
                clearTimeout(tooltips.timeouts[$(this).attr('id')])
                delete tooltips.timeouts[$(this).attr('id')]
             });
             });
         },
         });
        mouseMove: function(e) {
$('.appImage').replaceWith('<img src="https://wiki.the-west.net/images/8/8c/Transparent.png" class="job_Type" style="position:absolute;margin-top:-6px;margin-left:-6px;" />');
            tooltips.lastKnownMousePos = [e.pageX, e.pageY]
$("input[name='selectRadio']").change(
            tooltips.wrapperPosition(e.pageX, e.pageY)
function(){
        },
var $src = "";
     },
if ($(this).val() == '50') {
    hash: function(text) {
$src = "https://wiki.the-west.net/images/a/ac/Silverjob_small.png";
        /* Source: http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/ */
}
        var hash = 0, i, char;
else if ($(this).val() == '100') {
        if (text.length == 0) return hash;
$src = "https://wiki.the-west.net/images/a/a6/Goldjob_small.png";
        for (i = 0, l = text.length; i < l; i++) {
}
            char  = text.charCodeAt(i);
else{
            hash  = ((hash<<5)-hash)+char;
$src = "https://wiki.the-west.net/images/8/8c/Transparent.png"
            hash |= 0; // Convert to 32bit integer
$('.money').css({ 'font-weight': 'normal' });
        }
$('.xp').css({ 'font-weight': 'normal' });
        return hash;
}
    },
$('.job_Type').attr('src',$src);
}
});
addOnloadHook(tooltips.init)
     });
})(jQuery);
 
/**
  stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
  @version v3.4.1
  @link https://github.com/dollarshaveclub/stickybits#readme
  @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in)
  @license MIT
**/
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s():"function"==typeof define&&define.amd?define(s):s()}(0,function(){"use strict";var s=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.4.1",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:e.customStickyChangeNumber||null,noStyles:e.noStyles||!1,stickyBitStickyOffset:e.stickyBitStickyOffset||0,parentClass:e.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof e.scrollEl?document.querySelector(e.scrollEl):e.scrollEl||window,stickyClass:e.stickyClass||"js-is-sticky",stuckClass:e.stuckClass||"js-is-stuck",stickyChangeClass:e.stickyChangeClass||"js-is-sticky--change",useStickyClasses:e.useStickyClasses||!1,useFixed:e.useFixed||!1,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,a=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var r=0;r<this.els.length;r+=1){var l=this.els[r],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==a?a:"","fixed"===a||i.useStickyClasses){var f=this.addInstance(l,i);this.instances.push(f)}}return this}var s=t.prototype;return s.definePosition=function(){var t;if(this.props.useFixed)t="fixed";else{for(var s=["","-o-","-webkit-","-moz-","-ms-"],e=document.head.style,i=0;i<s.length;i+=1)e.position=s[i]+"sticky";t=e.position?e.position:"fixed",e.position=""}return t},s.addInstance=function(t,s){var e=this,i={el:t,parent:t.parentNode,props:s};this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);return this.computeScrollOffsets(i),i.parent.className+=" "+s.parentClass,i.state="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer),i},s.getClosestParent=function(t,s){var e=s,i=t;if(i.parentElement===e)return e;for(;i.parentElement!==e;)i=i.parentElement;return e},s.getOffsetTop=function(t){for(var s=0;s=t.offsetTop+s,t=t.offsetParent;);return s},s.computeScrollOffsets=function(t){var s=t,e=s.props,i=s.el,n=s.parent,o=!this.isWin&&"fixed"===e.positionVal,a="bottom"!==e.verticalPosition,r=o?this.getOffsetTop(e.scrollEl):0,l=o?this.getOffsetTop(n)-r:this.getOffsetTop(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=r+e.stickyBitStickyOffset,s.stickyStart=a?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?l+n.offsetHeight-(s.el.offsetHeight+s.offset):l+n.offsetHeight,s},s.toggleClasses=function(t,s,e){var i=t,n=i.className.split(" ");e&&-1===n.indexOf(e)&&n.push(e);var o=n.indexOf(s);-1!==o&&n.splice(o,1),i.className=n.join(" ")},s.manageState=function(t){var s=t,e=s.el,i=s.props,n=s.state,o=s.stickyStart,a=s.stickyChange,r=s.stickyStop,l=e.style,c=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,y=i.stuckClass,d=i.verticalPosition,k=function(t){t()},m=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,g=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,w=r<=v&&"sticky"===n;o<v&&v<r&&("default"===n||"stuck"===n)?(s.state="sticky",m(function(){g(e,y,p),l.position=f,c||(l.bottom="",l[d]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",m(function(){g(e,p),"fixed"===f&&(l.position="")})):w&&(s.state="stuck",m(function(){g(e,p,y),"fixed"!==f||c||(l.top="",l.bottom="0",l.position="absolute")}));var S=a<=v&&v<=r;return v<a||r<v?m(function(){g(e,h)}):S&&m(function(){g(e,"stub",h)}),s},s.update=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];this.computeScrollOffsets(s)}return this},s.removeInstance=function(t){var s=t.el,e=t.props,i=this.toggleClasses;s.style.position="",s.style[e.verticalPosition]="",i(s,e.stickyClass),i(s,e.stuckClass),i(s.parentNode,e.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.props.scrollEl.removeEventListener("scroll",s.stateContainer),this.removeInstance(s)}this.manageState=!1,this.instances=[]},t}();if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.stickybits=function(t){return new s(this,t)})}});
$('#right_menu').stickybits({stickyBitStickyOffset: 25});

Versione attuale delle 13:39, 12 nov 2022

/* Any JavaScript here will be loaded for all users on every page load. */
$('.tbbox-logo').wrap('<a href="/wiki/Pagina_principale"></a>');
if ($('.item_container').length!==0) {
    $('.item_container').each(function() {
        $(this).append('<img src="https://westzz.innogamescdn.com/images/items/' + $(this).attr('data-url') + '">');
    });
    $.getScript("https://wiki.the-west.it/wiki/Popup.js?action=raw");
}

$(window).scroll(function() {
    if ($(this).scrollTop() > 100) {
        $('#back-top').fadeIn();
    } else {
        $('#back-top').fadeOut();
    }
});
// Scroll body to top on click
$('#back-top a').click(function() {
    $('body,html').animate({
        scrollTop: 0
    }, 800);
    return false;
});
// Embed youtube videos
if ($('.youtube_video').length !== 0) {
    $('.youtube_video').each(function() {
        $(this).html('<iframe width="100%" height="100%" src="https://www.youtube.com/embed/' + $(this).attr('data-id') + '?cc_load_policy=1&cc_lang_pref=' + $(this).attr('data-subtitles') + '" frameborder="0" allowfullscreen></iframe>');
    });
}

//Let's generate an input box - Criminus
$('.target_input p').each(function() {
	var id = $(this).attr('id');
	var phrase = $(this).text();
	var newInput="<input type='number' name='input_nou' value='"+phrase+"' class='target' max='999' min='1' />";
	$(this).replaceWith(newInput);
});

$("input[name=input_nou]").on("click", function() {
    if ($(this).val() == "1")
        $(this).val("")
});

$(function () {
  $("input[name=input_nou]").keydown(function () {
    // Save old value.
    if (!$(this).val() || (parseInt($(this).val()) <= 9999 && parseInt($(this).val()) >= 0))
    $(this).data("old", $(this).val());
  });
  $("input[name=input_nou]").keyup(function () {
    // Check correct, else revert back to old value.
    if (!$(this).val() || (parseInt($(this).val()) <= 9999 && parseInt($(this).val()) >= 0))
      ;
    else
      $(this).val($(this).data("old"));
  });
});

(function($) {
    $(document).ready(function() {
        var multiplierValue = 1;
        var currentAmountsArray = [];
        $('.item_number').each(function(index) {
            currentAmountsArray[index] = parseInt($(this).text());
        });
        if ($("input[name='input_nou']").length > 0) {
            $("input[name='input_nou']").change(function() {
                multiplierValue = $(this).val();
                $('.item_number').each(function(index) {
                    $(this).text(currentAmountsArray[index] * multiplierValue);
                });
                $('.craft_extra').show();
                $('.craft_extra .item_container').each(function() {
                    $(this).children().addClass('OverlayItem');
                });

            });
            $("input[name='input_nou']").keyup(function() {
                multiplierValue = $(this).val();
                $('.item_number').each(function(index) {
                    $(this).text(currentAmountsArray[index] * multiplierValue);
                });
                $('.craft_extra').show();
                $('.craft_extra .item_container').each(function() {
                    $(this).children().addClass('OverlayItem');
                });
            });
        }
    });
})(jQuery);

//Live search through craft items - Criminus
$('.search_craft p').each(function() {
	var id = $(this).attr('id');
	var phrase = $(this).text();
	var newInput="<input type='text' id='live_search' name='craft_search' value='"+phrase+"' class='craft_search' />";
	$(this).replaceWith(newInput);
});

$("#live_search").on("keyup", function() {
    var value = $(this).val();
    $("table tr").each(function(index) {
        if (index !== 0) {
            $row = $(this);
            var id = $.map($row.find('td .item_container'), function(element) {
                return $(element).attr("data-popup")
            }).join(' ');
            if (id.toLowerCase().indexOf(value.toLowerCase()) < 0) {
                $row.hide();
            } else {
                $row.show();
            }
        }
    });
});

$("#live_search").on("click", function() {
    if ($(this).val() == "Nome o ID")
        $(this).val("")
});

(function($) {
    $(document).ready(function() {
		$('.radioButtonsHere').replaceWith('<center><input id="normal" type="radio" value="0" class="selectRadio" name="selectRadio"/> Semplice <input id="silver" type="radio" value="50" class="selectRadio" name="selectRadio"/> Argento <input id="aura" type="radio" value="100" class="selectRadio" name="selectRadio"/> Oro</center>');
        var multiplierValue = 1;
        var currentXPArray = [];
		var currentCashArray = [];
        $('.xp').each(function(index) {
            currentXPArray[index] = parseInt($(this).text());
        });
        $('.money').each(function(index) {
            var getNumber = $(this).text().replace(/[^0-9]/gi, '');
            currentCashArray[index] = parseFloat(getNumber, 10);
        });
        $("input[name='selectRadio']").change(function() {
            multiplierValue = $(this).val();
            $('.xp').each(function(index) {
				var finalXP = currentXPArray[index] + (currentXPArray[index] * (multiplierValue / 100));
                $(this).text(Math.round(finalXP));
				$(this).css({ 'font-weight': 'bold' });
            });
            $('.money').each(function(index) {
				var finalCash = currentCashArray[index] + (currentCashArray[index] * (multiplierValue / 100));
				var cashSymbol = "$ ";
                $(this).text(cashSymbol + Math.round(finalCash));
				$(this).css({ 'font-weight': 'bold' });
            });
        });
		$('.appImage').replaceWith('<img src="https://wiki.the-west.net/images/8/8c/Transparent.png" class="job_Type" style="position:absolute;margin-top:-6px;margin-left:-6px;" />');
		$("input[name='selectRadio']").change(
			function(){
				var $src = "";
				if ($(this).val() == '50') {
					$src = "https://wiki.the-west.net/images/a/ac/Silverjob_small.png";
				}
				else if ($(this).val() == '100') {
					$src = "https://wiki.the-west.net/images/a/a6/Goldjob_small.png";
				}
				else{
					$src = "https://wiki.the-west.net/images/8/8c/Transparent.png"
					$('.money').css({ 'font-weight': 'normal' });
					$('.xp').css({ 'font-weight': 'normal' });
				}
				$('.job_Type').attr('src',$src);
		});
    });
})(jQuery);

/**
  stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
  @version v3.4.1
  @link https://github.com/dollarshaveclub/stickybits#readme
  @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in)
  @license MIT
**/
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s():"function"==typeof define&&define.amd?define(s):s()}(0,function(){"use strict";var s=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.4.1",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:e.customStickyChangeNumber||null,noStyles:e.noStyles||!1,stickyBitStickyOffset:e.stickyBitStickyOffset||0,parentClass:e.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof e.scrollEl?document.querySelector(e.scrollEl):e.scrollEl||window,stickyClass:e.stickyClass||"js-is-sticky",stuckClass:e.stuckClass||"js-is-stuck",stickyChangeClass:e.stickyChangeClass||"js-is-sticky--change",useStickyClasses:e.useStickyClasses||!1,useFixed:e.useFixed||!1,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,a=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var r=0;r<this.els.length;r+=1){var l=this.els[r],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==a?a:"","fixed"===a||i.useStickyClasses){var f=this.addInstance(l,i);this.instances.push(f)}}return this}var s=t.prototype;return s.definePosition=function(){var t;if(this.props.useFixed)t="fixed";else{for(var s=["","-o-","-webkit-","-moz-","-ms-"],e=document.head.style,i=0;i<s.length;i+=1)e.position=s[i]+"sticky";t=e.position?e.position:"fixed",e.position=""}return t},s.addInstance=function(t,s){var e=this,i={el:t,parent:t.parentNode,props:s};this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);return this.computeScrollOffsets(i),i.parent.className+=" "+s.parentClass,i.state="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer),i},s.getClosestParent=function(t,s){var e=s,i=t;if(i.parentElement===e)return e;for(;i.parentElement!==e;)i=i.parentElement;return e},s.getOffsetTop=function(t){for(var s=0;s=t.offsetTop+s,t=t.offsetParent;);return s},s.computeScrollOffsets=function(t){var s=t,e=s.props,i=s.el,n=s.parent,o=!this.isWin&&"fixed"===e.positionVal,a="bottom"!==e.verticalPosition,r=o?this.getOffsetTop(e.scrollEl):0,l=o?this.getOffsetTop(n)-r:this.getOffsetTop(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=r+e.stickyBitStickyOffset,s.stickyStart=a?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?l+n.offsetHeight-(s.el.offsetHeight+s.offset):l+n.offsetHeight,s},s.toggleClasses=function(t,s,e){var i=t,n=i.className.split(" ");e&&-1===n.indexOf(e)&&n.push(e);var o=n.indexOf(s);-1!==o&&n.splice(o,1),i.className=n.join(" ")},s.manageState=function(t){var s=t,e=s.el,i=s.props,n=s.state,o=s.stickyStart,a=s.stickyChange,r=s.stickyStop,l=e.style,c=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,y=i.stuckClass,d=i.verticalPosition,k=function(t){t()},m=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,g=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,w=r<=v&&"sticky"===n;o<v&&v<r&&("default"===n||"stuck"===n)?(s.state="sticky",m(function(){g(e,y,p),l.position=f,c||(l.bottom="",l[d]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",m(function(){g(e,p),"fixed"===f&&(l.position="")})):w&&(s.state="stuck",m(function(){g(e,p,y),"fixed"!==f||c||(l.top="",l.bottom="0",l.position="absolute")}));var S=a<=v&&v<=r;return v<a||r<v?m(function(){g(e,h)}):S&&m(function(){g(e,"stub",h)}),s},s.update=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];this.computeScrollOffsets(s)}return this},s.removeInstance=function(t){var s=t.el,e=t.props,i=this.toggleClasses;s.style.position="",s.style[e.verticalPosition]="",i(s,e.stickyClass),i(s,e.stuckClass),i(s.parentNode,e.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.props.scrollEl.removeEventListener("scroll",s.stateContainer),this.removeInstance(s)}this.manageState=!1,this.instances=[]},t}();if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.stickybits=function(t){return new s(this,t)})}});
$('#right_menu').stickybits({stickyBitStickyOffset: 25});