imported>=海豚= |
imported>Zyksnowy |
第1行: |
第1行: |
| (function($, mw) {
| | 這是H醬的沙盒醬,目前還不會被經常清空。。 |
| $(function() {
| |
| var sidebarCookieName = 'sidebarHidden';
| |
| var commonImgUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb';
| |
| var localImgUrl = 'https://zh.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-';
| |
| var imgLogoLang = ['ca', 'cs', 'cy', 'el', 'en', 'et', 'hi', 'hy', 'ja', 'ka', 'la', 'ru', 'szl', 'th', 'uk', 'uz', 'zh'].indexOf(mw.config.get('wgContentLanguage')) > -1 ? mw.config.get('wgContentLanguage') : 'en';
| |
| var img = {
| |
| logo: localImgUrl + imgLogoLang + '.svg',
| |
| logo_zh_hans: localImgUrl + 'zh-hans.svg',
| |
| next: commonImgUrl + '/9/95/Icons8_flat_next.svg/15px-Icons8_flat_next.svg.png',
| |
| prev: commonImgUrl + '/b/bd/Icons8_flat_previous.svg/15px-Icons8_flat_previous.svg.png'
| |
| };
| |
| var isMobile = /(Android|iPad|iPhone|Mobile)/i.test(navigator.userAgent);
| |
| var cookieExpires = 365;
| |
| var sidebarHidden = false;
| |
| var sidebarGadgetLoaded = false;
| |
|
| |
|
| function hideSidebar() {
| | Error 503 Backend fetch failed |
| sidebarHidden = true;
| |
| $('#sidebarCollapse').attr('src', img.next);
| |
| updatePos();
| |
| $('#content').css('margin-left', '1em');
| |
| $('#footer').css('margin-left', '1em');
| |
| $('#mw-panel').hide();
| |
| $('#sliderCollapseLogo').show();
| |
| $.cookie(sidebarCookieName, 'true', {
| |
| expires: cookieExpires,
| |
| path: '/'
| |
| })
| |
| }
| |
|
| |
|
| function showSidebar() {
| | Backend fetch failed |
| sidebarHidden = false;
| |
| $('#sidebarCollapse').attr('src', img.prev);
| |
| updatePos();
| |
| $('#content').css('margin-left', '');
| |
| $('#footer').css('margin-left', '');
| |
| $('#mw-panel').show();
| |
| $('#sliderCollapseLogo').hide();
| |
| $.cookie(sidebarCookieName, 'false', {
| |
| expires: cookieExpires,
| |
| path: '/'
| |
| })
| |
| }
| |
|
| |
|
| function updatePosHelper(arr) {
| | Guru Meditation: |
| var divList = ['#sidebarCollapse', '#sliderCollapseLogo'];
| |
| for (var i = 0; i < arr.length; i++) {
| |
| if (arr[i] === null) continue;
| |
| var bDiv = divList[i];
| |
| var bLeft = $(bDiv).css('left');
| |
| var bSize = arr[i];
| |
| if (bLeft !== bSize) $(bDiv).css('left', bSize)
| |
| }
| |
| }
| |
|
| |
|
| function updatePos() {
| | XID: 10158253 |
| var bWidth = 0;
| |
| if (isMobile) {
| |
| bWidth = window.outerWidth > 0 ? window.outerWidth : $('body').width
| |
| } else {
| |
| bWidth = window.innerWidth > 0 ? window.innerWidth : $('body').width
| |
| }
| |
| if (bWidth >= 982) {
| |
| updatePosHelper(sidebarHidden ? ['0.3em', '3em'] : ['10.3em', null])
| |
| } else {
| |
| updatePosHelper(sidebarHidden ? ['0.3em', '2.5em'] : ['9.3em', null])
| |
| }
| |
| }
| |
|
| |
|
| function sidebarHiddenProc() {
| | Varnish cache server |
| sidebarGadgetLoaded = true;
| | Error 503 Backend fetch failed |
|
| |
|
| var sidebarCollapse = $('<img>').attr({
| | Backend fetch failed |
| 'id': 'sidebarCollapse',
| |
| 'src': img.prev
| |
| }).css({
| |
| 'position': 'fixed',
| |
| 'float': 'right',
| |
| 'z-index': '10',
| |
| 'width': '0.8em',
| |
| 'height': '0.8em',
| |
| 'top': '7.625em',
| |
| 'left': '11.6em',
| |
| 'cursor': 'pointer',
| |
| 'padding': '0.3em',
| |
| '-webkit-border-radius': '50px',
| |
| '-moz-border-radius': '50px',
| |
| 'border-radius': '50px',
| |
| 'text-align': 'center',
| |
| 'border': '1px solid #a7d7f9',
| |
| 'background': '#fff'
| |
| });
| |
|
| |
|
| var newLink = $('<a>').attr({
| | Guru Meditation: |
| 'id': 'newLink',
| |
| 'href': '/wiki',
| |
| 'title': $('.mw-wiki-logo').attr('title')
| |
| });
| |
|
| |
|
| if (mw.config.get('wgNoticeProject') === 'wikipedia') {
| | XID: 17072240 |
| $('<img>').attr({
| |
| 'id': 'sliderCollapseLogo',
| |
| 'src': "https://zh.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-zh.svg"
| |
| }).css({
| |
| 'display': 'none',
| |
| 'position': 'absolute',
| |
| 'top': '3.375em',
| |
| 'cursor': 'pointer',
| |
| 'float': 'none',
| |
| 'width': '6em'
| |
| }).appendTo(newLink);
| |
| }
| |
|
| |
|
| sidebarCollapse.appendTo('#mw-navigation');
| | Varnish cache server |
| newLink.appendTo('#mw-navigation');
| | https://zh.moegirl.org/User:Zyksnowy#.E7.BC.96.E8.BE.91 Failed to load resource: the server responded with a status of 503 (OK) |
| | |
| if ($.cookie(sidebarCookieName) === 'true') hideSidebar();
| |
| updatePos();
| |
| | |
| $(window).resize(function() {
| |
| updatePos()
| |
| });
| |
| | |
| $('#sidebarCollapse').mouseover(function() {
| |
| $(this).css('background', 'rgb(223, 245, 255)')
| |
| }).mouseout(function() {
| |
| $(this).css('background', 'white')
| |
| }).click(function() {
| |
| sidebarHidden ? showSidebar() : hideSidebar()
| |
| })
| |
| }
| |
| | |
| function sidebarHiddenInit() {
| |
| if (mw.config.get('skin') !== 'vector' || $('.mw-special-Blankpage').length !== 0 || $('#mw-sidebar-button').length > 0) return;
| |
| if (['ar', 'arc', 'arz', 'bo', 'ckb', 'dv', 'dz', 'glk', 'ks', 'mzn', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi'].indexOf(mw.config.get('wgContentLanguage')) > -1) return;
| |
| if ($('#mw-navigation').length === 0) {
| |
| var obs = new MutationObserver(function (mutations, observer) {
| |
| if (sidebarGadgetLoaded) return;
| |
| for (var i = 0; i < mutations.length; ++i) {
| |
| for (var j = 0; j < mutations[i].addedNodes.length; ++j) {
| |
| if (mutations[i].addedNodes[j].id === 'mw-navigation') {
| |
| sidebarHiddenProc();
| |
| break;
| |
| }
| |
| }
| |
| }
| |
| });
| |
| obs.observe(document.body, {
| |
| childList: true
| |
| });
| |
| return
| |
| }
| |
| sidebarHiddenProc()
| |
| }
| |
| sidebarHiddenInit()
| |
| })
| |
| })(jQuery, mw);
| |