(function() {
'use strict';
var button = $('<button class="oo-ui-buttonElement-button">Apply PST</button>');
button.click(function(e) {
button.prop('disabled', true);
var wpTextbox1 = $('#wpTextbox1');
wpTextbox1.prop('disabled', true);
var val = wpTextbox1.val();
wpTextbox1.val('Please wait. PST in progress');
new mw.Api().post({
action: 'parse',
title: mw.config.get('wgPageName'),
text: val,
prop: 'text',
onlypst: true
}).done(function(data) {
wpTextbox1.val(data.parse.text['*']);
}).fail(function() {
console.log.apply(console, arguments);
alert('PST failed. Technical details have been logged to the console.');
wpTextbox1.val(val);
}).always(function() {
wpTextbox1.prop('disabled', false);
button.prop('disabled', false);
});
e.preventDefault();
});
var span = $('<span class="oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement"></span>');
span.append(button);
$('#wpDiffWidget').after(' ', span);
})();