<commit_before>/**
 * The EvalSystem set of functions (keeps the namespace clean and tidy) -AZ
 * DEPENDS on jQuery 1.2 to operate
 * @author <NAME>
 * @author <NAME> (<EMAIL>)
 */
var EvalSystem = function() {
  function $it(elementID) {
    return document.getElementById(elementID);
  }
  
  /**
   * Because JQuery uses this sort of CSS based selector system, if you have 
   * wacky characters in your tag ID (such as RSF Colons) you have to escape 
   * them. At the moment this just escapes the colons, should probably have a
   * fuller (or automatic) jquery escaping mechanism.
   */
  function escIdForJquery(value) {
    return value != null ? "#" + value.replace(/:/g, "\\:") : null;
  }

  return {
    
    /**
     *  A little bit of javascript to validate the Eval Assign Page. At the 
     *  moment this is only for making sure users have selected at least one
     *  group or hierarchy node or something.
     *
     * @errorDivId A Div with an already translated message we can light up.
     * @submitButtonId The button that is doing the submitting.
     */
    initEvalAssignValidation: function(formId, errorDivId, submitButtonId) {
        var form = $(escIdForJquery(formId));
        var errorDiv = $(escIdForJquery(errorDivId));
        var submitButton = $(escIdForJquery(submitButtonId));
        
        // Boolean to store whether the form should submit based on validation.
        var passes = false;
        
        form.submit(function() {
            if (!passes) {
                errorDiv.show();
                RSF.getDOMModifyFirer().fireEvent();
            }
            return passes;
        });
        
        var onAssignClick = function(event) {
            passes = false;
            var n = $(".evalgroupselect:checked").length;
            if (n > 0) {
                passes=true;
            }
        }
        
        submitButton.click( function(event) { onAssignClick(event) } );
    },

    initEvalReportView: function (allCommentsId, allTextResponsesId) {
        // for now this is just enabling toggling of comments and responses
        // see the makeToggle method for description of arguments
        if (allCommentsId.length > 0) {
            $(escIdForJquery(allCommentsId)).show();
            EvalSystem.makeToggle(allCommentsId + "Show", allCommentsId + "Hide", null, "showcomments", false);
        }
        if (allTextResponsesId.length > 0) {
            $(escIdForJquery(allTextResponsesId)).show();
            EvalSystem.makeToggle(allTextResponsesId + "Show", allTextResponsesId + "Hide", null, "showtextresponses", false);
        }
    },

    /**
     * This will hide an area (or a set areas that match the toggleClass)
     * when the element with hideId is clicked (it will also be hidden),
     * it will show the area(s) and the hideId element when the element with showId is clicked,
     * and also hide the showId element
     * showId: the id of the element that triggers the show when clicked
     * hideId: the id of the element that triggers the hide when clicked
     * areaId: the id of area (div probably) to show/hide, set null if not used
     * toggleClass: a classname such that all elements with this class will be shown/hidden, set null if not used
     * initialHide: if true then start things hidden, else start things shown (default if unspecified)
     */
    makeToggle: function (showId, hideId, areaId, toggleClass, initialHide) {
        var showButton = $(escIdForJquery(showId));
        var hideButton = $(escIdForJquery(hideId));
        var area = $(escIdForJquery(areaId));
        var toggles = $(toggleClass == null ? null : "." + toggleClass);
        
        var togglearea = showButton.parent().parent();
        showButton.show();
        hideButton.show();

        var showAction = function(event) {
            showButton.hide();
            hideButton.show();
            area.show("normal");
            toggles.show("normal");
            RSF.getDOMModifyFirer().fireEvent();
        }

        var hideAction = function(event) {
            showButton.show();
            hideButton.hide();
            area.hide("normal");<commit_msg>CTL-1242: make the toggler add <a> around the text to make it appear clickable<commit_after>/**
 * The EvalSystem set of functions (keeps the namespace clean and tidy) -AZ
 * DEPENDS on jQuery 1.2 to operate
 * @author <NAME>
 * @author <NAME> (<EMAIL>)
 */
var EvalSystem = function() {
  function $it(elementID) {
    return document.getElementById(elementID);
  }
  
  /**
   * Because JQuery uses this sort of CSS based selector system, if you have 
   * wacky characters in your tag ID (such as RSF Colons) you have to escape 
   * them. At the moment this just escapes the colons, should probably have a
   * fuller (or automatic) jquery escaping mechanism.
   */
  function escIdForJquery(value) {
    return value != null ? "#" + value.replace(/:/g, "\\:") : null;
  }

  return {
    
    /**
     *  A little bit of javascript to validate the Eval Assign Page. At the 
     *  moment this is only for making sure users have selected at least one
     *  group or hierarchy node or something.
     *
     * @errorDivId A Div with an already translated message we can light up.
     * @submitButtonId The button that is doing the submitting.
     */
    initEvalAssignValidation: function(formId, errorDivId, submitButtonId) {
        var form = $(escIdForJquery(formId));
        var errorDiv = $(escIdForJquery(errorDivId));
        var submitButton = $(escIdForJquery(submitButtonId));
        
        // Boolean to store whether the form should submit based on validation.
        var passes = false;
        
        form.submit(function() {
            if (!passes) {
                errorDiv.show();
                RSF.getDOMModifyFirer().fireEvent();
            }
            return passes;
        });
        
        var onAssignClick = function(event) {
            passes = false;
            var n = $(".evalgroupselect:checked").length;
            if (n > 0) {
                passes=true;
            }
        }
        
        submitButton.click( function(event) { onAssignClick(event) } );
    },

    initEvalReportView: function (allCommentsId, allTextResponsesId) {
        // for now this is just enabling toggling of comments and responses
        // see the makeToggle method for description of arguments
        if (allCommentsId.length > 0) {
            $(escIdForJquery(allCommentsId)).show();
            EvalSystem.makeToggle(allCommentsId + "Show", allCommentsId + "Hide", null, "showcomments", false);
        }
        if (allTextResponsesId.length > 0) {
            $(escIdForJquery(allTextResponsesId)).show();
            EvalSystem.makeToggle(allTextResponsesId + "Show", allTextResponsesId + "Hide", null, "showtextresponses", false);
        }
    },

    /**
     * This will hide an area (or a set areas that match the toggleClass)
     * when the element with hideId is clicked (it will also be hidden),
     * it will show the area(s) and the hideId element when the element with showId is clicked,
     * and also hide the showId element
     * showId: the id of the element that triggers the show when clicked
     * hideId: the id of the element that triggers the hide when clicked
     * areaId: the id of area (div probably) to show/hide, set null if not used
     * toggleClass: a classname such that all elements with this class will be shown/hidden, set null if not used
     * initialHide: if true then start things hidden, else start things shown (default if unspecified)
     */
    makeToggle: function (showId, hideId, areaId, toggleClass, initialHide) {
        var showButton = $(escIdForJquery(showId));
        var hideButton = $(escIdForJquery(hideId));
        var area = $(escIdForJquery(areaId));
        var toggles = $(toggleClass == null ? null : "." + toggleClass);
        
        var togglearea = showButton.parent().parent();
        
        showButton.show();
        hideButton.show();
        showButton.parent().next().wrap("<a href=\"#\"></a>");
        
        var showAction = function(event) {
            showButton.hide();
            hideButton.show();
            area.show("normal");
            toggles.show("normal");
            RSF.getDOMModifyFirer().fireEvent();
        }

        var hideAction = function(event) {
            showButton.show();
            hideButton.hide();
            area.hide("normal");
{'fraction_non_alphanumeric': 0.09949370069468974, 'fraction_numerical': 0.0016484163428705993, 'mean_word_length': 2.354660347551343, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 18, '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': '5512550', 'n_tokens_mistral': 2355, 'n_tokens_neox': 2288, 'n_words': 792}