Widget:indexSorterGrouper: Difference between revisions
Jump to navigation
Jump to search
Changed class name |
Damn you, MediaWiki! |
||
(8 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
var paragraph = parent.next('p'); | var paragraph = parent.next('p'); | ||
paragraph.replaceWith(paragraph.children()); | 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!) | ||
$(".gfl-doll-card").each(function() { | $(".gfl-doll-card").each(function() { | ||
try { | |||
var element = $(this); | var element = $(this); | ||
var name = element.find('.name').first().text(); | var name = element.find('.name').first().text(); | ||
var index = parseInt(element.find('.index').last().text()); | var index = parseInt(element.find('.index').last().text()); | ||
var srcStr = element. | var srcStr = element.attr("class"); | ||
var myRegexp = / | var myRegexp = /doll\-rarity\-(.*?) doll\-classification\-(.*?)$/g; | ||
var match = myRegexp.exec(srcStr); | var match = myRegexp.exec(srcStr); | ||
var classification = match[ | var classification = match[2]; | ||
var rarity = match[ | 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 35: | Line 34: | ||
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 59: | 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 | var nativeGroupHeader = document.createElement("h3"); | ||
var groupHeader = $(nativeGroupHeader); | |||
groupHeader.text(currentLetter.toUpperCase() + "...").addClass("addedbysorter"); | |||
groupHeader.insertBefore(elements.first()); | groupHeader.insertBefore(elements.first()); | ||
Line 68: | Line 73: | ||
var groupHeaderText = nextElementLetter.toUpperCase() + "..."; | var groupHeaderText = nextElementLetter.toUpperCase() + "..."; | ||
if (groupHeaderText.trim() != "...") { | if (groupHeaderText.trim() != "...") { | ||
var groupHeader = $(" | var groupHeader = $(document.createElement("h3")).text(groupHeaderText).addClass("addedbysorter"); | ||
groupHeader.insertAfter(element); | groupHeader.insertAfter(element); | ||
} | } | ||
Line 86: | 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 145: | 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 = $(" | var groupHeader = $(document.createElement("h3")).text(groupHeaderText).addClass("addedbysorter"); | ||
groupHeader.insertAfter(element1); | groupHeader.insertAfter(element1); | ||
} | } | ||
Line 220: | 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 = $(" | var groupHeader = $(document.createElement("h3")).text(getNumberText(firstIndex) + "..." + getNumberText(firstTen)).addClass("addedbysorter"); | ||
groupHeader.insertBefore(elements.first()); | groupHeader.insertBefore(elements.first()); | ||
Line 233: | Line 238: | ||
return true; | return true; | ||
}); | }); | ||
} | }; | ||
tdollSorter(comparer, grouper); | tdollSorter(comparer, grouper); | ||
Line 259: | Line 264: | ||
var groupHeaderText = getNumberText(currentIdxShow) + "..." + getNumberText(nextElementTen); | var groupHeaderText = getNumberText(currentIdxShow) + "..." + getNumberText(nextElementTen); | ||
var groupHeader = $(" | var groupHeader = $(document.createElement("h3")).text(groupHeaderText).addClass("addedbysorter"); | ||
groupHeader.insertAfter(element); | groupHeader.insertAfter(element); | ||
} | } | ||
Line 266: | 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 283: | Line 288: | ||
$('[data-tdollserverbutton="true"]').removeClass("enabled"); | $('[data-tdollserverbutton="true"]').removeClass("enabled"); | ||
$('. | $('.gfl-doll-card.unreleased').removeClass('unreleased'); | ||
$('. | $('.gfl-doll-card').each(function() { | ||
var element = $(this); | var element = $(this); | ||
var nameToSet = ""; | var nameToSet = ""; | ||
Line 306: | Line 311: | ||
var parent = $(this); | var parent = $(this); | ||
// All elements inside the paragraph after the h2 which have special class | // All elements inside the paragraph after the h2 which have special class | ||
var elements = parent.nextUntil("h2", ". | var elements = parent.nextUntil("h2", ".gfl-doll-card"); | ||
elements.detach().sort(comparer); | elements.detach().sort(comparer); |
Latest revision as of 00:40, 27 July 2024
Released on this server: