LLWiki正在建设中,欢迎加入我们!
“MediaWiki:Mobile.js”的版本间差异
跳转到导航
跳转到搜索
小 标签:移动版网页编辑 移动版编辑 |
小 (// 使用Wikiplus小工具快速编辑) 标签:移动版网页编辑 移动版编辑 |
||
(未显示2个用户的53个中间版本) | |||
第1行: | 第1行: | ||
/* 这里的任何JavaScript将为使用移动版网站的用户加载 */ |
|||
//<nowiki> |
//<nowiki> |
||
// 由ResourceLoader直接调用,不可使用ES6语法 |
|||
(function($, mw) { |
|||
/** |
|||
mw.hook('wikipage.content').add( function($content) { |
|||
* @Description: 手机版全局JS |
|||
/* 沙盒顶部 */ |
|||
* @Author: 如无特殊说明,均为[[User:Bhsd]] |
|||
if(mw.config.get('wgPageName') == 'LLWiki:沙盒' && mw.config.get('wgAction') == 'view') { |
|||
*/ |
|||
var sandboxTop = $('<div>'); |
|||
"use strict"; |
|||
sandboxTop.load('/zh?title=LLWiki:沙盒/顶部&variant=' + mw.config.get('wgUserVariant') + ' #mw-content-text table', function() { |
|||
/* global wgULS */ |
|||
$content.prepend(sandboxTop.children()); |
|||
mw.hook( 'wikipage.content' ).add(function( $content ) { |
|||
}); |
|||
// tabs-dropdown解析错误 |
|||
} |
|||
$('.tabs-dropdown .tabs-content').append(function() { return $(this).next(); }); |
|||
}); |
|||
if (['Recentchanges', 'Watchlist'].includes( mw.config.get( 'wgCanonicalSpecialPageName' ) )) { |
|||
/* 引自[[moegirl:mediawiki:mobile.js]] */ |
|||
// 修改filter |
|||
/* jquery.collapsible */ |
|||
mw.hook( 'structuredChangeFilters.ui.initialized' ).add(function() { |
|||
if ($content.find('.mw-collapsible').length) { |
|||
console.log('Hook: structuredChangeFilters.ui.initialized,开始修改filter'); |
|||
mw.loader.using('jquery.makeCollapsible').then(function() { |
|||
mw.loader.using( ['mediawiki.Uri', 'ext.gadget.site-lib'] ).then(function() { |
|||
$('.mw-collapsible').makeCollapsible(); |
|||
var uri = new mw.Uri(), |
|||
}); |
|||
invert = uri.query.invert || 0; |
|||
} |
|||
const node = $( '.mw-rcfilters-ui-itemMenuOptionWidget-view-namespaces' ).first().clone() |
|||
.insertAfter( $( '.mw-rcfilters-ui-filterMenuSectionOptionWidget' ).first() ) |
|||
/* jquery.tablesorter */ |
|||
.attr('id', 'ooui-invert').removeClass( 'oo-ui-element-hidden' ) |
|||
if ($content.find('table.sortable').length) { |
|||
.on('click', function() { |
|||
uri = new mw.Uri(); |
|||
$('table.sortable').tablesorter(); |
|||
invert = uri.query.invert || 0; |
|||
}); |
|||
location.replace( uri.extend({ invert: 1 - invert }) ); |
|||
} |
|||
}); |
|||
node.find( 'span.oo-ui-labelElement-label' ).text( wgULS("排除选项", "排除所選") ); |
|||
node.find( 'input' ).prop('checked', invert > 0) |
|||
$.when( $.ready, mw.loader.using( 'ext.gadget.site-lib' ) ).then(function () { |
|||
.next().addClass( 'oo-ui-image-invert' ); |
|||
if( ['edit', 'submit'].includes( mw.config.get('wgAction') )) { $('.mw-editTools').insertBefore('#wpTextbox1'); } |
|||
}); |
|||
}); |
|||
// 页顶图标 |
|||
} |
|||
const restrictionEdit = mw.config.get('wgRestrictionEdit') || [], |
|||
restrictionMove = mw.config.get('wgRestrictionMove') || [], |
|||
isSysop = mw.config.get('wgUserGroups').includes('sysop'), |
|||
isProtected = restrictionEdit.length + restrictionMove.length, |
|||
fullurl = '/zh?title=' + mw.config.get('wgPageName'), |
|||
isMovable = restrictionMove.length === 0 || |
|||
mw.config.get('wgUserGroups').includes(restrictionMove[0]); |
|||
if(mw.config.get('wgAction') == 'view' && mw.config.get('wgIsArticle')) { |
|||
$( (isSysop ? '<li id="page-actions-protect" class="page-actions-menu__list-item"><a id="ca-protect" href="' + fullurl + '&action=protect" data-event-name="menu.protect" role="button" title="更改保护"><i class="fa fa-' + (isProtected? 'unlock' : 'lock') + '"></i></a></li><li id="page-actions-delete" class="page-actions-menu__list-item"><a id="ca-delete" href="' + fullurl + '&action=delete" data-event-name="menu.delete" role="button" title="删除"><i class="fa fa-cut"></i></a></li>' : '') + |
|||
(isMovable ? '<li id="page-actions-move" class="page-actions-menu__list-item"><a id="ca-move" href="/zh/special:移动页面/' + mw.config.get('wgPageName') + '" data-event-name="menu.move" role="button" title="移动"><i class="fa fa-truck"></i></a></li>' : '') ).insertAfter('#language-selector'); |
|||
} |
|||
/* 特殊页面 */ |
|||
if(mw.config.get('wgCanonicalSpecialPageName') == "Listusers") { |
|||
$('h1').html('LLWiki上的LLer'); |
|||
} |
|||
/* 添加撤销链接 */ |
|||
const isUser = mw.config.get('wgUserGroups').includes('user'), |
|||
title = mw.config.get('wgRelevantPageName'); |
|||
if(mw.config.get('wgCanonicalSpecialPageName') == "MobileDiff" && isUser ) { |
|||
const pagename = mw.config.get('wgPageName'); |
|||
if( /\.\.\./.test(pagename) ) { return; } |
|||
const undo = pagename.match(/\/(\d*)$/)[1], |
|||
undoafter = $('.revision-history-prev a').attr('href').match(/\/(\d*)$/)[1]; |
|||
$('.mw-mf-diff-info__link-latest a:last-child').after('<a href="/zh?title=' + title + '&action=edit&undo=' + undo + '&undoafter=' + undoafter + '">(' + wgULS("撤销","復原") + ')</a>'); |
|||
} |
|||
if(mw.config.get('wgCanonicalSpecialPageName') == "History" && isUser) { |
|||
var list = $('.page-summary a'), |
|||
oldid = []; |
|||
list.each(function() { |
|||
oldid.push( this.href.match(/[\/=](\d*)$/)[1] ); |
|||
}); |
|||
for(var i = 0; i < list.length - 1; i++) { |
|||
list.eq(i).append('<span style="font-size:0.9em">(<a href="/zh?title=' + title + '&action=edit&undo=' + oldid[i] + '&undoafter=' + oldid[i+1] + '">' + wgULS("撤销","復原") + '</a>)</span>'); |
|||
} |
|||
} |
|||
if(mw.config.get('wgCanonicalSpecialPageName') == "Recentchanges") { |
|||
var timerFilter = setInterval(function() { |
|||
if($( '.mw-rcfilters-ui-itemMenuOptionWidget-view-namespaces' ).length) { |
|||
clearInterval(timerFilter); |
|||
const isReverted = /invert=1/.test(window.location.href); |
|||
var node = $( '.mw-rcfilters-ui-itemMenuOptionWidget-view-namespaces' ).first().clone().insertAfter( $( '.mw-rcfilters-ui-filterMenuSectionOptionWidget' ).first() ) |
|||
.attr('id','ooui-invert') |
|||
.removeClass('oo-ui-element-hidden') |
|||
.on('click',function() { |
|||
if(isReverted) { window.location.href = window.location.href + '&invert=0'; } |
|||
else { window.location.href = window.location.href + '&invert=1'; } |
|||
}), |
|||
inputbox = node.find( 'input' ); |
|||
inputbox[0].checked = isReverted; |
|||
if(isReverted) { inputbox.next().addClass('oo-ui-icon-check'); } |
|||
else { inputbox.next().removeClass('oo-ui-icon-check'); } |
|||
node.find( 'span.oo-ui-labelElement-label' ).text( wgULS("排除选项", "排除所選") ); |
|||
} |
|||
}, 100); |
|||
} |
|||
/* Mobile Navmenu by GFwiki */ |
|||
var menu = $('<div>'); |
|||
menu.load('/zh?title=MediaWiki:MFSidebar' + wgULS("", "/zh-hant") + ' #mw-content-text ul', function() { |
|||
var navlist = menu.children(); |
|||
if(mw.config.get('wgNamespaceNumber') >= 0) { |
|||
navlist.append('<li><a href="/zh/Special:链入页面/' + mw.config.get("wgPageName") + '"><i class="fa fa-quote-right"></i><span>' + wgULS("链入页面", "連結至此的頁面") + '</span></a></li><li><a href="/zh/Special:链出更改/' + mw.config.get("wgPageName") + '"><i class="fa fa-share-alt"></i><span>' + wgULS("相关更改", "相關變更") + '</span></a></li><li><a href="/zh?title=Special:前缀索引&prefix=' + mw.config.get("wgTitle") + '/&namespace=' + mw.config.get("wgNamespaceNumber") + '&stripprefix=1"><i class="fa fa-folder-open"></i><span>' + wgULS("子页面", "子頁面") + '</span>'); |
|||
} |
|||
var timer = setInterval(function() { |
|||
if($('.menu ul').length) { |
|||
console.log("Mobile menu exists"); |
|||
clearInterval(timer); |
|||
navlist.insertAfter($(".menu > ul").first()); |
|||
} |
|||
}, 100); |
|||
}); |
|||
}); |
|||
})(jQuery, mediaWiki); |
|||
//</nowiki> |
//</nowiki> |
||
// [[category:作为模块的小工具]] [[category:不可关闭的小工具]] [[category:手机版小工具]] |
|||
// {{DEFAULTSORT:*}} |
2023年3月17日 (五) 13:28的最新版本
//<nowiki> // 由ResourceLoader直接调用,不可使用ES6语法 /** * @Description: 手机版全局JS * @Author: 如无特殊说明,均为[[User:Bhsd]] */ "use strict"; /* global wgULS */ mw.hook( 'wikipage.content' ).add(function( $content ) { // tabs-dropdown解析错误 $('.tabs-dropdown .tabs-content').append(function() { return $(this).next(); }); }); if (['Recentchanges', 'Watchlist'].includes( mw.config.get( 'wgCanonicalSpecialPageName' ) )) { // 修改filter mw.hook( 'structuredChangeFilters.ui.initialized' ).add(function() { console.log('Hook: structuredChangeFilters.ui.initialized,开始修改filter'); mw.loader.using( ['mediawiki.Uri', 'ext.gadget.site-lib'] ).then(function() { var uri = new mw.Uri(), invert = uri.query.invert || 0; const node = $( '.mw-rcfilters-ui-itemMenuOptionWidget-view-namespaces' ).first().clone() .insertAfter( $( '.mw-rcfilters-ui-filterMenuSectionOptionWidget' ).first() ) .attr('id', 'ooui-invert').removeClass( 'oo-ui-element-hidden' ) .on('click', function() { uri = new mw.Uri(); invert = uri.query.invert || 0; location.replace( uri.extend({ invert: 1 - invert }) ); }); node.find( 'span.oo-ui-labelElement-label' ).text( wgULS("排除选项", "排除所選") ); node.find( 'input' ).prop('checked', invert > 0) .next().addClass( 'oo-ui-image-invert' ); }); }); } //</nowiki> // [[category:作为模块的小工具]] [[category:不可关闭的小工具]] [[category:手机版小工具]] // {{DEFAULTSORT:*}}