משתמש:Guycn2/PerformanceInfo.js – הבדלי גרסאות
תוכן שנמחק תוכן שנוסף
אין תקציר עריכה |
אין תקציר עריכה |
||
שורה 37: | שורה 37: | ||
function showPerformanceInfo() { |
function showPerformanceInfo() { |
||
mw.loader.load('mediawiki.content.json'); |
|||
mw.loader.using(['mediawiki.api', 'oojs-ui-windows']).then(function () { |
mw.loader.using(['mediawiki.api', 'oojs-ui-windows']).then(function () { |
||
var report = mw.config.get('wgPageParseReport'), |
var report = mw.config.get('wgPageParseReport'), |
||
container = $('<div>').css({'text-align': 'left', 'direction': 'ltr'}); |
container = $('<div>').css({'text-align': 'left', 'direction': 'ltr', 'font-size': '90%'}); |
||
new mw.Api().get({ |
new mw.Api().get({ |
||
action: 'parse', |
action: 'parse', |
||
text: JSON.stringify(report, null, '\t'), |
text: '<syntaxhighlight lang="json">' + JSON.stringify(report, null, '\t') + '</syntaxhighlight>', |
||
prop: 'text', |
prop: 'text', |
||
title: mw.config.get('wgPageName') |
|||
contentmodel: 'json' |
|||
}).done(data => { |
}).done(data => { |
||
container.append(data.parse.text['*']); |
container.append(data.parse.text['*']); |
גרסה מ־21:59, 26 ביולי 2018
/*
הוספת כפתור בתיבת הכלים להצגת מידע על ביצועי המפענח
*/
$(function () {
'use strict';
if (
!mw.config.get('wgArticleId') || // wgPageParseReport returns null on non-existing pages
!$('#t-info').length // Same goes for pages where there is no "Page information" link, e.g. special pages
) {
return;
}
mw.loader.using('mediawiki.util').then(function () {
mw.util.addPortletLink('p-tb', null, 'מידע על ביצועי המפענח', 't-performance_info', 'הצגת מידע על ביצועי המפענח', null, '#t-info')
.onclick = initialization;
function initialization() {
if (mw.config.get('wgAction') === 'view') {
showPerformanceInfo();
}
else {
// Unfortunately, wgPageParseReport returns null when not in view mode,
// and thus we should first open the page in view mode to be able to retrieve the relevant information
window.open(mw.util.getUrl(mw.config.get('wgPageName'), {performanceInfo: '1'}));
}
}
if (mw.util.getParamValue('performanceInfo') === '1') {
showPerformanceInfo();
}
function showPerformanceInfo() {
mw.loader.using(['mediawiki.api', 'oojs-ui-windows']).then(function () {
var report = mw.config.get('wgPageParseReport'),
container = $('<div>').css({'text-align': 'left', 'direction': 'ltr', 'font-size': '90%'});
new mw.Api().get({
action: 'parse',
text: '<syntaxhighlight lang="json">' + JSON.stringify(report, null, '\t') + '</syntaxhighlight>',
prop: 'text',
title: mw.config.get('wgPageName')
}).done(data => {
container.append(data.parse.text['*']);
OO.ui.alert(container, {title: 'מידע על ביצועי המפענח', size: 'large'}).done(() => {
if (mw.util.getParamValue('performanceInfo') === '1') {
self.close();
}
});
});
});
}
});
});