Welcome to IOPWiki, Commander.
We are searching for new editors to keep track of Girls' Frontline 2 content, as well as veteran players to complete existing Girls' Frontline and Project Neural Cloud articles.
You can contribute without an account. Learn how to contribute and join our Discord server.

Widget:indexSorterGrouper: Difference between revisions

Welcome to IOP Wiki. This website is maintained by the Girls' Frontline community and is free to edit by anyone.
Jump to navigation Jump to search
m Fixed initial sort bug
Added grouping for class/rarity
Line 83: Line 83:
     };
     };
    
    
   tdollSorter(comparer);
  var grouper = getClassAndRarityGrouper();
 
   tdollSorter(comparer, grouper);
}
}


Line 95: Line 97:
     };
     };
    
    
   tdollSorter(comparer);
  var grouper = getClassAndRarityGrouper();
 
   tdollSorter(comparer, grouper );
}
 
function getClassAndRarityGrouper() {
  var grouper = function (parent, elements) {
    createClassRarityGroup(parent, elements.first());
   
    $.grep(elements, function(element, i) {
      if (elements.length <= i+1) {
        return true;
      }
      var nextElement = elements[i+1];
     
      createClassRarityGroup($(element), nextElement);
     
      return true;
    });
  };
  return grouper;
}
 
function createClassRarityGroup(element1, nextElement) {
  var currentKey = getSortKeyForClassRarityName(element1, true);
  var nextElementKey = getSortKeyForClassRarityName(nextElement, true);
 
  if (currentKey !== nextElementKey) {
    var linebreaker = $("<br />").addClass("addedbysorter");
    linebreaker.insertAfter(element1);
   
    var groupHeaderText = $(nextElement).data('classification') + " " + getNumberForRarity(nextElement) + "-Star";
    var groupHeader = $("<h3 />").text(groupHeaderText).addClass("addedbysorter");
    groupHeader.insertAfter(linebreaker);
  }
}
}


function getSortKeyForClassRarityName(element) {
function getSortKeyForClassRarityName(element, withoutName) {
   var classification = getNumberForClassification(element);
   var classification = getNumberForClassification(element);
   var rarity = getNumberForRarity(element);
   var rarity = getNumberForRarity(element);
   var name = $(element).data('name');
   var name = $(element).data('name');
   return classification + "_" + rarity + "_" + name;
   return classification + "_" + rarity + (withoutName ? "" : ("_" + name));
}
}



Revision as of 17:09, 1 May 2018


 

Released on this server:

Some heading