MediaWiki:AFC-submit-wizard.js: Difference between revisions

Content deleted Content added
update
No edit summary
Line 26:
}
 
var apiapiOptions = new mw.Api({
parameters: {
format: 'json',
Line 36:
}
}
});
 
// Two different API objects so that aborts on the lookupApi don't stop the final
// evaluate process
var lookupApi = new mw.Api(apiOptions),
submitApi = new mw.Api(apiOptions);
 
var draftLayout, talkTagsLayout, shortdescLayout, isBLPLayout, isCompanyLayout, topicsLayout, submitLayout, draftInput, talkTagsInput, shortdescInput, isBLPInput, isCompanyInput, topicsInput, submitButton, mainStatusLayout, mainStatusArea, talkStatusLayout, talkStatusArea;
 
 
// global
Line 52 ⟶ 56:
value: mw.util.getParamValue('draft').replace(/_/g, ' '),
placeholder: 'Enter the draft title, begins with "Draft:" or "User:"'
// }), {
}).on('change', onDraftInputChange), {
label: 'Draft title',
align: 'top',
Line 155 ⟶ 159:
 
function onDraftInputChange() {
// apilookupApi.abort(); // abort older API requests
 
if (!draftInput.getValue().trim()) { // empty
return;
}
// api.abort(); // abort older API requests
 
console.log('draft input changed: "' + draftInput.getValue() + '"');
Line 169 ⟶ 174:
pagetext = null;
 
apilookupApi.get({
"action": "query",
"prop": "revisions|description|info",
Line 180 ⟶ 185:
var preNormalizedTitle = json.query.normalized && json.query.normalized[0] &&
json.query.normalized[0].from;
console.log('draftInput.value: "' + draftInput.getValue() + '"');
console.log('preNormalizedTitle: "' + preNormalizedTitle + '"');
console.log('page.title: "' + page.title + '"');
if (draftInput.getValue() !== (preNormalizedTitle || page.title)) {
Line 199 ⟶ 202:
if (!/<ref>/.test(pagetext) && !/\{\{[Ss]fn\}\}/.test(pagetext)) {
draftLayout.setWarnings([
new OO.ui.HtmlSnippet('YourThis draft doesn\'t appear to contain any references. Please add references, without this it will almost certainly be declined. See <a href="/wiki/Help:Introduction_to_referencing_with_Wiki_Markup/2" target="_blank">help on adding references</a>.')
]);
}
Line 214 ⟶ 217:
console.log('ORES topics: ', topics);
if (!topics || !topics.length) { // unexpected API response or API returns unsorted
// if (!topicsLayout || !topicsLayout.isElementAttached()) {
// createOresTopicSelectionMenu();
// }
topicsLayout.toggle(true);
} else {
// if (topicsLayout && topicsLayout.isElementAttached()) {
// fieldset.removeItems([topicsLayout]);
// }
topicsLayout.toggle(false);
oresTopics = topics;
}
}, function() {
// if (!topicsLayout || !topicsLayout.isElementAttached()) {
// createOresTopicSelectionMenu();
// }
topicsLayout.toggle(true);
});
Line 241 ⟶ 235:
var talkpagename = talk.getTalkPage().toText();
console.log(talkpagename);
apilookupApi.get({
"action": "query",
"prop": "revisions",
Line 307 ⟶ 301:
});
}
 
// function createOresTopicSelectionMenu() {
// // create menu for user to make the selections
// fieldset.addItems([
// ], /* insertion point */ 5);
// }
 
function extractWikiProjectTagsFromText(text) {
Line 349 ⟶ 336:
console.log(isBLPInput.getValue());
 
apisubmitApi.get({
"action": "query",
"prop": "revisions",
Line 404 ⟶ 391:
 
// saving draft page
apisubmitApi.postWithEditToken({
"action": "edit",
"title": draft,
Line 454 ⟶ 441:
talktext = tagsToAddText + (talktext || '');
 
apisubmitApi.postWithEditToken({
"action": "edit",
"title": new mw.Title(draft).getTalkPage().toText(),