Difference between pages "Experiments" and "MediaWiki:Common.js"

From Innocent Witches
(Difference between pages)
Jump to navigation Jump to search
 
Tag: Reverted
 
Line 1: Line 1:
<div class="mainmenu" style="font-size: 60px; width: 1000px; height: 750px; margin: 0 auto">
mw.loader.using('mediawiki.util').then(function() {
<div style="position: relative;width: 235px; height: 730px; line-height: 2.6; text-align: center; left: 27px; top: -20px">
   
{{Nvl|st=top:1px|lnk=[https://wiki.teamsadcrab.com/index.php/Interface INTERFACE]}}
function zselector( $content ) {
{{Nvl|st=top:3px|lnk=[https://wiki.teamsadcrab.com/index.php/Locations LOCATIONS]}}
    var ActiveID = '';
{{Nvl|st=top:3px|lnk=[https://wiki.teamsadcrab.com/index.php/Characters CHARACTERS]}}
    $(function () {
{{Nvl|st=top:5px|lnk=[https://wiki.teamsadcrab.com/index.php/Mechanics MECHANICS]}}
        $('[class|="cc"]').click(function () {
{{Nvl|st=font-size: 55px; top: 12px|lnk=[https://wiki.teamsadcrab.com/index.php/Achievements ACHIEVEMENTS]}}
            var cn = $(this).attr('class');
</div>
            if (typeof cn !== 'undefined') {
<div style="position: relative; width: 350px; height: 730px; line-height: 2.3; text-align: center; left: 600px; top: -725px">
                ZContent(cn, '0');
{{Nvl|st=font-size: 72px; left:-30px|lnk=[https://wiki.teamsadcrab.com/index.php/Walkthrough WALKTHROUGH]}}
            }
{{Nvl|st=top:0px|lnk=[https://wiki.teamsadcrab.com/index.php?title=Walkthrough#First_Act._Where_it_all_began... FIRST ACT]}}
        });
{{Nvl|st=top:-15px|lnk=[https://wiki.teamsadcrab.com/index.php?title=Walkthrough#Second_Act._The_Deathly_Delights SECOND ACT]}}
        $('[class|="hh"]').mouseenter(function () {
{{Nvl|st=top:-25px;left: 36px|lnk=[https://wiki.teamsadcrab.com/index.php?title=Walkthrough THIRD ACT (soon)]}}
            var cn = $(this).attr('class');
{{Nvl|st=top: -30px; left:5px;transform:rotate(-5deg)|lnk=[https://wiki.teamsadcrab.com/index.php/Minigames MINIGAMES]}}
            if (typeof cn !== 'undefined') {
</div>
                ZContent(cn, '1');
            }
        });
        $('[class|="hh"]').mouseleave(function () {
            var cn = $(this).attr('class');
            if (typeof cn !== 'undefined') {
                ZContent(cn, '2');
            }
        });
        $('[class|="zz"]').each(function (i, elem) {
            if ($(this).css('display') == 'none') {
                $(this).css('opacity', 0);
            }
        });
    });
    function ZContent(classValue, effect) {
        if (classValue.split) {
            var ID = '';
            var elemClasses = classValue.split(' ');
            for (var i = 0; i < elemClasses.length; i++) {
                var elemClass = elemClasses[i];
                if (elemClass.substring(0, 3) == 'hh-' || elemClass.substring(0, 3) == 'cc-') {
                    ID = elemClass.substring(3);
                    if (effect == '0') {
                        ActiveID = ID;
                        ZEffect(ID);
                        SelectElem('cc', ID)
                        break;
                    } else if (effect == '1') {
                        ActiveID = ID;
                        ZEffect(ID);
                        SelectElem('hh', ID)
                        break;
                    } else if (effect == '2') {
                        ZEffect(ActiveID);
                        SelectElem('hh', ID);
                        break;
                    }
                }
            }
        }
    }
    function ZEffect(ID) {
        $('[class|="zz"]').each(function (i, elem) {
            if ($(this).hasClass('zz-' + ID)) {
                $(this).css('display', 'block');
                $(window).trigger('scroll');
                $(this).stop();
                $(this).animate({
                    opacity: 1,
                    queue: false
                }, 700);
            } else {
                $(this).css('display', 'none');
                $(this).stop();
                $(this).animate({
                    opacity: 0,
                    queue: false
                }, 0);
            }
        });
    }
    function SelectElem(type, ID) {
        $('[class|="cc"],[class|="hh"]').each(function (i, elem) {
            if ($(this).hasClass(type + '-' + ID)) {
                $(this).removeClass('sn');
                $(this).addClass('sy');
            } else {
                $(this).removeClass('sy');
                $(this).addClass('sn');
            }
        });
    }
}
   
    mw.hook( 'wikipage.content' ).add( zselector );
    zselector( mw.util.$content );
});
 
// Динамическая кнопка "back to top"
$(document).ready(function(){
    // Create the back to top button element
    var backButton = $('<button id="back-to-top" title="Back to top"> </button>');
   
    // Append the button to the body
    $('body').append(backButton);
   
 
    // Smooth scroll to top when the button is clicked
    backButton.click(function(){
        $('html, body').animate({scrollTop : 0},800);
        return false;
    });
});
 
window.addEventListener('scroll', function() {
    var toc = document.getElementById('toc');
    var bodyContent = document.getElementById('bodyContent');
    var scrollY = window.scrollY || window.pageYOffset;
 
    // Adjust the top position of the TOC based on scrolling
    if (scrollY > bodyContent.offsetTop) {
        toc.style.top = (scrollY - bodyContent.offsetTop) + 'px';
    } else {
        toc.style.top = '0';
    }
});
 
 
var slideIndex = 0;
carousel();
 
function carousel() {
  var i;
  var slides = document.getElementsByClassName("slideshow-slide");
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";
  }
  slideIndex++;
  if (slideIndex > slides.length) {slideIndex = 1}
  slides[slideIndex-1].style.display = "block";
  setTimeout(carousel, 2000); // Change image every 2 seconds
}
 
document.addEventListener('DOMContentLoaded', function() {
  var slideshowContainer = document.createElement('div');
  slideshowContainer.classList.add('slideshow-container');
 
  var slides = [
    {image: 'Image1.jpg', text: 'Описание первого изображения'},
    {image: 'Image2.jpg', text: 'Описание второго изображения'},
    {image: 'Image3.jpg', text: 'Описание третьего изображения'}
  ];
 
  slides.forEach(function(slide) {
    var slideElement = document.createElement('div');
    slideElement.classList.add('slideshow-slide');
    slideElement.innerHTML = '<img src="' + slide.image + '" style="width:100%">' +
                            '<div class="slideshow-text">' + slide.text + '</div>';
    slideshowContainer.appendChild(slideElement);
  });
 
  document.body.appendChild(slideshowContainer);
 
  var slideIndex = 0;
  carousel();
 
  function carousel() {
    var i;
    var slides = document.getElementsByClassName("slideshow-slide");
    for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
    }
    slideIndex++;
    if (slideIndex > slides.length) {slideIndex = 1}
    slides[slideIndex-1].style.display = "block";
    setTimeout(carousel, 2000); // Change image every 2 seconds
  }
});

Revision as of 05:36, 31 March 2024

mw.loader.using('mediawiki.util').then(function() {
    
function zselector( $content ) {
    var ActiveID = '';
    $(function () {
        $('[class|="cc"]').click(function () {
            var cn = $(this).attr('class');
            if (typeof cn !== 'undefined') {
                ZContent(cn, '0');
            }
        });
        $('[class|="hh"]').mouseenter(function () {
            var cn = $(this).attr('class');
            if (typeof cn !== 'undefined') {
                ZContent(cn, '1');
            }
        });
        $('[class|="hh"]').mouseleave(function () {
            var cn = $(this).attr('class');
            if (typeof cn !== 'undefined') {
                ZContent(cn, '2');
            }
        });
        $('[class|="zz"]').each(function (i, elem) {
            if ($(this).css('display') == 'none') {
                $(this).css('opacity', 0);
            }
        });
    });
    function ZContent(classValue, effect) {
        if (classValue.split) {
            var ID = '';
            var elemClasses = classValue.split(' ');
            for (var i = 0; i < elemClasses.length; i++) {
                var elemClass = elemClasses[i];
                if (elemClass.substring(0, 3) == 'hh-' || elemClass.substring(0, 3) == 'cc-') {
                    ID = elemClass.substring(3);
                    if (effect == '0') {
                        ActiveID = ID;
                        ZEffect(ID);
                        SelectElem('cc', ID)
                        break;
                    } else if (effect == '1') {
                        ActiveID = ID;
                        ZEffect(ID);
                        SelectElem('hh', ID)
                        break;
                    } else if (effect == '2') {
                        ZEffect(ActiveID);
                        SelectElem('hh', ID);
                        break;
                    }
                }
            }
        }
    }
    function ZEffect(ID) {
        $('[class|="zz"]').each(function (i, elem) {
            if ($(this).hasClass('zz-' + ID)) {
                $(this).css('display', 'block');
                $(window).trigger('scroll');
                $(this).stop();
                $(this).animate({
                    opacity: 1,
                    queue: false
                }, 700);
            } else {
                $(this).css('display', 'none');
                $(this).stop();
                $(this).animate({
                    opacity: 0,
                    queue: false
                }, 0);
            }
        });
    }
    function SelectElem(type, ID) {
        $('[class|="cc"],[class|="hh"]').each(function (i, elem) {
            if ($(this).hasClass(type + '-' + ID)) {
                $(this).removeClass('sn');
                $(this).addClass('sy');
            } else {
                $(this).removeClass('sy');
                $(this).addClass('sn');
            }
        });
    }
}
    
    mw.hook( 'wikipage.content' ).add( zselector );
    zselector( mw.util.$content );
});

// Динамическая кнопка "back to top"
$(document).ready(function(){
    // Create the back to top button element
    var backButton = $('<button id="back-to-top" title="Back to top"> </button>');
    
    // Append the button to the body
    $('body').append(backButton);
    

    // Smooth scroll to top when the button is clicked
    backButton.click(function(){
        $('html, body').animate({scrollTop : 0},800);
        return false;
    });
});

window.addEventListener('scroll', function() {
    var toc = document.getElementById('toc');
    var bodyContent = document.getElementById('bodyContent');
    var scrollY = window.scrollY || window.pageYOffset;

    // Adjust the top position of the TOC based on scrolling
    if (scrollY > bodyContent.offsetTop) {
        toc.style.top = (scrollY - bodyContent.offsetTop) + 'px';
    } else {
        toc.style.top = '0';
    }
});


var slideIndex = 0;
carousel();

function carousel() {
  var i;
  var slides = document.getElementsByClassName("slideshow-slide");
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";
  }
  slideIndex++;
  if (slideIndex > slides.length) {slideIndex = 1}
  slides[slideIndex-1].style.display = "block";
  setTimeout(carousel, 2000); // Change image every 2 seconds
}

document.addEventListener('DOMContentLoaded', function() {
  var slideshowContainer = document.createElement('div');
  slideshowContainer.classList.add('slideshow-container');

  var slides = [
    {image: 'Image1.jpg', text: 'Описание первого изображения'},
    {image: 'Image2.jpg', text: 'Описание второго изображения'},
    {image: 'Image3.jpg', text: 'Описание третьего изображения'}
  ];

  slides.forEach(function(slide) {
    var slideElement = document.createElement('div');
    slideElement.classList.add('slideshow-slide');
    slideElement.innerHTML = '<img src="' + slide.image + '" style="width:100%">' +
                             '<div class="slideshow-text">' + slide.text + '</div>';
    slideshowContainer.appendChild(slideElement);
  });

  document.body.appendChild(slideshowContainer);

  var slideIndex = 0;
  carousel();

  function carousel() {
    var i;
    var slides = document.getElementsByClassName("slideshow-slide");
    for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
    }
    slideIndex++;
    if (slideIndex > slides.length) {slideIndex = 1}
    slides[slideIndex-1].style.display = "block";
    setTimeout(carousel, 2000); // Change image every 2 seconds
  }
});