◆少前百科是非盈利性、非官方的少女前线维基百科。
◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科
◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科
◆To foreigners,You can use twitter to contact us.
Icon Nyto Silver.png

“MediaWiki:Vector.js”的版本间的差异

来自少前百科GFwiki
跳转至: 导航搜索
第34行: 第34行:
 
}
 
}
  
RLQ.push(function() {
+
mw.hook( 'wikipage.content' ).add( function ( $content ) {
function moveToc() {
+
if ( $content.is( '#mw-content-text' ) ) {
var toc = $('#toc');
+
const $toc = $content.find( '#toc' );
if (toc.length) {
+
if ( $toc.length ) {
var tocc = toc.clone();
+
var tocClone = $toc.clone();
$('.toctoggle', tocc).remove();
+
$( '.toctoggle', tocClone ).remove();
$('#bodyContent').after('<div id="toc-sidebar"></div>');
+
$content.parent().after( '<div id="toc-sidebar"></div>' );
toc.remove();
+
$toc.remove();
$('#toc-sidebar').append(tocc);
+
$content.parent().next().append( tocClone );
} else $('#content').addClass('notoc');
+
} else {
 +
$content.closes( '#content' ).addClass( 'notoc' );
 +
}
 
}
 
}
function checkLoop() {
+
} );
if (document.readyState == 'complete') moveToc();
 
else setTimeout(checkLoop, 200);
 
}
 
$(checkLoop);
 
});
 

2024年5月3日 (五) 15:08的版本

/* 这里的任何JavaScript将为使用Vector皮肤的用户加载 */

/** GFHideSidebar ver1.1 **/
var buttonNode = document.createElement('div');buttonNode.id="SidebarButton";buttonNode.title="点击隐藏侧边栏";buttonNode.dataset.status="show";
document.querySelector("#content").appendChild(buttonNode);
if(getCookie("GFwikiHideSidebar")=="True"){document.querySelector("#SidebarButton").dataset.status="hide";document.body.classList.add("hide");document.querySelector("#SidebarButton").setAttribute('title', "点击显示侧边栏");window.timeout=setTimeout(function(){document.querySelector("#MenuSidebar").style.display="none"},200)}
window.timeout=setTimeout(function(){},0);
function switchGroup(){
    	var button = document.querySelector("#SidebarButton");
        if(button.dataset.status == "hide"){
            button.dataset.status="show";document.querySelector("#MenuSidebar").style.display="";setTimeout(function(){document.body.classList.remove("hide")},1);button.setAttribute('title', "点击隐藏侧边栏");document.querySelector("#MenuSidebar").style.display="";clearTimeout(window.timeout);
            setCookie("GFwikiHideSidebar", "False", 1);
        } else {
            button.dataset.status="hide";document.body.classList.add("hide");button.setAttribute('title', "点击显示侧边栏");window.timeout=setTimeout(function(){document.querySelector("#MenuSidebar").style.display="none"},200);
            setCookie("GFwikiHideSidebar", "True", 1);
        }
}
document.querySelector("#SidebarButton").addEventListener("click",function(){switchGroup()})
function setCookie(cname,cvalue,exdays){
    var d = new Date();
    d.setTime(d.getTime()+(exdays*24*60*60*1000));
    var expires = "expires="+d.toGMTString();
    document.cookie = cname+"="+cvalue+"; "+expires;
}

function getCookie(cname){
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i].trim();
        if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
    }
    return "";
}

mw.hook( 'wikipage.content' ).add( function ( $content ) {
	if ( $content.is( '#mw-content-text' ) ) {
		const $toc = $content.find( '#toc' );
		if ( $toc.length ) {
			var tocClone = $toc.clone();
			$( '.toctoggle', tocClone ).remove();
			$content.parent().after( '<div id="toc-sidebar"></div>' );
			$toc.remove();
			$content.parent().next().append( tocClone );
		} else {
			$content.closes( '#content' ).addClass( 'notoc' );
		}
	}
} );