MediaWiki:Common.js

(Difference between revisions)
Jump to: navigation, search
Line 137: Line 137:
 
     window.location.replace("/index.php?title=ОПИТУВАННЯ");
 
     window.location.replace("/index.php?title=ОПИТУВАННЯ");
 
}
 
}
 +
 +
 +
/* ===== TIME COUT BACKAGS ===== */
 +
window.addEventListener("load", function () {
 +
 +
const electionDate = new Date("2026-05-26T09:00:00").getTime();
 +
 +
const timer = setInterval(function() {
 +
 +
    const now = new Date().getTime();
 +
    const distance = electionDate - now;
 +
 +
    const days = Math.floor(
 +
        distance / (1000 * 60 * 60 * 24)
 +
    );
 +
 +
    const hours = Math.floor(
 +
        (distance % (1000 * 60 * 60 * 24))
 +
        / (1000 * 60 * 60)
 +
    );
 +
 +
    const minutes = Math.floor(
 +
        (distance % (1000 * 60 * 60))
 +
        / (1000 * 60)
 +
    );
 +
 +
    const seconds = Math.floor(
 +
        (distance % (1000 * 60))
 +
        / 1000
 +
    );
 +
 +
    if(document.getElementById("days")) {
 +
 +
        document.getElementById("days").innerHTML = days;
 +
        document.getElementById("hours").innerHTML = hours;
 +
        document.getElementById("minutes").innerHTML = minutes;
 +
        document.getElementById("seconds").innerHTML = seconds;
 +
 +
    }
 +
 +
    if(distance < 0) {
 +
 +
        clearInterval(timer);
 +
 +
        document.getElementById(
 +
            "director-election-countdown"
 +
        ).innerHTML = `
 +
 +
        <div style="
 +
        padding:40px;
 +
        font-size:42px;
 +
        font-weight:bold;
 +
        color:#ffd600;
 +
        text-shadow:2px 2px 6px rgba(0,0,0,0.45);
 +
        ">
 +
        Вибори директора розпочались
 +
        </div>
 +
 +
        `;
 +
 +
    }
 +
 +
}, 1000);
 +
 +
});
 +
 +
 +
  
 
---<!-- -
 
---<!-- -

Revision as of 20:20, 22 May 2026

/* Any JavaScript here will be loaded for all users on every page load. */
if(mw.config.get('wgArticleId') == 1736) {
$( document ).ready( function() {
	var sli = $("#photoGroups .holder ul")[0];
	    sli.parentNode.style.height = "200px";
	$("#photoGroups p").each(function(i) {
 	    	$(this).mouseenter(function() {
			$(sli).stop();
			$(sli).animate({marginTop:"-"+(200+i*200)+"px"});
		});
	});
})};
$('.xpand a').click(function() {
	var c = this.firstChild.nodeValue,
	d = c.substring(0,c.length-1);
	this.innerHTML = c.charCodeAt(c.length-1) === 9658 ? d+'\u25BC' : d+'\u25BA';
	$('.'+$(this).attr('href').substring(1)).slideToggle();
	return false;
});
var ph = $('.photogal ul .thumbimage');
if (ph[0]) {
	ph[0].style.opacity = 0.66;
	var img = $('.photogal img')[0],
	caption = $('.photogal .thumbcaption')[0];
	img.removeAttribute('width');
	$('.photogal .thumbinner')[0].style.width = '';
	ph.each(function(i) {
		$(this).click(function() {
			var cpt = $('.thumbcaption',$('.photogal li')[i])[0];
			caption.innerHTML = cpt.innerText || cpt.textContent;
			img.src = this.src.replace('200px','800px');
			img.parentNode.href = this.parentNode.href;
			ph.each(function(j) { this.style.opacity = i === j ? 0.66 : 1 });
			return false;
		});
	});
}

var team = $('.team img');
if(team.length){
	var hl = $('<div class="photo_hl"></div>');
	hl.append(team.clone());
	team.before(hl);
	hl = hl.children();
	$('.team ul li').each(function(){
		$(this).mouseover(function() {
			var pos = $(this).attr('data-pos');
			if(pos) {
				pos = pos.split(':');
				hl.css('clip','rect('+
					hl.height()/(100/pos[1])+'px '+
					hl.width()/(100/(pos[0]*1+pos[2]*1))+'px '+
					hl.height()/(100/(pos[1]*1+pos[3]*1))+'px '+
					hl.width()/(100/pos[0])+'px)'
				);
			}
		});
		$(this).mouseout(function() {
			hl.css('clip','rect(0 '+hl.width()+'px '+hl.height()+'px 0)');
		});
		if(!hl.attr('style')) $(this).mouseout();
	});
}




/* ===== GOOGLE TRANSLATE FLAGS ===== */

function addTranslateFlags(){

if(document.getElementById('gt_flags')) return;

var flags =
'<div id="gt_flags" style="position:fixed;top:40px;right:20px;background:#fff;padding:6px 10px;border-radius:6px;box-shadow:0 2px 6px rgba(0,0,0,0.2);z-index:9999;">'+
'<a href="#" onclick="setLang(\'uk\');return false;"><img src="https://flagcdn.com/24x18/ua.png"></a> '+
'<a href="#" onclick="setLang(\'en\');return false;"><img src="https://flagcdn.com/24x18/gb.png"></a> '+
'<a href="#" onclick="setLang(\'de\');return false;"><img src="https://flagcdn.com/24x18/de.png"></a> '+
'<a href="#" onclick="setLang(\'fr\');return false;"><img src="https://flagcdn.com/24x18/fr.png"></a> '+
'<a href="#" onclick="setLang(\'es\');return false;"><img src="https://flagcdn.com/24x18/es.png"></a> '+
'<a href="#" onclick="setLang(\'pl\');return false;"><img src="https://flagcdn.com/24x18/pl.png"></a>'+
'</div>';

document.body.insertAdjacentHTML('afterbegin',flags);

}

function setLang(lang){

document.cookie="googtrans=/uk/"+lang;
document.cookie="googtrans=/uk/"+lang+";path=/";

location.reload();

}

function googleTranslateElementInit(){

new google.translate.TranslateElement(
{
pageLanguage:'uk',
autoDisplay:false
},
'google_translate_element'
);

}

$(document).ready(function(){

$('body').append('<div id="google_translate_element" style="display:none"></div>');

addTranslateFlags();

var gt=document.createElement('script');
gt.src='https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
document.head.appendChild(gt);

});

/* hide google banner */

setInterval(function(){

var banner=document.querySelector('.goog-te-banner-frame');

if(banner){
banner.style.display='none';
}

document.body.style.top='0px';

},500);

---<!-- -
if (window.location.pathname === "/ОПИТУВАННЯ") {
    window.location.replace("/index.php?title=ОПИТУВАННЯ");
}


/* ===== TIME COUT BACKAGS ===== */
window.addEventListener("load", function () {

const electionDate = new Date("2026-05-26T09:00:00").getTime();

const timer = setInterval(function() {

    const now = new Date().getTime();
    const distance = electionDate - now;

    const days = Math.floor(
        distance / (1000 * 60 * 60 * 24)
    );

    const hours = Math.floor(
        (distance % (1000 * 60 * 60 * 24))
        / (1000 * 60 * 60)
    );

    const minutes = Math.floor(
        (distance % (1000 * 60 * 60))
        / (1000 * 60)
    );

    const seconds = Math.floor(
        (distance % (1000 * 60))
        / 1000
    );

    if(document.getElementById("days")) {

        document.getElementById("days").innerHTML = days;
        document.getElementById("hours").innerHTML = hours;
        document.getElementById("minutes").innerHTML = minutes;
        document.getElementById("seconds").innerHTML = seconds;

    }

    if(distance < 0) {

        clearInterval(timer);

        document.getElementById(
            "director-election-countdown"
        ).innerHTML = `

        <div style="
        padding:40px;
        font-size:42px;
        font-weight:bold;
        color:#ffd600;
        text-shadow:2px 2px 6px rgba(0,0,0,0.45);
        ">
        Вибори директора розпочались
        </div>

        `;

    }

}, 1000);

});




---<!-- -
if (window.location.pathname.startsWith("/uk/")) {
  window.location.replace(window.location.pathname.replace("/uk/", "/"));
}
Personal tools
Navigation
societies
additional
Views
Namespaces
Variants
Toolbox
Actions