Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("table#aspect_statistics_StatisticsTransformer_table_list-table").each(function () {
- var legacy = false;
- //Si existen valores legados
- if ($(this).find("tr:contains('legacy')").length) {
- legacy = true;
- //Para cada fila legacy
- $(this).find("tr:contains('legacy')").each(function () {
- var name_legacy = $(this).find("td:nth-child(1)").text();
- var val_legacy = parseInt($(this).find("td:nth-child(2)").text());
- var finded = false;
- $(this).prevAll().each(function () {
- if (name_legacy === $(this).find("td:nth-child(1)").text() + "(legacy)") {
- $(this).find("td:nth-child(2)").text(val_legacy + parseInt($(this).find("td:nth-child(2)").text()));
- finded = true;
- }
- });
- $(this).nextAll().each(function () {
- if (name_legacy === $(this).find("td:nth-child(1)").text() + "(legacy)") {
- $(this).find("td:nth-child(2)").text(val_legacy + parseInt($(this).find("td:nth-child(2)").text()));
- finded = true;
- }
- });
- if (finded) {
- $(this).remove();
- } else {
- $(this).find("td:nth-child(1)").text(name_legacy.replace("(legacy)", ""));
- }
- });
- }
- if (legacy) {
- //Ordena y da estilo a la tabla si hay valores legados
- sortTable($(this));
- styleTable($(this));
- }
- });
- //Ordena las tablas de estadísticas de uso de los items
- function sortTable(table) {
- var tbody = table.find('tbody');
- tbody.find('tr').sort(function (a, b) {
- return parseInt($('td:last', b).text()) - parseInt($('td:last', a).text());
- }).appendTo(tbody);
- }
- //Añade estilo a las tablas de estadísticas de uso de los items
- function styleTable(table) {
- var tbody = table.find('tbody');
- tbody.find('tr').each(function (index) {
- if ((index + 1) % 2 === 0) {
- $(this).removeClass('even odd').addClass('even');
- } else {
- $(this).removeClass('even odd').addClass('odd');
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement