SHARE
TWEET

iichan ext

a guest Mar 14th, 2017 6 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var imagesRegExp = /.*\.(png|jpg|gif)$/i;
  2. var mobileAgents = /android|webos|iphone|ipad|ipod|blackberry|phone/i;
  3. function initLightbox() {
  4.     var lbFrame = document.createElement('img');
  5.     lbFrame.id = 'lightbox';
  6.     lbFrame.addEventListener('click', function() {
  7.         this.className = '';
  8.     });
  9.     document.body.appendChild(lbFrame);
  10.     var thumbs = document.querySelectorAll('form#delform img.thumb');
  11.     for (var i = 0; i < thumbs.length; i++) {
  12.         if (thumbs[i].parentNode.getAttribute('href').match(imagesRegExp) != null) {
  13.             thumbs[i].parentNode.addEventListener('click', function(evt) {
  14.                 lbFrame.setAttribute('src', this.getAttribute('href'));
  15.                 lbFrame.className = 'active';
  16.                 evt.preventDefault();
  17.             });
  18.         }
  19.     }
  20. }
  21. function initThreadHiders() {
  22.     var hiders = document.querySelectorAll('.thread-hider');
  23.     for (var i = 0; i < hiders.length; i++) {
  24.         hiders[i].addEventListener('click', function() {
  25.             hiddenThreads = localStorage.getItem('hiddenThreads') !== null ? JSON.parse(localStorage.getItem('hiddenThreads')) : [];
  26.             var threadElement = this.parentNode;
  27.             var threadLink = threadElement.querySelector('.reflink+a').getAttribute('href');
  28.             var storageIndex = hiddenThreads.indexOf(threadLink);
  29.             if (storageIndex < 0) {
  30.                 hiddenThreads.push(threadLink);
  31.                 threadElement.className = 'hidden';
  32.             } else {
  33.                 hiddenThreads.splice(storageIndex, 1);
  34.                 threadElement.className = '';
  35.             }
  36.             localStorage.setItem('hiddenThreads', JSON.stringify(hiddenThreads));
  37.         });
  38.     }
  39. }
  40. function hideThreadsOnLoad() {
  41.     var hiddenThreads = localStorage.getItem('hiddenThreads');
  42.     if (hiddenThreads == null) return;
  43.     var threadLinks = document.querySelectorAll('.reflink+a');
  44.     for (var i = 0; i < threadLinks.length; i++) {
  45.         if (hiddenThreads.indexOf(threadLinks[i].getAttribute('href')) >= 0) {
  46.             threadLinks[i].parentNode.className = 'hidden';
  47.         }
  48.     }  
  49. }
  50. function init() {
  51.     if (!navigator.userAgent.match(mobileAgents)) {
  52.         initLightbox();
  53.     }
  54.     initThreadHiders();
  55.     hideThreadsOnLoad();
  56. }
  57. if (document.addEventListener) {
  58.     document.addEventListener('DOMContentLoaded', init);
  59. } else {
  60.     document.onreadystatechange = function() {
  61.         if (document.readyState == "interactive") {
  62.             init();
  63.         }
  64.     }
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top