LLWiki正在建设中,欢迎加入我们!
“MediaWiki:Gadget-mainpage-edit.js”的版本间差异
跳转到导航
跳转到搜索
小 |
小 标签:移动版网页编辑 移动版编辑 |
||
第12行: | 第12行: | ||
getName = (ele) => $(ele).data( 'name' ) || ele.textContent.toLowerCase(), |
getName = (ele) => $(ele).data( 'name' ) || ele.textContent.toLowerCase(), |
||
findSelected = (name) => [...$menu.children()].find(ele => getName( ele ) == (dict[name] || name)); |
findSelected = (name) => [...$menu.children()].find(ele => getName( ele ) == (dict[name] || name)); |
||
mw.loader.addStyleTag( `.mainpage-flex |
mw.loader.addStyleTag( `.mainpage-flex table { overflow: visible; } |
||
.mainpage-flex td:first-child { position: relative; } |
|||
.mainpage-flex .oo-ui-textInputWidget { width: 277px; }` ); |
.mainpage-flex .oo-ui-textInputWidget { width: 277px; }` ); |
||
$menu.on('click', 'a', function() { |
$menu.on('click', 'a', function() { |
2021年2月20日 (六) 08:54的版本
"use strict"; /* global OO */ if (mw.config.get( 'wgPageName' ).startsWith( 'LLWiki:首页/当年今日/' ) && mw.config.get( 'wgAction' ) == 'view') { let items = []; const $menu = mw.menu([ {text: "µ's", data: {color: '#e4007f', name: 'muse'}}, {text: 'Aqours', data: {color: '#32aaff'}}, {text: 'Saint Snow', data: {color: '#cb3935'}}, {text: '虹学', data: {color: '#f39800', name: 'nijigaku'}}, {text: 'Liella!', data: {color: '#a5469c', name: 'liella'}}, {text: 'SIF', data: {color: '#77d2af'}}, {text: 'AS', data: {color: '#ff91af'}} ], {}, 1), dict = {ll: 'muse', llss: 'aqours', llspst: 'liella'}, getName = (ele) => $(ele).data( 'name' ) || ele.textContent.toLowerCase(), findSelected = (name) => [...$menu.children()].find(ele => getName( ele ) == (dict[name] || name)); mw.loader.addStyleTag( `.mainpage-flex table { overflow: visible; } .mainpage-flex td:first-child { position: relative; } .mainpage-flex .oo-ui-textInputWidget { width: 277px; }` ); $menu.on('click', 'a', function() { $menu.prev( '.mainpage-tag' ).css('background-color', $(this).data( 'color' )); items[ $menu.closest( 'tr' ).index() ][0] = getName( this ); }).css('z-index', 2); mw.standardQuery( new mw.Api() ).then(data => { items = [...data.query.pages[0].revisions[0].content.matchAll( /首[页頁]\/[标標][签籤]\|(.+?)}}(.+?)\n/g )] .map(ele => [ele[1].trim(), ele[2].trim()]); $('.mw-parser-output table').on('dblclick', 'td:first-child', function() { $menu.appendTo( this ); $menu.setSelected( findSelected( items[ $(this).parent().index() ][0].toLowerCase() ) ).open(); }).on('dblclick', 'td:last-child', function() { const $this = $(this), input = new OO.ui.MultilineTextInputWidget({autosize: true, value: items[ $this.parent().index() ][1]}); $this.html( input.$element ); }); }); }