您似乎还未注册一个账号?我们强烈推荐您点击此处创建一个账户。|如果您在H萌娘上发现某些内容错误/空缺/不中立,请勇于按右上角编辑按钮!
MediaWiki:Gadget-mobileNav.js:修订间差异
跳转到导航
跳转到搜索
imported>=海豚= 创建页面,内容为“→MobileNav.js by User:NHJR: (function ($, mw) { //加载内链脚本 function loadScript(scriptPath){ var pageTitle = encodeURIComponent(scriptPath); mw…” |
imported>=海豚= 无编辑摘要 |
||
| 第9行: | 第9行: | ||
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.com/index.php?title=" + pageTitle + "&action=raw&ctype=text/javascript"); | ||
} | |||
//是否为移动版 | |||
var isMobile = window.location.href.indexOf("m.hmoegirl.com") != -1; | |||
function mobile(onMobile){ | |||
if(isMobile){ | |||
onMobile(); | |||
} | |||
} | |||
function desktop(onDesktop){ | |||
if(!isMobile){ | |||
onDesktop(); | |||
} | |||
} | } | ||
2021年8月1日 (日) 23:45的版本
/*
MobileNav.js
by User:NHJR
*/
(function ($, mw) {
//加载内链脚本
function loadScript(scriptPath){
var pageTitle = encodeURIComponent(scriptPath);
mw.loader.load("https://www.hmoegirl.com/index.php?title=" + pageTitle + "&action=raw&ctype=text/javascript");
}
//是否为移动版
var isMobile = window.location.href.indexOf("m.hmoegirl.com") != -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.com/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);