您似乎还未注册一个账号?我们强烈推荐您点击此处创建一个账户。|如果您在H萌娘上发现某些内容错误/空缺/不中立,请勇于按右上角编辑按钮!

MediaWiki:Gadget-mobileNav.js:修订间差异

H萌娘,万物皆可H的百科全书!
跳转到导航 跳转到搜索
imported>=海豚=
无编辑摘要
top:​bad link repair, replaced: hmoegirl.com → hmoegirl.info (3)
 
第8行: 第8行:
function loadScript(scriptPath){
function loadScript(scriptPath){
     var pageTitle = encodeURIComponent(scriptPath);
     var pageTitle = encodeURIComponent(scriptPath);
     mw.loader.load("https://www.hmoegirl.com/index.php?title=" + pageTitle + "&action=raw&ctype=text/javascript");
     mw.loader.load("https://www.hmoegirl.info/index.php?title=" + pageTitle + "&action=raw&ctype=text/javascript");
}
}


//是否为移动版
//是否为移动版
var isMobile = window.location.href.indexOf("m.hmoegirl.com") != -1;
var isMobile = window.location.href.indexOf("m.hmoegirl.info") != -1;


function mobile(onMobile){
function mobile(onMobile){
第29行: 第29行:
function addNavbox(){
function addNavbox(){
     var pageName = mw.config.get("wgPageName");
     var pageName = mw.config.get("wgPageName");
     $.get("https://m.hmoegirl.com/api.php",{action:"parse",page:pageName,format:"json"},function(data,status){
     $.get("https://m.hmoegirl.info/api.php",{action:"parse",page:pageName,format:"json"},function(data,status){
         if(status == "success"){
         if(status == "success"){
             var desktopView = $($.parseJSON(data.replace("\"*\"","\"data\"")).parse.text.data);
             var desktopView = $($.parseJSON(data.replace("\"*\"","\"data\"")).parse.text.data);

2022年12月20日 (二) 16:16的最新版本

/*
MobileNav.js
by User:NHJR
*/
(function ($, mw) {

//加载内链脚本
function loadScript(scriptPath){
    var pageTitle = encodeURIComponent(scriptPath);
    mw.loader.load("https://www.hmoegirl.info/index.php?title=" + pageTitle + "&action=raw&ctype=text/javascript");
}

//是否为移动版
var isMobile = window.location.href.indexOf("m.hmoegirl.info") != -1;

function mobile(onMobile){
    if(isMobile){
        onMobile();
    }
}

function desktop(onDesktop){
    if(!isMobile){
        onDesktop();
    }
}

//添加Navbox
function addNavbox(){
    var pageName = mw.config.get("wgPageName");
    $.get("https://m.hmoegirl.info/api.php",{action:"parse",page:pageName,format:"json"},function(data,status){
        if(status == "success"){
            var desktopView = $($.parseJSON(data.replace("\"*\"","\"data\"")).parse.text.data);
            var navbox = desktopView.find(".navbox");
            navbox.each(function(){
                //查论编
                var viewTemplateLink = $(this).find("div.hlist.navbar").first();
                var templateView = $("<div class=\"plainlinks\" style=\"color:#aaa;transform:translate(-1.7px,20.9px);\">[</div>");
                templateView.append($(viewTemplateLink.html()));
                templateView.append("]");
                templateView.find("span").removeAttr("style");
                $("div.mw-parser-output").first().append(templateView);
                $("div.mw-parser-output").first().append($(this));
            });
            navbox.ready(function (){
            	mw.loader.using("jquery.makeCollapsible").then(function (){
            		$(".mw-collapsible").makeCollapsible();
            	});
            });
        }
    },"text");
}

mobile(function(){
    if($("div.mw-parser-output")[0] !== undefined){
        var currentNavbox = $(document).find(".navbox");
        if(currentNavbox.length === 0){
            addNavbox();
        }
    }
});

})(jQuery, mediaWiki);