Pengguna:Kenrick95/online.js: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
kTidak ada ringkasan suntingan |
Tidak ada ringkasan suntingan |
||
(3 revisi perantara oleh 2 pengguna tidak ditampilkan) | |||
Baris 10:
* - see which admin is listed on RCFeed, report to a list, show as "apparently online"
*/
mw.loader.using("mediawiki.util", function
function apparentlyOnline() {
var online_sysops = [], online_sysops_msg = "Tidak ada", last_seen = [];
var window_msg_data = null;
function loadNow() {
mw.loader.using("mediawiki.api", function () {
var api = new mw.Api();
var i;
api.get({
list: "allusers|recentchanges",
format: "json",
rclimit: 500,
rcprop: "user|userid|timestamp",
rcshow: "!bot|!anon",
augroup: "sysop",
aulimit: 500
})
.done(function (data) {
// console.log(data);
var sysops = data.query.allusers;
var is_sysop = {};
for (i = 0; i < sysops.length; i++) {
}
for (i = 0; i < rc.length; i++) {
if (is_sysop[rc[i].userid]) {
if (online_sysops.indexOf(rc[i].user) < 0) {
online_sysops.push(rc[i].user);
last_seen.push(rc[i].timestamp);
}
}
}
// console.log(online_sysops);
online_sysops_msg = "";
if (online_sysops.length === 0) {
online_sysops_msg = "Tidak ada";
}
for (i = 0; i < online_sysops.length; i++) {
var time = new Date(last_seen[i]);
online_sysops_msg += "<li><a href=\"" + mw.config.get("wgServer") + "/wiki/User:" + online_sysops[i] + "\">"
+
+
+
window_msg_data = {
title: 'Pengurus daring',
message: new OO.ui.HtmlSnippet("<div style=\"text-align:left;\">"
+ "Pengurus yang daring berdasarkan 500 suntingan terakhir di perubahan terbaru:"
+ "<br>" + online_sysops_msg + "</div> "),
actions: [
{
action: 'accept',
label: 'Tutup',
flags: 'primary'
}
]
};
windowManager.openWindow(messageDialog, window_msg_data);
});
});
}
var link = mw.util.addPortletLink(
'p-cactions', //p-cactions, p-tb, p-views
'#',
'Pengurus daring',
't-prettylinkwidget',
'Perlihatkan daftar pengurus yang daring',
null,
'#t-whatlinkshere'
);
mw.loader.using('oojs-ui', function() {
messageDialog = new OO.ui.MessageDialog();
windowManager = new OO.ui.WindowManager();
$( 'body' ).append( windowManager.$element );
windowManager.addWindows( [ messageDialog ] );
messageDialog.setSize("large");
});
$(link).click(function (e) {
e.preventDefault();
online_sysops_msg = "Memuat...";
loadNow();
});
}
$(apparentlyOnline);
});
|