Advertisement
Guest User

w.p js

a guest
May 12th, 2019
7,670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Event Drivers
  2. var cooldown = true;
  3. document.getElementById('divThreads').addEventListener("mouseover", function (e) {
  4.     if (e)
  5.         if (e.target.className == 'imgLink' || e.target.tagName == "IMG") {
  6.             hoverImg(e);
  7.         }
  8.     if (e.target.className == "myQuote") {
  9.         if (cooldown) {
  10.             hoverThis(e);
  11.             cooldown = false;
  12.             setTimeout(function () {
  13.                 cooldown = true;
  14.             }, 500);
  15.         }
  16.     }
  17.  
  18. });
  19.  
  20. var targetNode = document.getElementsByClassName('divPosts')[0];
  21. var config = {
  22.     childList : true
  23. };
  24. var callback = function (mutationsList) {
  25.     for (var mutation of mutationsList) {
  26.         if (mutation.type == 'childList') {
  27.             var quotes = mutation.addedNodes[0].querySelectorAll('.quoteLink');
  28.                 for (var i = 0; i < quotes.length; ++i) {
  29.                     prepNewhovers([quotes[i]]);
  30.                     console.log('mutated');
  31.                     newcount();
  32.                 }
  33.  
  34.         }
  35.     }
  36. };
  37. var observer = new MutationObserver(callback);
  38. observer.observe(targetNode, config);
  39.  
  40. //Image Hover
  41. var imagehover = document.createElement('div');
  42. imagehover.style = 'pointer-events: none;z-index: 9999999;position:fixed;top:20px;right:20px;max-width:90%;height:700px';
  43. imagehover.id = 'imageHover';
  44. document.body.appendChild(imagehover);
  45.  
  46. function hoverImg(e) {
  47.     if (e.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.className == 'quotebox') {
  48.         return;
  49.     }
  50.     if (e.target.src && e.target.src.indexOf('video') > -1) {
  51.         var ext = e.target.src.split('video')[1];
  52.             imagehover.innerHTML = '<video style="width:auto;height:100%;" src="' + e.target.src.replace("t_", "") + '.' + ext + '" autoplay controls loop>';
  53.     } else {
  54.         if (e.target.className == 'imgExpanded') {
  55.             return;
  56.         }
  57.         imagehover.innerHTML = '<img style="width:auto;height:100%;" src="' + e.target.parentElement.href + '">';
  58.     }
  59.     e.target.addEventListener("mouseout", function (e) {
  60.         imagehover.innerHTML = '';
  61.     });
  62. }
  63.  
  64. $(document).on('ready', function() {
  65.     if(active_page == "thread") {
  66.    
  67.         $duration = 1000;
  68.  
  69.         $("a[href='#bannerImage']").on("click", function(e) {
  70.           e.preventDefault();
  71.           $("html, body").stop().animate({ scrollTop: 0 }, $duration);
  72.         });
  73.  
  74.         $("a[href='#footer']").on("click", function(e) {
  75.           e.preventDefault();
  76.           $("html, body").stop().animate({ scrollTop: $(document).height()-$(window).height() }, $duration);
  77.         });
  78.     }
  79. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement