Difference between revisions of "MediaWiki:Common.js"

From Final Fantasy XIV Online Wiki
Jump to navigation Jump to search
Line 13: Line 13:
    
    
   var fixed_position = $("#IL_INSEARCH").offset().top;
   var fixed_position = $("#IL_INSEARCH").offset().top;
  console.log({fixed_position})
   var fixed_height = $("#IL_INSEARCH").height();
   var fixed_height = $("#IL_INSEARCH").height();


   var toCross_position = $("#taboola-below-article-thumbnails").offset().top;
   var toCross_position = $("#taboola-below-article-thumbnails").offset().top;
  console.log({toCross_position})
   var toCross_height = $("#taboola-below-article-thumbnails").height();
   var toCross_height = $("#taboola-below-article-thumbnails").height();


Line 26: Line 28:
   }
   }
  };   
  };   
try {
  setInterval(positionAdDivs, 200);
  setInterval(positionAdDivs, 200);
} catch(error){
console.log(error)
}
});
});

Revision as of 05:47, 22 October 2020

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

// Scripts to use when viewing articles
/* if (mw.config.get('wgIsArticle') || window.location.href.indexOf('action=submit') > -1 || mw.config.get('wgNamespaceNumber') == -1) {
    mw.loader.load( '/index.php?title=MediaWiki:CollapsibleTables.js&action=raw&ctype=text/javascript' );
}
*/

window.addEventListener("load", function(){

 var positionAdDivs= function () {
  var fixed = $("#IL_INSEARCH");
  
  var fixed_position = $("#IL_INSEARCH").offset().top;
  console.log({fixed_position})
  var fixed_height = $("#IL_INSEARCH").height();

  var toCross_position = $("#taboola-below-article-thumbnails").offset().top;
  console.log({toCross_position})
  var toCross_height = $("#taboola-below-article-thumbnails").height();

  if (fixed_position + fixed_height  < toCross_position) {
    fixed.removeClass('white');
  } else if (fixed_position > toCross_position + toCross_height) {
    fixed.removeClass('displaynone');
  } else {
    fixed.addClass('displaynone');
  }
 };  
 setInterval(positionAdDivs, 200);
});