MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
<div id="p-custom-categorytree" style="padding:10px; border:1px solid #ccc; margin-top:10px;"> | <div id="p-custom-categorytree" style="padding:10px; border:1px solid #ccc; margin-top:10px;"> | ||
<h3>Categories</h3> | <h3>Categories</h3> | ||
< | <div id="categorytree-content">Loading categories...</div> | ||
</div> | </div> | ||
`); | `); | ||
$.ajax({ | |||
url: mw.util.getUrl('api.php', {action:'query'}).replace('index.php', 'api.php'), | |||
data: { | |||
action: 'parse', | |||
page: 'SidebarMenu', | |||
format: 'json' | |||
}, | |||
dataType: 'json', | |||
success: function(data) { | |||
if (data.parse && data.parse.text) { | |||
$('#categorytree-content').html(data.parse.text['*']); | |||
} else { | |||
$('#categorytree-content').html('Failed to load categories.'); | |||
} | |||
}, | |||
error: function() { | |||
$('#categorytree-content').html('Error loading categories.'); | |||
} | |||
}); | |||
}); | }); | ||
Revision as of 17:32, 3 July 2025
$(function () {
$('#p-navigation').append(`
<div id="p-custom-categorytree" style="padding:10px; border:1px solid #ccc; margin-top:10px;">
<h3>Categories</h3>
<div id="categorytree-content">Loading categories...</div>
</div>
`);
$.ajax({
url: mw.util.getUrl('api.php', {action:'query'}).replace('index.php', 'api.php'),
data: {
action: 'parse',
page: 'SidebarMenu',
format: 'json'
},
dataType: 'json',
success: function(data) {
if (data.parse && data.parse.text) {
$('#categorytree-content').html(data.parse.text['*']);
} else {
$('#categorytree-content').html('Failed to load categories.');
}
},
error: function() {
$('#categorytree-content').html('Error loading categories.');
}
});
});