משתמש:Guycn2/PerformanceInfo.js – הבדלי גרסאות
תוכן שנמחק תוכן שנוסף
שיפוצים |
אין תקציר עריכה |
||
(3 גרסאות ביניים של אותו משתמש אינן מוצגות) | |||
שורה 42: | שורה 42: | ||
new mw.Api().get({ |
new mw.Api().get({ |
||
action: 'parse', |
action: 'parse', |
||
text: |
text: JSON.stringify(report, null, '\t'), |
||
prop: 'text', |
prop: 'text', |
||
contentmodel: ' |
//contentmodel: 'javascript' |
||
title: 'מדיה ויקי:Gadget-WLM.json' |
|||
}).done(data => { |
}).done(data => { |
||
container.append(data.parse.text['*']); |
container.append(data.parse.text['*']); |
גרסה מ־09:58, 25 ביולי 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: JSON.stringify(report, null, '\t'),
prop: 'text',
//contentmodel: 'javascript'
title: 'מדיה ויקי:Gadget-WLM.json'
}).done(data => {
container.append(data.parse.text['*']);
OO.ui.alert(container, {title: 'מידע על ביצועי המפענח', size: 'large'}).done(() => {
if (mw.util.getParamValue('performanceInfo') === '1') {
self.close();
}
});
});
});
}
});
});