MediaWiki:UserStatus.js

/** * * @module                 UserStatus * @description            Adds configurable user status to masthead avatars. * @author                 Americhino * @version                0.8.0 * @license                CC-BY-SA 3.0 * @todo                   Add dropdown menu option to quickly switch status * @todo                   Colorblind mode * @todo                   Change status to blocked when a user is blocked * @todo                   Add demo for SapphireSonata's userpage */ var avatar = '.UserProfileMasthead .masthead-avatar'; // Fetch content of User:USERNAME/status $.ajax({   method: 'GET',    dataType: 'text',    url: mw.util.wikiScript('index'),    data: {        title: 'User:' + wgTitle + '/status',        action: 'raw'    },    complete: function(data){        // Variables        var status = data.responseText || 'unknown';        var status_masthead = $('');        var status_text = {            'online': 'Online',            'away': 'Away',            'around': 'Around',            'offline': 'Offline',            'unavailable': 'Unavailable',            'unknown': 'Unknown',            'blocked': 'Blocked',        }        var status_color = {            'online': '#43b581',            'away': '#faa61a',            'around': '#436d8f',            'offline': '#f04747',            'unavailable': '#e2500b',            'unknown': '#666',            'blocked': '#8f0000',        }        var statusOptions = {            'online': 'online',            'away': 'away', 'around': 'around', 'offline': 'offline', 'unavailable': 'unavailable', 'unknown': 'unknown', 'blocked': 'blocked', }       // Create element $(avatar).append(           $(' ', { 'class': 'status-indicator', css: { height: '40px', position: 'absolute', right: '5px', bottom: '5px', width: '40px', borderRadius: '50%', background: status_color[status], title: status_text[status] }           })        );    } });