MediaWiki:Gadget-OnlineAdmins.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
// About this program:
// Only Support Chinese Wikipedia Currently.
// This program was done with implementation of codes, and combined codes of both Alexander Misel and Vjudge1
// Create portlet link
// Program was used for Chinese Wikipedia only. For English Wikipedia, please check in the English Box
// Version: 1.2
// Create Portlet Link
var portletLinkOnline = mw.util.addPortletLink(
var portletLinkOnline = mw.util.addPortletLink(
     'p-personal',
     'p-personal',
     '#',
     '#',
     '管理人員',
     'Online Admins',
     't-onlineadmin',
     't-onlineadmin',
     '查看当前在线管理员',
     'Seek help from these users',
     '',
     '',
     '#pt-userpage'
     '#pt-userpage'
Line 28: Line 25:
         patrollers = [];
         patrollers = [];


         // Recent Changes Detector
         // 最近更改30分钟内的编辑用户
         time = new Date();
         time = new Date();
         rcstart = time.toISOString();
         rcstart = time.toISOString();
         time.setMinutes(time.getMinutes() - 15);
         time.setMinutes(time.getMinutes() - 30);
         rcend = time.toISOSring();
         rcend = time.toISOString();


         //API:RecentChanges, Remove Bots and others
         //API:RecentChanges
         api.get({
         api.get({
             format: 'json',
             format: 'json',
Line 63: Line 60:
                 Array.prototype.push.apply(users, usersExt);
                 Array.prototype.push.apply(users, usersExt);


                 // Remove non-unique Usernames
                 // 使用者名稱去重與分割
                 users = $.unique(users.sort());
                 users = $.unique(users.sort());


Line 93: Line 90:
                 }
                 }


                 // Check User Group
                 // 查询用户权限
                 $.when.apply($, promises).done(function () {
                 $.when.apply($, promises).done(function () {
                     // Remove Users without User Group
                     // 消除空值
                     var filter = function(n) {
                     var filter = function(n) {
                         return n;
                         return n;
Line 106: Line 103:
                     var userlink = function(user) {
                     var userlink = function(user) {
                         var user2 = user.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&lt;');
                         var user2 = user.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&lt;');
                         return '<br><a href="/wiki/User:' + user2 + '" target="_blank">' + user2 + '</a>&nbsp;<small style="opacity:.75;">(<a href="/wiki/User talk:' + user2 + '" target="_blank">留言</a>)</small> ';
                         return '<br><a href="/wiki/User:' + user2 + '" target="_blank">' + user2 + '</a>&nbsp;<small style="opacity:.75;">(<a href="/wiki/User talk:' + user2 + '" target="_blank">Talk</a>)</small> ';
                     };
                     };
                      
                      
                     if (admins.length + rollbackers.length + patrollers.length > 0) {
                     if (admins.length + rollbackers.length + patrollers.length > 0) {
                         var adminsstring = ['<p>當前在線管理人員</p>'];
                         var adminsstring = ['<p><b>Current users with advanced rights</b></p>'];


                         if (admins.length > 0) {
                         if (admins.length > 0) {
                             adminsstring.push('<p style="word-break:break-all;">' + admins.length + '個管理員在線:');
                             adminsstring.push('<p style="word-break:break-all;">There are currently ' + admins.length + ' administrators online:');
                             $.each(admins, function(i, e) {
                             $.each(admins, function(i, e) {
                                 adminsstring.push(userlink(e));
                                 adminsstring.push(userlink(e));
Line 121: Line 118:


                         if (patrollers.length > 0) {
                         if (patrollers.length > 0) {
                             adminsstring.push('<p style="word-break:break-all;">' + patrollers.length + '個巡查員在線:');
                             adminsstring.push('<p style="word-break:break-all;">There are currently ' + patrollers.length + ' patrollers online:');
                             $.each(patrollers, function(i, e) {
                             $.each(patrollers, function(i, e) {
                                 adminsstring.push(userlink(e));
                                 adminsstring.push(userlink(e));
Line 129: Line 126:


                         if (rollbackers.length > 0) {
                         if (rollbackers.length > 0) {
                             adminsstring.push('<p style="word-break:break-all;">' + rollbackers.length + '個回退員在線:');
                             adminsstring.push('<p style="word-break:break-all;">There are currently ' + rollbackers.length + ' rollbackers online');
                             $.each(rollbackers, function(i, e) {
                             $.each(rollbackers, function(i, e) {
                                 adminsstring.push(userlink(e));
                                 adminsstring.push(userlink(e));
Line 138: Line 135:
                         mw.notify($(adminsstring.join('')));
                         mw.notify($(adminsstring.join('')));
                     } else {
                     } else {
                         mw.notify('現在沒有管理人員在線');
                         mw.notify('No administrators');
                     }
                     }
                 }).fail(function () {
                 }).fail(function () {
                     mw.notify('查詢時出現錯誤');
                     mw.notify('Error 404 - Connection not found');
                 });
                 });
             });
             });
         });
         });
     });
     });
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu