index.js
/** Validates and saves the current survey to `localStorage` */
Validates and saves the current survey to `localStorage`
Validates and saves the current survey to ` localStorage `
function saveSurvey() {
  if (!/^\d{1,4}[A-Z]?$/.test(teamMetric.value)) {
    alert("Invalid team value");
    teamMetric.focus();
    return;
  }
  if (currentTemplate.teams) {
    if (!currentTemplate.teams.some(team => team == teamMetric.value)) {
      alert("Invalid team value");
      teamMetric.focus();
      return;
    }
  }
  if (!/\d{1,3}/.test(matchMetric.value)) {
    alert("Invalid match value");
    matchMetric.focus();
    return;
  }
  if (!confirm("Confirm save?")) return;
  let surveys = JSON.parse(localStorage.surveys ?? "[]");
  surveys.push([
    { name: "Team", value: teamMetric.value },
    { name: "Match", value: matchMetric.value },
    { name: "Absent", value: isAbsent },
    ...gameMetrics.map(metric => { return { name: metric.name, value: metric.value } })
  ]);
  localStorage.surveys = JSON.stringify(surveys);
  resetSurvey(false);
}
function saveSurvey ( ) { if ( ! / ^\d{1,4}[A-Z]?$ / . test ( teamMetric . value ) ) { alert ( "Invalid team value" ) ; teamMetric . focus ( ) ; return ; } if ( currentTemplate . teams ) { if ( ! currentTemplate . teams . some ( team => team == teamMetric . value ) ) { alert ( "Invalid team value" ) ; teamMetric . focus ( ) ; return ; } } if ( ! / \d{1,3} / . test ( matchMetric . value ) ) { alert ( "Invalid match value" ) ; matchMetric . focus ( ) ; return ; } if ( ! confirm ( "Confirm save?" ) ) return ; let surveys = JSON . parse ( localStorage . surveys ?? "[]" ) ; surveys . push ( [ { name : "Team" , value : teamMetric . value } , { name : "Match" , value : matchMetric . value } , { name : "Absent" , value : isAbsent } , ... gameMetrics . map ( metric => { return { name : metric . name , value : metric . value } } ) ] ) ; localStorage . surveys = JSON . stringify ( surveys ) ; resetSurvey ( false ) ; }
Validates and saves the current survey to `localStorage`
Validates and saves the current survey to ` localStorage `
// Matches a 1-4 long sequence of numbers and an optional character
 // Matches a 1-3 long sequence of numbers
