Widget:indexSorterGrouper/sandbox: Difference between revisions
Jump to navigation
Jump to search
Initial setup for testing |
Removing first function |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly><script> | <includeonly><script> | ||
console.log("Debug0-1"); | RLQ.push(['jquery', function () { | ||
console.log("Debug0-2"); | |||
$(document).ready(function() { | |||
console.log("Debug1"); | |||
// 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()); | |||
}); | |||
console.log("Debug2"); | |||
// For now, we have to make sure the data is there (Change the template, dammit!) | |||
$(".gfl-doll-card").each(function() { | |||
try { | |||
console.log("Debug3-1"); | |||
var element = $(this); | |||
var name = element.find('.name').first().text(); | |||
var index = parseInt(element.find('.index').last().text()); | |||
var srcStr = element.attr("class"); | |||
var myRegexp = /doll\-rarity\-(.*?) doll\-classification\-(.*?)$/g; | |||
var match = myRegexp.exec(srcStr); | |||
var classification = match[2]; | |||
var rarity = match[1]; | |||
console.log("Debug3-2"); | |||
var serverDataSpans = $("span.serverdata[data-server-doll='" + name + "']"); | |||
serverDataSpans.each(function() { | |||
var serverDataSpan = $(this); | |||
var serverShort = serverDataSpan.attr('data-server-released'); | |||
var serverDollName = serverDataSpan.attr('data-server-releasename'); | |||
element.attr("data-server-" + serverShort, serverDollName); | |||
}); | |||
serverDataSpans.remove(); | |||
element.attr('data-server-WIKI', name); | |||
element.data('name', name); | |||
element.data('index', index); | |||
element.data('classification', classification); | |||
element.data('rarity', rarity); | |||
console.log("Debug3-3"); | |||
} | |||
catch(error) { | |||
console.log("Error handling index entry", error); | |||
} | |||
}); | |||
console.log("Debug4"); | |||
// Once everything is ready, default-sort it | |||
$('[data-initialsort]').click(); | |||
// Activate ui for user | |||
$(".gf-button").prop('disabled', false); | |||
$('.removeAfterInitIsg').remove(); | |||
}); | |||
}]); | |||
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>Rarity>Name</button> | <button class="gf-button" data-tdollsortbutton="true" disabled data-initialsort="true" onclick="orderByClassRarityName(this);">By Class>Rarity>Name</button> |
Latest revision as of 00:23, 27 July 2024
Released on this server: