MediaWiki:Gadget-ShowAvatar.js:修订间差异

imported>=海豚=
无编辑摘要
无编辑摘要
 
(未显示2个用户的20个中间版本)
第1行: 第1行:
var img = $('<img>').attr('src', '//commons.moegirl.org.cn/extensions/Avatar/avatar.php?user=' + mw.config.get('wgUserName'));
$(function() {
var link = $('<a>').attr('href', '//commons.moegirl.org.cn/Special:UploadAvatar').append(img);
    var username = mw.config.get('wgUserName');
$('#pt-userpage').before($('<li id="pt-avatar"></li>').append(link));
    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("/")) {
        $('.ns-2 #firstHeading').prepend(
            $('<a>').attr({
                href: '/Special:UserProfile/' + encodeURIComponent(pageName),
                title: '查看头像'
            }).prepend(
                $('<img>')
                .attr('src', avatarUrlBase + encodeURIComponent(pageName))
                .css({
                    width: '1.2em',
                    height: '1.2em',
                    'border-radius': '10px',
                    padding: '4px'
                })
            )
        );
    }
});