<commit_before>//= require jquery
//= require jquery_ujs
//= require_tree .
//= require bootstrap
//= require select2


"use strict";

var _Lobsters = Class.extend({
  curUser: null,

  storyFlagReasons: { <%= Vote::STORY_REASONS.map{|k,v|
      "#{k.inspect}: #{v.inspect}" }.join(", ") %> },
  commentDownvoteReasons: { <%= Vote::COMMENT_REASONS.map{|k,v|
      "#{k.inspect}: #{v.inspect}" }.join(", ") %> },

  upvoteStory: function(voterEl) {
    Lobsters.vote("story", voterEl, 1);
  },
  downvoteStory: function(voterEl) {
    Lobsters.vote("story", voterEl, -1);
  },
  flagStory: function(voterEl) {
    Lobsters._showDownvoteWhyAt("story", voterEl, function(k) {
      Lobsters.vote("story", voterEl, -1, k); });
  },
  hideStory: function(hiderEl) {
    if (!Lobsters.curUser)
      return Lobsters.bounceToLogin();

    var li = $(hiderEl).closest(".story, .comment");
    var act;

    if (li.hasClass("hidden")) {
      act = "unhide";
      li.removeClass("hidden");
      hiderEl.innerHTML = "hide";
    }
    else {
      act = "hide";
      li.addClass("hidden");
      hiderEl.innerHTML = "unhide";
    }

    $.post("/stories/" + li.attr("data-shortid") + "/" + act);
  },

  upvoteComment: function(voterEl) {
    Lobsters.vote("comment", voterEl, 1);
  },
  downvoteComment: function(voterEl) {
    Lobsters.vote("comment", voterEl, -1);
  },
  _showDownvoteWhyAt: function(thingType, voterEl, onChooseWhy) {
    if (!Lobsters.curUser)
      return Lobsters.bounceToLogin();

    var li = $(voterEl).closest(".story, .comment");
    if (li.hasClass("downvoted")) {
      /* already upvoted, neutralize */
      Lobsters.vote(thingType, voterEl, -1, null);
      return;
    }

    if ($("#downvote_why"))
      $("#downvote_why").remove();
    if ($("#downvote_why_shadow"))
      $("#downvote_why_shadow").remove();

    var sh = $("<div id=\"downvote_why_shadow\"></div>");
    $(voterEl).after(sh);
    sh.click(function() {
      $("#downvote_why_shadow").remove();
      $("#downvote_why").remove();
    });

    var d = $("<div id=\"downvote_why\"></div>");

    var reasons;
    if (thingType == "comment")<commit_msg>more markup<commit_after>//= require jquery
//= require jquery_ujs
//= require_tree .
//= require bootstrap
//= require select2


"use strict";

var _Lobsters = Class.extend({
  curUser: null,

  storyFlagReasons: { <%= Vote::STORY_REASONS.map{|k,v|
      "#{k.inspect}: #{v.inspect}" }.join(", ") %> },
  commentDownvoteReasons: { <%= Vote::COMMENT_REASONS.map{|k,v|
      "#{k.inspect}: #{v.inspect}" }.join(", ") %> },

  upvoteStory: function(voterEl) {
    Lobsters.vote("story", voterEl, 1);
  },
  downvoteStory: function(voterEl) {
    Lobsters.vote("story", voterEl, -1);
  },
  flagStory: function(voterEl) {
    Lobsters._showDownvoteWhyAt("story", voterEl, function(k) {
      Lobsters.vote("story", voterEl, -1, k); });
  },
  hideStory: function(hiderEl) {
    if (!Lobsters.curUser)
      return Lobsters.bounceToLogin();

    var li = $(hiderEl).closest(".story, .comment");
    var act;

    if (li.hasClass("hidden")) {
      act = "unhide";
      li.removeClass("hidden");
      hiderEl.innerHTML = "hide";
    }
    else {
      act = "hide";
      li.addClass("hidden");
      hiderEl.innerHTML = "unhide";
    }

    $.post("/stories/" + li.attr("data-shortid") + "/" + act);
  },

  upvoteComment: function(voterEl) {
    Lobsters.vote("comment", voterEl, 1);
  },
  downvoteComment: function(voterEl) {
    Lobsters._showDownvoteWhyAt("comment", voterEl, function(k) {
      Lobsters.vote("comment", voterEl, -1, k); });
  },
  _showDownvoteWhyAt: function(thingType, voterEl, onChooseWhy) {
    if (!Lobsters.curUser)
      return Lobsters.bounceToLogin();

    var li = $(voterEl).closest(".story, .comment");
    if (li.hasClass("downvoted")) {
      /* already upvoted, neutralize */
      Lobsters.vote(thingType, voterEl, -1, null);
      return;
    }

    if ($("#downvote_why"))
      $("#downvote_why").remove();
    if ($("#downvote_why_shadow"))
      $("#downvote_why_shadow").remove();

    var sh = $("<div id=\"downvote_why_shadow\"></div>");
    $(voterEl).after(sh);
    sh.click(function() {
      $("#downvote_why_shadow").remove();
      $("#downvote_why").remove();
    });

    var d = $("<div id=\"downvote_why\"></div>");

    var reasons;
    if (thingType == "comment")
{'fraction_non_alphanumeric': 0.20174032516601786, 'fraction_numerical': 0.003205862147927639, 'mean_word_length': 3.2448979591836733, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4999291', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1558, 'n_words': 262}