MediaWiki:Common.js

Da Wiki The-West IT.
Vai alla navigazione

Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.

  • Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
  • Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
  • Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
  • Opera: premi Ctrl-F5.
$(document).mousemove(function(e){
	if ($('.popup_window:visible').length!==0){
		var width;
		var height;
		var parent_left = $('.item_container:hover').offset().left;
		var parent_top = $('.item_container:hover').offset().top;
		var w = e.pageX;
		if (e.clientX < ($(window).width())/2){
			width = w + 20 - parent_left;
		} else {
			width = w - 20 - $('.popup_window:visible').outerWidth() - parent_left;
		}
		var h = e.pageY;
		var h2 = $('.popup_window:visible').outerHeight();
		var h3 =$(window).height();
		if (e.clientY < (h3/2)){
			height = h + 20 - parent_top;
			if (e.clientY + h2 +10 > h3) height = h - e.clientY - parent_top + h3 - h2 + 10;
		} else {
			height = h - h2 - parent_top;
			if (e.clientY - h2 < 10) height = h - e.clientY - parent_top + 10;
		}
		$('.popup_window:visible').css({top: height, left: width});
	}
});

//Input level
if ($("#input_level").length == 1) {
    $("#input_level").append('Livello pg: ');
    var input_level = $('<input type="number" class="west" placeholder="Livello" 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;
        }
        $(".calc").each(function() {
            if (input_level.val() == 0) {
                $(this).html(this.id);
                $('.per_level_off').addClass('per_level').removeClass('per_level_off');
            } else {
                $(this).html(Math.ceil(Number(this.id) * input_level.val()));
                $('.per_level').addClass('per_level_off').removeClass('per_level');
            }
        });
    }).appendTo($("#input_level"));
}

//Switch weapons
if ($("#switch").length == 1) {
    $("#fuoco").hide();
    $("#switch").on("click", function() {
        $('#contusione, #fuoco').toggle()
    });
}

//Switch maps
if ($("#switch1").length == 1) {
    $("#mandante1").hide();
    $("#mandante2").hide();
    $("#switch1").on("click", function() {
        $('#vuota, #mandante1').toggle()
        $("#mandante2").hide();
    });
}
if ($("#switch2").length == 1) {
    $("#mandante2").hide();
    $("#mandante1").hide();
    $("#switch2").on("click", function() {
        $('#vuota, #mandante2').toggle();
        $("#mandante1").hide();
    });
}