site/includes/modules.js
/**
 * 
 * @param {string} url The url to get the categories in JSON format.
 */
@param {string} url The url to get the categories in JSON format.
@param { string } url The url to get the categories in JSON format .
function loadCategories(url) {
  $.ajax({ url }).done(function(data) {
    let pos = 0
    for (const category of data.module_categories || []) {
      $("#browse").append(`<h2 class="categoryTitle">${category.title} <span class="categoryLengthText">(0)</span></h2><div class="categoryBar track resizable"><div class="trackContainer"></div><div class="trackButton trackButtonLeft"></div><div class="trackButton trackButtonRight"></div></div>`);
      if (category.populate_from) {
        $.ajax({url: category.populate_from, pos, limit: category.limit }).done(function(data) {
          const modules = JSON.parse(data).slice(0, this.limit)
          populateCategory(this.pos, modules);
          initTrack($('#browse .categoryBar').eq(this.pos), 0)
        });
      } else {
        if(category.order === "shuffled"){
          category.modules = shuffleArray(category.modules);
        } else if (typeof category.order == "object" && category.order.mode === "shuffled") {
          category.modules = shuffleArray(category.modules, category.order.from);
        }
        populateCategory(pos, category.modules);
        initTrack($('#browse .categoryBar').eq(pos), 0)
      }
      pos += 1
    }
  });
}
function loadCategories ( url ) { $ . ajax ( { url } ) . done ( function ( data ) { let pos = 0 for ( const category of data . module_categories || [ ] ) { $ ( "#browse" ) . append ( ` ${ category . title } ` ) ; if ( category . populate_from ) { $ . ajax ( { url : category . populate_from , pos , limit : category . limit } ) . done ( function ( data ) { const modules = JSON . parse ( data ) . slice ( 0 , this . limit ) populateCategory ( this . pos , modules ) ; initTrack ( $ ( '#browse .categoryBar' ) . eq ( this . pos ) , 0 ) } ) ; } else { if ( category . order === "shuffled" ) { category . modules = shuffleArray ( category . modules ) ; } else if ( typeof category . order == "object" && category . order . mode === "shuffled" ) { category . modules = shuffleArray ( category . modules , category . order . from ) ; } populateCategory ( pos , category . modules ) ; initTrack ( $ ( '#browse .categoryBar' ) . eq ( pos ) , 0 ) } pos += 1 } } ) ; }
@param {string} url The url to get the categories in JSON format.
@param { string } url The url to get the categories in JSON format .