<commit_before>var S36FeedbackActions = new function() {    

    var feedback = '.feedback';  // should be the parent of other vars in its group.
    var flag = '.flag-as';
    var vote_container = '.vote-action';
    var vote = '.vote-action a';
    var vote_count = '.vote_count';
    var rating_stat = '.rating-stat';
    var share = '.share-button';
    var fb_like_dummy = '.fb_like_dummy';  // fb-like
    var tw_share_dummy = '.tw_share_dummy';  // twitter-share-button
    var send_button = '.send-button';

    var me = this;

    this.initialize_actions = function() {
        me.flag_inapprt();
        me.vote();
        me.share();
        me.open_submission_form();
        me.admin_reply();
        me.attachment_controls();
        me.masonry_initialize();
        Helpers.close_lightbox();
    }

    this.flag_inapprt = function() {
        $(flag).click(function(){
            
            var this_flag = $(this);
            
            $.ajax({
                url: '/feedback_action/flag',
                type: 'post',
                data: {'feedbackId' : this_flag.parents(feedback).attr('fid')},
                success: function(result){
                    this_flag.hide().text('Thanks for your flag!').fadeIn();
                }
            });
            
        }); 
    }

    this.vote = function() { 
        $(vote).click(function(e){
            
            var this_vote = $(this);
            var vote_count_obj = $(this).parents(feedback).find(vote_count);
            
            $.ajax({
                url: '/feedback_action/vote',
                type: 'post',
                data: {'feedbackId' : this_vote.parents(feedback).attr('fid')},
                success: function(result){
                    $(this_vote).parents(feedback).find(rating_stat).css('display', 'block');
                    vote_count_obj.hide().text( parseInt(vote_count_obj.text()) + 1 ).fadeIn();
                    $(this_vote).parents(feedback).find(vote_container).hide().text('Thanks for your vote!').fadeIn();
                }
            });
            e.preventDefault();
        });
    }

    this.share = function() {      
        $(share).click(function(){
     
            var fb_like = $(this).parents(feedback).find(fb_like_dummy);
            var tw_share = $(this).parents(feedback).find(tw_share_dummy);

            if( ! fb_like.is('.fb-like') ){
                fb_like.addClass('fb-like');
                FB.XFBML.parse();
            }
            
            if( ! tw_share.is('.twitter-share-button') ){
                tw_share.addClass('twitter-share-button');
                twttr.widgets.load();
            } 

            $(this).find('.share-box').fadeIn('fast').hover(function() { 
                fb_like.addClass('fb-like');
            }, function() {
                $(this).fadeOut('fast');
                console.log("hovering out");
            });
        });
    }

    this.open_submission_form = function() { 
        $(send_button).click(function(){  
            var widgetkey = $(this).attr('widgetkey');
            createLightboxes();
            s36_openLightbox(448, 600, '/widget/widget_loader/' + widgetkey); 
        });
    }

    this.admin_reply = function() {
        /* admin replies */
        $('.adminReply').click(function() {
            var my_parent = $(this).parents('.admin-comment-block');
            var admin_reply = {
                feedbackId: $(my_parent).find('.admin-comment-id').val(),
                userId: $(my_parent).find('.admin-user-id').val(),
                adminReply: $(my_parent).find('.admin-comment-textbox').val()
            };

            if($.trim($(my_parent).find('.admin-comment-textbox').val()).length > 0) {
                $.ajax({
                    url: "/admin_reply",
                    dataType: "json",
                    data: admin_reply,
                    type: "POST",
                    success: function(result) {
                        if(undefined != result.feedbackid){
                            $(my_parent).find('.admin-comment .admin-message .message').html(result.adminreply);
                            $(my_parent).find('.admin-comment-box').css('display','none');
                            $(my_parent).find('.admin-comment').css('display','block');
                        }
                  }
                });
            } else {
                Helpers.display_error_mes(['Cannot be blank.']); 
            }  
        }); 
        
        //we do this to prevent multiple event bindings from happening
        $('.admin-delete-reply').unbind('click.delete_admin').bind('click.delete_admin', function(e) {
            var feedid = $(this).attr('feedid');
            var me = $(this);
            $.ajax({
                url: "/delete_admin_reply/" + feedid
              , type: "GET"
              , success: function(result) {
                    console.log(result);
                    me.parent('admin-comment').hide();
                    $('admin-comment-box[feedid=' + feedid + ']').removeAttr('style');
                }
            });
            e.preventDefault();
        });
    }

    this.attachment_controls = function() { 
        /*lightbox attachment code*/
        $('.uploaded-images-close').click(function(){
            $(this).parent().fadeOut();
        });
        $('.the-thumb,.video-circle').click(function(){
            var scroll_offset = $(document).scrollTop();
            var top_offset = scroll_offset + 100;<commit_msg>ming chern<commit_after>var S36FeedbackActions = new function() {    

    var feedback = '.feedback';  // should be the parent of other vars in its group.
    var flag = '.flag-as';
    var vote_container = '.vote-action';
    var vote = '.vote-action a';
    var vote_count = '.vote_count';
    var rating_stat = '.rating-stat';
    var share = '.share-button';
    var fb_like_dummy = '.fb_like_dummy';  // fb-like
    var tw_share_dummy = '.tw_share_dummy';  // twitter-share-button
    var send_button = '.send-button';

    var me = this;

    this.initialize_actions = function() {
        me.flag_inapprt();
        me.vote();
        me.share();
        me.open_submission_form();
        me.admin_reply();
        me.attachment_controls();
        me.masonry_initialize();
        Helpers.close_lightbox();
    }

    this.flag_inapprt = function() {
        $(flag).click(function(){
            
            var this_flag = $(this);
            
            $.ajax({
                url: '/feedback_action/flag',
                type: 'post',
                data: {'feedbackId' : this_flag.parents(feedback).attr('fid')},
                success: function(result){
                    this_flag.hide().text('Thanks for your flag!').fadeIn();
                }
            });
            
        }); 
    }

    this.vote = function() { 
        $(vote).click(function(e){
            
            var this_vote = $(this);
            var vote_count_obj = $(this).parents(feedback).find(vote_count);
            
            $.ajax({
                url: '/feedback_action/vote',
                type: 'post',
                data: {'feedbackId' : this_vote.parents(feedback).attr('fid')},
                success: function(result){
                    $(this_vote).parents(feedback).find(rating_stat).css('display', 'block');
                    vote_count_obj.hide().text( parseInt(vote_count_obj.text()) + 1 ).fadeIn();
                    $(this_vote).parents(feedback).find(vote_container).hide().text('Thanks for your vote!').fadeIn();
                }
            });
            e.preventDefault();
        });
    }

    this.share = function() {      
        $(share).click(function(){
     
            var fb_like = $(this).parents(feedback).find(fb_like_dummy);
            var tw_share = $(this).parents(feedback).find(tw_share_dummy);

            if( ! fb_like.is('.fb-like') ){
                fb_like.addClass('fb-like');
                FB.XFBML.parse();
            }
            
            if( ! tw_share.is('.twitter-share-button') ){
                tw_share.addClass('twitter-share-button');
                twttr.widgets.load();
            } 

            $(this).find('.share-box').fadeIn('fast').hover(function() { 
                fb_like.addClass('fb-like');
            }, function() {
                $(this).fadeOut('fast');
                console.log("hovering out");
            });
        });
    }

    this.open_submission_form = function() { 
        $(send_button).click(function(){  
            var widgetkey = $(this).attr('widgetkey');
            createLightboxes();
            s36_openLightbox(448, 600, '/widget/widget_loader/' + widgetkey); 
        });
    }

    this.admin_reply = function() {
        /* admin replies */
        $('.adminReply').click(function() {
            var my_parent = $(this).parents('.admin-comment-block');
            var admin_reply = {
                feedbackId: $(my_parent).find('.admin-comment-id').val(),
                userId: $(my_parent).find('.admin-user-id').val(),
                adminReply: $(my_parent).find('.admin-comment-textbox').val()
            };

            if($.trim($(my_parent).find('.admin-comment-textbox').val()).length > 0) {
                $.ajax({
                    url: "/admin_reply",
                    dataType: "json",
                    data: admin_reply,
                    type: "POST",
                    success: function(result) {
                        if(undefined != result.feedbackid){
                            $(my_parent).find('.admin-comment .admin-message .message').html(result.adminreply);
                            $(my_parent).find('.admin-comment-box').css('display','none');
                            $(my_parent).find('.admin-comment').css('display','block');
                        }
                  }
                });
            } else {
                Helpers.display_error_mes(['Cannot be blank.']); 
            }  
        }); 
        
        //we do this to prevent multiple event bindings from happening
        $('.admin-delete-reply').unbind('click.delete_admin').bind('click.delete_admin', function(e) {
            var feedid = $(this).attr('feedid');
            var me = $(this);
            $.ajax({
                url: "/delete_admin_reply/" + feedid
              , type: "GET"
              , success: function(result) {
                    console.log(result);
                    me.parent('.admin-comment').hide();
                    $('.admin-comment-box[feedid=' + feedid + ']').removeAttr('style');
                }
            });
            e.preventDefault();
        });
    }

    this.attachment_controls = function() { 
        /*lightbox attachment code*/
        $('.uploaded-images-close').click(function(){
            $(this).parent().fadeOut();
        });
        $('.the-thumb,.video-circle').click(function(){
            var scroll_offset = $(document).scrollTop();
            var top_offset = scroll_offset + 100;
{'fraction_non_alphanumeric': 0.15770027935478056, 'fraction_numerical': 0.002703433360367667, 'mean_word_length': 1.5407509157509158, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3013093', 'n_tokens_mistral': 3111, 'n_tokens_neox': 2911, 'n_words': 462}