<commit_before>/**
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
'use strict';

window.friendlyPix = window.friendlyPix || {};

/**
 * Handles the single post UI.
 */
friendlyPix.Post = class {
  /**
   * Initializes the single post's UI.
   * @constructor
   */
  constructor() {
    // List of all times running on the page.
    this.timers = [];

    // Firebase SDK.
    this.database = firebase.app().database();
    this.storage = firebase.app().storage();
    this.auth = firebase.app().auth();

    $(document).ready(() => {
      // Pointers to DOM elements.
      this.postPage = $('#page-post');
      this.postElement = $('.fp-post', this.postPage);
      this.toast = $('.mdl-js-snackbar');
      this.theatre = $('.fp-theatre');
    });
  }

  /**
   * Creates an unattached clone of the single post element.
   * @return friendlyPix.Post
   */
  clone() {
    let clone = new friendlyPix.Post();
    clone.postElement = friendlyPix.MaterialUtils.cloneElementWithTextField(clone.postElement);
    return clone;
  }

  /**
   * Loads the given post's details.
   */
  loadPost(postId) {
    // Load the posts information.
    friendlyPix.firebase.getPostData(postId).then(snapshot => {
      let post = snapshot.val();
      // Clear listeners and previous post data.
      this.clear();
      if (!post) {
        var data = {
          message: 'This post does not exists.',
          timeout: 5000
        };
        this.toast[0].MaterialSnackbar.showSnackbar(data);
        page(`/user/${this.auth.currentUser.uid}`);
      } else {<commit_msg>When post does not exists and user not authenticated redirect to the global feed.<commit_after>/**
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
'use strict';

window.friendlyPix = window.friendlyPix || {};

/**
 * Handles the single post UI.
 */
friendlyPix.Post = class {
  /**
   * Initializes the single post's UI.
   * @constructor
   */
  constructor() {
    // List of all times running on the page.
    this.timers = [];

    // Firebase SDK.
    this.database = firebase.app().database();
    this.storage = firebase.app().storage();
    this.auth = firebase.app().auth();

    $(document).ready(() => {
      // Pointers to DOM elements.
      this.postPage = $('#page-post');
      this.postElement = $('.fp-post', this.postPage);
      this.toast = $('.mdl-js-snackbar');
      this.theatre = $('.fp-theatre');
    });
  }

  /**
   * Creates an unattached clone of the single post element.
   * @return friendlyPix.Post
   */
  clone() {
    let clone = new friendlyPix.Post();
    clone.postElement = friendlyPix.MaterialUtils.cloneElementWithTextField(clone.postElement);
    return clone;
  }

  /**
   * Loads the given post's details.
   */
  loadPost(postId) {
    // Load the posts information.
    friendlyPix.firebase.getPostData(postId).then(snapshot => {
      let post = snapshot.val();
      // Clear listeners and previous post data.
      this.clear();
      if (!post) {
        var data = {
          message: 'This post does not exists.',
          timeout: 5000
        };
        this.toast[0].MaterialSnackbar.showSnackbar(data);
        if (this.auth.currentUser) {
          page(`/user/${this.auth.currentUser.uid}`);
        } else {
          page(`/feed`);
        }
      } else {
{'fraction_non_alphanumeric': 0.1296673455532926, 'fraction_numerical': 0.005883684091423399, 'mean_word_length': 2.6348684210526314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4584088', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1246, 'n_words': 399}