Jump to content

MediaWiki:Common.js: Difference between revisions

From Event Gates Wiki
No edit summary
No edit summary
Line 1: Line 1:
$(function () {
$.ajax({
  $('#p-navigation').append(`
  url: mw.util.wikiScript('api'),
    <div id="p-custom-categorytree" style="padding:10px; border:1px solid #ccc; margin-top:10px;">
  data: {
      <h3>Categories</h3>
    action: 'parse',
      <div id="categorytree-content">Loading categories...</div>
    page: 'SidebarMenu',
    </div>
    format: 'json'
  `);
  },
 
  dataType: 'json',
  $.ajax({
  success: function(data) {
    url: mw.util.getUrl('api.php', {action:'query'}).replace('index.php', 'api.php'),
    console.log('API parse response:', data);
    data: {
    if (data.parse && data.parse.text) {
      action: 'parse',
      $('#categorytree-content').html(data.parse.text['*']);
      page: 'SidebarMenu',
    } else {
      format: 'json'
      $('#categorytree-content').html('Failed to load categories.');
    },
    dataType: 'json',
    success: function(data) {
      console.log('API parse response:', data); // <-- Debug output here
      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.');
     }
     }
   });
   },
  error: function() {
    $('#categorytree-content').html('Error loading categories.');
  }
});
});

Revision as of 17:37, 3 July 2025

$.ajax({
  url: mw.util.wikiScript('api'),
  data: {
    action: 'parse',
    page: 'SidebarMenu',
    format: 'json'
  },
  dataType: 'json',
  success: function(data) {
    console.log('API parse response:', 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.');
  }
});