LLWiki正在建设中,欢迎加入我们!
“User:Bhsd/widget/songposition.js”的版本间差异
跳转到导航
跳转到搜索
标签:移动版网页编辑 移动版编辑 |
小 标签:移动版网页编辑 移动版编辑 |
||
第24行: | 第24行: | ||
if ($content.find( '.member-symbol-image' ).length === 0) { return; } |
if ($content.find( '.member-symbol-image' ).length === 0) { return; } |
||
console.log('Hook: wikipage.content, 开始更新songposition的图片映射'); |
console.log('Hook: wikipage.content, 开始更新songposition的图片映射'); |
||
$content.find( target ).each(function() { map.set(this, $(this).next( ' |
$content.find( target ).each(function() { map.set(this, $(this).next().find( 'img' )); }); |
||
}); |
}); |
||
mw.loader.using(['oojs-ui-core', 'ext.gadget.site-lib']).then(() => { |
mw.loader.using(['oojs-ui-core', 'ext.gadget.site-lib']).then(() => { |
2021年1月25日 (一) 14:00的版本
//<nowiki> // 用于[[Widget:Songposition]],可以使用ES6语法 /** * @Function: 鼠标移动至歌曲站位图标上方时提示角色姓名 * @Dependencies: oojs-ui-core, ext.gadget.site-lib * @Author: [[User:Bhsd]] */ "use strict"; /* global mw, $ */ (() => { const timer = setInterval(() => { if (!window.jQuery) { return; } clearInterval(timer); mw.widget = mw.widget || {}; if (mw.widget.songposition) { return; } console.log('End setInterval: jQuery加载完毕,开始执行Widget:Songposition'); const target = '.member-symbol', map = new Map(), $label = $('<div>', {html: '<div>'}), $body = $('body').on('mouseenter focus', target, function() { $label.children( 'div' ).html( map.get(this) ); }); mw.hook( 'wikipage.content' ).add($content => { // 更新图片对应关系 if ($content.find( '.member-symbol-image' ).length === 0) { return; } console.log('Hook: wikipage.content, 开始更新songposition的图片映射'); $content.find( target ).each(function() { map.set(this, $(this).next().find( 'img' )); }); }); mw.loader.using(['oojs-ui-core', 'ext.gadget.site-lib']).then(() => { mw.tipsy($body, target, {classes: ['member-popup']}, $label); }); mw.widget.songposition = true; }, 500); }) (); //</nowiki> // [[category:jQuery小部件]] {{DEFAULTSORT:Songposition}}