MediaWiki:Common.js: Difference between revisions
From Valheim Wiki
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
$(function () { | $(function () { | ||
$('.crafts.crafts-upgrades tr').each(function (item) { | |||
let tr = $(this); | |||
let tdValues = tr.find('td:nth-child(n+2)'); | |||
let lastVal = 'zzz'; | |||
let lastTd = false; | |||
tdValues.each(function (index) { | |||
let td = $(this); | |||
// console.log($(this).attr('data-prop')); | |||
let currentValue = $(td).text(); | |||
// console.log('currentvalue: ', currentValue); | |||
// console.log('lastvalue: ', lastVal); | |||
// console.log('currentvalue === lastvalue: ', currentValue === lastVal); | |||
if (currentValue === lastVal) { | |||
let firstTd = $(tdValues[0]); | |||
let currentColspan = $(firstTd).attr('colspan'); | |||
if (!currentColspan) { | |||
currentColspan = 1; | |||
} | |||
$(firstTd) | |||
.attr('colspan', currentColspan + 1) | |||
.css({textAlign: 'center'}); | |||
$(this).hide(); | |||
} | |||
lastTd = td; | |||
lastVal = currentValue; | |||
// console.log('---------------'); | |||
}); | |||
}); | |||
}); | }); | ||
Revision as of 23:52, 27 February 2021
/* Any JavaScript here will be loaded for all users on every page load. */
$(function () {
$('.crafts.crafts-upgrades tr').each(function (item) {
let tr = $(this);
let tdValues = tr.find('td:nth-child(n+2)');
let lastVal = 'zzz';
let lastTd = false;
tdValues.each(function (index) {
let td = $(this);
// console.log($(this).attr('data-prop'));
let currentValue = $(td).text();
// console.log('currentvalue: ', currentValue);
// console.log('lastvalue: ', lastVal);
// console.log('currentvalue === lastvalue: ', currentValue === lastVal);
if (currentValue === lastVal) {
let firstTd = $(tdValues[0]);
let currentColspan = $(firstTd).attr('colspan');
if (!currentColspan) {
currentColspan = 1;
}
$(firstTd)
.attr('colspan', currentColspan + 1)
.css({textAlign: 'center'});
$(this).hide();
}
lastTd = td;
lastVal = currentValue;
// console.log('---------------');
});
});
});