Difference between revisions of "Widget:indexSorterGrouper"
Jump to navigation
Jump to search
(Adding some data for sorting) |
m (Fixed starting index of index based grouping) |
||
(16 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() { | $(".card-bg-small").each(function() { | ||
var element = $(this); | var element = $(this); | ||
− | var name = element.find(' | + | var name = element.find('.name').first().text(); |
− | var index = parseInt(element.find(' | + | var index = parseInt(element.find('.index').last().text()); |
− | var srcStr = element.find("img" | + | var srcStr = element.find("img.rarity-class").attr("src"); |
var myRegexp = /^.*Icon_(.*)_(.*)star.*$/g; | var myRegexp = /^.*Icon_(.*)_(.*)star.*$/g; | ||
var match = myRegexp.exec(srcStr); | var match = myRegexp.exec(srcStr); | ||
Line 18: | Line 26: | ||
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. | + | 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); | ||
Line 35: | Line 44: | ||
$('.removeAfterInitIsg').remove(); | $('.removeAfterInitIsg').remove(); | ||
}); | }); | ||
− | }); | + | }]); |
function orderByName(currentButton) { | function orderByName(currentButton) { | ||
Line 246: | Line 255: | ||
} | } | ||
− | var groupHeaderText = getNumberText( | + | 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 = $("<h3 />").text(groupHeaderText).addClass("addedbysorter"); | ||
Line 265: | Line 276: | ||
return 1; | return 1; | ||
} | } | ||
+ | } | ||
+ | |||
+ | function switchServer(butt) { | ||
+ | var activeServer = $(butt).attr('data-tdollserver'); | ||
+ | |||
+ | $('[data-tdollserverbutton="true"]').removeClass("enabled"); | ||
+ | |||
+ | $('.card-bg-small.unreleased').removeClass('unreleased'); | ||
+ | $('.card-bg-small').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 305: | ||
parents.each(function() { | parents.each(function() { | ||
var parent = $(this); | var parent = $(this); | ||
+ | // All elements inside the paragraph after the h2 which have special class | ||
var elements = parent.nextUntil("h2", ".card-bg-small"); | var elements = parent.nextUntil("h2", ".card-bg-small"); | ||
Line 290: | Line 323: | ||
<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"> </div></div> | <div style="width:20px; height:20px; display:inline-block;" class="loading2 removeAfterInitIsg"> </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 07:40, 8 April 2022
Released on this server: