PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

MediaWiki:Common.js: Difference between revisions

From PC Gaming Shelter
No edit summary
Tag: Manual revert
No edit summary
Line 3: Line 3:
$(function() {
$(function() {
managePersonalIconVis();
managePersonalIconVis();
    sortPFCheckboxes();
});
});


Line 15: Line 16:
}
}
   }
   }
}
function sortPFCheckboxes() {
  const containers = document.querySelectorAll(".checkboxesSpan");
  containers.forEach(container => {
      const labels = Array.from(container.querySelectorAll("label.checkboxLabel"));
      labels.sort((a, b) => {
            const textA = a.querySelector("t").textContent.trim().toLowerCase();
            const textB = b.querySelector("t").textContent.trim().toLowerCase();
            return textA.localeCompare(textB);
      });
      labels.forEach(label => container.appendChild(label));
  });
}
}

Revision as of 10:40, 22 March 2026

/* Any JavaScript here will be loaded for all users on every page load. */

$(function() {
	managePersonalIconVis();
    sortPFCheckboxes();
});

function managePersonalIconVis(){
  if (mw.config.get('wgUserId') !== null) {
	const personal = document.getElementById('p-personal');
	document.querySelector('#pane4').appendChild(personal);
  } else {
	const personalIcon = document.querySelector('.personal-tools-icon');
	if (personalIcon) {
		personalIcon.classList.add('d-none');
	}
  }
}

function sortPFCheckboxes() {
   const containers = document.querySelectorAll(".checkboxesSpan");

   containers.forEach(container => {
       const labels = Array.from(container.querySelectorAll("label.checkboxLabel"));

       labels.sort((a, b) => {
            const textA = a.querySelector("t").textContent.trim().toLowerCase();
            const textB = b.querySelector("t").textContent.trim().toLowerCase();
            return textA.localeCompare(textB);
       });
       labels.forEach(label => container.appendChild(label));
   });
}