• 欢迎来到小可 · Wiki,人人可编辑的,多平台聊天机器人“小可”的官方文档资源。
  • 小可很可爱,请给我们打钱
  • 原 MkDocs 已迁入本站。若发现 404 属正常现象,请点击左上角搜索您想要的模块。

MediaWiki:Common.js:修订间差异

MediaWiki系统消息页面
无编辑摘要
无编辑摘要
第47行: 第47行:
}
}
siteNoticeScroll('.siteNoticeScroll',5000);
siteNoticeScroll('.siteNoticeScroll',5000);
/**
*
* tabbedWindow.js
*
* It embeds an OOUI tabbed window on all pages in the API namespace on MediaWiki.org.
* Each tab of the window contains sample code in a programming language (PHP, Javascript, Python, etc.)
* demonstrating the use of the MediaWiki Action API.
*
* @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
* @licstart  The following is the entire license notice for the JavaScript code in this gadget.
*
* Copyright (C) 2019 Jay Prakash <https://meta.wikimedia.org/wiki/User:Jayprakash12345> and contributors
*
* The JavaScript/Gadget code in this page is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version.  The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
*
* @licend  The above is the entire license notice for the JavaScript/Gadget code in this gadget.
*/
( function ( $ ) {
'use strict';
$( document ).ready( function () {
/**
* This function fetches sample code in different programming languages
* from the sub-sections of the section "Sample Code" and places
* them into an OOUI tabbed window.
*
*/
function makeTabWindow() {
var tabs = [];
$( '.mw-gadget-tabbedwindow' ).each( function () {
$( this ).find( 'h3 > .mw-editsection' ).remove();
var indexLayout = new OO.ui.IndexLayout( {
expanded: false
} );
$( this ).find( 'h3' ).each( function () {
var htmlcontent = '',
id;
id = $(this).find('span[class=mw-headline]').attr('id');
$('a[href="#'+ id +'"]').remove();
$( this ).nextUntil( 'h3' ).each(function(){
           htmlcontent += '\n' + $(this).prop( 'outerHTML' );
         });
        
tabs.push( new OO.ui.TabPanelLayout( $( this ).text(), {
expanded: false,
label: $( this ).text(),
content: [
new OO.ui.HtmlSnippet( htmlcontent )
]
} )
);
} );
indexLayout.addTabPanels( tabs );
tabs = [];
var panelLayout = new OO.ui.PanelLayout( {
expanded: false,
framed: true,
content: [ indexLayout ]
} );
$( this ).empty().append( panelLayout.$element );
$( '.oo-ui-indexLayout-stackLayout > .oo-ui-panelLayout' ).css( 'padding', '0.5em' );
} );
}
$.when( mw.loader.using( 'mediawiki.Title' ), $.ready ).then( function () {
var supportedNamespaces = [ '' ],
action = mw.config.get( 'wgAction' ),
namespace = mw.config.get( 'wgCanonicalNamespace' ),
mwTitle = mw.Title.newFromText( mw.config.get( 'wgPageName' ) ),
isTalkPage = mwTitle.isTalkPage(),
tabwindow = $( '.mw-gadget-tabbedwindow' ).length;
if ( action !== 'view' ||
namespace.indexOf( supportedNamespaces ) === -1 ||
isTalkPage === true ||
tabwindow === 0 ) {
return;
} else {
         $.when( mw.loader.using( 'oojs-ui', 'oojs-ui-core' ), $.ready ).then( function () {
           makeTabWindow();
         });
}
} );
} );
}( jQuery ) );

2021年6月14日 (一) 08:16的版本

/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
try {
	document.getElementById('skin-citizen-search-trigger').addEventListener('click', function() {
            var event = new Event('input',{
                bubbles: !0,
                composed: !0
            })
              , checkbox = document.getElementById('search-checkbox');
            checkbox.checked = !0;
            checkbox.dispatchEvent(event);
        });
} catch (e) {}

if (mw.config.get('wgPageName') === "小可_·_Wiki") {
$.ajax('https://api.github.com/repos/Teahouse-Studios/bot/commits').then(function (res) {
    var hash = res[0].sha
    var shortHash = hash.slice(0, 6)
    $('.commit-hash:not(commit-hash-short)').text(hash)
    $('.commit-hash.commit-hash-short').text(shortHash)
}).catch(function () {
	$('.commit-hash').text('???')
})
}

/** 顶部公告 **/
/* From wjghj.cn under CC BY-NC-SA 4.0*/
function siteNoticeScroll(obj,interval) {
  $(obj).animate({
    height: 'show',
    paddingTop: 'show',
    marginTop: 'show',
    paddingBottom: 'show',
    marginBottom: 'show',
  });
  setInterval(function() {
    $(obj).find('ul:first').animate({
      marginTop: '-25px'
    },
    300,
    function() {
      $(this).css({
        marginTop: '0px',
      }).find('li:first').appendTo(this);
    });
  },
  interval);
}
siteNoticeScroll('.siteNoticeScroll',5000);

/**
 *
 * tabbedWindow.js
 *
 * It embeds an OOUI tabbed window on all pages in the API namespace on MediaWiki.org. 
 * Each tab of the window contains sample code in a programming language (PHP, Javascript, Python, etc.) 
 * demonstrating the use of the MediaWiki Action API.
 * 
 * @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
 * @licstart  The following is the entire license notice for the JavaScript code in this gadget.
 * 
 * Copyright (C) 2019 Jay Prakash <https://meta.wikimedia.org/wiki/User:Jayprakash12345> and contributors
 * 
 * The JavaScript/Gadget code in this page is free software: you can
 * redistribute it and/or modify it under the terms of the GNU
 * General Public License (GNU GPL) as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option)
 * any later version.  The code is distributed WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
 * 
 * As additional permission under GNU GPL version 3 section 7, you
 * may distribute non-source (e.g., minimized or compacted) forms of
 * that code without the copy of the GNU GPL normally required by
 * section 4, provided you include this license notice and a URL
 * through which recipients can access the Corresponding Source.
 * 
 * @licend  The above is the entire license notice for the JavaScript/Gadget code in this gadget.
 */

( function ( $ ) {
	'use strict';

	$( document ).ready( function () {
		/**
		 * This function fetches sample code in different programming languages
		 * from the sub-sections of the section "Sample Code" and places 
		 * them into an OOUI tabbed window.
		 * 
		 */
		function makeTabWindow() {
			var tabs = [];

			$( '.mw-gadget-tabbedwindow' ).each( function () {

				$( this ).find( 'h3 > .mw-editsection' ).remove();

				var indexLayout = new OO.ui.IndexLayout( {
					expanded: false
				} );

				$( this ).find( 'h3' ).each( function () {
					var htmlcontent = '',
						id;
					
					id = $(this).find('span[class=mw-headline]').attr('id');
					$('a[href="#'+ id +'"]').remove();
					
					$( this ).nextUntil( 'h3' ).each(function(){
	                    htmlcontent += '\n' + $(this).prop( 'outerHTML' );
	                });
                
					tabs.push( new OO.ui.TabPanelLayout( $( this ).text(), {
						expanded: false,
						label: $( this ).text(),
						content: [
							new OO.ui.HtmlSnippet( htmlcontent )
						]
					} )
					);
				} );

				indexLayout.addTabPanels( tabs );
				tabs = [];

				var panelLayout = new OO.ui.PanelLayout( {
					expanded: false,
					framed: true,
					content: [ indexLayout ]
				} );

				$( this ).empty().append( panelLayout.$element );

				$( '.oo-ui-indexLayout-stackLayout > .oo-ui-panelLayout' ).css( 'padding', '0.5em' );
			} );
		}

		$.when( mw.loader.using( 'mediawiki.Title' ), $.ready ).then( function () {

			var supportedNamespaces = [ '' ],
				action = mw.config.get( 'wgAction' ),
				namespace = mw.config.get( 'wgCanonicalNamespace' ),
				mwTitle = mw.Title.newFromText( mw.config.get( 'wgPageName' ) ),
				isTalkPage = mwTitle.isTalkPage(),
				tabwindow = $( '.mw-gadget-tabbedwindow' ).length;

			if ( action !== 'view' ||
				namespace.indexOf( supportedNamespaces ) === -1 ||
				isTalkPage === true ||
				tabwindow === 0 ) {
				return;
			} else {
                $.when( mw.loader.using( 'oojs-ui', 'oojs-ui-core' ), $.ready ).then( function () {
                    makeTabWindow();
                });
			}
		} );

	} );
}( jQuery ) );
Cookie帮助我们提供我们的服务。通过使用我们的服务,您同意我们使用cookie。