MediaWiki:Common.js: Diferență între versiuni
Jump to navigation
Fără descriere a modificării |
Fără descriere a modificării |
||
Linia 63: | Linia 63: | ||
jQuery(document).ready(function($) { | jQuery(document).ready(function($) { | ||
$.getScript("/ | $.getScript("https://the-west.tools/js/en_itemdatabase.js?action=raw", function() { | ||
$('.load_items span').each(function() { | $('.load_items span').each(function() { | ||
var ide = $(this).attr('id'); | var ide = $(this).attr('id'); |
Versiunea de la data 15 octombrie 2022 20:41
/* Any JavaScript here will be loaded for all users on every page load. */ $('.tbbox-logo').after('<div id="search_live_item"><div class="search_item"><p id="1">Nume obiect sau ID</p</div><div class="audio-arrow-box" id="audio-arrow-box"><div class="popup-container" id="popup-container"><div class="load_items"><span id="2">Load items here</span></div></div></div></div></div>'); $('.search_item p').each(function() { var id = $(this).attr('id'); var phrase = $(this).text(); var newInput="<input type='text' id='live_search_item' name='search_item' value='"+phrase+"' class='search_item' />"; $(this).replaceWith(newInput); }); $(document).ready( function(){ $("#search_live_item").click(function () { $("#audio-arrow-box").fadeToggle(); }); $("#search_live_item").focusout(function () { $("#audio-arrow-box").fadeToggle(); }); }); $("#live_search_item").on("keyup", function() { var value = $(this).val(); $(".item").each(function() { $row = $(this); var id = $.map($row.find('span .item_container'), function(element) { return $(element).attr("data-popup") }).join(' '); if (id.toLowerCase().indexOf(value.toLowerCase()) < 0) { $row.hide(); } else { $row.show(); } }); }); $('#live_search_item').each(function(k, v){ var obj = $(this); obj.keyup(function(){ if(obj.val().length >= 4){ $(".load_items").show(); } else { $(".load_items").hide(); } }); }); $(document).ready( function() { $("#live_search_item").focus( function() { if ( $(this).val()=="Nume obiect sau ID") { $(this).val(''); } }); $("#live_search_item").blur( function() { if ( $(this).val()=="") { $(this).val('Nume obiect sau ID'); } }); }); jQuery(document).ready(function($) { $.getScript("https://the-west.tools/js/en_itemdatabase.js?action=raw", function() { $('.load_items span').each(function() { var ide = $(this).attr('id'); $(this).replaceWith(loadItems); }); $('.item_container').each(function() { $(this).append('<img src="https://westzz.innogamescdn.com/images/items/' + $(this).attr('data-url') + '?1">'); }); if ($('.item_container').length) { $('.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>'); }); } //Configuration du tri des diacritique dans les tables de class "sortable" mw.config.set( 'tableSorterCollation', {'à':'a', 'â':'a', 'æ':'ae', 'é':'e', 'è':'e', 'ê':'e', 'î':'i', 'ï':'i', 'ô':'o', 'œ':'oe', 'û':'u', 'ç':'c', } ); if ($('#calcLvlLoss').length !== 0) { var context = $('#calcLvlLoss'); var input_character_level = $('<input type="number" style="width:150px;" class="west" placeholder="Nivel" min="0" max="150">').bind("propertychange keyup input paste", function() { if (this.value > 150) { this.value = 150; } else if (this.value < 0) { this.value = 0; } calcLvlLoss(); }).appendTo(context.find(".character_level")); var input_duel_level = $('<input type="number" style="width:150px;" class="west" placeholder="Nivelul duelului" 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; } calcLvlLoss(); }).appendTo(context.find(".duel_level")); function calcLvlLoss() { var duel_lvl = parseInt(input_duel_level.val()), char_lvl = parseInt(input_character_level.val()); if (isNaN(duel_lvl) || isNaN(char_lvl) || duel_lvl < char_lvl) { context.find('.result').html(''); } else { var getXp = function(lvl) { return Math.ceil(Math.pow((lvl) / 0.1, 1 / 0.6)); }, getLvl = function(xp, perc) { return char_lvl + Math.floor(Math.pow(xp * (perc || 1), 0.6) * 0.1); }; var minXp = getXp(duel_lvl - char_lvl), maxXp = duel_lvl === 450 ? '∞' : getXp(duel_lvl + 1 - char_lvl), minLvl = getLvl(minXp, 0.9), maxLvl = duel_lvl === 450 ? 450 : getLvl(maxXp, 0.9); context.find('.result').html('Experiența de duel actuală: ' + minXp + ' - ' + maxXp + '<br/>Nivelul de duel după utilizarea poțiunii: ' + minLvl + (maxLvl > minLvl ? ' - ' + maxLvl : '')); } } } //Quests header translation & repeatable translation - Criminus $(".prq_dispo b").each(function() { $(this).text($(this).text().replace(/from/g, "De pe").replace(/at/g, "de la ora").replace(/until/g, "până pe")); }); //Quest Realtime Search - Criminus //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); }); $(document).on('keyup', 'input[name=input_nou]', function() { var _this = $(this); var min = parseInt(_this.attr('min')) || 1; // if min attribute is not defined, 1 is default var max = parseInt(_this.attr('max')) || 100; // if max attribute is not defined, 100 is default var val = parseInt(_this.val()) || (min - 1); // if input char is not a number the value will be (min - 1) so first condition will be true if (val < min) _this.val(min); if (val > max) _this.val(max); }); (function($) { $(document).ready(function() { var multiplierValue = 1; var currentAmountsArray = []; $('.amount').each(function(index) { currentAmountsArray[index] = parseInt($(this).text()); }); if ($("input[name='input_nou']").length > 0) { $("input[name='input_nou']").change(function() { multiplierValue = $(this).val(); $('.amount').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(); $('.amount').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(); } } }); });