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
Adding some data for sorting
Damn you, MediaWiki!
 
(26 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><script>
<includeonly><script>
RLQ.push(function () {
RLQ.push(['jquery', function () {
   $(document).ready(function() {
   $(document).ready(function() {
    // initially remove the paragraph
    var parents = $(".mw-headline").closest("h2");
    parents.each(function() {
      var parent = $(this);
      var paragraph = parent.next('p');
      paragraph.replaceWith(paragraph.children());
    }); 
     // For now, we have to make sure the data is there (Change the template, dammit!)
     // For now, we have to make sure the data is there (Change the template, dammit!)
$(".card-bg-small").each(function() {
$(".gfl-doll-card").each(function() {
try {
  var element = $(this);
  var element = $(this);
  var name = element.find('span').first().text();
  var name = element.find('.name').first().text();
  var index = parseInt(element.find('span').last().text());
  var index = parseInt(element.find('.index').last().text());
  var srcStr = element.find("img").eq(2).attr("src");
  var srcStr = element.attr("class");
  var myRegexp = /^.*Icon_(.*)_(.*)star.*$/g;
  var myRegexp = /doll\-rarity\-(.*?) doll\-classification\-(.*?)$/g;
  var match = myRegexp.exec(srcStr);
  var match = myRegexp.exec(srcStr);
  var classification = match[1];
  var classification = match[2];
  var rarity = match[2];
  var rarity = match[1];
         
           var serverDataSpans = $("span.serverdata[data-server-doll='" + name + "']");
           var serverDataSpans = $("span.serverdata[data-server-doll='" + name + "']");
           serverDataSpans.each(function() {
           serverDataSpans.each(function() {
Line 18: Line 25:
             var serverShort = serverDataSpan.attr('data-server-released');
             var serverShort = serverDataSpan.attr('data-server-released');
             var serverDollName = serverDataSpan.attr('data-server-releasename');
             var serverDollName = serverDataSpan.attr('data-server-releasename');
             element.data("data-server-" + serverShort, serverDollName);
             element.attr("data-server-" + serverShort, serverDollName);
           });
           });
           serverDataSpans.remove();
           serverDataSpans.remove();
   
 
  element.attr('data-server-WIKI', name);
  element.data('name', name);
  element.data('name', name);
  element.data('index', index);
  element.data('index', index);
  element.data('classification', classification);
  element.data('classification', classification);
  element.data('rarity', rarity);
  element.data('rarity', rarity);
  }
  catch(error) {
    console.log("Error handling index entry", error);
  }
});
});
      
      
Line 35: Line 47:
     $('.removeAfterInitIsg').remove();
     $('.removeAfterInitIsg').remove();
   });
   });
});
}]);


function orderByName(currentButton) {
function orderByName(currentButton) {
Line 50: Line 62:
   var grouper = function (parent, elements) {
   var grouper = function (parent, elements) {
     var currentLetter = getFirstLetterGroup($(elements).first().data('name'));
     var currentLetter = getFirstLetterGroup($(elements).first().data('name'));
     var groupHeader = $("<h3 />").text(currentLetter.toUpperCase() + "...").addClass("addedbysorter");
     var nativeGroupHeader = document.createElement("h3");
    var groupHeader = $(nativeGroupHeader);
    groupHeader.text(currentLetter.toUpperCase() + "...").addClass("addedbysorter");
     groupHeader.insertBefore(elements.first());
     groupHeader.insertBefore(elements.first());
      
      
Line 59: Line 73:
         var groupHeaderText = nextElementLetter.toUpperCase() + "...";
         var groupHeaderText = nextElementLetter.toUpperCase() + "...";
         if (groupHeaderText.trim() != "...") {
         if (groupHeaderText.trim() != "...") {
           var groupHeader = $("<h3 />").text(groupHeaderText).addClass("addedbysorter");
           var groupHeader = $(document.createElement("h3")).text(groupHeaderText).addClass("addedbysorter");
           groupHeader.insertAfter(element);
           groupHeader.insertAfter(element);
         }
         }
Line 77: Line 91:
   var letter = element.charAt(0);
   var letter = element.charAt(0);
   if (letter >= "0" && letter <= "9") {
   if (letter >= "0" && letter <= "9") {
     letter = "#"
     letter = "#";
   }
   }
   return letter.toLowerCase();
   return letter.toLowerCase();
Line 136: Line 150:
   if (currentKey !== nextElementKey) {
   if (currentKey !== nextElementKey) {
     var groupHeaderText = $(nextElement).data('classification') + " " + getNumberForRarity(nextElement) + "-Star";
     var groupHeaderText = $(nextElement).data('classification') + " " + getNumberForRarity(nextElement) + "-Star";
     var groupHeader = $("<h3 />").text(groupHeaderText).addClass("addedbysorter");
     var groupHeader = $(document.createElement("h3")).text(groupHeaderText).addClass("addedbysorter");
     groupHeader.insertAfter(element1);
     groupHeader.insertAfter(element1);
   }
   }
Line 211: Line 225:
     var firstTen = Math.ceil(parseInt(firstIndex) / 10) * 10;
     var firstTen = Math.ceil(parseInt(firstIndex) / 10) * 10;
     if (sortOrder == -1) { firstTen -= 9; }
     if (sortOrder == -1) { firstTen -= 9; }
     var groupHeader = $("<h3 />").text(getNumberText(firstIndex) + "..." + getNumberText(firstTen)).addClass("addedbysorter");
     var groupHeader = $(document.createElement("h3")).text(getNumberText(firstIndex) + "..." + getNumberText(firstTen)).addClass("addedbysorter");
     groupHeader.insertBefore(elements.first());
     groupHeader.insertBefore(elements.first());
      
      
Line 224: Line 238:
       return true;
       return true;
     });
     });
   }
   };
    
    
   tdollSorter(comparer, grouper);
   tdollSorter(comparer, grouper);
Line 246: Line 260:
       }
       }
        
        
       var groupHeaderText = getNumberText(currentTen) + "..." + getNumberText(nextElementTen);
      var currentIdxShow = currentTen;
      if (sortOrder != -1 && currentIdxShow > 1) currentIdxShow += 1;
       var groupHeaderText = getNumberText(currentIdxShow) + "..." + getNumberText(nextElementTen);
        
        
       var groupHeader = $("<h3 />").text(groupHeaderText).addClass("addedbysorter");
       var groupHeader = $(document.createElement("h3")).text(groupHeaderText).addClass("addedbysorter");
       groupHeader.insertAfter(element);
       groupHeader.insertAfter(element);
     }
     }
Line 255: Line 271:


function tdollSorterActiveButton(butt) {
function tdollSorterActiveButton(butt) {
   var isAscending = $(butt).is('.ascending')
   var isAscending = $(butt).is('.ascending');
   $('[data-tdollsortbutton="true"]').removeClass("enabled").removeClass("ascending");
   $('[data-tdollsortbutton="true"]').removeClass("enabled").removeClass("ascending");
   $(butt).addClass("enabled");
   $(butt).addClass("enabled");
Line 265: Line 281:
     return 1;
     return 1;
   }
   }
}
function switchServer(butt) {
  var activeServer = $(butt).attr('data-tdollserver');
 
  $('[data-tdollserverbutton="true"]').removeClass("enabled");
 
  $('.gfl-doll-card.unreleased').removeClass('unreleased');
  $('.gfl-doll-card').each(function() {
    var element = $(this);
    var nameToSet = "";
    if (element.is("[data-server-" + activeServer + "]")) {
      nameToSet = element.attr('data-server-' + activeServer);
    } else {
      element.addClass('unreleased');
      nameToSet = element.attr('data-server-wiki');
    }
    element.find('.name').first().text(nameToSet);
  });
 
  $(butt).addClass("enabled");
}
}


Line 273: Line 310:
   parents.each(function() {
   parents.each(function() {
     var parent = $(this);
     var parent = $(this);
     var elements = parent.nextUntil("h2", ".card-bg-small");
    // All elements inside the paragraph after the h2 which have special class
     var elements = parent.nextUntil("h2", ".gfl-doll-card");
    
    
     elements.detach().sort(comparer);
     elements.detach().sort(comparer);
Line 290: Line 328:
<button class="gf-button" data-tdollsortbutton="true" disabled onclick="orderByIndex(this);">By Index</button>
<button class="gf-button" data-tdollsortbutton="true" disabled onclick="orderByIndex(this);">By Index</button>
<div style="width:20px; height:20px; display:inline-block;" class="loading2 removeAfterInitIsg">&nbsp;</div></div>
<div style="width:20px; height:20px; display:inline-block;" class="loading2 removeAfterInitIsg">&nbsp;</div></div>
<p>
Released on this server:<br/>
<button class="gf-button" data-tdollserverbutton="true" data-tdollserver="WIKI" disabled data-initialsort="true" onclick="switchServer(this);">All</button>
<button class="gf-button" data-tdollserverbutton="true" data-tdollserver="CN" disabled onclick="switchServer(this);">CN</button>
<button class="gf-button" data-tdollserverbutton="true" data-tdollserver="TW" disabled onclick="switchServer(this);">TW</button>
<button class="gf-button" data-tdollserverbutton="true" data-tdollserver="KR" disabled onclick="switchServer(this);">KR</button>
<button class="gf-button" data-tdollserverbutton="true" data-tdollserver="EN" disabled onclick="switchServer(this);">EN</button>
<button class="gf-button" data-tdollserverbutton="true" data-tdollserver="JP" disabled onclick="switchServer(this);">JP</button>
</p>
</includeonly>
</includeonly>



Latest revision as of 00:40, 27 July 2024


 

Released on this server:

Some heading