打开/关闭菜单
打开/关闭个人菜单
未登录
如果您进行任何编辑,您的IP地址会公开展示。

MediaWiki:Common.js

MediaWiki界面页面
imported>Wr2022年4月25日 (一) 12:58的版本

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
// 调用 MediaWiki 的 OOUI 每年只弹出一次提示, 使用 SonicpediaAlertValue Cookies 进行判定
// SonicpediaAlertValue=0即代表
function setCookie(alertValue,value){
    var Days = 365;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = alertValue + "="+ escape (value) + ";expires=" + exp.toGMTString();
} 

function getCookie(alertValue){
    var arr,reg=new RegExp("(^| )"+alertValue+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null;
} 


function showAlert(){
	if (getCookie("SonicpediaAlertValue")==0){
		return null;
	}
	else {
		// Use the verbose option to communicate a long message.
		var messageDialog = new OO.ui.MessageDialog();
		
		// Create and append window manager
		var windowManager = new OO.ui.WindowManager();
		$( 'body' ).append( windowManager.$element );

		// Add the dialog to the window manager
		windowManager.addWindows( [ messageDialog ] );

		// Configure the message dialog when it is opened with the window manager’s openWindow() method.
		windowManager.openWindow( messageDialog, {
		  title: '欢迎来到索尼克百科!',
		  message: '索尼克百科 Sonicpedia 是刺猬索尼克中文百科全书,欢迎任何人在这里新建或者编辑 Wiki 内容!如果您不适应默认的简体中文,请在:子菜单中或者在您的索尼克百科账号 "参数设置" 中选择您偏好的的中文变体。Gotta Go Fast!\n注意: 本网站需要使用 Cookies 且仅用于身份验证! 使用本网站时必须遵守中国法律,严禁发布违反<a href="https://sonicpedia.org.cn/wiki/Sonicpedia:规定" target="_href">Sonicpedia:规定</a>的内容。',
		  verbose: true,
		  actions: [
		    {
		      action: 'accept',
		      label: '了解',
		      flags: 'primary'
		    }
		  ]
		});
		setCookie("SonicpediaAlertValue","0");
	}
}
showAlert()
/* 调用 ImageMap 工具 */
if (mw.config.get('wgNamespaceNumber')==6 && mw.config.get('wgAction')=='view') {
	mw.loader.load('//imagemapedit.toolforge.org/ime.js');
}

		/*剧透按钮*/
			var spofr = document.getElementById('spoiler'); //内容大框
			var spo = document.getElementById('spoilercon'); //剧透内容
			var spobut = document.getElementById('spoilerbut'); //剧透按钮
			/*检测显示或隐藏状态,并交给按钮显示*/
			if (spo.style.display == 'block') {
				var sposta = 'block';
				spobut.innerHTML = "隐藏"
			} else {
				var sposta = 'none';
				spobut.innerHTML = "显示"
			}
			var spoheight = spo.clientHeight; //检测高度
			var spostartclick //定义检测按钮是否在执行过程被重复按下
			spobut.onclick = function() {
				/*检测是否重复点击*/
				if (spostartclick == true) {
					console.log('用户重复点击按钮')
				} else {
					spostartclick = true; //禁止重复点击
					/*隐藏或显示*/
					if (sposta == 'block') {
						spofr.style.overflow = 'hidden'
						spofr.style.maxHeight = '21px'
						spo.style.opacity = '0';
						spobut.innerHTML = "显示"
						setTimeout(
							function() {
								spo.style.display = 'none';
								sposta = "none";
								spostartclick = false //可以点击
							}, 1000)
					} else {
						spo.style.display = 'block';
						sposta = 'block';
						spobut.innerHTML = "隐藏"
						spofr.style.maxHeight = (spo.clientHeight + 37 + 'px');
												spo.style.opacity = '100';
						setTimeout(function() {
							spostartclick = false; //可以点击
						}, 1000)
					}
				}
			}
我们提供服务需要使用Cookie。您使用我们的服务,即表示您同意我们使用Cookie。