{"size": 1514, "ext": "js", "max_stars_repo_path": "openshift/templates/issuer-web/config/esr2/custom-scripts.js", "max_stars_repo_name": "esune/covid-19-essential-services", "max_stars_repo_stars_event_min_datetime": "2020-04-09T18:24:35.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-06T14:22:14.000Z", "max_issues_repo_path": "openshift/templates/issuer-web/config/esr2/custom-scripts.js", "max_issues_repo_name": "esune/covid-19-essential-services", "max_issues_repo_issues_event_min_datetime": "2020-04-09T20:18:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-16T20:35:33.000Z", "max_forks_repo_path": "openshift/templates/issuer-web/config/esr2/custom-scripts.js", "max_forks_repo_name": "esune/covid-19-essential-services", "max_forks_repo_forks_event_min_datetime": "2020-04-09T17:10:03.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-14T22:02:15.000Z"}
{"max_stars_count": 4, "max_issues_count": 35, "max_forks_count": 7, "avg_line_length": 30.28, "max_line_length": 87, "alphanum_fraction": 0.6737120211}
/* Include all your custom JS code in here, it will be available to the app instance */

function setCurrentISODate(params) {
  if (params.length < 1) {
    throw new Error(
      "setCurrentISODate is missing one or more required parameters"
    );
  }
  var dateField = params[0];
  var survey = this.survey;

  var date = new Date();
  survey.setValue(dateField, date.toISOString());
}

function setExpiryDate(params) {
  if (params.length < 2) {
    throw new Error("setExpiryDate is missing one or more required parameters");
  }
  var dateField = params[0];
  var dateControl = params[1];
  var survey = this.survey;

  var date = new Date();

  if (survey.getValue(dateControl) === "1 Week") {
    date.setUTCDate(date.getDate() + 7);
  } else if (survey.getValue(dateControl) === "2 Weeks") {
    date.setUTCDate(date.getDate() + 2 * 7);
  } else if (survey.getValue(dateControl) === "1 Month") {
    date.setUTCMonth(date.getMonth() + 1);
  } else if (survey.getValue(dateControl) === "3 Months") {
    date.setUTCMonth(date.getMonth() + 1);
  } else if (survey.getValue(dateControl) === "1 Year") {
    date.setYear(date.getFullYear() + 1);
  } else {
    date.setYear(3000);
    date.setUTCMonth(0);
    date.setUTCDate(1);
  }
  date.setUTCHours(23,59,59);

  survey.setValue(dateField, date.toISOString());
}

/* An array containing custom functions that will be automatically registered with
 * SurveyJS so that they can be used in triggers.
 */
surveyFunctions = [setCurrentISODate, setExpiryDate];
