<commit_before>import Component from '../../../helpers/Component'
import Cookies from '../../../helpers/Cookies'

import Table from './components/Table'
import List from './components/List'

import MaterialButton from '../../../imports/materialdesign/components/MaterialButton'
import Preloader from '../../../imports/materialdesign/components/Preloader'

export default class PostsPage extends Component {
  beforeRender () {
    this.tableLoaded = false
    this.listLoaded = false

    this.isTable = true

    this.checkBoxes = false
    this.checkedCheckBoxes = 0

    this.clickedPost = null

    this.toggledPictures = false

    this.selectedPosts = []

    this.loadedPage = 0

    this.postsData = [
      {
        id: 11,
        title: 'Post with style',
        author: '<NAME>',
        content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas in neque turpis. Aenean tincidunt nunc nec ligula cursus iaculis. Pellentesque nisl nulla, malesuada a est a, tempor dapibus eros. Sed facilisis porta',
        date: '15.06.2017 13:02',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: [
          {
            author: '<NAME>',
            userID: 1,
            content: 'Warto wiedzieć',
            date: '31.05.2017 18:14',
            avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281'
          }
        ],
        style: {
          background: '#2196F3',
          light: true,
          ripple: true
        }
      },
      {
        id: 10,
        title: 'Test',
        author: '<NAME>',
        content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas in neque turpis. Aenean tincidunt nunc nec ligula cursus iaculis. Pellentesque nisl nulla, malesuada a est a, tempor dapibus eros. Sed facilisis porta auctor.',
        date: '14.04.2017 20:38',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [
          {
            userName: '<NAME>',
            userID: 1
          },
          {
            userName: '<NAME>',
            userID: 15
          }
        ],
        comments: [
          {
            author: '<NAME>',
            userID: 1,
            content: 'Lorem ipsum dolor sit amet',
            date: '31.05.2017 18:14',
            avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281'
          }
        ]
      },
      {
        id: 9,
        media: 'http://img11.deviantart.net/a66d/i/2015/109/3/b/forest_wallpaper_16_9_by_iorgudesign-d8qa67w.jpg',
        title: 'Test',
        author: '<NAME>',
        content: 'Card with picture test',
        date: '14.04.2017 10:38',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: []
      },
      {
        id: 8,
        media: 'https://images.alphacoders.com/120/120313.jpg',
        title: 'Rain',
        author: '<NAME>',
        content: 'Rainy day',
        date: '14.04.2017 9:45',
        avatar: 'https://images.alphacoders.com/120/thumb-1920-120313.jpg',
        likes: [],
        comments: []
      },
      {
        id: 7,
        title: 'HTML TAGS TEST',
        author: '<NAME>',
        content: '<div id="tag-test-margin"></div><div id="tag-test"></div><style>#tag-test-margin {height:128px;} #tag-test{width:48px;height:48px;background-color:#2196f3;border-radius:100%;animation-name:tag-test-animation;animation-duration:2s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;position:absolute;top:0;left:0;right:0;margin:0 auto;}</style><style>@keyframes tag-test-animation {0% {border-radius:100%;width:48px; height:48px;background-color:#2196f3;}25% {border-radius:0%;width:152px;height:152px;background-color:#90CAF9;}100%{border-radius:100%;width:48px;height:48px;background-color:#2196f3;}}</style>',
        date: '14.04.2017 8:07',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: []
      },
      {
        id: 6,
        title: 'Test 2',
        author: '<NAME>',
        content: '6',
        date: '14.04.2017 10:38',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: []
      },
      {
        id: 5,
        title: 'Test 2',
        author: '<NAME>',
        content: '6',
        date: '14.04.2017 10:38',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: []
      }
    ]
  }

  /**
   * Gets root.
   * @return {DOMElement} root
   */
  getRoot = () => {
    return this.elements.root
  }

  /**
   * Loads posts.
   */
  load = () => {
    const self = this
    const app = window.app
    const tables = this.elements.tables

    app.loadedPages.posts = true

    setTimeout(function () {
      app.togglePreloader(false)
      app.isLoading = false

      let cookieTable = Cookies.getCookie('table')
      const windowWidth = window.innerWidth

      let table = true

      if (windowWidth < 1000 && cookieTable !== 'true' || windowWidth >= 1000 && cookieTable === 'false') {
        table = false
      }

      if (table) {
        self.switchToTable()
      } else {
        self.switchToList()
      }

      tables.style.opacity = '1'

      self.elements.loadButton.getRoot().innerHTML = 'ZAŁADUJ WIĘCEJ (3)'

      self.toggleLoadButtonContainer(true)
    }, 1000)
  }

  /**
   * On select this page event.
   */
  onSelect = () => {
    const app = window.app

    app.toggleFAB(true)
  }

  /**
   * On deselect this page event.
   */
  onDeselect = () => {
    const app = window.app

    app.toggleFAB(false)
  }

  /**
   * Switch to table.
   */
  switchToTable = (hide) => {
    const app = window.app
    const toolbar = app.getToolbar()
    const viewIcon = toolbar.getViewIcon()

    const table = this.elements.table
    const list = this.elements.list

    this.isTable = true
    viewIcon.classList.remove('table')
<commit_msg>Fix toolbar icons<commit_after>import Component from '../../../helpers/Component'
import Cookies from '../../../helpers/Cookies'

import Table from './components/Table'
import List from './components/List'

import MaterialButton from '../../../imports/materialdesign/components/MaterialButton'
import Preloader from '../../../imports/materialdesign/components/Preloader'

export default class PostsPage extends Component {
  beforeRender () {
    this.tableLoaded = false
    this.listLoaded = false

    this.isTable = true

    this.checkBoxes = false
    this.checkedCheckBoxes = 0

    this.clickedPost = null

    this.toggledPictures = false

    this.selectedPosts = []

    this.loadedPage = 0

    this.postsData = [
      {
        id: 11,
        title: 'Post with style',
        author: '<NAME>',
        content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas in neque turpis. Aenean tincidunt nunc nec ligula cursus iaculis. Pellentesque nisl nulla, malesuada a est a, tempor dapibus eros. Sed facilisis porta',
        date: '15.06.2017 13:02',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: [
          {
            author: '<NAME>',
            userID: 1,
            content: 'Warto wiedzieć',
            date: '31.05.2017 18:14',
            avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281'
          }
        ],
        style: {
          background: '#2196F3',
          light: true,
          ripple: true
        }
      },
      {
        id: 10,
        title: 'Test',
        author: '<NAME>',
        content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas in neque turpis. Aenean tincidunt nunc nec ligula cursus iaculis. Pellentesque nisl nulla, malesuada a est a, tempor dapibus eros. Sed facilisis porta auctor.',
        date: '14.04.2017 20:38',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [
          {
            userName: '<NAME>',
            userID: 1
          },
          {
            userName: '<NAME>',
            userID: 15
          }
        ],
        comments: [
          {
            author: '<NAME>',
            userID: 1,
            content: 'Lorem ipsum dolor sit amet',
            date: '31.05.2017 18:14',
            avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281'
          }
        ]
      },
      {
        id: 9,
        media: 'http://img11.deviantart.net/a66d/i/2015/109/3/b/forest_wallpaper_16_9_by_iorgudesign-d8qa67w.jpg',
        title: 'Test',
        author: '<NAME>',
        content: 'Card with picture test',
        date: '14.04.2017 10:38',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: []
      },
      {
        id: 8,
        media: 'https://images.alphacoders.com/120/120313.jpg',
        title: 'Rain',
        author: '<NAME>',
        content: 'Rainy day',
        date: '14.04.2017 9:45',
        avatar: 'https://images.alphacoders.com/120/thumb-1920-120313.jpg',
        likes: [],
        comments: []
      },
      {
        id: 7,
        title: 'HTML TAGS TEST',
        author: '<NAME>',
        content: '<div id="tag-test-margin"></div><div id="tag-test"></div><style>#tag-test-margin {height:128px;} #tag-test{width:48px;height:48px;background-color:#2196f3;border-radius:100%;animation-name:tag-test-animation;animation-duration:2s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;position:absolute;top:0;left:0;right:0;margin:0 auto;}</style><style>@keyframes tag-test-animation {0% {border-radius:100%;width:48px; height:48px;background-color:#2196f3;}25% {border-radius:0%;width:152px;height:152px;background-color:#90CAF9;}100%{border-radius:100%;width:48px;height:48px;background-color:#2196f3;}}</style>',
        date: '14.04.2017 8:07',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: []
      },
      {
        id: 6,
        title: 'Test 2',
        author: '<NAME>',
        content: '6',
        date: '14.04.2017 10:38',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: []
      },
      {
        id: 5,
        title: 'Test 2',
        author: '<NAME>',
        content: '6',
        date: '14.04.2017 10:38',
        avatar: 'https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/14581320_549947718524540_5437545186607783553_n.jpg?oh=1d709d8978f80d6887041c3e9583f27f&oe=59994281',
        likes: [],
        comments: []
      }
    ]
  }

  /**
   * Gets root.
   * @return {DOMElement} root
   */
  getRoot = () => {
    return this.elements.root
  }

  /**
   * Loads posts.
   */
  load = () => {
    const self = this
    const app = window.app
    const tables = this.elements.tables

    app.loadedPages.posts = true

    setTimeout(function () {
      app.togglePreloader(false)
      app.isLoading = false

      let cookieTable = Cookies.getCookie('table')
      const windowWidth = window.innerWidth

      let table = true

      if (windowWidth < 1000 && cookieTable !== 'true' || windowWidth >= 1000 && cookieTable === 'false') {
        table = false
      }

      if (table) {
        self.switchToTable()
      } else {
        self.switchToList()
      }

      tables.style.opacity = '1'

      self.elements.loadButton.getRoot().innerHTML = 'ZAŁADUJ WIĘCEJ (3)'

      self.toggleLoadButtonContainer(true)
    }, 1000)
  }

  /**
   * On select this page event.
   */
  onSelect = () => {
    const app = window.app
    const toolbar = app.getToolbar()

    app.toggleFAB(true)

    toolbar.showItems()
  }

  /**
   * On deselect this page event.
   */
  onDeselect = () => {
    const app = window.app
    const toolbar = app.getToolbar()

    app.toggleFAB(false)

    toolbar.hideItems(false, false)
  }

  /**
   * Switch to table.
   */
  switchToTable = (hide) => {
    const app = window.app
    const toolbar = app.getToolbar()
    const viewIcon = toolbar.getViewIcon()

    const table = this.elements.table
    const list = this.elements.list

    this.isTable = true
    viewIcon.classList.remove('table')

{'fraction_non_alphanumeric': 0.14114797416324135, 'fraction_numerical': 0.12874339401056958, 'mean_word_length': 2.3876181004475385, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 53, 'https://': 20, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4538871', 'n_tokens_mistral': 5967, 'n_tokens_neox': 4950, 'n_words': 781}