MediaWiki:Diag.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at MediaWiki:Diag. |
/**
**
** JavaScript tool to ease problem diagnostics
** @author Rillke, 2011
**
**/
/*global jQuery:false, mediaWiki:false, VisualFileChange:false*/
/*jshint curly:false*/
(function(mw, $) {
'use strict';
$('#ComDiag').hide();
window.comDiag = { out: '', $out: null, alogl: null };
var $d = window.comDiag.$out = $('<pre>', {text: '<pre>'});
var alogl = window.comDiag.alogl = function(text, html) {
window.comDiag.out += text + '\n';
if (html) $d.append(text + '<br>');
else $d.append($('<div>', {text: text}));
};
alogl('Commons Troubleshooter v.0.2');
alogl('------------------------------');
alogl('---- NAVIGATOR ----');
alogl('userAgent: ' + navigator.userAgent);
var c = jQuery.client.profile();
mw.loader.using('jquery.client', function() {
alogl('---- CLIENT ----');
alogl('clientn: ' + c.name);
alogl('clientv: ' + c.version);
});
alogl('skin: ' + mw.config.get('skin'));
mw.loader.using('mediawiki.user', function() {
alogl('---- USER OPTIONS ----');
alogl(' ---- GADGETS ----');
$.each(mw.user.options.get(), function(key, val) {
if (/^gadget\-/.test(key)) alogl(' ' + key.replace(/^gadget\-/, '') + ' ->' + ((val-0) === 1 ? "on" : "off") + ' -->' + mw.loader.getState('ext.gadget.' + key.replace(/^gadget\-/, '')));
});
alogl('edit-cols: ' + mw.user.options.get('cols'));
alogl('edit-rows: ' + mw.user.options.get('rows'));
alogl('imagesize: ' + mw.user.options.get('imagesize'));
alogl('thumbsize: ' + mw.user.options.get('thumbsize'));
alogl('beta toolbar: ' + mw.user.options.get('usebetatoolbar'));
alogl('usebetatoolbar-cgd: ' + mw.user.options.get('usebetatoolbar-cgd'));
alogl('usebetatoolbar-cgd: ' + mw.user.options.get('usebetatoolbar-cgd'));
alogl('wikilove-enabled: ' + mw.user.options.get('wikilove-enabled'));
alogl('lang: ' + mw.user.options.get('language'));
});
alogl('---- COMMONS SPECIFIC ----');
var ait = function() {
alogl(' ---- AJAX INLINE TRANSLATION ----');
alogl(' AjaxTranslations: ' + typeof mw.libs.AjaxTranslations);
if (mw.libs.AjaxTranslations) alogl(' State: ' + mw.libs.AjaxTranslations.state);
};
$(ait);
alogl(' ---- AJAX QUICK DELETE ----');
alogl(' AQD: ' + typeof AjaxQuickDelete);
alogl(' AQD-ExtraButtons: ' + typeof AjaxDeleteExtraButtons);
alogl(' AQD-WatchUser: ' + typeof AjaxDeleteWatchUserTalk);
alogl(' AQD-AjaxDeleteWatchFile: ' + typeof AjaxDeleteWatchFile);
alogl(' AQD-AjaxDeleteOptOut: ' + typeof AjaxDeleteOptOut);
alogl(' ---- USER MESSAGES ----');
alogl(' PreSelect: ' + typeof AxUserMsgPreSelect);
alogl(' PreSelectIP: ' + typeof AxUserMsgPreSelectIP);
alogl(' installOldLinks: ' + typeof installOldLinks);
alogl(' fireAsYouClick: ' + typeof AxUserMsgFireAsYouClick);
alogl(' customText: ' + typeof AxUserMsgCustomText);
alogl(' noParse: ' + typeof AxUserMsgNoParse);
alogl(' maxSelect: ' + typeof AxUserMsgMaxSelect);
alogl(' ---- VISUAL FILE CHANGE ----');
alogl(' VFC: ' + typeof VisualFileChange);
if (window.VisualFileChange) {
alogl(' VFC display: ' + typeof VisualFileChange.displayComponents);
alogl(' VFC edit: ' + typeof VisualFileChange.editComponents);
alogl(' VFC config: ' + typeof VisualFileChange.configManager);
}
alogl(' VFC custom settings: ' + typeof vFCSettings);
if (window.AjaxMassDeleteInterval) alogl(' VFC old setting loadBatchSize detected. Please upgrade your settings using the settings wizard! Value is: ' + window.AjaxMassDeleteInterval);
if (window.AjaxMassDeleteUserNote) alogl(' VFC old setting UserNote detected. Please upgrade your settings using the settings wizard! Value is: ' + typeof AjaxMassDeleteUserNote);
alogl('---- RL MODULES ----');
$.each(mw.loader.getModuleNames(), function(i, n) {
if (n === 'ext.narayam') alogl('Naryiam clutters the module definitions! Sorry, this is nothing you can change!');
alogl(n + ': ' + mw.loader.getState(n));
});
var l, a = [], o = {};
for (l in a) {
if (!a.hasOwnProperty(l)) alogl('Array protype :' + l);
}
for (l in o) {
if (!o.hasOwnProperty(l)) alogl('Object protype :' + l);
}
var didAppend = false;
$(function() {
$('.mw-body, #mw-content-text').first().append($d.append(mw.html.escape('</pre>')));
didAppend = true;
});
setTimeout(function() {
if (!didAppend) $('#bodyContent').append($d.append(mw.html.escape('</pre>')));
}, 7000);
$(document).triggerHandler('scriptLoaded', ['Diag', window.comDiag]);
})(mediaWiki, jQuery);