site/includes/modules.js
/**
 * Populate the category once the cards are loaded.
 * In most cases this is instant but some may need to
 * Load external source data first.
 * @param {number} pos The index of the category
 * @param {string} modules The list of modules corresponding to this category
 */
Populate the category once the cards are loaded.
In most cases this is instant but some may need to
Load external source data first.
@param {number} pos The index of the category
@param {string} modules The list of modules corresponding to this category
Populate the category once the cards are loaded . In most cases this is instant but some may need to Load external source data first . @param { number } pos The index of the category @param { string } modules The list of modules corresponding to this category
function populateCategory(pos, modules) {
  const track = $("#browse .trackContainer").eq(pos);
  cards = "";
  for(j=0;j<modules.length;j++){
    cards += `<div class="trackItem moduleCard noselect" data-module_id="${modules[j]}"><img width="100%" height="100%" src="${get_module_icon(modules[j])}" onerror="image_error(this)" alt="${modules[j].replace(/_/g, " ")} icon"><span class="cardName">${modules[j].replace(/_/g, " ")}</span></div>`;
  }
  track.html(cards);
  track.append('<div class="trackItem moduleCard trackEndItem noselect"><img width="100%" height="100%" src="/images/enderpuff_by_qbert.png" title="End of results. Artwork by Qbert" alt="End of data pack results"/><span class="cardName">You\'ve reached the end</span></div>');
  $(".categoryLengthText").eq(pos).html(`(${modules.length})`);
  track.find(".moduleCard").each(function(){
    this.addEventListener("click",function(){
      if($(this).attr("data-module_id")!=undefined){
        if ($(this).hasClass('selected')) {
          $(this).removeClass('selected');
          $('#browse .preview').remove();
        } else {
          $('.selected').removeClass('selected');
          $(this).addClass('selected');
          loadPreview($(this).parent().parent(), $(this).attr("data-module_id"));
        }
      }
    },{passive:true});
  });
}
function populateCategory ( pos , modules ) { const track = $ ( "#browse .trackContainer" ) . eq ( pos ) ; cards = "" ; for ( j = 0 ; j < modules . length ; j ++ ) { cards += ` ${ modules [ j ] } ${ get_module_icon ( modules [ j ] ) } ${ modules [ j ] . replace ( / _ / g , " " ) } ${ modules [ j ] . replace ( / _ / g , " " ) } ` ; } track . html ( cards ) ; track . append ( '<div class="trackItem moduleCard trackEndItem noselect"><img width="100%" height="100%" src="/images/enderpuff_by_qbert.png" title="End of results. Artwork by Qbert" alt="End of data pack results"/><span class="cardName">You\'ve reached the end</span></div>' ) ; $ ( ".categoryLengthText" ) . eq ( pos ) . html ( ` ${ modules . length } ` ) ; track . find ( ".moduleCard" ) . each ( function ( ) { this . addEventListener ( "click" , function ( ) { if ( $ ( this ) . attr ( "data-module_id" ) != undefined ) { if ( $ ( this ) . hasClass ( 'selected' ) ) { $ ( this ) . removeClass ( 'selected' ) ; $ ( '#browse .preview' ) . remove ( ) ; } else { $ ( '.selected' ) . removeClass ( 'selected' ) ; $ ( this ) . addClass ( 'selected' ) ; loadPreview ( $ ( this ) . parent ( ) . parent ( ) , $ ( this ) . attr ( "data-module_id" ) ) ; } } } , { passive : true } ) ; } ) ; }
Populate the category once the cards are loaded.
Populate the category once the cards are loaded .
//add listeners