Note: After saving, you have to
bypass your browser's cache to see the changes.
Internet Explorer: press
Ctrl-F5 ,
Mozilla: hold down
Shift while clicking
Reload (or press
Ctrl-Shift-R ),
Opera/Konqueror: press
F5 ,
Safari: hold down
Shift + Alt while clicking
Reload ,
Chrome: hold down
Shift while clicking
Reload .
function createsubcat () {
let catname = mw . config . get ( 'wgPageName' ) ;
let subcatname = document . getElementById ( "SubCatName" ). value ;
let subcatdesc_de = document . getElementById ( "DescriptionDE" ). value ;
let subcatdesc_en = document . getElementById ( "DescriptionEN" ). value ;
let text = "[[" + catname + "]]" ;
if ( subcatdesc_en !== "" )
text = "{{en|" + subcatdesc_en + "}}\n\n" + text ;
if ( subcatdesc_de !== "" )
text = "{{de|" + subcatdesc_de + "}}\n\n" + text ;
var api = new mw . Api ();
api . postWithToken ( "edit" , {
action : "edit" ,
title : "Category:" + subcatname ,
summary : "Created new Category" ,
text : text
} ). done ( function ( result , jqXHR ) {
mw . log ( "Saved successfully" );
location . reload ();
} ). fail ( function ( code , result ) {
if ( code === "http" ) {
mw . log ( "HTTP error: " + result . textStatus ); // result.xhr contains the jqXHR object
} else if ( code === "ok-but-empty" ) {
mw . log ( "Got an empty response from the server" );
} else {
mw . log ( "API error: " + code );
}
} );
$ ( "#createsubcat" ). dialog ( "close" );
}
if ( ( mw . config . get ( 'wgNamespaceNumber' ) === 14 ) && ( mw . config . get ( 'wgAction' ) == "view" ) ) $ (
function CreateSubCatMain () {
$ ( "body" ). append ( `
<div style="display:none" title="Unterkategorie anlegen" id="createsubcat">
<form id="subcatform" action="">
<div class="form-group">
<label for="SubCatName">Name der Unterkategorie:</label>
<div>
<input id="SubCatName" name="SubCatName" type="text">
</div>
</div>
<div class="form-group">
<label for="DescriptionEN">Description (en):</label>
<div>
<input id="DescriptionEN" name="DescriptionEN" type="text">
</div>
</div>
<div class="form-group">
<label for="DescriptionDE">Description (de):</label>
<div>
<input id="DescriptionDE" name="DescriptionDE" type="text">
</div>
</div>
</form>
<button onclick="createsubcat()">Unterkategorie anlegen</button>
</div>` );
// Button to create a sub-category
$ ( "#contentSub" ). append ( '<button onclick="$( \'#createsubcat\' ).dialog()">Unterkategorie anlegen</button>' );
});