Ero sivun ”Järjestelmäviesti:Common.js” versioiden välillä

KKWikistä
(Sisällysluettelon alatasojen piilotusviritelmän hienosäätöä)
Rivi 20: Rivi 20:
 
$('#toc li:not(.toclevel-1)').hide();
 
$('#toc li:not(.toclevel-1)').hide();
 
$('.x-toc-main-only').show();
 
$('.x-toc-main-only').show();
 +
}
 +
 +
// item displays
 +
if ($('.x-item').length > 0) {
 +
 +
var itemImage = $(this).attr('data-item');
 +
 +
if (itemImage != '') {
 +
            if (itemImage.indexOf('http') == 0) {
 +
                $(this).css('background-image', 'url("' + itemImage + '")');
 +
            } else {
 +
                $(this).css('background-image', 'url("https://static.lehtodigital.fi/xeno/textures/generic/' + itemImage + '.png")');
 +
            }
 +
        } else {
 +
            $(this).css('cursor', 'default');
 +
        }
 +
 
}
 
}
 
 

Versio 27. joulukuuta 2020 kello 16.56

/* Tämän sivun JavaScript-koodi liitetään jokaiseen sivulataukseen */


$(document).ready(function(){
	
	// replace feathericons
	feather.replace();
	
	// hide the stupid navigation options under the title
	$('#mw-page-header-links').hide();
	
	$('#p-views li').each(function(){
		if (!$(this).is('#ca-more')) {
			$('#p-cactions ul').prepend($(this));
		}
	});
	
	// if the current page asks us to hide non-top-level toc entries
	if ($('.x-toc-main-only').length > 0) {
		$('#toc li:not(.toclevel-1)').hide();
		$('.x-toc-main-only').show();
	}
	
	// item displays
	if ($('.x-item').length > 0) {
		
		var itemImage = $(this).attr('data-item');
		
		if (itemImage != '') {
            if (itemImage.indexOf('http') == 0) {
                $(this).css('background-image', 'url("' + itemImage + '")');
            } else {
                $(this).css('background-image', 'url("https://static.lehtodigital.fi/xeno/textures/generic/' + itemImage + '.png")');
            }
        } else {
            $(this).css('cursor', 'default');
        }
		
	}
	
});


/*
 * RECIPE VIEWER
 */
$(document).ready(function(){
        
        var tooltipVisible = false;
        
        if ($('.x-crafting').length > 0) {
            
            $('body').append('<div class="x-crafting-tooltip" style="display: none;">Tooltip is not working.<br>Please contact Tapsa.</div>');
            $('.x-crafting-item').each(function(){
                
                var itemImage = $(this).attr('data-item');
                
                if (itemImage != '') {
                    if (itemImage.indexOf('item:') == 0) {
                        $(this).css('background-image', 'url("https://static.lehtodigital.fi/xeno/textures/generic/' + itemImage.replace('item:', '') + '.png")');
                    } else {
                        $(this).css('background-image', 'url("' + itemImage + '")');
                    }
                } else {
                    $(this).css('cursor', 'default');
                }
                
            });
            
            $('body').on('mousemove', function(e){
                if (tooltipVisible) {
                    
                    $('.x-crafting-tooltip').css({
                        top: (e.clientY + 15)+'px',
                        left: (e.clientX + 15)+'px'
                    });
                    
                }
            });
            
            $('.x-crafting-item').on('mouseover', function(e){
                
                if ($(this).attr('data-item') != '' && $(this).attr('data-hover') != '') {
                    $('.x-crafting-tooltip').text($(this).attr('data-hover')).show();
                    tooltipVisible = true;
                }
                
            });
            
            $('.x-crafting-item').on('mouseout', function(e){
                
                $('.x-crafting-tooltip').hide();
                tooltipVisible = false;
                
            });
            
            $('.x-crafting-item').on('click', function(e){
                window.location.href = 'https://kk.xenomc.fi/wiki/index.php/' + encodeURIComponent($(this).attr('data-hover'));
            });
            
            var rs = function(){
                $('.x-crafting').each(function(){
                    if ($(this).parent().width() < 350) {
                        var sc = $(this).parent().width()/375;
                        $(this).css('transform-origin', 'top left');
                        $(this).css('transform', 'scale('+sc+')');
                    }
                });
            }
            
            rs();
            $(window).resize(rs);
            
        }
        
    });