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/sandbox: 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
More debugging
Adding functions step by step
Line 55: Line 55:
   });
   });
}]);
}]);
function orderByName(currentButton) {
  var sortOrder = tdollSorterActiveButton(currentButton);
 
  var comparer = function (a, b) {
    var nameA=$(a).data('name').toLowerCase();
    var nameB=$(b).data('name').toLowerCase();
    if (nameA < nameB) return -1 * sortOrder;
    if (nameA > nameB) return 1 * sortOrder;
    return 0;
  };
 
  var grouper = function (parent, elements) {
    var currentLetter = getFirstLetterGroup($(elements).first().data('name'));
    var groupHeader = $("<h3><span class="mw-headline" id="Some_heading">").text(currentLetter.toUpperCase() + "...").addClass("addedbysorter");
    groupHeader.insertBefore(elements.first());
   
    $.grep(elements, function(element, i) {
      var currentLetter = getFirstLetterGroup($(element).data('name'));
      var nextElementLetter = getFirstLetterGroup($(elements[i+1]).data('name'));
      if (currentLetter !== nextElementLetter) {
        var groupHeaderText = nextElementLetter.toUpperCase() + "...";
        if (groupHeaderText.trim() != "...") {
          var groupHeader = $("<h3 />").text(groupHeaderText).addClass("addedbysorter");
          groupHeader.insertAfter(element);
        }
      }
      return true;
    });
  };
 
  tdollSorter(comparer, grouper);
}
function getFirstLetterGroup(element) {
  if (!element || element == null) {
    return " ";
  }
 
  var letter = element.charAt(0);
  if (letter >= "0" && letter <= "9") {
    letter = "#";
  }
  return letter.toLowerCase();
}
</script><div style="display:inline-block">
</script><div style="display:inline-block">
<button class="gf-button" data-tdollsortbutton="true" disabled data-initialsort="true" onclick="orderByClassRarityName(this);">By Class&gt;Rarity&gt;Name</button>
<button class="gf-button" data-tdollsortbutton="true" disabled data-initialsort="true" onclick="orderByClassRarityName(this);">By Class&gt;Rarity&gt;Name</button>

Revision as of 00:21, 27 July 2024


 

Released on this server:

Some heading