Content deleted Content added
outlink-topic-model |
Sync with sandbox |
||
Line 6:
( function ( $, mw ) { mw.loader.using( ["mediawiki.api", "jquery.chosen", "oojs-ui-core"], function () {
mw.loader.load( "mediawiki.ui.input", "text/css" );
var api = new mw.Api();
if ( mw.config.get( "wgNamespaceNumber" ) !== 118 ) {
Line 74 ⟶ 75:
var wikiprojects = {};
action: "query",
titles: "Draft talk:" + mw.config.get( "wgTitle" ),
Line 117 ⟶ 118:
try {
listData = await
} catch (jsonerror) {
console.warn("Unable to fetch contents of " + listName + ":");
Line 146 ⟶ 147:
$( "#draft-sorter-status" ).append( "<li>Suggested categories from <a href=\"https://www.mediawiki.org/wiki/ORES#Topic_routing\">ORES</a>:<ul id=\"draft-sorter-suggest\"></ul></li>" );
predicts.forEach( function(item) {
function addWithLink(p) {
.text("add")▼
$( "<li>" ).
$(
$( select ).val().concat( [ "WikiProject " + item ] )▼
$( select ).val( ▼
).trigger("chosen:updated");▼
} );▼
▲ ).trigger("chosen:updated");
)
var singularItem = item.replace(/s$/, '');
if( !existingProjects.includes( "WikiProject " + item )
&& wikiprojects[item]
) { //Prediction matches a WikiProject and doesn't already exist
addWithLink(item);
▲ $( "#draft-sorter-suggest" ).append( $( "<li>" )
▲ );
} else if( singularItem != item
&& !existingProjects.includes( "WikiProject " + singularItem )
&& wikiprojects[singularItem]
) { //Singular form of prediction matches a WikiProject and doesn't exist
▲ addLink.click( function() {
▲ $( select ).val(
▲ } );
▲ .append( singularItem + " (" )
▲ );
} else { //Prediction doesn't match a WikiProject or already exists
$( "#draft-sorter-suggest" ).append(
Line 359 ⟶ 354:
params[prefix + "text"] = text;
if ( data && data.edit && data.edit.result && data.edit.result === "Success" ) {
showStatus( "Edit saved successfully! (" )
Line 382 ⟶ 377:
}
action: "query",
titles: "Draft talk:" + mw.config.get( 'wgTitle' ),
|