MediaWiki:AFC-submit-wizard.js: Difference between revisions
Content deleted Content added
update |
No edit summary |
||
Line 26:
}
var
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:"'
label: 'Draft title',
align: 'top',
Line 155 ⟶ 159:
function onDraftInputChange() {
if (!draftInput.getValue().trim()) { // empty
return;
}
▲ // api.abort(); // abort older API requests
console.log('draft input changed: "' + draftInput.getValue() + '"');
Line 169 ⟶ 174:
pagetext = null;
"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('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('
]);
}
Line 214 ⟶ 217:
console.log('ORES topics: ', topics);
if (!topics || !topics.length) { // unexpected API response or API returns unsorted
topicsLayout.toggle(true);
} else {
topicsLayout.toggle(false);
oresTopics = topics;
}
}, function() {
▲ // }
topicsLayout.toggle(true);
});
Line 241 ⟶ 235:
var talkpagename = talk.getTalkPage().toText();
console.log(talkpagename);
"action": "query",
"prop": "revisions",
Line 307 ⟶ 301:
});
}
function extractWikiProjectTagsFromText(text) {
Line 349 ⟶ 336:
console.log(isBLPInput.getValue());
"action": "query",
"prop": "revisions",
Line 404 ⟶ 391:
// saving draft page
"action": "edit",
"title": draft,
Line 454 ⟶ 441:
talktext = tagsToAddText + (talktext || '');
"action": "edit",
"title": new mw.Title(draft).getTalkPage().toText(),
|