<commit_before>var Flickity = require('flickity');
require('flickity-imagesloaded');
var openseadragon = require('../openseadragon');

module.exports = (ctx) => {
  var carousel = document.querySelector('.carousel');
  if (carousel) {
    var thumbnails = document.getElementsByClassName('record-imgpanel__thumb');
    var captions = Array.prototype.slice.call(document.getElementsByClassName('record-imgpanel__caption'));
    var rights = Array.prototype.slice.call(document.getElementsByClassName('cite__menu__methods'));
    var zooms = Array.prototype.slice.call(document.getElementsByClassName('osd__toolbar-container'));
    var useImage = Array.prototype.slice.call(document.getElementsByClassName('cite__button'));

    ctx.carousel = new Flickity('.carousel', {
      wrapAround: thumbnails.length >= 3,
      setGallerySize: false,
      pageDots: false,
      imagesLoaded: true,
      lazyLoad: 1,
      arrowShape: {
        x0: 30,
        x1: 63.5,
        y1: 50,
        x2: 70,
        y2: 45.5,
        x3: 40
      }
    });

    var flkty = Flickity.data(carousel);
    ctx.carousel.on('select', function () {
      if (navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)) {
        document.querySelector('#openseadragon').style.width = '100%';
      }
      Array.prototype.slice.call(thumbnails).forEach((el) => {
        el.classList.remove('record-imgpanel__thumb--selected');
      });
      if (thumbnails[flkty.selectedIndex]) {
        thumbnails[flkty.selectedIndex].classList.add('record-imgpanel__thumb--selected');
      }
      captions.forEach((el) => showHide('record-imgpanel__caption', flkty, el));
      zooms.forEach((el) => showHide('openseadragon-toolbar', flkty, el));
      rights.forEach((el) => showHide('cite__method', flkty, el));
      useImage.forEach((el) => showHide('cite__button', flkty, el));
    });

    Array.prototype.slice.call(thumbnails).forEach((el, i) => el.addEventListener('click', function (e) {
      ctx.carousel.select(i);
      if (ctx.viewer) {
        ctx.viewer.destroy();
        ctx.viewer = false;
        ctx.save();
        openseadragon.init(ctx, e.target.src);
      }
    }));
  }

  var citeButton = document.getElementsByClassName('cite__button');

  if (citeButton) {
    Array.prototype.slice.call(citeButton).forEach((el, i) => el.addEventListener('click', function (e) {
      document.getElementById('cite__menu').classList.toggle('cite__menu--active');
      document.getElementById('cite__button-' + i).classList.toggle('cite__button--active');
    }));<commit_msg>adding back in the logged error which fixes the safari crashing bug<commit_after>var Flickity = require('flickity');
require('flickity-imagesloaded');
var openseadragon = require('../openseadragon');

module.exports = (ctx) => {
  var carousel = document.querySelector('.carousel');
  if (carousel) {
    var thumbnails = document.getElementsByClassName('record-imgpanel__thumb');
    var captions = Array.prototype.slice.call(document.getElementsByClassName('record-imgpanel__caption'));
    var rights = Array.prototype.slice.call(document.getElementsByClassName('cite__menu__methods'));
    var zooms = Array.prototype.slice.call(document.getElementsByClassName('osd__toolbar-container'));
    var useImage = Array.prototype.slice.call(document.getElementsByClassName('cite__button'));

    ctx.carousel = new Flickity('.carousel', {
      wrapAround: thumbnails.length >= 3,
      setGallerySize: false,
      pageDots: false,
      imagesLoaded: true,
      lazyLoad: 1,
      arrowShape: {
        x0: 30,
        x1: 63.5,
        y1: 50,
        x2: 70,
        y2: 45.5,
        x3: 40
      }
    });

    var flkty = Flickity.data(carousel);
    ctx.carousel.on('select', function () {
      if (navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)) {
        document.querySelector('#openseadragon').style.width = '100%';
      }
      Array.prototype.slice.call(thumbnails).forEach((el) => {
        el.classList.remove('record-imgpanel__thumb--selected');
      });
      thumbnails[flkty.selectedIndex].classList.add('record-imgpanel__thumb--selected');
      captions.forEach((el) => showHide('record-imgpanel__caption', flkty, el));
      zooms.forEach((el) => showHide('openseadragon-toolbar', flkty, el));
      rights.forEach((el) => showHide('cite__method', flkty, el));
      useImage.forEach((el) => showHide('cite__button', flkty, el));
    });

    Array.prototype.slice.call(thumbnails).forEach((el, i) => el.addEventListener('click', function (e) {
      ctx.carousel.select(i);
      if (ctx.viewer) {
        ctx.viewer.destroy();
        ctx.viewer = false;
        ctx.save();
        openseadragon.init(ctx, e.target.src);
      }
    }));
  }

  var citeButton = document.getElementsByClassName('cite__button');

  if (citeButton) {
    Array.prototype.slice.call(citeButton).forEach((el, i) => el.addEventListener('click', function (e) {
      document.getElementById('cite__menu').classList.toggle('cite__menu--active');
      document.getElementById('cite__button-' + i).classList.toggle('cite__button--active');
    }));
{'fraction_non_alphanumeric': 0.15658432211631979, 'fraction_numerical': 0.009725734292939117, 'mean_word_length': 3.570666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5979393', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1589, 'n_words': 237}