MediaWiki:Common.js: Difference between revisions

From Wiki The-West EN
Jump to navigation
No edit summary
No edit summary
 
(169 intermediate revisions by 3 users not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
$('.tbbox-logo').wrap('<a href="/wiki/Main_Page"></a>');
$(document).ready(function() {
if ($('.item_container').length!==0) {
    $('.item_container').each(function() {
var currentUrl = window.location.pathname.split('/').pop();
        $(this).append('<img src="https://westzz.innogamescdn.com/images/items/' + $(this).attr('data-url') + '?1">');
    });
if (currentUrl == 'Main_Page') {
    $.getScript("/wiki/Popup.js?action=raw");
$.getScript("/wiki/QuestsCalendar.js?action=raw", function() {
}
// Script loaded
});
}
if (currentUrl == 'Category:Questlines') {
$.getScript("/wiki/Quests.js?action=raw", function() {
// Script loaded
});
}
 
    $('body').append($('<div></div>').load('https://wiki.the-west.net/wiki/Dock.html?action=raw'));
 
    if ($('.item_container').length !== 0) {
        $('.item_container').each(function() {
            $(this).append('<img src="https://westzz.innogamescdn.com/images/items/' + $(this).attr('data-url') + '?1">');
        });
        $.getScript("/wiki/Popup.js?action=raw");
    }
});


$(window).scroll(function() {
$(window).scroll(function() {
Line 18: Line 36:
$('#back-top a').click(function() {
$('#back-top a').click(function() {
     $('body,html').animate({
     $('body,html').animate({
        scrollTop: 0
            scrollTop: 0,
    }, 800);
        },
        800
    );
     return false;
     return false;
});
});
Line 25: Line 45:
if ($('.youtube_video').length !== 0) {
if ($('.youtube_video').length !== 0) {
     $('.youtube_video').each(function() {
     $('.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>');
         $(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>'
        );
    });
}
//calculate box - n3mesis
if ($('.calculate_box').length) {
    $.getScript('/wiki/Calculate.js?action=raw');
};
//crafting
if ($('.target_input').length) {
    $('.target_input p').each(function() {
        var id = $(this).attr('id');
        var phrase = $(this).text();
        var newInput = "<input type='number' name='input_new' value='" +
            phrase + "' class='target' max='50000' min='' />";
        $(this).replaceWith(newInput);
    });
    var multiplierValue = 1;
    var currentAmountsArray = [];
    $('.amount').each(function(index) {
        currentAmountsArray[index] = parseInt($(this).text());
    });
    $("input[name='input_new']").on('input paste keyup', function() {
        this.value > 50000 ? (this.value = 50000) : this.value < 0 && (this.value = 0);
        multiplierValue = this.value;
        $('.amount').each(function(index) {
            $(this).text(currentAmountsArray[index] * multiplierValue);
        });
        $('.craft_extra').show();
        $('.craft_extra .item_container').each(function() {
            $(this).children().addClass('OverlayItem');
        });
     });
     });
}
}
// calculation boxes - n3mesis
 
var OnOrNoClick=['<div class="tw_checkbox_no"></div>','<div class="tw_checkbox_on"></div>',];if($('#calcDuelExp').length!==0){var context=$('#calcDuelExp');var input_character_level=$('<input type="number" style="width:150px;" class="west" placeholder="Your duel level" min="0" max="450">').bind('propertychange keyup input paste',function(){if(this.value>450){this.value=450;}else if(this.value<0){this.value=0;}
// As seen on https://bitbucket.org/cmcqueen1975/htmlfloatingtableheader/overview
calcDuelExp();}).appendTo(context.find('.character_level'));var input_oponent_level=$('<input type="number" style="width:150px;" class="west" placeholder="Opponents duel level" min="0" max="450">').bind('propertychange keyup input paste',function(){if(this.value>450){this.value=450;}else if(this.value<0){this.value=0;}
function UpdateTableHeaders() {
calcDuelExp();}).appendTo(context.find('.oponent_level'));var input_duel_motivation=$('<input type="number" style="width:150px;" class="west" placeholder="Duel motivation" min="0" max="100">').bind('propertychange keyup input paste',function(){if(this.value>100){this.value=100;}else if(this.value<0){this.value=0;}
    $("div.divTableWithFloatingHeader").each(function() {
calcDuelExp();}).appendTo(context.find('.duel_motivation'));function calcDuelExp(){var oponent_lvl=parseInt(input_oponent_level.val()),char_lvl=parseInt(input_character_level.val()),duel_mot=parseInt(input_duel_motivation.val());if(isNaN(oponent_lvl)||isNaN(char_lvl)||isNaN(duel_mot)){context.find('.result').html('');}else{var getduelexp=Math.round((oponent_lvl*7-5*char_lvl+5)*(duel_mot/100));var getexp=Math.round(getduelexp*3);var loseduelexp=Math.round(getduelexp/3);context.find('.result').html('If you win you will get <b>'+
        var originalHeaderRow = $(".tableFloatingHeaderOriginal", this);
getduelexp+' duelexp</b> and <b>'+
        var floatingHeaderRow = $(".tableFloatingHeader", this);
getexp+' exp</b>.<br/>If you lose you will lose <b>'+
        var offset = $(this).offset();
loseduelexp+' duelexp</b>.');}
        var scrollTop = $(window).scrollTop();
if(isNaN(char_lvl)){context.find('.result1').html('');}else{var maxduellvl=Math.floor(char_lvl*1.4);var minduellvl=Math.ceil(char_lvl/1.4);context.find('.result1').html('Maximum duellevel: <b>'+
        if ((scrollTop > originalHeaderRow.offset().top) && (scrollTop < offset.top + $(this).height() - originalHeaderRow.height())) {
maxduellvl+'</b><br/>Minimum duellevel: <b>'+
            floatingHeaderRow.css("visibility", "visible");
minduellvl+'</b>');}}}
            floatingHeaderRow.css("top", "0px");
if($('#calcSpeed').length!==0){hide_spd_vip();var context=$('#calcSpeed');var input_horse_speed=$('<input type="number" style="width:150px;" class="west" placeholder="Horse speed" min="0" max="19900">').bind('propertychange keyup input paste',function(){if(this.value>19900){this.value=19900;}else if(this.value<0){this.value=0;}
 
calcSpeed();}).appendTo(context.find('.horse_speed'));var input_skill_horsebackriding=$('<input type="number" style="width:150px;" class="west" placeholder="horseback riding" min="0" max="9000">').bind('propertychange keyup input paste',function(){if(this.value>9000){this.value=9000;}else if(this.value<0){this.value=0;}
            // Copy cell widths from original header
calcSpeed();}).appendTo(context.find('.skill_horsebackriding'));var input_gear_bonus=$('<input type="number" style="width:150px;" class="west" placeholder="Gear speed in %" min="0" max="5000">').bind('propertychange keyup input paste',function(){if(this.value>5000){this.value=5000;}else if(this.value<0){this.value=0;}
            $("th", floatingHeaderRow).each(function(index) {
calcSpeed();}).appendTo(context.find('.gear_bonus'));var input_speed_buff=$('<input type="number" style="width:150px;" class="west" placeholder="Buff speed in %" min="0" max="5000">').bind('propertychange keyup input paste',function(){if(this.value>5000){this.value=5000;}else if(this.value<0){this.value=0;}
                var cellWidth = $("th", originalHeaderRow).eq(index).css('width');
calcSpeed();}).appendTo(context.find('.speed_buff'));function hide_spd_lvl15(){document.getElementById('checked_lvl15').innerHTML='';document.getElementById('txt_spd_lvl15').innerHTML='';}
                $(this).css('width', cellWidth);
function show_spd_lvl15(){document.getElementById('checked_lvl15').innerHTML=OnOrNoClick[0];document.getElementById('txt_spd_lvl15').innerHTML=' Under level 15?';}
            });
function hide_spd_vip(){document.getElementById('checked_duelvip').innerHTML='';document.getElementById('txt_spd_vip').innerHTML='';}
 
function show_spd_vip(){document.getElementById('checked_duelvip').innerHTML=OnOrNoClick[0];document.getElementById('txt_spd_vip').innerHTML=' Character bonus?';}
            // Copy row width from whole table
function hide_spd_dueler(){document.getElementById('checked_dueler').innerHTML='';document.getElementById('txt_spd_dueler').innerHTML='';}
            floatingHeaderRow.css("width", $(this).css("width"));
function show_spd_dueler(){document.getElementById('checked_dueler').innerHTML=OnOrNoClick[0];document.getElementById('txt_spd_dueler').innerHTML=' Dueler?';}
        } else {
function hide_spd_prem(){document.getElementById('checked_prem').innerHTML='';document.getElementById('txt_spd_prem').innerHTML='';}
            floatingHeaderRow.css("visibility", "hidden");
function show_spd_prem(){document.getElementById('checked_prem').innerHTML=OnOrNoClick[0];document.getElementById('txt_spd_prem').innerHTML=' Speed premium?';}
            floatingHeaderRow.css("top", "0px");
var prem_var=0;var prem_spd=1;checked_prem.onclick=function(){if(prem_var==1){prem_var=prem_var-2;}
        }
prem_var=prem_var+1;document.getElementById('checked_prem').innerHTML=OnOrNoClick[prem_var];prem_spd=prem_var+1;calcSpeed();};var duel_var=0;var duel_spd=1;var duel_list=[1,1.1];checked_dueler.onclick=function(){if(duel_var==1){duel_var=duel_var-2;duelvip_var=0;duelvip_spd=0;hide_spd_vip();show_spd_lvl15();}else{hide_spd_lvl15();show_spd_vip();}
    });
duel_var=duel_var+1;document.getElementById('checked_dueler').innerHTML=OnOrNoClick[duel_var];duel_spd=duel_list[duel_var];calcSpeed();};var lvl15_var=0;var lvl15_spd=1;var lvl15_list=[1,51];checked_lvl15.onclick=function(){if(lvl15_var==1){lvl15_var=lvl15_var-2;show_spd_dueler();show_spd_prem();}else{hide_spd_dueler();hide_spd_prem();prem_var=0;prem_spd=1;}
};
lvl15_var=lvl15_var+1;document.getElementById('checked_lvl15').innerHTML=OnOrNoClick[lvl15_var];lvl15_spd=lvl15_list[lvl15_var];calcSpeed();};var duelvip_var=0;var duelvip_spd=0;var duelvip_list=[0,0.1];checked_duelvip.onclick=function(){if(duelvip_var==1){duelvip_var=duelvip_var-2;}
 
duelvip_var=duelvip_var+1;document.getElementById('checked_duelvip').innerHTML=OnOrNoClick[duelvip_var];duelvip_spd=duelvip_list[duelvip_var];calcSpeed();};function calcSpeed(){var horse_spd=parseInt(input_horse_speed.val()),skill_rid=parseInt(input_skill_horsebackriding.val()),gear_spd=parseInt(input_gear_bonus.val()),buff_spd=parseInt(input_speed_buff.val());if(isNaN(horse_spd)||isNaN(skill_rid)||isNaN(gear_spd)||isNaN(buff_spd)){context.find('.result_spd').html('Enter <u>all</u> Values to calculate');}else{var speed=Math.round((100+horse_spd+skill_rid)*(1+gear_spd/100+buff_spd/100)*prem_spd*(duel_spd+duelvip_spd)*lvl15_spd);var mph=Math.round(4*(speed/100));context.find('.result_spd').html('Your movement speed is: <b>'+
$(function() {
mph+' mph ('+
    $("table.tableWithFloatingHeader").each(function() {
speed+'%</b>)');}}}
        $(this).wrap("<div class=\"divTableWithFloatingHeader\" style=\"position:relative\"></div>");
if($('#calcBuilding1').length!==0){var context=$('#calcBuilding1');var input_bui_labour_points=$('<input type="number" style="width:150px;" class="west" placeholder="Your labour points" min="0" max="500000">').bind('propertychange keyup input paste',function(){if(this.value>50000){this.value=50000;}else if(this.value<0){this.value=0;}
 
calcBuilding1();}).appendTo(context.find('.bui_labour_points'));var input_bui_motivation=$('<input type="number" style="width:150px;" class="west" placeholder="Building motivation" min="0" max="100">').bind('propertychange keyup input paste',function(){if(this.value>100){this.value=100;}else if(this.value<0){this.value=0;}
        var cls = "tr.floatingHeader";
calcBuilding1();}).appendTo(context.find('.bui_motivation'));function onclick_bui_15m(){document.getElementById('checked_bui15').innerHTML=OnOrNoClick[1];}
        if ($(cls, this).length == 0) {
function noclick_bui_15m(){document.getElementById('checked_bui15').innerHTML=OnOrNoClick[0];}
            cls = "tr";
function onclick_bui_30m(){document.getElementById('checked_bui30').innerHTML=OnOrNoClick[1];}
        }
function noclick_bui_30m(){document.getElementById('checked_bui30').innerHTML=OnOrNoClick[0];}
        var originalHeaderRow = $(cls, this).first();
function onclick_bui_60m(){document.getElementById('checked_bui60').innerHTML=OnOrNoClick[1];}
        var clonedHeaderRow = originalHeaderRow.clone().insertBefore(originalHeaderRow);
function noclick_bui_60m(){document.getElementById('checked_bui60').innerHTML=OnOrNoClick[0];}
 
onclick_bui_60m();var bui_time=4;checked_bui15.onclick=function(){onclick_bui_15m();noclick_bui_30m();noclick_bui_60m();bui_time=1;calcBuilding1();};checked_bui30.onclick=function(){noclick_bui_15m();onclick_bui_30m();noclick_bui_60m();bui_time=2;calcBuilding1();};checked_bui60.onclick=function(){noclick_bui_15m();noclick_bui_30m();onclick_bui_60m();bui_time=4;calcBuilding1();};function calcBuilding1(){var bui_mot=parseInt(input_bui_motivation.val()),bui_lab=parseInt(input_bui_labour_points.val());if(isNaN(bui_lab)||isNaN(bui_mot)){context.find('.bui_result1').html('Enter <u>all</u> Values to calculate');}else{if(bui_lab<32768){var buipts=Math.round((bui_lab/10+5)*(bui_mot/100)*bui_time);context.find('.bui_result1').html('With '+
        clonedHeaderRow.addClass("tableFloatingHeader");
bui_lab+' labour points you will upgrade your building with <b>'+
        clonedHeaderRow.css("position", "fixed");
buipts+'</b> construction points.');}
        clonedHeaderRow.css("top", "0px");
if(bui_lab>32767){context.find('.bui_result1').html("<u></u>If you have more than 32767 labour points you can't build anymore!</u>");}}}}
        clonedHeaderRow.css("left", $(this).offset().left);
        clonedHeaderRow.css("visibility", "hidden");
        clonedHeaderRow.css("z-index", 1);
 
        originalHeaderRow.addClass("tableFloatingHeaderOriginal");
    });
    UpdateTableHeaders();
    $(window).on('scroll', UpdateTableHeaders);
    $(window).on('resize', UpdateTableHeaders);
});
 
(function($) {
    $(document).ready(function() {
        $('.radioButtonsHere').replaceWith('<center><input id="normal" type="radio" value="0" class="selectRadio" name="selectRadio"/> Normal Job <input id="silver" type="radio" value="50" class="selectRadio" name="selectRadio"/> Silver <input id="aura" type="radio" value="100" class="selectRadio" name="selectRadio"/> Gold</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);
 
//Page translator - Criminus 2023
(function($) {
    $(document).ready(function() {
        //$('#p-Language > div.border-1 > div > div').append(
        $('#module-page-navigation').append(
            $('<div>')
            .addClass('inner-body')
        );
        //$('#p-Language > div.border-1 > div > div > div').append(
        $('#module-page-navigation').append(
            $('<div>')
            .addClass('langPicker')
        );
 
        var languages = [{
                lang: 'en',
                title: 'English',
                src: 'https://wiki.the-west.net/images/c/ce/Gb.png',
                //link: 'https://wiki.the-west.net/wiki/Main_Page'
                link: 'https://wiki.the-west.net/wiki/Main_Page'
            },
            {
                lang: 'dk',
                title: 'Danish',
                src: 'https://wiki.the-west.net/images/0/06/Dk.png',
                //link: 'https://wiki.the-west.net/wiki/Forside'
                link: 'https://wiki.the-west.net/wiki/Forside'
            },
            {
                lang: 'se',
                title: 'Swedish',
                src: 'https://wiki.the-west.net/images/d/d0/Se.png',
                //link: 'https://wiki.the-west.net/wiki/Huvudsida'
                link: 'https://wiki.the-west.net/wiki/Huvudsida'
            }
        ];
 
        var translations = {
            en: {
                //Search Box Translation
                searchNav: 'Search',
                searchNavAdv: 'Advanced search',
                searchNavFText: 'Search Wiki The-West EN',
                searchNavFTitle: 'Search Wiki The-West EN [alt-shift-f]',
                //Main Page Translation
                mainPage: 'Main Page',
                mainPageLink: '/wiki/Main_Page',
                //Navigation Categories Translation
                navigationText: 'Navigation',
                gettingStartedText: 'Getting Started',
                gameFeaturesText: 'Game Features',
                newToWikiText: 'New to the Wiki',
                toolsText: 'Tools',
                quickAccessText: 'Quick access',
                moreGamesText: 'More games',
                followUSText: 'Follow us',
                // Navigation links
                rulesText: 'Game rules',
                rulesLink: 'https://wiki.the-west.net/wiki/Game_Rules',
            },
            dk: {
                //Search Box Translation
                searchNav: 'Søg',
                searchNavAdv: 'Avanceret søgning',
                searchNavFText: 'Søg på Wiki The-West DK',
                searchNavFTitle: 'Søg på Wiki The-West DK [alt-shift-f]',
                //Main Page Translation
                mainPage: 'Forside',
                mainPageLink: '/wiki/Forside',
                //Navigation Categories Translation
                navigationText: 'Naviger',
                gettingStartedText: 'Kom godt i gang',
                gameFeaturesText: 'Spilfunktioner',
                newToWikiText: 'Nyt på wikien',
                toolsText: 'Værktøjer',
                quickAccessText: 'Genveje',
                moreGamesText: 'Flere spil',
                followUSText: 'Følg os',
                // Navigation links
                rulesText: 'Regler',
                rulesLink: 'https://wiki.the-west.net/wiki/Regler_pr._September_2020',
            },
            se: {
                //Search Box Translation
                searchNav: 'Sök',
                searchNavAdv: 'Avancerad sökning',
                searchNavFText: 'Sök på Wiki The-West SE',
                searchNavFTitle: 'Sök på Wiki The-West SE [alt-shift-f]',
                //Main Page Translation
                mainPage: 'Huvudsida',
                mainPageLink: '/wiki/Huvudsida',
                //Navigation Categories Translation
                navigationText: 'Navigering',
                gettingStartedText: 'Börja',
                gameFeaturesText: 'Spelfunktioner',
                newToWikiText: 'Nytt på wikin',
                toolsText: 'Verktyg',
                quickAccessText: 'Genvägar',
                moreGamesText: 'Fler spel',
                followUSText: 'Följ oss',
                // Navigation links
                rulesText: 'Spelregler',
                rulesLink: 'https://wiki.the-west.net/wiki/Game_Rules',
            }
        };
 
        function updateLinks(language) {
            if (translations[language]) {
                //Logo redirects
                $('.tbbox-logo')
                    .wrap('<a href=' + translations[language].mainPageLink + '></a>');
                // Search Box
                $('h3#p-search-label')
                    .text(translations[language].searchNav);
                $('#searchform > a')
                    .text(translations[language].searchNavAdv);
                $('input#searchInput')
                    .attr('placeholder', translations[language].searchNavFText)
                    .attr('title', translations[language].searchNavFTitle);
                // Navigation Categories and Links
                $('#n-Main-Page > a')
                    .text(translations[language].mainPage)
                    .attr('href', translations[language].mainPageLink);
                $('h3#p-Navigation-label')
                    .text(translations[language].navigationText);
                $('h3#p-Getting_Started-label')
                    .text(translations[language].gettingStartedText);
                $('h3#p-Game_Features-label')
                    .text(translations[language].gameFeaturesText);
                $('h3#p-New_to_the_Wiki-label')
                    .text(translations[language].newToWikiText);
                $('h3#p-tb-label')
                    .text(translations[language].toolsText);
                $('span#Quick_access')
                    .text(translations[language].quickAccessText);
                $('span#More_games')
                    .text(translations[language].moreGamesText);
                $('span#Follow_us')
                    .text(translations[language].followUSText);
                //Navigation links
                $('#n-Game-rules > a')
                    .text(translations[language].rulesText)
                    .attr('href', translations[language].rulesLink);
            }
        }
 
        var storedLanguage = localStorage.getItem('selectedLanguage');
 
        if (storedLanguage) {
            updateLinks(storedLanguage);
        }
 
        for (var i = 0; i < languages.length; i++) {
            var imageElement = $('<img>').attr('src', languages[i].src).attr('title', languages[i].title);
            var linkElement = $('<a>')
                .attr('href', languages[i].link)
                .append(imageElement)
                .on('click', {
                    lang: languages[i].lang
                }, function(event) {
                    localStorage.setItem('selectedLanguage', event.data.lang);
                    updateLinks(event.data.lang);
                });
            $('.langPicker').append(linkElement);
        }
    });
})(jQuery);
 
(function($) {
    $(document).ready(function() {
        var elementToMove = $("#module-site-navigation").detach();
 
        elementToMove.insertAfter("#mirage-fixed-header");
 
    });
})(jQuery);
 
 
(function($) {
    $(document).ready(function() {
        $('.contact_team-btn').click(function() {
            var url = $(this).data('url');
            if (url) {
                window.open(url, '_blank');
            }
        });
        $('.normal_quest').click(function() {
            var url = $(this).data('url');
            if (url) {
                window.open(url, '_blank');
            }
        });
        $('.repeatable_quest').click(function() {
            var url = $(this).data('url');
            if (url) {
                window.open(url, '_blank');
            }
        });
    });
})(jQuery);
 
(function($) {
    $(document).on('click', '.dock-toggler', function() {
        const dockItems = $('.dock-items-container');
        const toggler = $('.dock-toggler');
        const toggleDockIcon = $('.toggle-dock');
 
        dockItems.toggleClass('toggled');
        toggler.toggleClass('toggled');
        toggleDockIcon.toggleClass('toggled');
    });
})(jQuery);
 
(function($) {
    $(document).ready(function() {
        function adjustColspan() {
            var screenWidth = $(window).width();
 
            var threshold = 768;
 
            $('quest.table td, quest.table th').each(function() {
                if (!$(this).data('original-colspan') && $(this).attr('colspan')) {
                    $(this).data('original-colspan', $(this).attr('colspan'));
                }
 
                if (screenWidth <= threshold) {
                    if ($(this).attr('colspan') && parseInt($(this).attr('colspan'), 10) === 3) {
                        $(this).attr('colspan', '1');
                    }
                } else {
                    if ($(this).data('original-colspan')) {
                        $(this).attr('colspan', $(this).data('original-colspan'));
                    }
                }
            });
        }
 
        adjustColspan();
 
        $(window).resize(adjustColspan);
    });
})(jQuery);
 
(function($) {
    $(document).ready(function() {
        var currentUrl = window.location.pathname.split('/').pop();
 
        if (currentUrl !== 'MediaWiki:Common.css' || currentUrl !== 'MediaWiki:Common.js') {
            $('#firstHeading').hide();
        }
        if (currentUrl == 'Category:Item_sets' || currentUrl == 'Category:Questlines') {
            $('.mw-category-generated').hide();
        }
    });
})(jQuery);
 
(function($) {
$(document).ready(function() {
$('.quickSearchQuest').append('<span class="textfield_wrapper textfield_flex"><span class="textfield_label"></span><span class="textfield"><span><input type="text" id="QsearchBox" placeholder="Quick Search Quest"></span></span></span>');
});
})(jQuery);
 
(function($) {
$(document).ready(function() {
  var $images = $(".set_bonus img");
  $images.each(function() {
var width = $(this).width();
var height = $(this).height();
if (height < 40) {
  $(this).css("margin-top", "10px");
}
  });
});
})(jQuery);
 
(function($) {
  $(document).ready(function() {
    var currentMonthContainer = $('#current-month-quests');
    var nextMonthContainer = $('#next-month-quests');
 
    // Function to start infinite scrolling animation
    function startAnimation(container) {
      var speed = 20; // Adjust the speed as needed
      var scrollDirection = 1; // 1 for scrolling down, -1 for scrolling up
      var scrollDistance = 1; // Adjust the scroll distance as needed
 
      // Clone the content and append it to create a continuous loop
      var containerContent = container.html();
      container.append(containerContent);
 
      // Set initial scroll position to 0
      container.scrollTop(0);
 
      // Define animation function
      function scrollContent() {
        container.scrollTop(container.scrollTop() + (scrollDirection * scrollDistance));
        if (container.scrollTop() >= container.prop('scrollHeight') - container.height()) {
          // Change direction to up when reaching the bottom
          scrollDirection = -1;
        } else if (container.scrollTop() <= 0) {
          // Change direction to down when reaching the top
          scrollDirection = 1;
        }
      }
 
      // Start the animation loop
      var scrollInterval;
 
      function startScrollInterval() {
        clearInterval(scrollInterval);
        scrollInterval = setInterval(scrollContent, speed);
      }
 
      startScrollInterval();
 
      // Pause animation on hover
      container.on('mouseenter', function() {
        clearInterval(scrollInterval);
      });
 
      // Resume animation on hover out
      container.on('mouseleave', function() {
        startScrollInterval();
      });
    }
 
    // Start animation for both containers
    startAnimation(currentMonthContainer);
    startAnimation(nextMonthContainer);
  });
})(jQuery);

Latest revision as of 13:09, 9 February 2024

/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
	
	var currentUrl = window.location.pathname.split('/').pop();
	
	if (currentUrl == 'Main_Page') {
		$.getScript("/wiki/QuestsCalendar.js?action=raw", function() {
			// Script loaded
		});	
	}
	
	if (currentUrl == 'Category:Questlines') {
		$.getScript("/wiki/Quests.js?action=raw", function() {
			// Script loaded
		});
	}

    $('body').append($('<div></div>').load('https://wiki.the-west.net/wiki/Dock.html?action=raw'));

    if ($('.item_container').length !== 0) {
        $('.item_container').each(function() {
            $(this).append('<img src="https://westzz.innogamescdn.com/images/items/' + $(this).attr('data-url') + '?1">');
        });
        $.getScript("/wiki/Popup.js?action=raw");
    }
});

$(window).scroll(function() {
    if ($(this).scrollTop() > 300) {
        $('#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>'
        );
    });
}
//calculate box - n3mesis
if ($('.calculate_box').length) {
    $.getScript('/wiki/Calculate.js?action=raw');
};
//crafting
if ($('.target_input').length) {
    $('.target_input p').each(function() {
        var id = $(this).attr('id');
        var phrase = $(this).text();
        var newInput = "<input type='number' name='input_new' value='" +
            phrase + "' class='target' max='50000' min='' />";
        $(this).replaceWith(newInput);
    });
    var multiplierValue = 1;
    var currentAmountsArray = [];
    $('.amount').each(function(index) {
        currentAmountsArray[index] = parseInt($(this).text());
    });
    $("input[name='input_new']").on('input paste keyup', function() {
        this.value > 50000 ? (this.value = 50000) : this.value < 0 && (this.value = 0);
        multiplierValue = this.value;
        $('.amount').each(function(index) {
            $(this).text(currentAmountsArray[index] * multiplierValue);
        });
        $('.craft_extra').show();
        $('.craft_extra .item_container').each(function() {
            $(this).children().addClass('OverlayItem');
        });
    });
}

// As seen on https://bitbucket.org/cmcqueen1975/htmlfloatingtableheader/overview
function UpdateTableHeaders() {
    $("div.divTableWithFloatingHeader").each(function() {
        var originalHeaderRow = $(".tableFloatingHeaderOriginal", this);
        var floatingHeaderRow = $(".tableFloatingHeader", this);
        var offset = $(this).offset();
        var scrollTop = $(window).scrollTop();
        if ((scrollTop > originalHeaderRow.offset().top) && (scrollTop < offset.top + $(this).height() - originalHeaderRow.height())) {
            floatingHeaderRow.css("visibility", "visible");
            floatingHeaderRow.css("top", "0px");

            // Copy cell widths from original header
            $("th", floatingHeaderRow).each(function(index) {
                var cellWidth = $("th", originalHeaderRow).eq(index).css('width');
                $(this).css('width', cellWidth);
            });

            // Copy row width from whole table
            floatingHeaderRow.css("width", $(this).css("width"));
        } else {
            floatingHeaderRow.css("visibility", "hidden");
            floatingHeaderRow.css("top", "0px");
        }
    });
};

$(function() {
    $("table.tableWithFloatingHeader").each(function() {
        $(this).wrap("<div class=\"divTableWithFloatingHeader\" style=\"position:relative\"></div>");

        var cls = "tr.floatingHeader";
        if ($(cls, this).length == 0) {
            cls = "tr";
        }
        var originalHeaderRow = $(cls, this).first();
        var clonedHeaderRow = originalHeaderRow.clone().insertBefore(originalHeaderRow);

        clonedHeaderRow.addClass("tableFloatingHeader");
        clonedHeaderRow.css("position", "fixed");
        clonedHeaderRow.css("top", "0px");
        clonedHeaderRow.css("left", $(this).offset().left);
        clonedHeaderRow.css("visibility", "hidden");
        clonedHeaderRow.css("z-index", 1);

        originalHeaderRow.addClass("tableFloatingHeaderOriginal");
    });
    UpdateTableHeaders();
    $(window).on('scroll', UpdateTableHeaders);
    $(window).on('resize', UpdateTableHeaders);
});

(function($) {
    $(document).ready(function() {
        $('.radioButtonsHere').replaceWith('<center><input id="normal" type="radio" value="0" class="selectRadio" name="selectRadio"/> Normal Job <input id="silver" type="radio" value="50" class="selectRadio" name="selectRadio"/> Silver <input id="aura" type="radio" value="100" class="selectRadio" name="selectRadio"/> Gold</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);

//Page translator - Criminus 2023
(function($) {
    $(document).ready(function() {
        //$('#p-Language > div.border-1 > div > div').append(
        $('#module-page-navigation').append(
            $('<div>')
            .addClass('inner-body')
        );
        //$('#p-Language > div.border-1 > div > div > div').append(
        $('#module-page-navigation').append(
            $('<div>')
            .addClass('langPicker')
        );

        var languages = [{
                lang: 'en',
                title: 'English',
                src: 'https://wiki.the-west.net/images/c/ce/Gb.png',
                //link: 'https://wiki.the-west.net/wiki/Main_Page'
                link: 'https://wiki.the-west.net/wiki/Main_Page'
            },
            {
                lang: 'dk',
                title: 'Danish',
                src: 'https://wiki.the-west.net/images/0/06/Dk.png',
                //link: 'https://wiki.the-west.net/wiki/Forside'
                link: 'https://wiki.the-west.net/wiki/Forside'
            },
            {
                lang: 'se',
                title: 'Swedish',
                src: 'https://wiki.the-west.net/images/d/d0/Se.png',
                //link: 'https://wiki.the-west.net/wiki/Huvudsida'
                link: 'https://wiki.the-west.net/wiki/Huvudsida'
            }
        ];

        var translations = {
            en: {
                //Search Box Translation
                searchNav: 'Search',
                searchNavAdv: 'Advanced search',
                searchNavFText: 'Search Wiki The-West EN',
                searchNavFTitle: 'Search Wiki The-West EN [alt-shift-f]',
                //Main Page Translation
                mainPage: 'Main Page',
                mainPageLink: '/wiki/Main_Page',
                //Navigation Categories Translation
                navigationText: 'Navigation',
                gettingStartedText: 'Getting Started',
                gameFeaturesText: 'Game Features',
                newToWikiText: 'New to the Wiki',
                toolsText: 'Tools',
                quickAccessText: 'Quick access',
                moreGamesText: 'More games',
                followUSText: 'Follow us',
                // Navigation links
                rulesText: 'Game rules',
                rulesLink: 'https://wiki.the-west.net/wiki/Game_Rules',
            },
            dk: {
                //Search Box Translation
                searchNav: 'Søg',
                searchNavAdv: 'Avanceret søgning',
                searchNavFText: 'Søg på Wiki The-West DK',
                searchNavFTitle: 'Søg på Wiki The-West DK [alt-shift-f]',
                //Main Page Translation
                mainPage: 'Forside',
                mainPageLink: '/wiki/Forside',
                //Navigation Categories Translation
                navigationText: 'Naviger',
                gettingStartedText: 'Kom godt i gang',
                gameFeaturesText: 'Spilfunktioner',
                newToWikiText: 'Nyt på wikien',
                toolsText: 'Værktøjer',
                quickAccessText: 'Genveje',
                moreGamesText: 'Flere spil',
                followUSText: 'Følg os',
                // Navigation links
                rulesText: 'Regler',
                rulesLink: 'https://wiki.the-west.net/wiki/Regler_pr._September_2020',
            },
            se: {
                //Search Box Translation
                searchNav: 'Sök',
                searchNavAdv: 'Avancerad sökning',
                searchNavFText: 'Sök på Wiki The-West SE',
                searchNavFTitle: 'Sök på Wiki The-West SE [alt-shift-f]',
                //Main Page Translation
                mainPage: 'Huvudsida',
                mainPageLink: '/wiki/Huvudsida',
                //Navigation Categories Translation
                navigationText: 'Navigering',
                gettingStartedText: 'Börja',
                gameFeaturesText: 'Spelfunktioner',
                newToWikiText: 'Nytt på wikin',
                toolsText: 'Verktyg',
                quickAccessText: 'Genvägar',
                moreGamesText: 'Fler spel',
                followUSText: 'Följ oss',
                // Navigation links
                rulesText: 'Spelregler',
                rulesLink: 'https://wiki.the-west.net/wiki/Game_Rules',
            }
        };

        function updateLinks(language) {
            if (translations[language]) {
                //Logo redirects
                $('.tbbox-logo')
                    .wrap('<a href=' + translations[language].mainPageLink + '></a>');
                // Search Box
                $('h3#p-search-label')
                    .text(translations[language].searchNav);
                $('#searchform > a')
                    .text(translations[language].searchNavAdv);
                $('input#searchInput')
                    .attr('placeholder', translations[language].searchNavFText)
                    .attr('title', translations[language].searchNavFTitle);
                // Navigation Categories and Links
                $('#n-Main-Page > a')
                    .text(translations[language].mainPage)
                    .attr('href', translations[language].mainPageLink);
                $('h3#p-Navigation-label')
                    .text(translations[language].navigationText);
                $('h3#p-Getting_Started-label')
                    .text(translations[language].gettingStartedText);
                $('h3#p-Game_Features-label')
                    .text(translations[language].gameFeaturesText);
                $('h3#p-New_to_the_Wiki-label')
                    .text(translations[language].newToWikiText);
                $('h3#p-tb-label')
                    .text(translations[language].toolsText);
                $('span#Quick_access')
                    .text(translations[language].quickAccessText);
                $('span#More_games')
                    .text(translations[language].moreGamesText);
                $('span#Follow_us')
                    .text(translations[language].followUSText);
                //Navigation links
                $('#n-Game-rules > a')
                    .text(translations[language].rulesText)
                    .attr('href', translations[language].rulesLink);
            }
        }

        var storedLanguage = localStorage.getItem('selectedLanguage');

        if (storedLanguage) {
            updateLinks(storedLanguage);
        }

        for (var i = 0; i < languages.length; i++) {
            var imageElement = $('<img>').attr('src', languages[i].src).attr('title', languages[i].title);
            var linkElement = $('<a>')
                .attr('href', languages[i].link)
                .append(imageElement)
                .on('click', {
                    lang: languages[i].lang
                }, function(event) {
                    localStorage.setItem('selectedLanguage', event.data.lang);
                    updateLinks(event.data.lang);
                });
            $('.langPicker').append(linkElement);
        }
    });
})(jQuery);

(function($) {
    $(document).ready(function() {
        var elementToMove = $("#module-site-navigation").detach();

        elementToMove.insertAfter("#mirage-fixed-header");

    });
})(jQuery);


(function($) {
    $(document).ready(function() {
        $('.contact_team-btn').click(function() {
            var url = $(this).data('url');
            if (url) {
                window.open(url, '_blank');
            }
        });
        $('.normal_quest').click(function() {
            var url = $(this).data('url');
            if (url) {
                window.open(url, '_blank');
            }
        });
        $('.repeatable_quest').click(function() {
            var url = $(this).data('url');
            if (url) {
                window.open(url, '_blank');
            }
        });
    });
})(jQuery);

(function($) {
    $(document).on('click', '.dock-toggler', function() {
        const dockItems = $('.dock-items-container');
        const toggler = $('.dock-toggler');
        const toggleDockIcon = $('.toggle-dock');

        dockItems.toggleClass('toggled');
        toggler.toggleClass('toggled');
        toggleDockIcon.toggleClass('toggled');
    });
})(jQuery);

(function($) {
    $(document).ready(function() {
        function adjustColspan() {
            var screenWidth = $(window).width();

            var threshold = 768;

            $('quest.table td, quest.table th').each(function() {
                if (!$(this).data('original-colspan') && $(this).attr('colspan')) {
                    $(this).data('original-colspan', $(this).attr('colspan'));
                }

                if (screenWidth <= threshold) {
                    if ($(this).attr('colspan') && parseInt($(this).attr('colspan'), 10) === 3) {
                        $(this).attr('colspan', '1');
                    }
                } else {
                    if ($(this).data('original-colspan')) {
                        $(this).attr('colspan', $(this).data('original-colspan'));
                    }
                }
            });
        }

        adjustColspan();

        $(window).resize(adjustColspan);
    });
})(jQuery);

(function($) {
    $(document).ready(function() {
        var currentUrl = window.location.pathname.split('/').pop();

        if (currentUrl !== 'MediaWiki:Common.css' || currentUrl !== 'MediaWiki:Common.js') {
            $('#firstHeading').hide();
        }
        if (currentUrl == 'Category:Item_sets' || currentUrl == 'Category:Questlines') {
            $('.mw-category-generated').hide();
        }
    });
})(jQuery);

(function($) {
	$(document).ready(function() {
		$('.quickSearchQuest').append('<span class="textfield_wrapper textfield_flex"><span class="textfield_label"></span><span class="textfield"><span><input type="text" id="QsearchBox" placeholder="Quick Search Quest"></span></span></span>');
	});
})(jQuery);

(function($) {
	$(document).ready(function() {
	  var $images = $(".set_bonus img");
	  $images.each(function() {
		var width = $(this).width();
		var height = $(this).height();
		if (height < 40) {
		  $(this).css("margin-top", "10px");
		}
	  });
	});
})(jQuery);

(function($) {
  $(document).ready(function() {
    var currentMonthContainer = $('#current-month-quests');
    var nextMonthContainer = $('#next-month-quests');

    // Function to start infinite scrolling animation
    function startAnimation(container) {
      var speed = 20; // Adjust the speed as needed
      var scrollDirection = 1; // 1 for scrolling down, -1 for scrolling up
      var scrollDistance = 1; // Adjust the scroll distance as needed

      // Clone the content and append it to create a continuous loop
      var containerContent = container.html();
      container.append(containerContent);

      // Set initial scroll position to 0
      container.scrollTop(0);

      // Define animation function
      function scrollContent() {
        container.scrollTop(container.scrollTop() + (scrollDirection * scrollDistance));
        if (container.scrollTop() >= container.prop('scrollHeight') - container.height()) {
          // Change direction to up when reaching the bottom
          scrollDirection = -1;
        } else if (container.scrollTop() <= 0) {
          // Change direction to down when reaching the top
          scrollDirection = 1;
        }
      }

      // Start the animation loop
      var scrollInterval;

      function startScrollInterval() {
        clearInterval(scrollInterval);
        scrollInterval = setInterval(scrollContent, speed);
      }

      startScrollInterval();

      // Pause animation on hover
      container.on('mouseenter', function() {
        clearInterval(scrollInterval);
      });

      // Resume animation on hover out
      container.on('mouseleave', function() {
        startScrollInterval();
      });
    }

    // Start animation for both containers
    startAnimation(currentMonthContainer);
    startAnimation(nextMonthContainer);
  });
})(jQuery);