<commit_before>$(document).ready(function () {
  
    var Feedback = {};
  
    var $window = $(window);
  
    var cookieVariablesNames = ['feedbackSubmitted', 'path', 'uuid'];
    var defaultFormValues = {
      email: "",
      inaccurateContent: false,
      inaccurateOutdatedContentText: "",
      otherMoreInformation: false,
      otherMoreInformationText: "",
      textErrors: false,
      typosLinksElementsText: "",
      outdatedSample: false,
      inaccurateOutdatedCodeSamplesText: "",
      otherFeedback: false,
      textFeedback: ""
    };
  
    $("#feedback-checkbox-area").click(function (e) {
      $("span.k-tooltip-validation").remove();
    });
  
    var formIsProcessing = false;
    //Util functions
    var generateUUID = function () {
      return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
      });
    };
  
    var getCookieByName = function (name) {
      //This is very crude, but necessary because currently there is some kind of url rewriting going on
      //so the cookies are set for a base path but then additional navigation is done with url rewriting
      //so we set the cookie name as complete path to avoid a problem where the cookie is set for multiple pages.
      if (name === "yesNoFeedback") {
        name = currentPath;
      }
      var match = document.cookie.match(new RegExp(name + '=([^;]+)'));
      if (match) return match[1];
    };
  
    //Init utility variables
    var rawLocationObject = $(location);
    var currentPath = rawLocationObject[0].origin + rawLocationObject[0].pathname;
  
    var setCookieByName = function (name, value) {
      var cookieUUID = getCookieByName("uuid");
      if (!cookieUUID) {
        document.cookie = "uuid=" + generateUUID() + "; path=/";
      }
      //This is very crude, but necessary because currently there is some kind of url rewriting going on
      //so the cookies are set for a base path but then additional navigation is done with url rewriting
      //so we set the cookie name as complete path to avoid a problem where the cookie is set for multiple pages.
      if (name === "yesNoFeedback") {
        name = currentPath;
      }
      document.cookie = name + "=" + value + ";";
    };
  
    //Feedback menu controls
    var feedbackButtonsContainer = $("#helpful-buttons-container");
    var feedbackSubmittedContainer = $("#feedback-submitted-container");
    var toggleFeedbackButtons = function (toggle) {
      if (toggle) {
        feedbackButtonsContainer.show();
        feedbackSubmittedContainer.hide();
      } else {
        feedbackButtonsContainer.hide();
        feedbackSubmittedContainer.show();
      }
    };
  
    var hideFeedback = function () {
      $("#feedback-container").hide();
    };
  
    if (getCookieByName("yesNoFeedback")) {
      hideFeedback();
    } else {
      toggleFeedbackButtons(true);
    }
  
    //FORM
    //Init the form popup window
    var win = $("#feedback-form-window").kendoWindow({
      actions: ["Close"],
      draggable: true,
      modal: true,
      pinned: false,
      visible: false,
      title: false,
      resizable: false,
      width: "500px",
	  height: "530px"
    }).data("kendoWindow");
    //Init form
    var feedbackForm = $("#feedback-form");
    var formModel = kendo.observable(defaultFormValues);
    var isFormModelEmpty = function () {
      var isModelDefault = true;
      for (var key in defaultFormValues) {
        if (key === 'email') {
          continue;
        }
        var isValueEqual = formModel[key] === defaultFormValues[key];
        if (!isValueEqual) {
          isModelDefault = false;
          break;
        }
      }
      return isModelDefault;
    };
  
    var isFormModelSatisfied = function (key, formValue) {
      var value = formModel[key];
      if (value) {
        return formValue && formValue.length > 0;
      } else {
        return true;
      }
    }
    //Bind model to form
    kendo.bind($("div#feedback-form-window"), formModel);
    //Attach to form submit to adjust variables and send request
    var emptyFormValidator = $("#feedback-checkbox-area").kendoValidator({
      validateOnBlur: false,
      messages: {
        // defines a message for the custom validation rule
        emptyForm: "You need to provide some feedback before submitting the form."
      },
      rules: {
        emptyForm: function (input) {
          return !isFormModelEmpty();
        }
      }
  
    }).data("kendoValidator");
  
    var emailValidator = $("#feedback-email-input").kendoValidator({
      validateOnBlur: false,
      messages: {
        email: "Invalid email address."
      },
      rules: {
        email: function (input) {
          if (input.val().length > 0) {
            var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            return re.test(input.val());
          }
          return true;
        }
      }
    }).data("kendoValidator");
  
    var textAreaValidator = function (selector, formModelKey) {
      return $(selector).kendoValidator({
        validateOnBlur: false,
        messages: {
          emptyValidation: "Provide some additional information.",
          htmlValidation: "HTML tags are not allowed in this field.",
          messageLength: "The message length must not exceed 2500 characters.",
          whiteSpaces: "Using only white spaces is not allowed in this field.",
          feedbackValidation: "Select a category and provide some additional information."
        },
        rules: {
          emptyValidation: function (input) {
            var text = input.val();
            return isFormModelSatisfied(formModelKey, text);
          },
          htmlValidation: function (input) {
            var text = input.val();
            var matches = text.match(/(<([^>]+)>)/ig);
            if (matches != null) {
              return false;
            }
            return true;
          },
          messageLength: function (input) {
            var text = input.val();
            if (text.length > 2500) {
              return false;
            }
            return true;
          },
          whiteSpaces: function (input) {
            var text = input.val();
            if (text.length > 0) {
              return $.trim(text) !== "";
            }
            return true;
          },
          feedbackValidation: function (input) {
            var text = input.val();
            if (text.length > 0) {
              return formModel[formModelKey];
            }
            return true;
          }
        }
      }).data("kendoValidator");
    };
  
    var canSubmitForm = function () {
      return textAreaValidator("#feedback-code-sample-text-input", "outdatedSample").validate() &&
        textAreaValidator("#feedback-more-information-text-input", "otherMoreInformation").validate() &&
        textAreaValidator("#feedback-text-errors-text-input", "textErrors").validate() &&
        textAreaValidator("#feedback-inaccurate-content-text-input", "inaccurateContent").validate() &&
        textAreaValidator("#feedback-other-text-input", "otherFeedback").validate() &&
        emptyFormValidator.validate() &&
        emailValidator.validate();
    };
  
    feedbackForm.submit(function (e) {
      e.preventDefault();
      if (formIsProcessing) {
        return;
      }
      formIsProcessing = true;
  
      if (canSubmitForm()) {
        win.close();
        setCookieByName("submittingFeedback")
        formModel.yesNoFeedback = getCookieByName("yesNoFeedback") || "Not submitted";
        formModel.uuid = getCookieByName("uuid");
        formModel.path = currentPath;
        formModel.sheetId = $("#hidden-sheet-id").val();
        $.post("https://api.everlive.com/v1/lzrla9wpuk636rdd/functions/saveFeedback", formModel.toJSON(), function () {
          formIsProcessing = false;
        });
      } else {
        formIsProcessing = false;
      }
    });
  
    //Attach to close button inside form window
    $("#form-close-button").click(function () {
      win.close();
    });
  
    //Attach to submit button inside form window
    $("#form-submit-button").click(function () {
      feedbackForm.submit();
    });
  
    //Init buttons
    $("#yesButton").click(function () {
      setCookieByName("yesNoFeedback", "Yes");
      toggleFeedbackButtons(false);
      Feedback.closeFeedback();
      Feedback.hideFeedbackForm();
      Feedback.adjustNavigationPosition();
    });
    $("#noButton").click(function () {
      setCookieByName("yesNoFeedback", "No");
      toggleFeedbackButtons(false);
      Feedback.closeFeedback();
      Feedback.hideFeedbackForm();
      Feedback.adjustNavigationPosition();
      win.center().open();
    });
    $("#additional-feedback-button").click(function () {
      win.center().open();
    });
  
    var windowHeight = $window.height();
    var headerHeight = $(".TK-Hat").outerHeight() + $("#page-header").outerHeight();
    var footerHeight = $("#feedback-section").outerHeight() + $("footer").outerHeight();
    var articleHeight = windowHeight - (headerHeight + footerHeight);
    var feedbackOffsetTop = document.body.scrollHeight - footerHeight;
    var shouldOverlayFeedback = !getCookieByName("yesNoFeedback") && !getCookieByName("yesNoFeedbackClosed");
    var showingFeedbackBar = false;
    var scrollFold = $window.scrollTop() + windowHeight;
    var feedbackPinned = false;
  
    function updateVariables() {
      windowHeight = $window.height();
      headerHeight = $(".TK-Hat").outerHeight() + $("#page-header").outerHeight();
      footerHeight = $("#feedback-section").outerHeight() + $("footer").outerHeight();
      articleHeight = windowHeight - (headerHeight + footerHeight);
      feedbackOffsetTop = document.body.scrollHeight - footerHeight;
      scrollFold = $window.scrollTop() + windowHeight;
    }
  
    Feedback = $.extend(Feedback, {
  
      init: function () {
  
        Feedback._events();
  
        Feedback.adjustArticleHeight();
        Feedback.adjustNavigationPosition();
  
        if (shouldOverlayFeedback) {
  
          showingFeedbackBar = true;
  
          window.setTimeout(function () {
            showingFeedbackBar = false;
            Feedback.adjustFeedbackPoistion();
            Feedback.adjustNavigationPosition();
          }, 10000);
        }
  
      },
  
  
      // #region events
      _events: function () {
        $window.scroll(Feedback._window_scroll);
        $window.resize(Feedback._window_resize);
        $("#close-button").click(Feedback._button_click);
      },
      _window_scroll: function () {
        updateVariables();
  
        scrollFold = $window.scrollTop() + windowHeight;
  
        Feedback.adjustFeedbackPoistion();
        Feedback.adjustNavigationPosition();
      },
      _window_resize: function () {
        updateVariables();
  
        Feedback.adjustArticleHeight();
        Feedback.adjustFeedbackPoistion();
        Feedback.adjustNavigationPosition();
      },
      _button_click: function () {
        Feedback.closeFeedback();
        Feedback.adjustNavigationPosition();
      },
      // #endregion
  
  
      // #region adjusters
      adjustNavigationPosition: function Feedback_adjustNavigationPosition() {
        //var bottom = 0;
       
        //if (!window.matchMedia('(max-width: 1200px)').matches) {
        //  bottom = Math.max(feedbackPinned ? $("#feedback-section").outerHeight() : 0, scrollFold - feedbackOffsetTop);
        //}
        //$("#page-inner-content").css("bottom", bottom);
      },<commit_msg>add comment for the future generations<commit_after>$(document).ready(function () {
  
    var Feedback = {};
  
    var $window = $(window);
  
    var cookieVariablesNames = ['feedbackSubmitted', 'path', 'uuid'];
    var defaultFormValues = {
      email: "",
      inaccurateContent: false,
      inaccurateOutdatedContentText: "",
      otherMoreInformation: false,
      otherMoreInformationText: "",
      textErrors: false,
      typosLinksElementsText: "",
      outdatedSample: false,
      inaccurateOutdatedCodeSamplesText: "",
      otherFeedback: false,
      textFeedback: ""
    };
  
    $("#feedback-checkbox-area").click(function (e) {
      $("span.k-tooltip-validation").remove();
    });
  
    var formIsProcessing = false;
    //Util functions
    var generateUUID = function () {
      return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
      });
    };
  
    var getCookieByName = function (name) {
      //This is very crude, but necessary because currently there is some kind of url rewriting going on
      //so the cookies are set for a base path but then additional navigation is done with url rewriting
      //so we set the cookie name as complete path to avoid a problem where the cookie is set for multiple pages.
      if (name === "yesNoFeedback") {
        name = currentPath;
      }
      var match = document.cookie.match(new RegExp(name + '=([^;]+)'));
      if (match) return match[1];
    };
  
    //Init utility variables
    var rawLocationObject = $(location);
    var currentPath = rawLocationObject[0].origin + rawLocationObject[0].pathname;
  
    var setCookieByName = function (name, value) {
      var cookieUUID = getCookieByName("uuid");
      if (!cookieUUID) {
        document.cookie = "uuid=" + generateUUID() + "; path=/";
      }
      //This is very crude, but necessary because currently there is some kind of url rewriting going on
      //so the cookies are set for a base path but then additional navigation is done with url rewriting
      //so we set the cookie name as complete path to avoid a problem where the cookie is set for multiple pages.
      if (name === "yesNoFeedback") {
        name = currentPath;
      }
      document.cookie = name + "=" + value + ";";
    };
  
    //Feedback menu controls
    var feedbackButtonsContainer = $("#helpful-buttons-container");
    var feedbackSubmittedContainer = $("#feedback-submitted-container");
    var toggleFeedbackButtons = function (toggle) {
      if (toggle) {
        feedbackButtonsContainer.show();
        feedbackSubmittedContainer.hide();
      } else {
        feedbackButtonsContainer.hide();
        feedbackSubmittedContainer.show();
      }
    };
  
    var hideFeedback = function () {
      $("#feedback-container").hide();
    };
  
    if (getCookieByName("yesNoFeedback")) {
      hideFeedback();
    } else {
      toggleFeedbackButtons(true);
    }
  
    //FORM
    //Init the form popup window
    var win = $("#feedback-form-window").kendoWindow({
      actions: ["Close"],
      draggable: true,
      modal: true,
      pinned: false,
      visible: false,
      title: false,
      resizable: false,
      width: "500px",
	  height: "530px"
    }).data("kendoWindow");
    //Init form
    var feedbackForm = $("#feedback-form");
    var formModel = kendo.observable(defaultFormValues);
    var isFormModelEmpty = function () {
      var isModelDefault = true;
      for (var key in defaultFormValues) {
        if (key === 'email') {
          continue;
        }
        var isValueEqual = formModel[key] === defaultFormValues[key];
        if (!isValueEqual) {
          isModelDefault = false;
          break;
        }
      }
      return isModelDefault;
    };
  
    var isFormModelSatisfied = function (key, formValue) {
      var value = formModel[key];
      if (value) {
        return formValue && formValue.length > 0;
      } else {
        return true;
      }
    }
    //Bind model to form
    kendo.bind($("div#feedback-form-window"), formModel);
    //Attach to form submit to adjust variables and send request
    var emptyFormValidator = $("#feedback-checkbox-area").kendoValidator({
      validateOnBlur: false,
      messages: {
        // defines a message for the custom validation rule
        emptyForm: "You need to provide some feedback before submitting the form."
      },
      rules: {
        emptyForm: function (input) {
          return !isFormModelEmpty();
        }
      }
  
    }).data("kendoValidator");
  
    var emailValidator = $("#feedback-email-input").kendoValidator({
      validateOnBlur: false,
      messages: {
        email: "Invalid email address."
      },
      rules: {
        email: function (input) {
          if (input.val().length > 0) {
            var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            return re.test(input.val());
          }
          return true;
        }
      }
    }).data("kendoValidator");
  
    var textAreaValidator = function (selector, formModelKey) {
      return $(selector).kendoValidator({
        validateOnBlur: false,
        messages: {
          emptyValidation: "Provide some additional information.",
          htmlValidation: "HTML tags are not allowed in this field.",
          messageLength: "The message length must not exceed 2500 characters.",
          whiteSpaces: "Using only white spaces is not allowed in this field.",
          feedbackValidation: "Select a category and provide some additional information."
        },
        rules: {
          emptyValidation: function (input) {
            var text = input.val();
            return isFormModelSatisfied(formModelKey, text);
          },
          htmlValidation: function (input) {
            var text = input.val();
            var matches = text.match(/(<([^>]+)>)/ig);
            if (matches != null) {
              return false;
            }
            return true;
          },
          messageLength: function (input) {
            var text = input.val();
            if (text.length > 2500) {
              return false;
            }
            return true;
          },
          whiteSpaces: function (input) {
            var text = input.val();
            if (text.length > 0) {
              return $.trim(text) !== "";
            }
            return true;
          },
          feedbackValidation: function (input) {
            var text = input.val();
            if (text.length > 0) {
              return formModel[formModelKey];
            }
            return true;
          }
        }
      }).data("kendoValidator");
    };
  
    var canSubmitForm = function () {
      return textAreaValidator("#feedback-code-sample-text-input", "outdatedSample").validate() &&
        textAreaValidator("#feedback-more-information-text-input", "otherMoreInformation").validate() &&
        textAreaValidator("#feedback-text-errors-text-input", "textErrors").validate() &&
        textAreaValidator("#feedback-inaccurate-content-text-input", "inaccurateContent").validate() &&
        textAreaValidator("#feedback-other-text-input", "otherFeedback").validate() &&
        emptyFormValidator.validate() &&
        emailValidator.validate();
    };
  
    feedbackForm.submit(function (e) {
      e.preventDefault();
      if (formIsProcessing) {
        return;
      }
      formIsProcessing = true;
  
      if (canSubmitForm()) {
        win.close();
        setCookieByName("submittingFeedback")
        formModel.yesNoFeedback = getCookieByName("yesNoFeedback") || "Not submitted";
        formModel.uuid = getCookieByName("uuid");
        formModel.path = currentPath;
        formModel.sheetId = $("#hidden-sheet-id").val();
        $.post("https://api.everlive.com/v1/lzrla9wpuk636rdd/functions/saveFeedback", formModel.toJSON(), function () {
          formIsProcessing = false;
        });
      } else {
        formIsProcessing = false;
      }
    });
  
    //Attach to close button inside form window
    $("#form-close-button").click(function () {
      win.close();
    });
  
    //Attach to submit button inside form window
    $("#form-submit-button").click(function () {
      feedbackForm.submit();
    });
  
    //Init buttons
    $("#yesButton").click(function () {
      setCookieByName("yesNoFeedback", "Yes");
      toggleFeedbackButtons(false);
      Feedback.closeFeedback();
      Feedback.hideFeedbackForm();
      Feedback.adjustNavigationPosition();
    });
    $("#noButton").click(function () {
      setCookieByName("yesNoFeedback", "No");
      toggleFeedbackButtons(false);
      Feedback.closeFeedback();
      Feedback.hideFeedbackForm();
      Feedback.adjustNavigationPosition();
      win.center().open();
    });
    $("#additional-feedback-button").click(function () {
      win.center().open();
    });
  
    var windowHeight = $window.height();
    var headerHeight = $(".TK-Hat").outerHeight() + $("#page-header").outerHeight();
    var footerHeight = $("#feedback-section").outerHeight() + $("footer").outerHeight();
    var articleHeight = windowHeight - (headerHeight + footerHeight);
    var feedbackOffsetTop = document.body.scrollHeight - footerHeight;
    var shouldOverlayFeedback = !getCookieByName("yesNoFeedback") && !getCookieByName("yesNoFeedbackClosed");
    var showingFeedbackBar = false;
    var scrollFold = $window.scrollTop() + windowHeight;
    var feedbackPinned = false;
  
    function updateVariables() {
      windowHeight = $window.height();
      headerHeight = $(".TK-Hat").outerHeight() + $("#page-header").outerHeight();
      footerHeight = $("#feedback-section").outerHeight() + $("footer").outerHeight();
      articleHeight = windowHeight - (headerHeight + footerHeight);
      feedbackOffsetTop = document.body.scrollHeight - footerHeight;
      scrollFold = $window.scrollTop() + windowHeight;
    }
  
    Feedback = $.extend(Feedback, {
  
      init: function () {
  
        Feedback._events();
  
        Feedback.adjustArticleHeight();
        Feedback.adjustNavigationPosition();
  
        if (shouldOverlayFeedback) {
  
          showingFeedbackBar = true;
  
          window.setTimeout(function () {
            showingFeedbackBar = false;
            Feedback.adjustFeedbackPoistion();
            Feedback.adjustNavigationPosition();
          }, 10000);
        }
  
      },
  
  
      // #region events
      _events: function () {
        $window.scroll(Feedback._window_scroll);
        $window.resize(Feedback._window_resize);
        $("#close-button").click(Feedback._button_click);
      },
      _window_scroll: function () {
        updateVariables();
  
        scrollFold = $window.scrollTop() + windowHeight;
  
        Feedback.adjustFeedbackPoistion();
        Feedback.adjustNavigationPosition();
      },
      _window_resize: function () {
        updateVariables();
  
        Feedback.adjustArticleHeight();
        Feedback.adjustFeedbackPoistion();
        Feedback.adjustNavigationPosition();
      },
      _button_click: function () {
        Feedback.closeFeedback();
        Feedback.adjustNavigationPosition();
      },
      // #endregion
  
  
      // #region adjusters
      adjustNavigationPosition: function Feedback_adjustNavigationPosition() {
        //called in various places to update location and position of feedback buttons container and article content container, not necessary in AJAX in the moment because we do not use the feedback container that pops up on scroll
	//var bottom = 0;
       
        //if (!window.matchMedia('(max-width: 1200px)').matches) {
        //  bottom = Math.max(feedbackPinned ? $("#feedback-section").outerHeight() : 0, scrollFold - feedbackOffsetTop);
        //}
        //$("#page-inner-content").css("bottom", bottom);
      },
{'fraction_non_alphanumeric': 0.13656998738965953, 'fraction_numerical': 0.005548549810844893, 'mean_word_length': 2.364111990950226, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '643845', 'n_tokens_mistral': 6680, 'n_tokens_neox': 6513, 'n_words': 1478}