<commit_before>/*eslint new-cap:0, max-statements:0*/
/*global window document localStorage*/

import React from "react/addons";
import assign from "object-assign";
import cloneWithProps from "react/lib/cloneWithProps";
import Radium from "radium";
import _ from "lodash";
import Presenter from "./presenter";
import Export from "./export";
import Overview from "./overview";

React.initializeTouchEvents(true);

const Style = Radium.Style;

import Progress from "./progress";
const TransitionGroup = Radium(React.addons.TransitionGroup);

@Radium
class Deck extends React.Component {
  constructor(props) {
    super(props);
    this._handleKeyPress = this._handleKeyPress.bind(this);
    this._handleClick = this._handleClick.bind(this);
    this._goToSlide = this._goToSlide.bind(this);
    this.state = {
      lastSlide: null
    };
  }
  componentDidMount() {
    const slide = this.context.slide;
    this.setState({
      lastSlide: slide
    });
    localStorage.setItem("spectacle-slide",
      JSON.stringify({slide, forward: false, time: Date.now()}));
    this._attachEvents();
  }
  componentWillUnmount() {
    this._detachEvents();
  }
  _attachEvents() {
    window.addEventListener("storage", this._goToSlide);
    window.addEventListener("keydown", this._handleKeyPress);
  }
  _detachEvents() {
    window.removeEventListener("storage", this._goToSlide);
    window.removeEventListener("keydown", this._handleKeyPress);
  }
  _handleKeyPress(e) {
    const event = window.event ? window.event : e;
    // left, page down
    if (event.keyCode === 37 || event.keyCode === 33) {
      this._prevSlide();
    }
    // right, page up
    if (event.keyCode === 39 || event.keyCode === 34) {
      this._nextSlide();
    }
    if (event.keyCode === 79) { // o
      this._toggleOverviewMode();
    }
    if (event.keyCode === 80) { // o
      this._togglePresenterMode();
    }
  }
  _toggleOverviewMode() {
    const suffix = this.context.overview ? "" : "?overview";
    this.context.router.replaceWith("/" + (this.context.slide) + suffix);
  }
  _togglePresenterMode() {
    const suffix = this.context.presenter ? "" : "?presenter";
    this.context.router.replaceWith("/" + (this.context.slide) + suffix);
  }
  _getSuffix() {
    if (this.context.presenter) {
      return "?presenter";
    } else if (this.context.overview) {
      return "?overview";
    } else {
      return "";
    }
  }
  _goToSlide(e) {
    if (e.key === "spectacle-slide") {
      const data = JSON.parse(e.newValue);
      const slide = this.context.slide;
      this.setState({
        lastSlide: slide || 0
      });
      if (this._checkFragments(slide, data.forward)) {<commit_msg>Fixing presenter mode triggering when printing<commit_after>/*eslint new-cap:0, max-statements:0*/
/*global window document localStorage*/

import React from "react/addons";
import assign from "object-assign";
import cloneWithProps from "react/lib/cloneWithProps";
import Radium from "radium";
import _ from "lodash";
import Presenter from "./presenter";
import Export from "./export";
import Overview from "./overview";

React.initializeTouchEvents(true);

const Style = Radium.Style;

import Progress from "./progress";
const TransitionGroup = Radium(React.addons.TransitionGroup);

@Radium
class Deck extends React.Component {
  constructor(props) {
    super(props);
    this._handleKeyPress = this._handleKeyPress.bind(this);
    this._handleClick = this._handleClick.bind(this);
    this._goToSlide = this._goToSlide.bind(this);
    this.state = {
      lastSlide: null
    };
  }
  componentDidMount() {
    const slide = this.context.slide;
    this.setState({
      lastSlide: slide
    });
    localStorage.setItem("spectacle-slide",
      JSON.stringify({slide, forward: false, time: Date.now()}));
    this._attachEvents();
  }
  componentWillUnmount() {
    this._detachEvents();
  }
  _attachEvents() {
    window.addEventListener("storage", this._goToSlide);
    window.addEventListener("keydown", this._handleKeyPress);
  }
  _detachEvents() {
    window.removeEventListener("storage", this._goToSlide);
    window.removeEventListener("keydown", this._handleKeyPress);
  }
  _handleKeyPress(e) {
    const event = window.event ? window.event : e;
    // left, page down
    if (event.keyCode === 37 || event.keyCode === 33) {
      this._prevSlide();
    }
    // right, page up
    if (event.keyCode === 39 || event.keyCode === 34) {
      this._nextSlide();
    }
    if (event.keyCode === 79 && !event.ctrlKey && !event.metaKey) { // o
      this._toggleOverviewMode();
    }
    if (event.keyCode === 80 && !event.ctrlKey && !event.metaKey) { // o
      this._togglePresenterMode();
    }
  }
  _toggleOverviewMode() {
    const suffix = this.context.overview ? "" : "?overview";
    this.context.router.replaceWith("/" + (this.context.slide) + suffix);
  }
  _togglePresenterMode() {
    const suffix = this.context.presenter ? "" : "?presenter";
    this.context.router.replaceWith("/" + (this.context.slide) + suffix);
  }
  _getSuffix() {
    if (this.context.presenter) {
      return "?presenter";
    } else if (this.context.overview) {
      return "?overview";
    } else {
      return "";
    }
  }
  _goToSlide(e) {
    if (e.key === "spectacle-slide") {
      const data = JSON.parse(e.newValue);
      const slide = this.context.slide;
      this.setState({
        lastSlide: slide || 0
      });
      if (this._checkFragments(slide, data.forward)) {
{'fraction_non_alphanumeric': 0.14962502286445947, 'fraction_numerical': 0.0054874702762026705, 'mean_word_length': 3.2585669781931466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '50822', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1715, 'n_words': 349}