MediaWiki:Bracket.js: Difference between revisions

MediaWiki interface page
(Created page with "$(document).ready(function(){ const matchElements = document.querySelectorAll('.match'); if (matchElements.length > 0) { // Add event listeners to each match element matchElements.forEach(matchElement => { matchElement.addEventListener('mouseover', () => { // Get the position of the .match element const matchRect = matchElement.getBoundingClientRect(); // Position the .match-details element to the right of the .match element con...")
 
mNo edit summary
Line 1: Line 1:
$(document).ready(function(){
$(document).ready(function(){
     const matchElements = document.querySelectorAll('.match');
     const matchElements = document.querySelectorAll('.match');
console.log('HALLOOO')
if (matchElements.length > 0) {
if (matchElements.length > 0) {
  console.log('Olen sees')
   // Add event listeners to each match element
   // Add event listeners to each match element
   matchElements.forEach(matchElement => {
   matchElements.forEach(matchElement => {
Line 7: Line 9:
       // Get the position of the .match element
       // Get the position of the .match element
       const matchRect = matchElement.getBoundingClientRect();
       const matchRect = matchElement.getBoundingClientRect();
        
       console.log('Huuuuver')
       // Position the .match-details element to the right of the .match element
       // Position the .match-details element to the right of the .match element
       const matchDetails = matchElement.querySelector('.match-details');
       const matchDetails = matchElement.querySelector('.match-details');

Revision as of 21:12, 8 October 2023

$(document).ready(function(){
    const matchElements = document.querySelectorAll('.match');
console.log('HALLOOO')
if (matchElements.length > 0) {
  console.log('Olen sees')
  // Add event listeners to each match element
  matchElements.forEach(matchElement => {
    matchElement.addEventListener('mouseover', () => {
      // Get the position of the .match element
      const matchRect = matchElement.getBoundingClientRect();
      console.log('Huuuuver')
      // Position the .match-details element to the right of the .match element
      const matchDetails = matchElement.querySelector('.match-details');
      if (matchDetails) {
        matchDetails.style.position = 'fixed';
        matchDetails.style.top = `${matchRect.top}px`; // Keep the top position the same as .match
        matchDetails.style.left = `${matchRect.right}px`; // Position to the right of .match
        matchDetails.style.transform = 'translateY(-25%)';
      }
    });
    });
  });
}
});