MediaWiki:Gadget-ShowAvatar.js:修订间差异
imported>=海豚= 无编辑摘要 |
无编辑摘要 |
||
| (未显示2个用户的16个中间版本) | |||
| 第1行: | 第1行: | ||
$(function() { | $(function() { | ||
var img = $('<img>').attr('src', '/ | var username = mw.config.get('wgUserName'); | ||
var pageName = mw.config.get("wgPageName").replace(/^user:/i, ''); | |||
// The new BlueSpice Avatar URL format | |||
var avatarUrlBase = '/rest.php/mws/v1/dynamic-file-dispatcher/userprofileimage?username='; | |||
// 1. Top right personal menu avatar | |||
if ( username ) { | |||
var img = $('<img>') | |||
.attr('src', avatarUrlBase + encodeURIComponent(username)) | |||
.on('error', function() { img.attr('src', '/index.php/Special:FilePath/Moehime.jpg') }) | |||
.css({ | |||
width: '1.2em', | |||
height: '1.2em', | |||
'border-radius': '10px', | |||
'vertical-align': 'middle', | |||
'margin-right': '4px' | |||
}); | |||
var link = $('<a>') | |||
// BlueSpice Avatars uses the UserProfile page for uploads, not Special:上传头像 | |||
.attr('href', '/Special:UserProfile') | |||
.append(img); | |||
$('#pt-userpage').before($('<li id="pt-avatar"></li>').append(link)); | |||
} | |||
// 2. Avatar next to the title on User pages | |||
if (mw.config.get("wgNamespaceNumber") === 2 && !mw.config.get("wgPageName").includes("/")) { | if (mw.config.get("wgNamespaceNumber") === 2 && !mw.config.get("wgPageName").includes("/")) { | ||
$('.ns-2 #firstHeading').prepend( | $('.ns-2 #firstHeading').prepend( | ||
$('<a>').attr({ | $('<a>').attr({ | ||
href: ' | href: '/Special:UserProfile/' + encodeURIComponent(pageName), | ||
title: '查看头像' | title: '查看头像' | ||
}).prepend( | }).prepend( | ||
$('<img>') | $('<img>') | ||
.attr('src', | .attr('src', avatarUrlBase + encodeURIComponent(pageName)) | ||
.css({ | .css({ | ||
width: '1.2em', | width: '1.2em', | ||