User:Cmg/onedi.js

function apparentlyOnline { var online_sysops = [], online_sysops_msg = "Tidak ada", last_seen = []; function loadNow { mw.loader.using("mediawiki.api", function {			var api = new mw.Api;			api.get({ action: "query", list: "allusers|recentchanges", format: "json", rclimit: 1000, rcprop: "user|userid|timestamp", rcshow: "!bot|!anon", augroup: "editor", aulimit: 1000 })			.done(function (data) { // console.log(data); var rc = data.query.recentchanges; var sysops = data.query.allusers; var is_sysop = {}; for (var i = 0; i < sysops.length; i++) { is_sysop[sysops[i].userid] = true; }				for (var 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 (var i = 0; i < online_sysops.length; i++) { var time = new Date(last_seen[i]); online_sysops_msg += "" + online_sysops[i] + " (aktivitas terakhir: "						+ time.toLocaleString						+ ")"; }				document.getElementById("online_sysops_msg").innerHTML = online_sysops_msg; });		});	}	var link = mw.util.addPortletLink(		'p-cactions', //p-cactions, p-tb, p-views		'#',		'Editor yang aktif',		't-prettylinkwidget',		'Perlihatkan daftar pengurus yang aktif',		null,		'#t-whatlinkshere'	); mw.loader.using('jquery.ui', function {		$dialog = $(" ")			.html("Editor yang aktif berdasarkan 1000 suntingan terakhir di perubahan terbaru:" + " " + online_sysops_msg + " ")			.dialog({ autoOpen: false, title: "Editor Aktif", width: '500px', modal: true });	});	$(link).click(function (e) {		e.preventDefault;		online_sysops_msg = "Memuat...";		loadNow;		$dialog.dialog("open");	}); }

$(apparentlyOnline);