MediaWiki:Common.js
From Valheim Wiki
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
$(function () {
$('.crafts.crafts-upgrades tr').each(function (item) {
var tr = $(this);
var tdValues = tr.find('td:nth-child(n+2)');
var lastVal = 'zzz';
var lastTd = false;
tdValues.each(function (index) {
var td = $(this);
// console.log($(this).attr('data-prop'));
var currentValue = $(td).text();
// console.log('currentvalue: ', currentValue);
// console.log('lastvalue: ', lastVal);
// console.log('currentvalue === lastvalue: ', currentValue === lastVal);
if (currentValue === lastVal) {
var firstTd = $(tdValues[0]);
var currentColspan = $(firstTd).attr('colspan');
if (!currentColspan) {
currentColspan = 1;
}
$(firstTd)
.attr('colspan', currentColspan + 1)
.css({textAlign: 'center'});
$(this).hide();
}
lastTd = td;
lastVal = currentValue;
// console.log('---------------');
});
});
});