LLWiki正在建设中,欢迎加入我们!
“User:Bhsd/vector.js”的版本间差异
跳转到导航
跳转到搜索
小 |
小 |
||
第4行: | 第4行: | ||
// 应用mediawiki.util对页面名称进行转义 |
// 应用mediawiki.util对页面名称进行转义 |
||
$.when($.ready, mw.loader.using( 'mediawiki.util' )).then(function() { |
$.when($.ready, mw.loader.using( 'mediawiki.util' )).then(function() { |
||
⚫ | |||
⚫ | |||
// responsive Vector |
|||
const $menu = $('<ul>', {class: 'menu', html: $('<li>')}), |
|||
$switch = $('<input>', {type: 'checkbox', class: 'vectorMenuCheckbox', 'aria-labeledby': 'pt-userpage'}), |
|||
$items = $('#pt-notifications-notice').nextAll( ':not(#utcdate)' ), |
|||
$userpage = $('#pt-userpage').addClass( 'vectorMenu' ).append( $switch ), |
|||
$userpagelink = $userpage.children( 'a' ), |
|||
responsive = function() { |
|||
if (!matchMedia( '(max-width:720px)' ).matches) { |
|||
$items.insertAfter( '#pt-notifications-notice' ); |
|||
$switch.add( $menu ).detach(); |
|||
} else { |
|||
$menu.append( $items ); |
|||
$userpage.append([ $switch, $menu ]); |
|||
} |
|||
}; |
|||
$('<a>', {href: $userpagelink.attr( 'href' ), text: $userpagelink.text()}).appendTo( $menu.children( 'li' ) ); |
|||
responsive(); |
|||
$(window).resize( responsive ); |
|||
const nsid = mw.config.get( 'wgNamespaceNumber' ), |
const nsid = mw.config.get( 'wgNamespaceNumber' ), |
||
pageName = mw.util.wikiUrlencode( mw.config.get('wgPageName') ), |
pageName = mw.util.wikiUrlencode( mw.config.get('wgPageName') ), |
||
第37行: | 第15行: | ||
.click(function() { mw.loader.load( 'ext.gadget.Cat-a-lot' ); }); |
.click(function() { mw.loader.load( 'ext.gadget.Cat-a-lot' ); }); |
||
} |
} |
||
else if (specialPage == 'Contributions') { |
else if (specialPage == 'Contributions') { |
||
const $nonCode = $('.mw-contributions-list').children().not(function() { |
const $nonCode = $('.mw-contributions-list').children().not(function() { |
||
第44行: | 第22行: | ||
$('<a>', {text: '代码筛选'}).click(function() { $nonCode.toggle(); }).appendTo( '.mw-pager-navigation-bar' ); |
$('<a>', {text: '代码筛选'}).click(function() { $nonCode.toggle(); }).appendTo( '.mw-pager-navigation-bar' ); |
||
} |
} |
||
else if (action == 'view' && $('.Lyrics_box').length && $('.photrans-button').length === 0) { |
else if (action == 'view' && $('.Lyrics_box').length && $('.photrans-button').length === 0) { |
||
$(mw.util.addPortletLink('p-cactions', '#', '歌词注音')).click(function(e) { |
$(mw.util.addPortletLink('p-cactions', '#', '歌词注音')).click(function(e) { |
||
第54行: | 第32行: | ||
}); |
}); |
||
} |
} |
||
else if (mw.loader.getState( 'ext.codeEditor' ) == 'ready') { |
else if (mw.loader.getState( 'ext.codeEditor' ) == 'ready') { |
||
$('.ace_text-input').keyup(function(e) { |
$('.ace_text-input').keyup(function(e) { |
||
第76行: | 第54行: | ||
{href: '/zh?title=Special:所有页面&namespace=' + nsid, text: "所有页面"}] |
{href: '/zh?title=Special:所有页面&namespace=' + nsid, text: "所有页面"}] |
||
.forEach(function(ele) { addToolLink(ele, '#t-info'); }); |
.forEach(function(ele) { addToolLink(ele, '#t-info'); }); |
||
⚫ | |||
⚫ | |||
}); |
}); |
||
//</nowiki> |
//</nowiki> |
2021年10月5日 (二) 06:00的版本
//<nowiki> // 拆分自[[Special:Mypage/common.js]],不可使用ES6语法 "use strict"; // 应用mediawiki.util对页面名称进行转义 $.when($.ready, mw.loader.using( 'mediawiki.util' )).then(function() { const nsid = mw.config.get( 'wgNamespaceNumber' ), pageName = mw.util.wikiUrlencode( mw.config.get('wgPageName') ), title = mw.util.wikiUrlencode( mw.config.get('wgTitle') ), specialPage = mw.config.get( 'wgCanonicalSpecialPageName' ), action = mw.config.get( 'wgAction' ); if (nsid == 14) { // 加载ext.gadget.Cat-a-lot;尽量避免htmlString $('<li>', {html: $('<a>', {text: 'Cat-a-lot'})}).appendTo( '#p-cactions ul' ) .click(function() { mw.loader.load( 'ext.gadget.Cat-a-lot' ); }); } else if (specialPage == 'Contributions') { const $nonCode = $('.mw-contributions-list').children().not(function() { return /(^Widget:|\.(js|css)$)/.test( $(this).find( '.mw-contributions-title' ).text() ); }); $('<a>', {text: '代码筛选'}).click(function() { $nonCode.toggle(); }).appendTo( '.mw-pager-navigation-bar' ); } else if (action == 'view' && $('.Lyrics_box').length && $('.photrans-button').length === 0) { $(mw.util.addPortletLink('p-cactions', '#', '歌词注音')).click(function(e) { e.preventDefault(); this.remove(); mw.loader.using( 'oojs-ui-windows' ).then(function() { mw.loader.load( '/zh?title=user:bhsd/photrans.js&action=raw&ctype=text/javascript' ); }); }); } else if (mw.loader.getState( 'ext.codeEditor' ) == 'ready') { $('.ace_text-input').keyup(function(e) { if (!e.metaKey || e.key != 'f') { return; } $('.ace_search_form > input').select(); }); } // 自定义左侧导航,使用短地址 const addToolLink = function(obj, nextNode) { // 如果能用对象解构就很舒服了…… mw.util.addPortletLink('p-tb', obj.href, obj.text, null, null, null, nextNode); }; $('#t-whatlinkshere a').attr('href', '/zh?hidelinks=1&hideredirs=1&namespace=0&title=Special:链入页面/' + pageName); $('#t-recentchangeslinked a').attr('href', '/zh?title=Special:链出更改&hidemyself=1&target=' + pageName); [{href: '/zh?title=Special:前缀索引&stripprefix=1&prefix=' + title + '/&namespace=' + nsid, text: "子页面"}, {href: '/zh?title=Special:展开模板&wpRemoveComments=1&wpGenerateRawHtml=true&wpInput={{:' + pageName + '}}', text: "展开模板"}].forEach(function(ele) { addToolLink(ele, '#t-recentchangeslinked'); }); [{href: '/zh/Special:版本', text: "版本"}, {href: '/zh?title=Special:用户列表&creationSort=1&desc=1', text: "用户列表"}, {href: '/zh?target=http://*&title=Special:链接搜索', text: "链接搜索"}, {href: '/zh/Special:滥用过滤器', text: "滥用过滤器"}, {href: '/zh/Special:替换文本', text: "替换文本"}, {href: '/zh?title=Special:所有页面&namespace=' + nsid, text: "所有页面"}] .forEach(function(ele) { addToolLink(ele, '#t-info'); }); // 自定义顶部导航,使用短地址 mw.util.addPortletLink('p-personal', '/zh/Help:沙盒', "沙盒", null, null, null, '#pt-preferences'); }); //</nowiki>