Anonymous
×
Create a new article
Write your page title here:
We currently have 452 articles on Gachimuchi Wiki. Type your article name above or click on one of the titles below and start writing!



Gachimuchi Wiki

Difference between revisions of "MediaWiki:Common.js"

m
m
 
(6 intermediate revisions by the same user not shown)
Line 2: Line 2:
mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Tutorial-QuickRC.js&action=raw&ctype=text/javascript');
mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Tutorial-QuickRC.js&action=raw&ctype=text/javascript');
mw.config.set('UMFBypassLicenseCheck',true);
mw.config.set('UMFBypassLicenseCheck',true);
(function () {
/*(function () {
var lang = '';
if(navigator.cookieEnabled == true){
if(navigator.cookieEnabled == true){
     if(document.cookie.indexOf("u1476219_mw19788language") == -1){
     if(document.cookie.indexOf("u1476219_mw19788language") == -1){
         document.cookie = "u1476219_mw19788language="+ navigator.languages[0].slice(0, 2);
         lang = navigator.languages[0].slice(0, 2);
    }else{
        lang = mediaWiki.cookie.get("u1476219_mw19788language", "").slice(0, 2);
     }
     }
}
}
var lang = mediaWiki.cookie.get("u1476219_mw19788language", "").slice(0, 2);
var page = window.location.pathname.slice(6);
var page = window.location.pathname.slice(6);
var l = page.slice(-2);
var l = page.slice(-2);
if(lang !== null && l !== lang && lang != 'en' && l != 'en' && l != 'ru' || l != 'vi')
if(lang !== null && (l !== lang&& l !== 'en' && l !== 'ru' && l !== 'vi')
{
{
     //if(l == 'en' || l == 'ru' || l == 'vi'){
     if(lang == 'en' && (l !== 'en' && l !== 'ru' && l !== 'vi')){
    //    page = page.slice(0, -3);
      lang = '';
     //}
     }else
    var translate_exist = true;
     $.getJSON('https://gachiwiki.info/api.php?action=query&titles='+page +'/' + lang +'&format=json', function(response) {
     $.getJSON('https://gachiwiki.info/api.php?action=query&titles='+page +'/' + lang +'&format=json', function(response) {
        console.log(response.query.pages);
         if(response.query.pages['-1'])
         if(response.query.pages['-1'])
             return;
             return;
Line 30: Line 30:
}
}
}());
}());
 
*/
(function () {
(function () {
     var SlideNow = window.SlideNow || 1;
     var SlideNow = window.SlideNow || 1;

Latest revision as of 21:57, 11 December 2022

mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Tutorial-QuickRC.js&action=raw&ctype=text/javascript');
mw.config.set('UMFBypassLicenseCheck',true);
/*(function () {
var lang = '';
if(navigator.cookieEnabled == true){
    if(document.cookie.indexOf("u1476219_mw19788language") == -1){
        lang = navigator.languages[0].slice(0, 2);
    }else{
        lang = mediaWiki.cookie.get("u1476219_mw19788language", "").slice(0, 2);
    }
}
var page = window.location.pathname.slice(6);
var l = page.slice(-2);
if(lang !== null && (l !== lang)  && l !== 'en' && l !== 'ru' && l !== 'vi')
{
    if(lang == 'en' && (l !== 'en' && l !== 'ru' && l !== 'vi')){
       lang = '';
    }else
    $.getJSON('https://gachiwiki.info/api.php?action=query&titles='+page +'/' + lang +'&format=json', function(response) {
        if(response.query.pages['-1'])
            return;
        else
            window.location.href = 'https://gachiwiki.info/wiki/' + page+'/' + lang;
    });
}
if (window.history.replaceState) {
   if(window.location.pathname.slice(-3) == '/en')
        window.history.replaceState('wow', 'title', window.location.pathname.slice(0,-3));
}
}());
*/
(function () {
    var SlideNow = window.SlideNow || 1;
    var SlideCount = window.SlideCount || 0;
    var SlideInterval = window.SlideInterval || 0;
    var TranslateWidth = window.TranslateWidth || 0;
    var TimerPause = window.TimerPause || !1;
    mw.hook('wikipage.content').add(function() {
      var Slides = 0;
      var HeightSize = 'auto';
      var Data = ($('#SliderData').attr('class') || '').split('|');
      if (Data.length == 3) {
        Slides = Data[0];
        SlideInterval = Data[1];
        HeightSize = Data[2];
      }
      if (SlideInterval < 1000 || SlideInterval === undefined) {
        SlideInterval = 3000;
      }
      $('.Sld').each(function (index) {
        if (index + 1 > Slides) {
          $(this).remove();
        }
      });
      $('.NavBtn').each(function (index) {
        if (index + 1 > Slides) {
          $(this).remove();
        }
      });
      $('#SliderView').css('height', HeightSize);
      SlideCount = $('#SliderWrapper').children().length;
      $('#SliderWrapper').css('width', 100 * SlideCount + '%');
      $('.Sld').css('width', 100 / SlideCount + '%');
      setTimeout(function tick() {
        if (TimerPause === false) {
          NextSlide();
        }
        setTimeout(tick, SlideInterval);
      }, SlideInterval);
      $('#SliderView').mouseenter(function () {
        TimerPause = true;
        $('.nmBottom').css('background', 'linear-gradient(to top,rgba(4,4,16,0.75),rgba(4,4,16,0.75),transparent)');
      });
      $('#SliderView').mouseleave(function () {
        TimerPause = false;
        $('.nmBottom').css('background', '0');
      });
      $('.NavBtn').click(function () {
        SelectSlide($(this));
        var navBtnId = $(this).index();
        if (navBtnId + 1 != SlideNow) {
          TranslateWidth = - $('#SliderView').width() * (navBtnId);
          $('#SliderWrapper').css({
            'transform': 'translate(' + TranslateWidth + 'px, 0)',
            '-webkit-transform': 'translate(' + TranslateWidth + 'px, 0)',
            '-ms-transform': 'translate(' + TranslateWidth + 'px, 0)',
          });
          SlideNow = navBtnId + 1;
        }
      });
      var SSlider = 0;
         $(window).trigger('scroll');// trigger image lazy loader
      if (HeightSize != 'auto') {
        SSlider = $('#SliderView').outerHeight(true);
        $('.Sld').each(function (index, value) {
          var HSlide = $(this).find('img').outerHeight(false);
          var RMath = (SSlider - HSlide) / 2;
          $(this).find('img').css('transform', 'translateY(' + RMath + 'px)');
        });
      }
      var BtnCount = $('.NavBtn').length;
      var SBtn = 0;
      if ($('#NavBtns').hasClass('nmLeft')) {
        SSlider = $('#NavBtns').outerHeight(true);
        SBtn = $('#NavBtns li').outerHeight(true);
        if ($('#NavBtns').hasClass('nmP2')) {
          $('#NavBtns li').css('transform', 'translateY(' + (SSlider - SBtn * BtnCount) / 2 + 'px)');
        } else if ($('#NavBtns').hasClass('nmP3')) {
          $('#NavBtns li').css('transform', 'translateY(' + (SSlider - SBtn * BtnCount) + 'px)');
        }
      } else if ($('#NavBtns').hasClass('nmRight')) {
        SSlider = $('#NavBtns').outerHeight(true);
        SBtn = $('#NavBtns li').outerHeight(true);
        if ($('#NavBtns').hasClass('nmP2')) {
          $('#NavBtns li').css('transform', 'translateY(' + (SSlider - SBtn * BtnCount) / 2 + 'px)');
        } else if ($('#NavBtns').hasClass('nmP3')) {
          $('#NavBtns li').css('transform', 'translateY(' + (SSlider - SBtn * BtnCount) + 'px)');
        }
      } else if ($('#NavBtns').hasClass('nmTop')) {
        SSlider = $('#NavBtns').outerWidth(true);
        SBtn = $('#NavBtns li').outerWidth(true);
        if ($('#NavBtns').hasClass('nmP2')) {
          $('#NavBtns li').css('transform', 'translateX(' + (SSlider - SBtn * BtnCount) / 2 + 'px)');
        } else if ($('#NavBtns').hasClass('nmP3')) {
          $('#NavBtns li').css('transform', 'translateX(' + (SSlider - SBtn * BtnCount) + 'px)');
        }
      } else if ($('#NavBtns').hasClass('nmBottom')) {
        SSlider = $('#NavBtns').outerWidth(true);
        SBtn = $('#NavBtns li').outerWidth(true);
        if ($('#NavBtns').hasClass('nmP2')) {
          $('#NavBtns li').css('transform', 'translateX(' + (SSlider - SBtn * BtnCount) / 2 + 'px)');
        } else if ($('#NavBtns').hasClass('nmP3')) {
          $('#NavBtns li').css('transform', 'translateX(' + (SSlider - SBtn * BtnCount) + 'px)');
        }
      }
    });
    function NextSlide() {
      if (SlideNow == SlideCount || SlideNow <= 0 || SlideNow > SlideCount) {
        $('#SliderWrapper').css('transform', 'translate(0, 0)');
        SlideNow = 1;
      } else {
        TranslateWidth = - $('#SliderView').width() * (SlideNow);
        $('#SliderWrapper').css({
          'transform': 'translate(' + TranslateWidth + 'px, 0)',
          '-webkit-transform': 'translate(' + TranslateWidth + 'px, 0)',
          '-ms-transform': 'translate(' + TranslateWidth + 'px, 0)',
        });
        SlideNow++;
      }
      SelectSlide($('#NavBtns').children().eq(SlideNow - 1));
    }
    function SelectSlide(ActiveBtn) {
        $(window).trigger('scroll');// trigger image lazy loader
      $('.NavBtn').removeClass('nbActiveLeft');
      $('.NavBtn').removeClass('nbActiveRight');
      $('.NavBtn').removeClass('nbActiveTop');
      $('.NavBtn').removeClass('nbActiveBottom');
      if ($('#NavBtns').hasClass('nmRight')) {
        ActiveBtn.addClass('nbActiveRight');
      } else if ($('#NavBtns').hasClass('nmTop')) {
        ActiveBtn.addClass('nbActiveTop');
      } else if ($('#NavBtns').hasClass('nmBottom')) {
        ActiveBtn.addClass('nbActiveBottom');
      } else {
        ActiveBtn.addClass('nbActiveLeft');
      }
    }
}());
Cookies help us deliver our services. By using our services, you agree to our use of cookies.