From f7a22477354bbe671300597c02ec1c8f4ab24371 Mon Sep 17 00:00:00 2001 From: Alex West Date: Thu, 16 May 2024 23:40:17 -0700 Subject: [PATCH 1/2] added missing data args --- app/services/taggerButtonData.js | 4263 +++++++++++++++--------------- 1 file changed, 2069 insertions(+), 2194 deletions(-) diff --git a/app/services/taggerButtonData.js b/app/services/taggerButtonData.js index 9221268..f39a5c7 100644 --- a/app/services/taggerButtonData.js +++ b/app/services/taggerButtonData.js @@ -40,203 +40,194 @@ var player1GameScore = 0; var player2GameScore = 0; function updateScore(shotInRally, isWinner, serverName) { -if ((shotInRally % 2 == 0) & + if ((shotInRally % 2 == 0) & isWinner == '1') { - if (returnerScore == 40) { - if (serverName == 'Player1') { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; - } - else - { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; - } + if (returnerScore == 40) { + if (serverName == 'Player1') { + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; + } + else { + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; + } - } - else if (returnerScore != 30) { - returnerScore += 15; - } - else { - returnerScore += 10; - } -} -else if (shotInRally % 2 == 0) { - if (serverScore == 40) { - if (serverName == 'Player1') { - serverScore = 0; - returnerScore = 0; - player1GameScore += 1; - } - else - { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; - } - } - else if (serverScore != 30) { - serverScore += 15; - } - else { - serverScore += 10; - } - } -else if (shotInRally % 2 == 1 & -isWinner == '1') { + else if (returnerScore != 30) { + returnerScore += 15; + } + else { + returnerScore += 10; + } + } + else if (shotInRally % 2 == 0) { if (serverScore == 40) { - if (serverName == 'Player1') { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; - } - else - { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; - } + if (serverName == 'Player1') { + serverScore = 0; + returnerScore = 0; + player1GameScore += 1; + } + else { + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; + } } else if (serverScore != 30) { - serverScore += 15; - } - else { - serverScore += 10; - } -} -else { - if (returnerScore == 40) { - if (serverName == 'Player1') { - serverScore = 0; - returnerScore = 0; - player2GameScore += 1; - } - else - { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; - } - - } - else if (returnerScore != 30) { - returnerScore += 15; - } - else { - returnerScore += 10; - } -} -} -function chooseSide() { - if (serverScore == 40 || returnerScore == 40) { - if ((serverScore + returnerScore) % 2 == 0) { - return "Ad"; - } - else - { - return "Deuce"; - } + serverScore += 15; } else { - if ((serverScore + returnerScore) % 2 == 0) { - return "Deuce"; - } - else - { - return "Ad"; - } + serverScore += 10; } - -} -function doubleFault(serverName) { - if (returnerScore < 30) { - returnerScore += 15; + + } + else if (shotInRally % 2 == 1 & + isWinner == '1') { + if (serverScore == 40) { + if (serverName == 'Player1') { + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; + } + else { + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; + } } - else if (returnerScore < 40) { - returnerScore += 10; + else if (serverScore != 30) { + serverScore += 15; } else { - if (serverName == 'Player1') { - player2GameScore += 1; + serverScore += 10; + } + } + else { + if (returnerScore == 40) { + if (serverName == 'Player1') { serverScore = 0; returnerScore = 0; - } - else - { + player2GameScore += 1; + } + else { player1GameScore += 1; serverScore = 0; - returnerScore = 0; - } + returnerScore = 0; + } + + } + else if (returnerScore != 30) { + returnerScore += 15; + } + else { + returnerScore += 10; } + } } -function ace(serverName) { - if (serverScore < 30) { - serverScore += 15; +function chooseSide() { + if (serverScore == 40 || returnerScore == 40) { + if ((serverScore + returnerScore) % 2 == 0) { + return "Ad"; } - else if (serverScore < 40) { - serverScore += 10; + else { + return "Deuce"; + } + } + else { + if ((serverScore + returnerScore) % 2 == 0) { + return "Deuce"; } else { + return "Ad"; + } + } + +} +function doubleFault(serverName) { + if (returnerScore < 30) { + returnerScore += 15; + } + else if (returnerScore < 40) { + returnerScore += 10; + } + else { if (serverName == 'Player1') { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; } - else - { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; + else { + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; + } + } +} +function ace(serverName) { + if (serverScore < 30) { + serverScore += 15; + } + else if (serverScore < 40) { + serverScore += 10; + } + else { + if (serverName == 'Player1') { + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; } + else { + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; } - } + } +} function updateTiebreakScore(shotInRally, isWinner, serverName) { - if ((shotInRally % 2 == 0) & + if ((shotInRally % 2 == 0) & isWinner == '1') { - if (serverName == 'Player1') { - returnerScore += 1; - } - else { - serverScore += 1; - } + if (serverName == 'Player1') { + returnerScore += 1; } - else if ((shotInRally % 2 == 0)) { - if (serverName == 'Player1') { - serverScore += 1; - } - else { - returnerScore += 1; - } + else { + serverScore += 1; + } + } + else if ((shotInRally % 2 == 0)) { + if (serverName == 'Player1') { + serverScore += 1; + } + else { + returnerScore += 1; } - else if ((shotInRally % 2 == 1) & + } + else if ((shotInRally % 2 == 1) & isWinner == '1') { - if (serverName == 'Player1') { - serverScore += 1; - } - else { - returnerScore += 1; - } + if (serverName == 'Player1') { + serverScore += 1; } - else { - if (serverName == 'Player1') { - returnerScore += 1; - } - else { - serverScore += 1; - } + else { + returnerScore += 1; } + } + else { + if (serverName == 'Player1') { + returnerScore += 1; + } + else { + serverScore += 1; + } + } } function chooseTiebreakSide() { - if ((serverScore + returnerScore) % 2 == 0) { - return "Deuce"; - } -else - { - return "Ad"; - } + if ((serverScore + returnerScore) % 2 == 0) { + return "Deuce"; + } + else { + return "Ad"; + } } // function endPoint() { @@ -256,1829 +247,1720 @@ else // } // } export const getTaggerButtonData = (updateActiveRow, addNewRow, setCurrentPage) => ({ - // //added SetScore - // 'SetScore': [ - // { - // label: '0-0', - // action: () => { - // addNewRow(); - // updateLastRow('setScore', '0-0'); - // setCurrentPage('GameScore'); - // } - // }, - // { - // label: '0-1', - // action: () => { - // addNewRow(); - // updateLastRow('setScore', '0-1'); - // setCurrentPage('GameScore'); - // } - // }, - // { - // label: '1-0', - // action: () => { - // addNewRow(); - // updateLastRow('setScore', '1-0'); - // setCurrentPage('GameScore'); - // } - // }, - // { - // label: '1-1', - // action: () => { - // addNewRow(); - // updateLastRow('setScore', '1-1'); - // setCurrentPage('GameScore'); - // } - // }, - // ], - // // added GameScore - // 'GameScore': [ - // { - // label: '0-0', - // action: () => { - // updateLastRow('gameScore', '0-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-1', - // action: () => { - // updateLastRow('gameScore', '0-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-2', - // action: () => { - // updateLastRow('gameScore', '0-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-3', - // action: () => { - // updateLastRow('gameScore', '0-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-4', - // action: () => { - // updateLastRow('gameScore', '0-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-5', - // action: () => { - // updateLastRow('gameScore', '0-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-0', - // action: () => { - // updateLastRow('gameScore', '1-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-1', - // action: () => { - // updateLastRow('gameScore', '1-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-2', - // action: () => { - // updateLastRow('gameScore', '1-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-3', - // action: () => { - // updateLastRow('gameScore', '1-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-4', - // action: () => { - // updateLastRow('gameScore', '1-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-5', - // action: () => { - // updateLastRow('gameScore', '1-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-0', - // action: () => { - // updateLastRow('gameScore', '2-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-1', - // action: () => { - // updateLastRow('gameScore', '2-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-2', - // action: () => { - // updateLastRow('gameScore', '2-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-3', - // action: () => { - // updateLastRow('gameScore', '2-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-4', - // action: () => { - // updateLastRow('gameScore', '2-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-5', - // action: () => { - // updateLastRow('gameScore', '2-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-0', - // action: () => { - // updateLastRow('gameScore', '3-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-1', - // action: () => { - // updateLastRow('gameScore', '3-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-2', - // action: () => { - // updateLastRow('gameScore', '3-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-3', - // action: () => { - // updateLastRow('gameScore', '3-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-4', - // action: () => { - // updateLastRow('gameScore', '3-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-5', - // action: () => { - // updateLastRow('gameScore', '3-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-0', - // action: () => { - // updateLastRow('gameScore', '4-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-1', - // action: () => { - // updateLastRow('gameScore', '4-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-2', - // action: () => { - // updateLastRow('gameScore', '4-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-3', - // action: () => { - // updateLastRow('gameScore', '4-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-4', - // action: () => { - // updateLastRow('gameScore', '4-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-5', - // action: () => { - // updateLastRow('gameScore', '4-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-0', - // action: () => { - // updateLastRow('gameScore', '5-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-1', - // action: () => { - // updateLastRow('gameScore', '5-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-2', - // action: () => { - // updateLastRow('gameScore', '5-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-3', - // action: () => { - // updateLastRow('gameScore', '5-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-4', - // action: () => { - // updateLastRow('gameScore', '5-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-5', - // action: () => { - // updateLastRow('gameScore', '5-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-6', - // action: () => { - // updateLastRow('gameScore', '5-6'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '6-5', - // action: () => { - // updateLastRow('gameScore', '6-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '6-6', - // action: () => { - // updateLastRow('gameScore', '6-6'); - // setCurrentPage('ServerName'); - // } - // }, - - // ], - 'ServerName': [ - { - label: 'Player1', - action: () => { - addNewRow(); - updateActiveRow('serverName', 'Player1'); - setCurrentPage('ServerSide') - } - }, - { - label: 'Player2', - action: () => { - addNewRow(); - updateActiveRow('serverName', 'Player2'); - setCurrentPage('ServerSide') - } - }, - ], - 'ServerNameTiebreak': [ - { - label: 'Player1', - action: () => { - addNewRow(); - updateActiveRow('serverName', 'Player1'); - setCurrentPage('ServerSideTiebreak') - } - }, - { - label: 'Player2', - action: () => { - addNewRow(); - updateActiveRow('serverName', 'Player2'); - setCurrentPage('ServerSideTiebreak') - } - }, - ], - 'ServerSide': [ - { - label: 'NearSide', - action: () => { - updateActiveRow('serverFarNear', 'Near'); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - //setCurrentPage('PointScore') - } - }, - { - label: 'FarSide', - action: () => { - updateActiveRow('serverFarNear', 'Far'); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - // setCurrentPage('PointScore') - } - }, - ], - 'ServerSideTiebreak': [ - { - label: 'NearSide', - action: () => { - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseTiebreakSide()); - setCurrentPage('FirstServe'); - } - }, - { - label: 'FarSide', - action: () => { - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseTiebreakSide()); - setCurrentPage('FirstServe'); - } - }, - ], - 'PointScore': [ - { - label: '40-40 (Ad Side)', - action: (data) => { - updateActiveRow('pointScore', '40-40'); - updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', 'Ad'); - updateActiveRow('isBreakPoint', 1); - setCurrentPage('FirstServe'); - } - }, - { - label: '40-40 (Deuce Side)', - action: (data) => { - updateActiveRow('pointScore', '40-40'); - updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', 'Deuce'); - updateActiveRow('isBreakPoint', 1); - setCurrentPage('FirstServe'); - } - }, - ], - 'FirstServe': [ + // //added SetScore + // 'SetScore': [ + // { + // label: '0-0', + // action: () => { + // addNewRow(); + // updateLastRow('setScore', '0-0'); + // setCurrentPage('GameScore'); + // } + // }, + // { + // label: '0-1', + // action: () => { + // addNewRow(); + // updateLastRow('setScore', '0-1'); + // setCurrentPage('GameScore'); + // } + // }, + // { + // label: '1-0', + // action: () => { + // addNewRow(); + // updateLastRow('setScore', '1-0'); + // setCurrentPage('GameScore'); + // } + // }, + // { + // label: '1-1', + // action: () => { + // addNewRow(); + // updateLastRow('setScore', '1-1'); + // setCurrentPage('GameScore'); + // } + // }, + // ], + // // added GameScore + // 'GameScore': [ + // { + // label: '0-0', + // action: () => { + // updateLastRow('gameScore', '0-0'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '0-1', + // action: () => { + // updateLastRow('gameScore', '0-1'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '0-2', + // action: () => { + // updateLastRow('gameScore', '0-2'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '0-3', + // action: () => { + // updateLastRow('gameScore', '0-3'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '0-4', + // action: () => { + // updateLastRow('gameScore', '0-4'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '0-5', + // action: () => { + // updateLastRow('gameScore', '0-5'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '1-0', + // action: () => { + // updateLastRow('gameScore', '1-0'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '1-1', + // action: () => { + // updateLastRow('gameScore', '1-1'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '1-2', + // action: () => { + // updateLastRow('gameScore', '1-2'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '1-3', + // action: () => { + // updateLastRow('gameScore', '1-3'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '1-4', + // action: () => { + // updateLastRow('gameScore', '1-4'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '1-5', + // action: () => { + // updateLastRow('gameScore', '1-5'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '2-0', + // action: () => { + // updateLastRow('gameScore', '2-0'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '2-1', + // action: () => { + // updateLastRow('gameScore', '2-1'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '2-2', + // action: () => { + // updateLastRow('gameScore', '2-2'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '2-3', + // action: () => { + // updateLastRow('gameScore', '2-3'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '2-4', + // action: () => { + // updateLastRow('gameScore', '2-4'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '2-5', + // action: () => { + // updateLastRow('gameScore', '2-5'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '3-0', + // action: () => { + // updateLastRow('gameScore', '3-0'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '3-1', + // action: () => { + // updateLastRow('gameScore', '3-1'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '3-2', + // action: () => { + // updateLastRow('gameScore', '3-2'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '3-3', + // action: () => { + // updateLastRow('gameScore', '3-3'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '3-4', + // action: () => { + // updateLastRow('gameScore', '3-4'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '3-5', + // action: () => { + // updateLastRow('gameScore', '3-5'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '4-0', + // action: () => { + // updateLastRow('gameScore', '4-0'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '4-1', + // action: () => { + // updateLastRow('gameScore', '4-1'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '4-2', + // action: () => { + // updateLastRow('gameScore', '4-2'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '4-3', + // action: () => { + // updateLastRow('gameScore', '4-3'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '4-4', + // action: () => { + // updateLastRow('gameScore', '4-4'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '4-5', + // action: () => { + // updateLastRow('gameScore', '4-5'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '5-0', + // action: () => { + // updateLastRow('gameScore', '5-0'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '5-1', + // action: () => { + // updateLastRow('gameScore', '5-1'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '5-2', + // action: () => { + // updateLastRow('gameScore', '5-2'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '5-3', + // action: () => { + // updateLastRow('gameScore', '5-3'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '5-4', + // action: () => { + // updateLastRow('gameScore', '5-4'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '5-5', + // action: () => { + // updateLastRow('gameScore', '5-5'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '5-6', + // action: () => { + // updateLastRow('gameScore', '5-6'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '6-5', + // action: () => { + // updateLastRow('gameScore', '6-5'); + // setCurrentPage('ServerName'); + // } + // }, + // { + // label: '6-6', + // action: () => { + // updateLastRow('gameScore', '6-6'); + // setCurrentPage('ServerName'); + // } + // }, + + // ], + 'ServerName': [ + { + label: 'Player1', + action: () => { + addNewRow(); + updateActiveRow('serverName', 'Player1'); + setCurrentPage('ServerSide') + } + }, + { + label: 'Player2', + action: () => { + addNewRow(); + updateActiveRow('serverName', 'Player2'); + setCurrentPage('ServerSide') + } + }, + ], + 'ServerNameTiebreak': [ + { + label: 'Player1', + action: () => { + addNewRow(); + updateActiveRow('serverName', 'Player1'); + setCurrentPage('ServerSideTiebreak') + } + }, + { + label: 'Player2', + action: () => { + addNewRow(); + updateActiveRow('serverName', 'Player2'); + setCurrentPage('ServerSideTiebreak') + } + }, + ], + 'ServerSide': [ + { + label: 'NearSide', + action: () => { + updateActiveRow('serverFarNear', 'Near'); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + //setCurrentPage('PointScore') + } + }, + { + label: 'FarSide', + action: () => { + updateActiveRow('serverFarNear', 'Far'); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + // setCurrentPage('PointScore') + } + }, + ], + 'ServerSideTiebreak': [ + { + label: 'NearSide', + action: (data) => { + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseTiebreakSide()); + setCurrentPage('FirstServe'); + } + }, { - label: 'Ace', - action: () => { + label: 'FarSide', + action: (data) => { + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseTiebreakSide()); + setCurrentPage('FirstServe'); + } + }, + ], + 'PointScore': [ + { + label: '40-40 (Ad Side)', + action: (data) => { + updateActiveRow('pointScore', '40-40'); + updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', 'Ad'); + updateActiveRow('isBreakPoint', 1); + setCurrentPage('FirstServe'); + } + }, + { + label: '40-40 (Deuce Side)', + action: (data) => { + updateActiveRow('pointScore', '40-40'); + updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', 'Deuce'); + updateActiveRow('isBreakPoint', 1); + setCurrentPage('FirstServe'); + } + }, + ], + 'FirstServe': [ + { + label: 'Ace', + action: () => { updateActiveRow('isAce', '1'); updateActiveRow('isPointEnd', '1'); updateActiveRow('isWinner', '1'); //setCurrentPage('PointScore') - } + } }, { - courtImage: 'serve', - label: 'Select First Serve Position', - action: (data) => { - updateActiveRow('firstServeXCoord', data.x); - updateActiveRow('firstServeYCoord', data.y); - // Depending on coordinates, fill location of serve, etc... - if (data.table[data.activeRowIndex]['serverFarNear'] == 'Near') { - if ((data.table[data.activeRowIndex])['side'] == 'Deuce') // split by side - { - // Assuming coordinate range of x: 0-(-157), y: 0-245 - if (data.x >= -157 & data.x < -101) - { - updateActiveRow('firstServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else if (data.x >= -101 & data.x <= -54) - { - updateActiveRow('firstServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else if (data.x > -54 & data.x <= 0) - { - updateActiveRow('firstServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - if (data.x > 0) - { - updateActiveRow('firstServeZone', 'T'); - } - else - { - updateActiveRow('firstServeZone', 'Wide') - } - setCurrentPage('SecondServe'); - } - } - else // wide and T inverted for Ad side - { // Assuming coordinate range of x: 0-157, y: 0-245 - if (data.x >= 0 & data.x < 55) - { - updateActiveRow('firstServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else if (data.x >= 55 & data.x <= 105) - { - updateActiveRow('firstServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } + courtImage: 'serve', + label: 'Select First Serve Position', + action: (data) => { + updateActiveRow('firstServeXCoord', data.x); + updateActiveRow('firstServeYCoord', data.y); + // Depending on coordinates, fill location of serve, etc... + if (data.table[data.activeRowIndex]['serverFarNear'] == 'Near') { + if ((data.table[data.activeRowIndex])['side'] == 'Deuce') // split by side + { + // Assuming coordinate range of x: 0-(-157), y: 0-245 + if (data.x >= -157 & data.x < -101) { + updateActiveRow('firstServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } - else if (data.x > 105 & data.x <= 157) - { - updateActiveRow('firstServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } - else - { - updateActiveRow('firstServeIn', '0'); - if (data.x < 0) - { - updateActiveRow('firstServeZone', 'T'); - } - else - { - updateActiveRow('firstServeZone', 'Wide') - } - setCurrentPage('SecondServe'); - } + } + } + else { + setCurrentPage('GroundstrokeContact'); } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - // FAR SIDE - else - { - if ((data.table[data.activeRowIndex])['side'] == 'Ad') // split by side - { - // Assuming coordinate range of x: 0-(-157), y: 0-245 - if (data.x >= -157 & data.x < -105) - { - updateActiveRow('firstServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + else if (data.x >= -101 & data.x <= -54) { + updateActiveRow('firstServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } + } + } + else { + setCurrentPage('GroundstrokeContact'); } - else if (data.x >= -105 & data.x <= -52) - { - updateActiveRow('firstServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } + } + else if (data.x > -54 & data.x <= 0) { + updateActiveRow('firstServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } + } + } + else { + setCurrentPage('GroundstrokeContact'); } - else if (data.x > -52 & data.x < 0) - { - updateActiveRow('firstServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } + } + else { + updateActiveRow('firstServeIn', '0'); + if (data.x > 0) { + updateActiveRow('firstServeZone', 'T'); + } + else { + updateActiveRow('firstServeZone', 'Wide') + } + setCurrentPage('SecondServe'); + } + } + else // wide and T inverted for Ad side + { // Assuming coordinate range of x: 0-157, y: 0-245 + if (data.x >= 0 & data.x < 55) { + updateActiveRow('firstServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } + } } - else - { - updateActiveRow('firstServeIn', '0'); - if (data.x > 0) - { - updateActiveRow('firstServeZone', 'T'); - } - else - { - updateActiveRow('firstServeZone', 'Wide') - } - setCurrentPage('SecondServe'); + else { + setCurrentPage('GroundstrokeContact'); } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - else // wide and T inverted for Deuce side - { // Assuming coordinate range of x: 0-157, y: 0-245 - if (data.x >= 0 & data.x < 50) - { - updateActiveRow('firstServeZone', 'T'); - if (data.y <= 10 & data.y >= -245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + else if (data.x >= 55 & data.x <= 105) { + updateActiveRow('firstServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else if (data.x >= 50 & data.x <= 105) - { - updateActiveRow('firstServeZone', 'Body'); - if (data.y <= 10 & data.y >= -245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } + } } - else if (data.x > 105 & data.x <= 157) - { - updateActiveRow('firstServeZone', 'Wide'); - if (data.y <= 10 & data.y >= -245) - { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) - { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else - { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } + else { + setCurrentPage('GroundstrokeContact'); } - else - { - updateActiveRow('firstServeIn', '0'); - if (data.x <= 0) - { - updateActiveRow('firstServeZone', 'T'); - } - else - { - updateActiveRow('firstServeZone', 'Wide') - } - setCurrentPage('SecondServe'); - } - } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - } - }, - ], - 'SecondServe': [ - { - courtImage: 'serve', - label: 'Select Second Serve Position', - action: (data) => { - updateActiveRow('secondServeXCoord', data.x); - updateActiveRow('secondServeYCoord', data.y); - console.log(data.x); - console.log(data.y); - // Depending on coordinates, fill location of serve, etc... - if (data.table[data.activeRowIndex]['serverFarNear'] == 'Near') { - if ((data.table[data.activeRowIndex])['side'] == 'Deuce') // split by side - { - // Assuming coordinate range of x: 0-(-157), y: 0-245 - if (data.x >= -157 & data.x < -101) - { - updateActiveRow('secondServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + else if (data.x > 105 & data.x <= 157) { + updateActiveRow('firstServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } + else { + setCurrentPage('GroundstrokeContact'); } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - else if (data.x >= -101 & data.x <= -54) - { - updateActiveRow('secondServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + else { + updateActiveRow('firstServeIn', '0'); + if (data.x < 0) { + updateActiveRow('firstServeZone', 'T'); + } + else { + updateActiveRow('firstServeZone', 'Wide') + } + setCurrentPage('SecondServe'); + } + } + } + // FAR SIDE + else { + if ((data.table[data.activeRowIndex])['side'] == 'Ad') // split by side + { + // Assuming coordinate range of x: 0-(-157), y: 0-245 + if (data.x >= -157 & data.x < -105) { + updateActiveRow('firstServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } + else { + setCurrentPage('GroundstrokeContact'); } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - else if (data.x > -54 & data.x <= 0) - { - updateActiveRow('secondServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + else if (data.x >= -105 & data.x <= -52) { + updateActiveRow('firstServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } + else { + setCurrentPage('GroundstrokeContact'); } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - else - { - updateActiveRow('secondServeIn', '0'); - if (data.x > 0) - { - updateActiveRow('secondServeZone', 'T'); - } - else - { - updateActiveRow('secondServeZone', 'Wide') - } - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { + else if (data.x > -52 & data.x < 0) { + updateActiveRow('firstServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { setCurrentPage('ServerName'); - } - else { + } + else { addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } - } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } + else { + updateActiveRow('firstServeIn', '0'); + if (data.x > 0) { + updateActiveRow('firstServeZone', 'T'); + } + else { + updateActiveRow('firstServeZone', 'Wide') + } + setCurrentPage('SecondServe'); } - } - else // wide and T inverted for Ad side - { // Assuming coordinate range of x: 0-157, y: 0-245 - if (data.x >= 0 & data.x < 55) - { - updateActiveRow('secondServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + } + else // wide and T inverted for Deuce side + { // Assuming coordinate range of x: 0-157, y: 0-245 + if (data.x >= 0 & data.x < 50) { + updateActiveRow('firstServeZone', 'T'); + if (data.y <= 10 & data.y >= -245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } + else { + setCurrentPage('GroundstrokeContact'); } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - else if (data.x >= 55 & data.x <= 105) - { - updateActiveRow('secondServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + else if (data.x >= 50 & data.x <= 105) { + updateActiveRow('firstServeZone', 'Body'); + if (data.y <= 10 & data.y >= -245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } + else { + setCurrentPage('GroundstrokeContact'); } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - else if (data.x > 105 & data.x <= 157) - { - updateActiveRow('secondServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + else if (data.x > 105 & data.x <= 157) { + updateActiveRow('firstServeZone', 'Wide'); + if (data.y <= 10 & data.y >= -245) { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } + else { + setCurrentPage('GroundstrokeContact'); } + } + else { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - else - { + else { + updateActiveRow('firstServeIn', '0'); + if (data.x <= 0) { + updateActiveRow('firstServeZone', 'T'); + } + else { + updateActiveRow('firstServeZone', 'Wide') + } + setCurrentPage('SecondServe'); + } + } + } + } + }, + ], + 'SecondServe': [ + { + courtImage: 'serve', + label: 'Select Second Serve Position', + action: (data) => { + updateActiveRow('secondServeXCoord', data.x); + updateActiveRow('secondServeYCoord', data.y); + console.log(data.x); + console.log(data.y); + // Depending on coordinates, fill location of serve, etc... + if (data.table[data.activeRowIndex]['serverFarNear'] == 'Near') { + if ((data.table[data.activeRowIndex])['side'] == 'Deuce') // split by side + { + // Assuming coordinate range of x: 0-(-157), y: 0-245 + if (data.x >= -157 & data.x < -101) { + updateActiveRow('secondServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { updateActiveRow('secondServeIn', '0'); - if (data.x < 0) - { - updateActiveRow('secondServeZone', 'T'); - } - else - { - updateActiveRow('secondServeZone', 'Wide') - } doubleFault(data.table[data.activeRowIndex]['serverName']); if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + setCurrentPage('ServerName'); } else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { setCurrentPage('PointScore'); - } - else { + } + else { if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - } - } - } - // FAR SIDE - else - { - if ((data.table[data.activeRowIndex])['side'] == 'Ad') // split by side - { - // Assuming coordinate range of x: 75 -215, y: 470-723 - if (data.x >= -157 & data.x < -105) - { - updateActiveRow('secondServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); + else if (data.x >= -101 & data.x <= -54) { + updateActiveRow('secondServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else if (data.x >= -105 & data.x <= -52) - { - updateActiveRow('secondServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); + else if (data.x > -54 & data.x <= 0) { + updateActiveRow('secondServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } - else - { - updateActiveRow('secondServeIn', '0'); - addNewRow(); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } + } + else { + updateActiveRow('secondServeIn', '0'); + if (data.x > 0) { + updateActiveRow('secondServeZone', 'T'); + } + else { + updateActiveRow('secondServeZone', 'Wide') + } + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } } + } } - else if (data.x > -52 & data.x < 0) - { - updateActiveRow('secondServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); + } + else // wide and T inverted for Ad side + { // Assuming coordinate range of x: 0-157, y: 0-245 + if (data.x >= 0 & data.x < 55) { + updateActiveRow('secondServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else - { + else if (data.x >= 55 & data.x <= 105) { + updateActiveRow('secondServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { updateActiveRow('secondServeIn', '0'); - if (data.x < 0) - { - updateActiveRow('secondServeZone', 'T'); - } - else - { - updateActiveRow('secondServeZone', 'Wide') - } doubleFault(data.table[data.activeRowIndex]['serverName']); if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + setCurrentPage('ServerName'); } else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } + } + else if (data.x > 105 & data.x <= 157) { + updateActiveRow('secondServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } + else { + updateActiveRow('secondServeIn', '0'); + if (data.x < 0) { + updateActiveRow('secondServeZone', 'T'); + } + else { + updateActiveRow('secondServeZone', 'Wide') + } + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } } + } } - else // wide and T inverted for Deuce side - { // Assuming coordinate range of x: 215-350, y: 470-723 - if (data.x >= 0 & data.x < 50) - { - updateActiveRow('secondServeZone', 'T'); - if (data.y <= 10 & data.y >= -245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); + // FAR SIDE + else { + if ((data.table[data.activeRowIndex])['side'] == 'Ad') // split by side + { + // Assuming coordinate range of x: 75 -215, y: 470-723 + if (data.x >= -157 & data.x < -105) { + updateActiveRow('secondServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else if (data.x >= 50 & data.x <= 105) - { - updateActiveRow('secondServeZone', 'Body'); - if (data.y <= 10 & data.y >= -245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); + else if (data.x >= -105 & data.x <= -52) { + updateActiveRow('secondServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + addNewRow(); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } + } + else if (data.x > -52 & data.x < 0) { + updateActiveRow('secondServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } + } + else { + updateActiveRow('secondServeIn', '0'); + if (data.x < 0) { + updateActiveRow('secondServeZone', 'T'); + } + else { + updateActiveRow('secondServeZone', 'Wide') + } + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } } + } } - else if (data.x > 105 & data.x <= 157) - { - updateActiveRow('secondServeZone', 'Wide'); - if (data.y <= 10 & data.y >= -245) - { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); + } + else // wide and T inverted for Deuce side + { // Assuming coordinate range of x: 215-350, y: 470-723 + if (data.x >= 0 & data.x < 50) { + updateActiveRow('secondServeZone', 'T'); + if (data.y <= 10 & data.y >= -245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } - else - { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } + } + else if (data.x >= 50 & data.x <= 105) { + updateActiveRow('secondServeZone', 'Body'); + if (data.y <= 10 & data.y >= -245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else - { + else if (data.x > 105 & data.x <= 157) { + updateActiveRow('secondServeZone', 'Wide'); + if (data.y <= 10 & data.y >= -245) { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else { updateActiveRow('secondServeIn', '0'); - if (data.x < 0) - { - updateActiveRow('secondServeZone', 'T'); - } - else - { - updateActiveRow('secondServeZone', 'Wide') - } doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } else { + updateActiveRow('secondServeIn', '0'); + if (data.x < 0) { + updateActiveRow('secondServeZone', 'T'); + } + else { + updateActiveRow('secondServeZone', 'Wide') + } + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); updateActiveRow('pointScore', serverScore + '-' + returnerScore); @@ -2087,362 +1969,355 @@ export const getTaggerButtonData = (updateActiveRow, addNewRow, setCurrentPage) updateActiveRow('isPointStart', 1); updateActiveRow('shotInRally', 1); updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } - } + } + } + } } - - } + + } } - ], - 'GroundstrokeContact': [ - { - courtImage: true, - label: 'Select Shot Contact Position', - action: (data) => { - addNewRow(); - updateActiveRow('shotContactX', data.x); - updateActiveRow('shotContactY', data.y); - if (data.activeRowIndex > 0) { - updateActiveRow('shotInRally', parseInt(data.table[data.activeRowIndex]['shotInRally']) + 1); - // Need to copy down: pointScore, gameScore, setScore, serverName, serverSide - updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']); - updateActiveRow('pointScore', data.table[data.activeRowIndex]['pointScore']); - updateActiveRow('gameScore', data.table[data.activeRowIndex]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex]['setScore']); - updateActiveRow('tiebreakScore', data.table[data.activeRowIndex]['tiebreakScore']); - updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']); - } - else { - updateActiveRow('shotInRally', parseInt(data.table[0]['shotInRally']) + 1); - // Need to copy down: pointScore, gameScore, setScore, serverName, serverSide - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', data.table[0]['pointScore']); - updateActiveRow('gameScore', data.table[0]['gameScore']); - updateActiveRow('setScore', data.table[0]['setScore']); - updateActiveRow('tiebreakScore', data.table[0]['tiebreakScore']); - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - } - if (data.y > 0) - { // assuming 0 is halfway point - if (data.x < 0) - { - updateActiveRow('side', 'Deuce'); - setCurrentPage('GroundstrokeShotInfo') - } - else - { - updateActiveRow('side', 'Ad'); - setCurrentPage('GroundstrokeShotInfo') - } - } - else - { - if (data.x < 0) - { - updateActiveRow('side', 'Ad'); - setCurrentPage('GroundstrokeShotInfo') - } - else - { - updateActiveRow('side', 'Deuce'); - setCurrentPage('GroundstrokeShotInfo') - - } - } - }, + ], + 'GroundstrokeContact': [ + { + courtImage: true, + label: 'Select Shot Contact Position', + action: (data) => { + addNewRow(); + updateActiveRow('shotContactX', data.x); + updateActiveRow('shotContactY', data.y); + if (data.activeRowIndex > 0) { + updateActiveRow('shotInRally', parseInt(data.table[data.activeRowIndex]['shotInRally']) + 1); + // Need to copy down: pointScore, gameScore, setScore, serverName, serverSide + updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']); + updateActiveRow('pointScore', data.table[data.activeRowIndex]['pointScore']); + updateActiveRow('gameScore', data.table[data.activeRowIndex]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex]['setScore']); + updateActiveRow('tiebreakScore', data.table[data.activeRowIndex]['tiebreakScore']); + updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']); + } + else { + updateActiveRow('shotInRally', parseInt(data.table[0]['shotInRally']) + 1); + // Need to copy down: pointScore, gameScore, setScore, serverName, serverSide + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', data.table[0]['pointScore']); + updateActiveRow('gameScore', data.table[0]['gameScore']); + updateActiveRow('setScore', data.table[0]['setScore']); + updateActiveRow('tiebreakScore', data.table[0]['tiebreakScore']); + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + } + if (data.y > 0) { // assuming 0 is halfway point + if (data.x < 0) { + updateActiveRow('side', 'Deuce'); + setCurrentPage('GroundstrokeShotInfo') + } + else { + updateActiveRow('side', 'Ad'); + setCurrentPage('GroundstrokeShotInfo') + } + } + else { + if (data.x < 0) { + updateActiveRow('side', 'Ad'); + setCurrentPage('GroundstrokeShotInfo') + } + else { + updateActiveRow('side', 'Deuce'); + setCurrentPage('GroundstrokeShotInfo') + + } + } + }, } - ], - 'GroundstrokeShotInfo': [ - { - label: 'Forehand', - action: () => { - updateActiveRow('shotFhBh', 'Forehand'); - setCurrentPage('GroundstrokeLocation'); - } - }, - { - label: 'Backhand', - action: () => { - updateActiveRow('shotFhBh', 'Backhand'); - setCurrentPage('GroundstrokeLocation'); - } - }, + ], + 'GroundstrokeShotInfo': [ + { + label: 'Forehand', + action: () => { + updateActiveRow('shotFhBh', 'Forehand'); + setCurrentPage('GroundstrokeLocation'); + } + }, + { + label: 'Backhand', + action: () => { + updateActiveRow('shotFhBh', 'Backhand'); + setCurrentPage('GroundstrokeLocation'); + } + }, - ], - 'GroundstrokeLocation': [ - { - label: 'Slice', - action: () => { - updateActiveRow('isSlice', '1'); - } - }, - { - label: 'Dropshot', - action: () => { - updateActiveRow('isDropshot', '1'); - } - }, - { - label: 'Approach', - action: () => { - updateActiveRow('isApproach', '1'); - } - }, - { - label: 'Volley', - action: () => { - updateActiveRow('isVolley', '1'); - } - }, - { - label: 'Overhead', - action: () => { - updateActiveRow('isOverhead', '1'); + ], + 'GroundstrokeLocation': [ + { + label: 'Slice', + action: () => { + updateActiveRow('isSlice', '1'); + } + }, + { + label: 'Dropshot', + action: () => { + updateActiveRow('isDropshot', '1'); + } + }, + { + label: 'Approach', + action: () => { + updateActiveRow('isApproach', '1'); + } + }, + { + label: 'Volley', + action: () => { + updateActiveRow('isVolley', '1'); + } + }, + { + label: 'Overhead', + action: () => { + updateActiveRow('isOverhead', '1'); + } + }, + { + label: 'Lob', + action: () => { + updateActiveRow('isLob', '1'); + } + }, + { + label: 'Player1AtNet', + action: () => { + updateActiveRow('atNetPlayer1', '1'); + } + }, + { + label: 'Player2AtNet', + action: () => { + updateActiveRow('atNetPlayer2', '1'); + } + }, + { + label: 'Winner', + action: () => { + updateActiveRow('isWinner', '1'); + updateActiveRow('isPointEnd', '1'); + } + }, + { + courtImage: true, + label: 'Select Shot Result Location', + action: (data) => { + updateActiveRow('shotLocationX', data.x); + updateActiveRow('shotLocationY', data.y); + // assuming 0 is halfway point + if (data.x <= 0 & data.table[data.activeRowIndex]["shotContactX"] <= 0) { + updateActiveRow('shotDirection', "Down the Line"); + } + else if (data.x <= 0 & data.table[data.activeRowIndex]["shotContactX"] > 0) { + updateActiveRow('shotDirection', "Crosscourt"); + } + else if (data.x >= 0 & data.table[data.activeRowIndex]["shotContactX"] < 0) { + updateActiveRow('shotDirection', "Crosscourt"); + } + else { + updateActiveRow('shotDirection', "Down the Line"); + } + if (data.table[data.activeRowIndex]["shotContactY"] >= 0) { + if (data.y >= 0) { + updateActiveRow('isErrorNet', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.x > 157) { + updateActiveRow('isErrorWideL', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.x < -157) { + updateActiveRow('isErrorWideR', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.y < -455) { + updateActiveRow('isErrorLong', '1'); + updateActiveRow('isPointEnd', '1'); + } + + } + else { + if (data.y <= 0) { + updateActiveRow('isErrorNet', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.x < -157) { + updateActiveRow('isErrorWideL', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.x > 157) { + updateActiveRow('isErrorWideR', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.y > 455) { + updateActiveRow('isErrorLong', '1'); + updateActiveRow('isPointEnd', '1'); + } + } + + if ((data.table[data.activeRowIndex]["shotContactY"] >= 0 & ((data.y >= 0 || data.y < -455) || (data.x > 157 || data.x < -157))) || + (data.table[data.activeRowIndex]["shotContactY"] < 0 & ((data.y <= 0 || data.y > 455) || (data.x > 157 || data.x < -157))) || + (data.table[data.activeRowIndex]["isWinner"] == "1")) { + serverScore = parseInt(data.table[data.activeRowIndex]['pointScore'].split("-")[0]); + returnerScore = parseInt(data.table[data.activeRowIndex]['pointScore'].split("-")[1]); + player1GameScore = parseInt(data.table[data.activeRowIndex]['gameScore'].split("-")[0]); + player2GameScore = parseInt(data.table[data.activeRowIndex]['gameScore'].split("-")[1]); + player1SetScore = parseInt(data.table[data.activeRowIndex]['setScore'].split("-")[0]); + player2SetScore = parseInt(data.table[data.activeRowIndex]['setScore'].split("-")[1]); + if (player1GameScore == 6 && player2GameScore == 6) { + updateTiebreakScore(parseInt(data.table[data.activeRowIndex]["shotInRally"]), + data.table[data.activeRowIndex]["isWinner"], + data.table[data.activeRowIndex]["serverName"]); + if (serverScore >= 7 && (serverScore - returnerScore) >= 2) { + player1SetScore += 1; + player1GameScore = 0; + player2GameScore = 0; + serverScore = 0; + returnerScore = 0; + setCurrentPage('ServerName'); } - }, - { - label: 'Lob', - action: () => { - updateActiveRow('isLob', '1'); + else if (returnerScore >= 7 && (returnerScore - serverScore) >= 2) { + player1SetScore += 1; + player1GameScore = 0; + player2GameScore = 0; + returnerScore = 0; + serverScore = 0; + setCurrentPage('ServerName'); } - }, - { - label: 'Player1AtNet', - action: () => { - updateActiveRow('atNetPlayer1', '1'); + else { + if ((serverScore + returnerScore) % 2 == 1) { // need to switch scores cuz server switches + var tempServeScore = serverScore; + serverScore = returnerScore; + returnerScore = tempServeScore; + } + setCurrentPage('ServerName'); } - }, - { - label: 'Player2AtNet', - action: () => { - updateActiveRow('atNetPlayer2', '1'); + } + else { + updateScore(parseInt(data.table[data.activeRowIndex]["shotInRally"]), + data.table[data.activeRowIndex]["isWinner"], + data.table[data.activeRowIndex]["serverName"]); + if (serverScore == 0 && returnerScore == 0) { + if (player1GameScore >= 6) { + if (player1GameScore - player2GameScore >= 2) { + player1SetScore += 1; + player1GameScore = 0; + player2GameScore = 0; + } + } + else if (player2GameScore >= 6) { + if (player2GameScore - player1GameScore >= 2) { + player2SetScore += 1; + player2GameScore = 0; + player1GameScore = 0; + } + } + setCurrentPage('ServerName'); } - }, - { - label: 'Winner', - action: () => { - updateActiveRow('isWinner', '1'); - updateActiveRow('isPointEnd', '1'); + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']) + updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']) + setCurrentPage('PointScore'); + } + else { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', data.table[data.activeRowIndex]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } } - }, - { - courtImage: true, - label: 'Select Shot Result Location', - action: (data) => { - updateActiveRow('shotLocationX', data.x); - updateActiveRow('shotLocationY', data.y); - // assuming 0 is halfway point - if (data.x <= 0 & data.table[data.activeRowIndex]["shotContactX"] <= 0) { - updateActiveRow('shotDirection', "Down the Line"); - } - else if (data.x <= 0 & data.table[data.activeRowIndex]["shotContactX"] > 0) { - updateActiveRow('shotDirection', "Crosscourt"); - } - else if (data.x >= 0 & data.table[data.activeRowIndex]["shotContactX"] < 0) { - updateActiveRow('shotDirection', "Crosscourt"); - } - else { - updateActiveRow('shotDirection', "Down the Line"); - } - if (data.table[data.activeRowIndex]["shotContactY"] >= 0) { - if (data.y >= 0) { - updateActiveRow('isErrorNet', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.x > 157) { - updateActiveRow('isErrorWideL', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.x < -157) { - updateActiveRow('isErrorWideR', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.y < -455) { - updateActiveRow('isErrorLong', '1'); - updateActiveRow('isPointEnd', '1'); - } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } - } - else { - if (data.y <= 0) { - updateActiveRow('isErrorNet', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.x < -157) { - updateActiveRow('isErrorWideL', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.x > 157) { - updateActiveRow('isErrorWideR', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.y > 455) { - updateActiveRow('isErrorLong', '1'); - updateActiveRow('isPointEnd', '1'); - } - } + } - if ((data.table[data.activeRowIndex]["shotContactY"] >= 0 & ((data.y >= 0 || data.y <-455) || (data.x > 157 || data.x < -157))) || - (data.table[data.activeRowIndex]["shotContactY"] < 0 & ((data.y <= 0 || data.y > 455) || (data.x > 157 || data.x < -157))) || - (data.table[data.activeRowIndex]["isWinner"] == "1")) { - serverScore = parseInt(data.table[data.activeRowIndex]['pointScore'].split("-")[0]); - returnerScore = parseInt(data.table[data.activeRowIndex]['pointScore'].split("-")[1]); - player1GameScore = parseInt(data.table[data.activeRowIndex]['gameScore'].split("-")[0]); - player2GameScore = parseInt(data.table[data.activeRowIndex]['gameScore'].split("-")[1]); - player1SetScore = parseInt(data.table[data.activeRowIndex]['setScore'].split("-")[0]); - player2SetScore = parseInt(data.table[data.activeRowIndex]['setScore'].split("-")[1]); - if (player1GameScore == 6 && player2GameScore == 6) { - updateTiebreakScore(parseInt(data.table[data.activeRowIndex]["shotInRally"]), - data.table[data.activeRowIndex]["isWinner"], - data.table[data.activeRowIndex]["serverName"]); - if (serverScore >= 7 && (serverScore - returnerScore) >= 2 ) { - player1SetScore += 1; - player1GameScore = 0; - player2GameScore = 0; - serverScore = 0; - returnerScore = 0; - setCurrentPage('ServerName'); - } - else if (returnerScore >= 7 && (returnerScore - serverScore) >= 2 ) { - player1SetScore += 1; - player1GameScore = 0; - player2GameScore = 0; - returnerScore = 0; - serverScore = 0; - setCurrentPage('ServerName'); - } - else { - if ((serverScore + returnerScore) % 2 == 1) { // need to switch scores cuz server switches - var tempServeScore = serverScore; - serverScore = returnerScore; - returnerScore = tempServeScore; - } - setCurrentPage('ServerName'); - } - } - else { - updateScore(parseInt(data.table[data.activeRowIndex]["shotInRally"]), - data.table[data.activeRowIndex]["isWinner"], - data.table[data.activeRowIndex]["serverName"]); - if (serverScore == 0 && returnerScore == 0) { - if (player1GameScore >= 6) { - if (player1GameScore - player2GameScore >= 2) { - player1SetScore += 1; - player1GameScore = 0; - player2GameScore = 0; - } - } - else if (player2GameScore >= 6) { - if (player2GameScore - player1GameScore >= 2) { - player2SetScore += 1; - player2GameScore = 0; - player1GameScore = 0; - } - } - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']) - updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']) - setCurrentPage('PointScore'); - } - else { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', data.table[data.activeRowIndex]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } - else - { - setCurrentPage('GroundstrokeContact'); - } - - } - - }, - ], + }, + ], }); export const columnNames = [ - 'pointScore', - 'gameScore', - 'setScore', - 'isPointStart', - 'pointStartTime', - 'isPointEnd', - 'pointEndTime', - 'pointNumber', - 'isBreakPoint', - 'shotInRally', - 'side', - 'serverName', - 'serverFarNear', - 'firstServeIn', - 'firstServeZone', - 'firstServeXCoord', - 'firstServeYCoord', - 'secondServeIn', - 'secondServeZone', - 'secondServeXCoord', - 'secondServeYCoord', - 'isAce', - 'shotContactX', - 'shotContactY', - 'shotDirection', - 'shotFhBh', - 'isSlice', - 'isVolley', - 'isOverhead', - 'isApproach', - 'isDropshot', - 'atNetPlayer1', - 'atNetPlayer2', - 'isLob', - 'shotLocationX', - 'shotLocationY', - 'isWinner', - 'isErrorWideR', - 'isErrorWideL', - 'isErrorNet', - 'isErrorLong', - 'clientTeam', - 'Date', - 'Division', - 'Event', - 'lineupPosition', - 'matchDetails', - 'matchVenue', - 'opponentTeam', - 'player1Name', - 'player2Name', - 'player1Hand', - 'player2Hand', - 'Round', - 'Surface', - 'Notes', + 'pointScore', + 'gameScore', + 'setScore', + 'isPointStart', + 'pointStartTime', + 'isPointEnd', + 'pointEndTime', + 'pointNumber', + 'isBreakPoint', + 'shotInRally', + 'side', + 'serverName', + 'serverFarNear', + 'firstServeIn', + 'firstServeZone', + 'firstServeXCoord', + 'firstServeYCoord', + 'secondServeIn', + 'secondServeZone', + 'secondServeXCoord', + 'secondServeYCoord', + 'isAce', + 'shotContactX', + 'shotContactY', + 'shotDirection', + 'shotFhBh', + 'isSlice', + 'isVolley', + 'isOverhead', + 'isApproach', + 'isDropshot', + 'atNetPlayer1', + 'atNetPlayer2', + 'isLob', + 'shotLocationX', + 'shotLocationY', + 'isWinner', + 'isErrorWideR', + 'isErrorWideL', + 'isErrorNet', + 'isErrorLong', + 'clientTeam', + 'Date', + 'Division', + 'Event', + 'lineupPosition', + 'matchDetails', + 'matchVenue', + 'opponentTeam', + 'player1Name', + 'player2Name', + 'player1Hand', + 'player2Hand', + 'Round', + 'Surface', + 'Notes', ]; \ No newline at end of file From 84709bcbbcad7110b115796364705ee7eda2d906 Mon Sep 17 00:00:00 2001 From: Leo Cardozo Date: Sat, 18 May 2024 23:23:48 -0700 Subject: [PATCH 2/2] added exciting point --- app/services/taggerButtonData.js | 3959 ++++++++++++++---------------- 1 file changed, 1890 insertions(+), 2069 deletions(-) diff --git a/app/services/taggerButtonData.js b/app/services/taggerButtonData.js index f39a5c7..c3ef708 100644 --- a/app/services/taggerButtonData.js +++ b/app/services/taggerButtonData.js @@ -40,194 +40,203 @@ var player1GameScore = 0; var player2GameScore = 0; function updateScore(shotInRally, isWinner, serverName) { - if ((shotInRally % 2 == 0) & +if ((shotInRally % 2 == 0) & isWinner == '1') { - if (returnerScore == 40) { - if (serverName == 'Player1') { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; - } - else { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; - } + if (returnerScore == 40) { + if (serverName == 'Player1') { + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; + } + else + { + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; + } + } + else if (returnerScore != 30) { + returnerScore += 15; + } + else { + returnerScore += 10; + } +} +else if (shotInRally % 2 == 0) { + if (serverScore == 40) { + if (serverName == 'Player1') { + serverScore = 0; + returnerScore = 0; + player1GameScore += 1; + } + else + { + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; + } + } + else if (serverScore != 30) { + serverScore += 15; + } + else { + serverScore += 10; + } + } - else if (returnerScore != 30) { - returnerScore += 15; - } - else { - returnerScore += 10; - } - } - else if (shotInRally % 2 == 0) { - if (serverScore == 40) { - if (serverName == 'Player1') { - serverScore = 0; - returnerScore = 0; - player1GameScore += 1; - } - else { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; - } - } - else if (serverScore != 30) { - serverScore += 15; - } - else { - serverScore += 10; - } - - } - else if (shotInRally % 2 == 1 & - isWinner == '1') { +else if (shotInRally % 2 == 1 & +isWinner == '1') { if (serverScore == 40) { - if (serverName == 'Player1') { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; - } - else { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; - } + if (serverName == 'Player1') { + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; + } + else + { + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; + } } else if (serverScore != 30) { - serverScore += 15; - } - else { - serverScore += 10; + serverScore += 15; + } + else { + serverScore += 10; } - } - else { +} +else { if (returnerScore == 40) { - if (serverName == 'Player1') { - serverScore = 0; - returnerScore = 0; - player2GameScore += 1; - } - else { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; - } + if (serverName == 'Player1') { + serverScore = 0; + returnerScore = 0; + player2GameScore += 1; + } + else + { + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; + } - } - else if (returnerScore != 30) { - returnerScore += 15; - } - else { - returnerScore += 10; - } - } + } + else if (returnerScore != 30) { + returnerScore += 15; + } + else { + returnerScore += 10; + } +} } function chooseSide() { - if (serverScore == 40 || returnerScore == 40) { - if ((serverScore + returnerScore) % 2 == 0) { - return "Ad"; - } - else { - return "Deuce"; - } - } - else { - if ((serverScore + returnerScore) % 2 == 0) { - return "Deuce"; + if (serverScore == 40 || returnerScore == 40) { + if ((serverScore + returnerScore) % 2 == 0) { + return "Ad"; + } + else + { + return "Deuce"; + } } else { - return "Ad"; + if ((serverScore + returnerScore) % 2 == 0) { + return "Deuce"; + } + else + { + return "Ad"; + } } - } - + } function doubleFault(serverName) { - if (returnerScore < 30) { - returnerScore += 15; - } - else if (returnerScore < 40) { - returnerScore += 10; - } - else { - if (serverName == 'Player1') { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; + if (returnerScore < 30) { + returnerScore += 15; } - else { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; + else if (returnerScore < 40) { + returnerScore += 10; } - } -} -function ace(serverName) { - if (serverScore < 30) { - serverScore += 15; - } - else if (serverScore < 40) { - serverScore += 10; - } - else { + else { if (serverName == 'Player1') { - player1GameScore += 1; - serverScore = 0; - returnerScore = 0; + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; } - else { - player2GameScore += 1; - serverScore = 0; - returnerScore = 0; + else + { + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; + } } - } } -function updateTiebreakScore(shotInRally, isWinner, serverName) { - if ((shotInRally % 2 == 0) & - isWinner == '1') { - if (serverName == 'Player1') { - returnerScore += 1; +function ace(serverName) { + if (serverScore < 30) { + serverScore += 15; } - else { - serverScore += 1; + else if (serverScore < 40) { + serverScore += 10; } - } - else if ((shotInRally % 2 == 0)) { + else { if (serverName == 'Player1') { - serverScore += 1; + player1GameScore += 1; + serverScore = 0; + returnerScore = 0; } - else { - returnerScore += 1; + else + { + player2GameScore += 1; + serverScore = 0; + returnerScore = 0; } - } - else if ((shotInRally % 2 == 1) & + } + } +function updateTiebreakScore(shotInRally, isWinner, serverName) { + if ((shotInRally % 2 == 0) & isWinner == '1') { - if (serverName == 'Player1') { - serverScore += 1; + if (serverName == 'Player1') { + returnerScore += 1; + } + else { + serverScore += 1; + } } - else { - returnerScore += 1; + else if ((shotInRally % 2 == 0)) { + if (serverName == 'Player1') { + serverScore += 1; + } + else { + returnerScore += 1; + } } - } - else { - if (serverName == 'Player1') { - returnerScore += 1; + else if ((shotInRally % 2 == 1) & + isWinner == '1') { + if (serverName == 'Player1') { + serverScore += 1; + } + else { + returnerScore += 1; + } } - else { - serverScore += 1; + else { + if (serverName == 'Player1') { + returnerScore += 1; + } + else { + serverScore += 1; + } } - } } function chooseTiebreakSide() { - if ((serverScore + returnerScore) % 2 == 0) { - return "Deuce"; - } - else { - return "Ad"; - } + if ((serverScore + returnerScore) % 2 == 0) { + return "Deuce"; + } +else + { + return "Ad"; + } } // function endPoint() { @@ -247,1720 +256,1518 @@ function chooseTiebreakSide() { // } // } export const getTaggerButtonData = (updateActiveRow, addNewRow, setCurrentPage) => ({ - // //added SetScore - // 'SetScore': [ - // { - // label: '0-0', - // action: () => { - // addNewRow(); - // updateLastRow('setScore', '0-0'); - // setCurrentPage('GameScore'); - // } - // }, - // { - // label: '0-1', - // action: () => { - // addNewRow(); - // updateLastRow('setScore', '0-1'); - // setCurrentPage('GameScore'); - // } - // }, - // { - // label: '1-0', - // action: () => { - // addNewRow(); - // updateLastRow('setScore', '1-0'); - // setCurrentPage('GameScore'); - // } - // }, - // { - // label: '1-1', - // action: () => { - // addNewRow(); - // updateLastRow('setScore', '1-1'); - // setCurrentPage('GameScore'); - // } - // }, - // ], - // // added GameScore - // 'GameScore': [ - // { - // label: '0-0', - // action: () => { - // updateLastRow('gameScore', '0-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-1', - // action: () => { - // updateLastRow('gameScore', '0-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-2', - // action: () => { - // updateLastRow('gameScore', '0-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-3', - // action: () => { - // updateLastRow('gameScore', '0-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-4', - // action: () => { - // updateLastRow('gameScore', '0-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '0-5', - // action: () => { - // updateLastRow('gameScore', '0-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-0', - // action: () => { - // updateLastRow('gameScore', '1-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-1', - // action: () => { - // updateLastRow('gameScore', '1-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-2', - // action: () => { - // updateLastRow('gameScore', '1-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-3', - // action: () => { - // updateLastRow('gameScore', '1-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-4', - // action: () => { - // updateLastRow('gameScore', '1-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '1-5', - // action: () => { - // updateLastRow('gameScore', '1-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-0', - // action: () => { - // updateLastRow('gameScore', '2-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-1', - // action: () => { - // updateLastRow('gameScore', '2-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-2', - // action: () => { - // updateLastRow('gameScore', '2-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-3', - // action: () => { - // updateLastRow('gameScore', '2-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-4', - // action: () => { - // updateLastRow('gameScore', '2-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '2-5', - // action: () => { - // updateLastRow('gameScore', '2-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-0', - // action: () => { - // updateLastRow('gameScore', '3-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-1', - // action: () => { - // updateLastRow('gameScore', '3-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-2', - // action: () => { - // updateLastRow('gameScore', '3-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-3', - // action: () => { - // updateLastRow('gameScore', '3-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-4', - // action: () => { - // updateLastRow('gameScore', '3-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '3-5', - // action: () => { - // updateLastRow('gameScore', '3-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-0', - // action: () => { - // updateLastRow('gameScore', '4-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-1', - // action: () => { - // updateLastRow('gameScore', '4-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-2', - // action: () => { - // updateLastRow('gameScore', '4-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-3', - // action: () => { - // updateLastRow('gameScore', '4-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-4', - // action: () => { - // updateLastRow('gameScore', '4-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '4-5', - // action: () => { - // updateLastRow('gameScore', '4-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-0', - // action: () => { - // updateLastRow('gameScore', '5-0'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-1', - // action: () => { - // updateLastRow('gameScore', '5-1'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-2', - // action: () => { - // updateLastRow('gameScore', '5-2'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-3', - // action: () => { - // updateLastRow('gameScore', '5-3'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-4', - // action: () => { - // updateLastRow('gameScore', '5-4'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-5', - // action: () => { - // updateLastRow('gameScore', '5-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '5-6', - // action: () => { - // updateLastRow('gameScore', '5-6'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '6-5', - // action: () => { - // updateLastRow('gameScore', '6-5'); - // setCurrentPage('ServerName'); - // } - // }, - // { - // label: '6-6', - // action: () => { - // updateLastRow('gameScore', '6-6'); - // setCurrentPage('ServerName'); - // } - // }, - - // ], - 'ServerName': [ - { - label: 'Player1', - action: () => { - addNewRow(); - updateActiveRow('serverName', 'Player1'); - setCurrentPage('ServerSide') - } - }, - { - label: 'Player2', - action: () => { - addNewRow(); - updateActiveRow('serverName', 'Player2'); - setCurrentPage('ServerSide') - } - }, - ], - 'ServerNameTiebreak': [ - { - label: 'Player1', - action: () => { - addNewRow(); - updateActiveRow('serverName', 'Player1'); - setCurrentPage('ServerSideTiebreak') - } - }, - { - label: 'Player2', - action: () => { - addNewRow(); - updateActiveRow('serverName', 'Player2'); - setCurrentPage('ServerSideTiebreak') - } - }, - ], - 'ServerSide': [ - { - label: 'NearSide', - action: () => { - updateActiveRow('serverFarNear', 'Near'); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - //setCurrentPage('PointScore') - } - }, - { - label: 'FarSide', - action: () => { - updateActiveRow('serverFarNear', 'Far'); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - // setCurrentPage('PointScore') - } - }, - ], - 'ServerSideTiebreak': [ - { - label: 'NearSide', - action: (data) => { - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseTiebreakSide()); - setCurrentPage('FirstServe'); - } - }, - { - label: 'FarSide', - action: (data) => { - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseTiebreakSide()); - setCurrentPage('FirstServe'); - } - }, - ], - 'PointScore': [ - { - label: '40-40 (Ad Side)', - action: (data) => { - updateActiveRow('pointScore', '40-40'); - updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', 'Ad'); - updateActiveRow('isBreakPoint', 1); - setCurrentPage('FirstServe'); - } - }, - { - label: '40-40 (Deuce Side)', - action: (data) => { - updateActiveRow('pointScore', '40-40'); - updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', 'Deuce'); - updateActiveRow('isBreakPoint', 1); - setCurrentPage('FirstServe'); - } - }, - ], - 'FirstServe': [ + + 'ServerName': [ + { + label: 'Player1', + action: () => { + addNewRow(); + updateActiveRow('serverName', 'Player1'); + setCurrentPage('ServerSide') + } + }, + { + label: 'Player2', + action: () => { + addNewRow(); + updateActiveRow('serverName', 'Player2'); + setCurrentPage('ServerSide') + } + }, + ], + 'ServerNameTiebreak': [ + { + label: 'Player1', + action: () => { + addNewRow(); + updateActiveRow('serverName', 'Player1'); + setCurrentPage('ServerSideTiebreak') + } + }, + { + label: 'Player2', + action: () => { + addNewRow(); + updateActiveRow('serverName', 'Player2'); + setCurrentPage('ServerSideTiebreak') + } + }, + ], + 'ServerSide': [ + { + label: 'NearSide', + action: () => { + updateActiveRow('serverFarNear', 'Near'); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + //setCurrentPage('PointScore') + } + }, + { + label: 'FarSide', + action: () => { + updateActiveRow('serverFarNear', 'Far'); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + // setCurrentPage('PointScore') + } + }, + ], + 'ServerSideTiebreak': [ + { + label: 'NearSide', + action: () => { + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseTiebreakSide()); + setCurrentPage('FirstServe'); + } + }, + { + label: 'FarSide', + action: () => { + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseTiebreakSide()); + setCurrentPage('FirstServe'); + } + }, + ], + 'PointScore': [ + { + label: '40-40 (Ad Side)', + action: (data) => { + updateActiveRow('pointScore', '40-40'); + updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', 'Ad'); + updateActiveRow('isBreakPoint', 1); + setCurrentPage('FirstServe'); + } + }, + { + label: '40-40 (Deuce Side)', + action: (data) => { + updateActiveRow('pointScore', '40-40'); + updateActiveRow('gameScore', data.table[data.activeRowIndex - 1]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex - 1]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', 'Deuce'); + updateActiveRow('isBreakPoint', 1); + setCurrentPage('FirstServe'); + } + }, + ], + 'FirstServe': [ { - label: 'Ace', - action: () => { + label: 'Ace', + action: () => { updateActiveRow('isAce', '1'); updateActiveRow('isPointEnd', '1'); updateActiveRow('isWinner', '1'); //setCurrentPage('PointScore') - } + } }, { - courtImage: 'serve', - label: 'Select First Serve Position', - action: (data) => { - updateActiveRow('firstServeXCoord', data.x); - updateActiveRow('firstServeYCoord', data.y); - // Depending on coordinates, fill location of serve, etc... - if (data.table[data.activeRowIndex]['serverFarNear'] == 'Near') { - if ((data.table[data.activeRowIndex])['side'] == 'Deuce') // split by side - { - // Assuming coordinate range of x: 0-(-157), y: 0-245 - if (data.x >= -157 & data.x < -101) { - updateActiveRow('firstServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + courtImage: 'serve', + label: 'Select First Serve Position', + action: (data) => { + updateActiveRow('firstServeXCoord', data.x); + updateActiveRow('firstServeYCoord', data.y); + // Depending on coordinates, fill location of serve, etc... + if (data.table[data.activeRowIndex]['serverFarNear'] == 'Near') { + if ((data.table[data.activeRowIndex])['side'] == 'Deuce') // split by side + { + // Assuming coordinate range of x: 0-(-157), y: 0-245 + if (data.x >= -157 & data.x < -101) + { + updateActiveRow('firstServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } + } + else if (data.x >= -101 & data.x <= -54) + { + updateActiveRow('firstServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } + } + else if (data.x > -54 & data.x <= 0) + { + updateActiveRow('firstServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + if (data.x > 0) + { + updateActiveRow('firstServeZone', 'T'); + } + else + { + updateActiveRow('firstServeZone', 'Wide') + } + setCurrentPage('SecondServe'); + } } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else // wide and T inverted for Ad side + { // Assuming coordinate range of x: 0-157, y: 0-245 + if (data.x >= 0 & data.x < 55) + { + updateActiveRow('firstServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - } - } - else { - setCurrentPage('GroundstrokeContact'); + else if (data.x >= 55 & data.x <= 105) + { + updateActiveRow('firstServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } + } + else if (data.x > 105 & data.x <= 157) + { + updateActiveRow('firstServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + if (data.x < 0) + { + updateActiveRow('firstServeZone', 'T'); + } + else + { + updateActiveRow('firstServeZone', 'Wide') + } + setCurrentPage('SecondServe'); + } } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } } - else if (data.x >= -101 & data.x <= -54) { - updateActiveRow('firstServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + // FAR SIDE + else + { + if ((data.table[data.activeRowIndex])['side'] == 'Ad') // split by side + { + // Assuming coordinate range of x: 0-(-157), y: 0-245 + if (data.x >= -157 & data.x < -105) + { + updateActiveRow('firstServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); } - } - } - else { - setCurrentPage('GroundstrokeContact'); } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else if (data.x > -54 & data.x <= 0) { - updateActiveRow('firstServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else if (data.x >= -105 & data.x <= -52) + { + updateActiveRow('firstServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); } - } - } - else { - setCurrentPage('GroundstrokeContact'); } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else { - updateActiveRow('firstServeIn', '0'); - if (data.x > 0) { - updateActiveRow('firstServeZone', 'T'); - } - else { - updateActiveRow('firstServeZone', 'Wide') - } - setCurrentPage('SecondServe'); - } - } - else // wide and T inverted for Ad side - { // Assuming coordinate range of x: 0-157, y: 0-245 - if (data.x >= 0 & data.x < 55) { - updateActiveRow('firstServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else if (data.x > -52 & data.x < 0) + { + updateActiveRow('firstServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); } - } } - else { - setCurrentPage('GroundstrokeContact'); + else + { + updateActiveRow('firstServeIn', '0'); + if (data.x > 0) + { + updateActiveRow('firstServeZone', 'T'); + } + else + { + updateActiveRow('firstServeZone', 'Wide') + } + setCurrentPage('SecondServe'); } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } } - else if (data.x >= 55 & data.x <= 105) { - updateActiveRow('firstServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else // wide and T inverted for Deuce side + { // Assuming coordinate range of x: 0-157, y: 0-245 + if (data.x >= 0 & data.x < 50) + { + updateActiveRow('firstServeZone', 'T'); + if (data.y <= 10 & data.y >= -245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); } - } - } - else { - setCurrentPage('GroundstrokeContact'); } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else if (data.x > 105 & data.x <= 157) { - updateActiveRow('firstServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else if (data.x >= 50 & data.x <= 105) + { + updateActiveRow('firstServeZone', 'Body'); + if (data.y <= 10 & data.y >= -245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } else { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - else { - setCurrentPage('GroundstrokeContact'); + else if (data.x > 105 & data.x <= 157) + { + updateActiveRow('firstServeZone', 'Wide'); + if (data.y <= 10 & data.y >= -245) + { + updateActiveRow('firstServeIn', '1'); + if (data.table[data.activeRowIndex]['isAce'] == '1') { + ace(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) + { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + } + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + else { + setCurrentPage('GroundstrokeContact'); + } + } + else + { + updateActiveRow('firstServeIn', '0'); + setCurrentPage('SecondServe'); + } } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else { - updateActiveRow('firstServeIn', '0'); - if (data.x < 0) { - updateActiveRow('firstServeZone', 'T'); - } - else { - updateActiveRow('firstServeZone', 'Wide') - } - setCurrentPage('SecondServe'); + else + { + updateActiveRow('firstServeIn', '0'); + if (data.x <= 0) + { + updateActiveRow('firstServeZone', 'T'); + } + else + { + updateActiveRow('firstServeZone', 'Wide') + } + setCurrentPage('SecondServe'); + } + } } - } } - // FAR SIDE - else { - if ((data.table[data.activeRowIndex])['side'] == 'Ad') // split by side - { + }, + ], + 'SecondServe': [ + { + courtImage: 'serve', + label: 'Select Second Serve Position', + action: (data) => { + updateActiveRow('secondServeXCoord', data.x); + updateActiveRow('secondServeYCoord', data.y); + console.log(data.x); + console.log(data.y); + // Depending on coordinates, fill location of serve, etc... + if (data.table[data.activeRowIndex]['serverFarNear'] == 'Near') { + if ((data.table[data.activeRowIndex])['side'] == 'Deuce') // split by side + { // Assuming coordinate range of x: 0-(-157), y: 0-245 - if (data.x >= -157 & data.x < -105) { - updateActiveRow('firstServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + if (data.x >= -157 & data.x < -101) + { + updateActiveRow('secondServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else if (data.x >= -105 & data.x <= -52) { - updateActiveRow('firstServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else { - setCurrentPage('GroundstrokeContact'); } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } } - else if (data.x > -52 & data.x < 0) { - updateActiveRow('firstServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else if (data.x >= -101 & data.x <= -54) + { + updateActiveRow('secondServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else { - updateActiveRow('firstServeIn', '0'); - if (data.x > 0) { - updateActiveRow('firstServeZone', 'T'); - } - else { - updateActiveRow('firstServeZone', 'Wide') - } - setCurrentPage('SecondServe'); - } - } - else // wide and T inverted for Deuce side - { // Assuming coordinate range of x: 0-157, y: 0-245 - if (data.x >= 0 & data.x < 50) { - updateActiveRow('firstServeZone', 'T'); - if (data.y <= 10 & data.y >= -245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else { - setCurrentPage('GroundstrokeContact'); } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } } - else if (data.x >= 50 & data.x <= 105) { - updateActiveRow('firstServeZone', 'Body'); - if (data.y <= 10 & data.y >= -245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + else if (data.x > -54 & data.x <= 0) + { + updateActiveRow('secondServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else if (data.x > 105 & data.x <= 157) { - updateActiveRow('firstServeZone', 'Wide'); - if (data.y <= 10 & data.y >= -245) { - updateActiveRow('firstServeIn', '1'); - if (data.table[data.activeRowIndex]['isAce'] == '1') { - ace(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); + addNewRow(); if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + setCurrentPage('PointScore'); } else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - } - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else { - setCurrentPage('GroundstrokeContact'); } - } - else { - updateActiveRow('firstServeIn', '0'); - setCurrentPage('SecondServe'); - } - } - else { - updateActiveRow('firstServeIn', '0'); - if (data.x <= 0) { - updateActiveRow('firstServeZone', 'T'); - } - else { - updateActiveRow('firstServeZone', 'Wide') - } - setCurrentPage('SecondServe'); } - } - } - } - }, - ], - 'SecondServe': [ - { - courtImage: 'serve', - label: 'Select Second Serve Position', - action: (data) => { - updateActiveRow('secondServeXCoord', data.x); - updateActiveRow('secondServeYCoord', data.y); - console.log(data.x); - console.log(data.y); - // Depending on coordinates, fill location of serve, etc... - if (data.table[data.activeRowIndex]['serverFarNear'] == 'Near') { - if ((data.table[data.activeRowIndex])['side'] == 'Deuce') // split by side - { - // Assuming coordinate range of x: 0-(-157), y: 0-245 - if (data.x >= -157 & data.x < -101) { - updateActiveRow('secondServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { + else + { updateActiveRow('secondServeIn', '0'); + if (data.x > 0) + { + updateActiveRow('secondServeZone', 'T'); + } + else + { + updateActiveRow('secondServeZone', 'Wide') + } doubleFault(data.table[data.activeRowIndex]['serverName']); if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + setCurrentPage('ServerName'); } else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { setCurrentPage('PointScore'); - } - else { + } + else { if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else if (data.x >= -101 & data.x <= -54) { - updateActiveRow('secondServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + } + } + else // wide and T inverted for Ad side + { // Assuming coordinate range of x: 0-157, y: 0-245 + if (data.x >= 0 & data.x < 55) + { + updateActiveRow('secondServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else if (data.x > -54 & data.x <= 0) { - updateActiveRow('secondServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + else if (data.x >= 55 & data.x <= 105) + { + updateActiveRow('secondServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } - } - else { - updateActiveRow('secondServeIn', '0'); - if (data.x > 0) { - updateActiveRow('secondServeZone', 'T'); - } - else { - updateActiveRow('secondServeZone', 'Wide') - } - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } } - } } - } - else // wide and T inverted for Ad side - { // Assuming coordinate range of x: 0-157, y: 0-245 - if (data.x >= 0 & data.x < 55) { - updateActiveRow('secondServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + else if (data.x > 105 & data.x <= 157) + { + updateActiveRow('secondServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else if (data.x >= 55 & data.x <= 105) { - updateActiveRow('secondServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { + else + { updateActiveRow('secondServeIn', '0'); + if (data.x < 0) + { + updateActiveRow('secondServeZone', 'T'); + } + else + { + updateActiveRow('secondServeZone', 'Wide') + } doubleFault(data.table[data.activeRowIndex]['serverName']); if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + setCurrentPage('ServerName'); } else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { setCurrentPage('PointScore'); - } - else { + } + else { if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else if (data.x > 105 & data.x <= 157) { - updateActiveRow('secondServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + } + } + } + // FAR SIDE + else + { + if ((data.table[data.activeRowIndex])['side'] == 'Ad') // split by side + { + // Assuming coordinate range of x: 75 -215, y: 470-723 + if (data.x >= -157 & data.x < -105) + { + updateActiveRow('secondServeZone', 'Wide'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } - } - else { - updateActiveRow('secondServeIn', '0'); - if (data.x < 0) { - updateActiveRow('secondServeZone', 'T'); - } - else { - updateActiveRow('secondServeZone', 'Wide') - } - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } } - } } - } - } - // FAR SIDE - else { - if ((data.table[data.activeRowIndex])['side'] == 'Ad') // split by side - { - // Assuming coordinate range of x: 75 -215, y: 470-723 - if (data.x >= -157 & data.x < -105) { - updateActiveRow('secondServeZone', 'Wide'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + else if (data.x >= -105 & data.x <= -52) + { + updateActiveRow('secondServeZone', 'Body'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else + { + updateActiveRow('secondServeIn', '0'); + addNewRow(); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else if (data.x >= -105 & data.x <= -52) { - updateActiveRow('secondServeZone', 'Body'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { - updateActiveRow('secondServeIn', '0'); - addNewRow(); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + else if (data.x > -52 & data.x < 0) + { + updateActiveRow('secondServeZone', 'T'); + if (data.y >= 10 & data.y <= 245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else if (data.x > -52 & data.x < 0) { - updateActiveRow('secondServeZone', 'T'); - if (data.y >= 10 & data.y <= 245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { + else + { updateActiveRow('secondServeIn', '0'); + if (data.x < 0) + { + updateActiveRow('secondServeZone', 'T'); + } + else + { + updateActiveRow('secondServeZone', 'Wide') + } doubleFault(data.table[data.activeRowIndex]['serverName']); if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + setCurrentPage('ServerName'); } else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { setCurrentPage('PointScore'); - } - else { + } + else { if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else { - updateActiveRow('secondServeIn', '0'); - if (data.x < 0) { + } + } + else // wide and T inverted for Deuce side + { // Assuming coordinate range of x: 215-350, y: 470-723 + if (data.x >= 0 & data.x < 50) + { updateActiveRow('secondServeZone', 'T'); - } - else { - updateActiveRow('secondServeZone', 'Wide') - } - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); + if (data.y <= 10 & data.y >= -245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); + } + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } } - } } - } - else // wide and T inverted for Deuce side - { // Assuming coordinate range of x: 215-350, y: 470-723 - if (data.x >= 0 & data.x < 50) { - updateActiveRow('secondServeZone', 'T'); - if (data.y <= 10 & data.y >= -245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + else if (data.x >= 50 & data.x <= 105) + { + updateActiveRow('secondServeZone', 'Body'); + if (data.y <= 10 & data.y >= -245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else if (data.x >= 50 & data.x <= 105) { - updateActiveRow('secondServeZone', 'Body'); - if (data.y <= 10 & data.y >= -245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { - updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + else if (data.x > 105 & data.x <= 157) + { + updateActiveRow('secondServeZone', 'Wide'); + if (data.y <= 10 & data.y >= -245) + { + updateActiveRow('secondServeIn', '1'); + setCurrentPage('GroundstrokeContact'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); + else + { + updateActiveRow('secondServeIn', '0'); + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } } - else if (data.x > 105 & data.x <= 157) { - updateActiveRow('secondServeZone', 'Wide'); - if (data.y <= 10 & data.y >= -245) { - updateActiveRow('secondServeIn', '1'); - setCurrentPage('GroundstrokeContact'); - } - else { + else + { updateActiveRow('secondServeIn', '0'); - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); + if (data.x < 0) + { + updateActiveRow('secondServeZone', 'T'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - } - } - } + else + { + updateActiveRow('secondServeZone', 'Wide') + } + doubleFault(data.table[data.activeRowIndex]['serverName']); + if (serverScore == 0 && returnerScore == 0) { + setCurrentPage('ServerName'); } else { - updateActiveRow('secondServeIn', '0'); - if (data.x < 0) { - updateActiveRow('secondServeZone', 'T'); - } - else { - updateActiveRow('secondServeZone', 'Wide') - } - doubleFault(data.table[data.activeRowIndex]['serverName']); - if (serverScore == 0 && returnerScore == 0) { - setCurrentPage('ServerName'); - } - else { addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - setCurrentPage('PointScore'); - } - else { - if (data.activeRowIndex > 0) { + if (serverScore == 40 && returnerScore == 40) { + setCurrentPage('PointScore'); + } + else { + if (data.activeRowIndex > 0) { updateActiveRow('serverFarNear', data.table[data.activeRowIndex - 1]['serverFarNear']); updateActiveRow('serverName', data.table[data.activeRowIndex - 1]['serverName']); updateActiveRow('pointScore', serverScore + '-' + returnerScore); @@ -1969,355 +1776,369 @@ export const getTaggerButtonData = (updateActiveRow, addNewRow, setCurrentPage) updateActiveRow('isPointStart', 1); updateActiveRow('shotInRally', 1); updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } - else { - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); - updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } + setCurrentPage('FirstServe'); } - } - } - } - } - - } - } - ], - 'GroundstrokeContact': [ - { - courtImage: true, - label: 'Select Shot Contact Position', - action: (data) => { - addNewRow(); - updateActiveRow('shotContactX', data.x); - updateActiveRow('shotContactY', data.y); - if (data.activeRowIndex > 0) { - updateActiveRow('shotInRally', parseInt(data.table[data.activeRowIndex]['shotInRally']) + 1); - // Need to copy down: pointScore, gameScore, setScore, serverName, serverSide - updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']); - updateActiveRow('pointScore', data.table[data.activeRowIndex]['pointScore']); - updateActiveRow('gameScore', data.table[data.activeRowIndex]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex]['setScore']); - updateActiveRow('tiebreakScore', data.table[data.activeRowIndex]['tiebreakScore']); - updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']); - } - else { - updateActiveRow('shotInRally', parseInt(data.table[0]['shotInRally']) + 1); - // Need to copy down: pointScore, gameScore, setScore, serverName, serverSide - updateActiveRow('serverName', data.table[0]['serverName']); - updateActiveRow('pointScore', data.table[0]['pointScore']); - updateActiveRow('gameScore', data.table[0]['gameScore']); - updateActiveRow('setScore', data.table[0]['setScore']); - updateActiveRow('tiebreakScore', data.table[0]['tiebreakScore']); - updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + else { + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', player1GameScore + '-' + player2GameScore); + updateActiveRow('setScore', player1SetScore + '-' + player2SetScore); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } } - if (data.y > 0) { // assuming 0 is halfway point - if (data.x < 0) { - updateActiveRow('side', 'Deuce'); - setCurrentPage('GroundstrokeShotInfo') - } - else { - updateActiveRow('side', 'Ad'); - setCurrentPage('GroundstrokeShotInfo') - } + } + } } - else { - if (data.x < 0) { - updateActiveRow('side', 'Ad'); - setCurrentPage('GroundstrokeShotInfo') - } - else { - updateActiveRow('side', 'Deuce'); - setCurrentPage('GroundstrokeShotInfo') - - } - } - }, + } - ], - 'GroundstrokeShotInfo': [ - { - label: 'Forehand', - action: () => { - updateActiveRow('shotFhBh', 'Forehand'); - setCurrentPage('GroundstrokeLocation'); - } - }, - { - label: 'Backhand', - action: () => { - updateActiveRow('shotFhBh', 'Backhand'); - setCurrentPage('GroundstrokeLocation'); - } - }, - - ], - 'GroundstrokeLocation': [ - { - label: 'Slice', - action: () => { - updateActiveRow('isSlice', '1'); - } - }, - { - label: 'Dropshot', - action: () => { - updateActiveRow('isDropshot', '1'); - } - }, - { - label: 'Approach', - action: () => { - updateActiveRow('isApproach', '1'); - } - }, - { - label: 'Volley', - action: () => { - updateActiveRow('isVolley', '1'); - } - }, - { - label: 'Overhead', - action: () => { - updateActiveRow('isOverhead', '1'); - } - }, - { - label: 'Lob', - action: () => { - updateActiveRow('isLob', '1'); - } - }, - { - label: 'Player1AtNet', - action: () => { - updateActiveRow('atNetPlayer1', '1'); - } - }, - { - label: 'Player2AtNet', - action: () => { - updateActiveRow('atNetPlayer2', '1'); - } - }, - { - label: 'Winner', - action: () => { - updateActiveRow('isWinner', '1'); - updateActiveRow('isPointEnd', '1'); - } - }, - { - courtImage: true, - label: 'Select Shot Result Location', - action: (data) => { - updateActiveRow('shotLocationX', data.x); - updateActiveRow('shotLocationY', data.y); - // assuming 0 is halfway point - if (data.x <= 0 & data.table[data.activeRowIndex]["shotContactX"] <= 0) { - updateActiveRow('shotDirection', "Down the Line"); - } - else if (data.x <= 0 & data.table[data.activeRowIndex]["shotContactX"] > 0) { - updateActiveRow('shotDirection', "Crosscourt"); - } - else if (data.x >= 0 & data.table[data.activeRowIndex]["shotContactX"] < 0) { - updateActiveRow('shotDirection', "Crosscourt"); - } - else { - updateActiveRow('shotDirection', "Down the Line"); - } - if (data.table[data.activeRowIndex]["shotContactY"] >= 0) { - if (data.y >= 0) { - updateActiveRow('isErrorNet', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.x > 157) { - updateActiveRow('isErrorWideL', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.x < -157) { - updateActiveRow('isErrorWideR', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.y < -455) { - updateActiveRow('isErrorLong', '1'); - updateActiveRow('isPointEnd', '1'); - } - - } - else { - if (data.y <= 0) { - updateActiveRow('isErrorNet', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.x < -157) { - updateActiveRow('isErrorWideL', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.x > 157) { - updateActiveRow('isErrorWideR', '1'); - updateActiveRow('isPointEnd', '1'); - } - if (data.y > 455) { - updateActiveRow('isErrorLong', '1'); - updateActiveRow('isPointEnd', '1'); - } - } + } + ], + 'GroundstrokeContact': [ + { + courtImage: true, + label: 'Select Shot Contact Position', + action: (data) => { + addNewRow(); + updateActiveRow('shotContactX', data.x); + updateActiveRow('shotContactY', data.y); + if (data.activeRowIndex > 0) { + updateActiveRow('shotInRally', parseInt(data.table[data.activeRowIndex]['shotInRally']) + 1); + // Need to copy down: pointScore, gameScore, setScore, serverName, serverSide + updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']); + updateActiveRow('pointScore', data.table[data.activeRowIndex]['pointScore']); + updateActiveRow('gameScore', data.table[data.activeRowIndex]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex]['setScore']); + updateActiveRow('tiebreakScore', data.table[data.activeRowIndex]['tiebreakScore']); + updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']); + } + else { + updateActiveRow('shotInRally', parseInt(data.table[0]['shotInRally']) + 1); + // Need to copy down: pointScore, gameScore, setScore, serverName, serverSide + updateActiveRow('serverName', data.table[0]['serverName']); + updateActiveRow('pointScore', data.table[0]['pointScore']); + updateActiveRow('gameScore', data.table[0]['gameScore']); + updateActiveRow('setScore', data.table[0]['setScore']); + updateActiveRow('tiebreakScore', data.table[0]['tiebreakScore']); + updateActiveRow('serverFarNear', data.table[0]['serverFarNear']); + } + if (data.y > 0) + { // assuming 0 is halfway point + if (data.x < 0) + { + updateActiveRow('side', 'Deuce'); + setCurrentPage('GroundstrokeShotInfo') + } + else + { + updateActiveRow('side', 'Ad'); + setCurrentPage('GroundstrokeShotInfo') + } + } + else + { + if (data.x < 0) + { + updateActiveRow('side', 'Ad'); + setCurrentPage('GroundstrokeShotInfo') + } + else + { + updateActiveRow('side', 'Deuce'); + setCurrentPage('GroundstrokeShotInfo') + + } + } + }, + } + ], + 'GroundstrokeShotInfo': [ + { + label: 'Forehand', + action: () => { + updateActiveRow('shotFhBh', 'Forehand'); + setCurrentPage('GroundstrokeLocation'); + } + }, + { + label: 'Backhand', + action: () => { + updateActiveRow('shotFhBh', 'Backhand'); + setCurrentPage('GroundstrokeLocation'); + } + }, - if ((data.table[data.activeRowIndex]["shotContactY"] >= 0 & ((data.y >= 0 || data.y < -455) || (data.x > 157 || data.x < -157))) || - (data.table[data.activeRowIndex]["shotContactY"] < 0 & ((data.y <= 0 || data.y > 455) || (data.x > 157 || data.x < -157))) || - (data.table[data.activeRowIndex]["isWinner"] == "1")) { - serverScore = parseInt(data.table[data.activeRowIndex]['pointScore'].split("-")[0]); - returnerScore = parseInt(data.table[data.activeRowIndex]['pointScore'].split("-")[1]); - player1GameScore = parseInt(data.table[data.activeRowIndex]['gameScore'].split("-")[0]); - player2GameScore = parseInt(data.table[data.activeRowIndex]['gameScore'].split("-")[1]); - player1SetScore = parseInt(data.table[data.activeRowIndex]['setScore'].split("-")[0]); - player2SetScore = parseInt(data.table[data.activeRowIndex]['setScore'].split("-")[1]); - if (player1GameScore == 6 && player2GameScore == 6) { - updateTiebreakScore(parseInt(data.table[data.activeRowIndex]["shotInRally"]), - data.table[data.activeRowIndex]["isWinner"], - data.table[data.activeRowIndex]["serverName"]); - if (serverScore >= 7 && (serverScore - returnerScore) >= 2) { - player1SetScore += 1; - player1GameScore = 0; - player2GameScore = 0; - serverScore = 0; - returnerScore = 0; - setCurrentPage('ServerName'); + ], + 'GroundstrokeLocation': [ + { + label: 'Slice', + action: () => { + updateActiveRow('isSlice', '1'); } - else if (returnerScore >= 7 && (returnerScore - serverScore) >= 2) { - player1SetScore += 1; - player1GameScore = 0; - player2GameScore = 0; - returnerScore = 0; - serverScore = 0; - setCurrentPage('ServerName'); + }, + { + label: 'Dropshot', + action: () => { + updateActiveRow('isDropshot', '1'); } - else { - if ((serverScore + returnerScore) % 2 == 1) { // need to switch scores cuz server switches - var tempServeScore = serverScore; - serverScore = returnerScore; - returnerScore = tempServeScore; - } - setCurrentPage('ServerName'); + }, + { + label: 'Approach', + action: () => { + updateActiveRow('isApproach', '1'); } - } - else { - updateScore(parseInt(data.table[data.activeRowIndex]["shotInRally"]), - data.table[data.activeRowIndex]["isWinner"], - data.table[data.activeRowIndex]["serverName"]); - if (serverScore == 0 && returnerScore == 0) { - if (player1GameScore >= 6) { - if (player1GameScore - player2GameScore >= 2) { - player1SetScore += 1; - player1GameScore = 0; - player2GameScore = 0; - } - } - else if (player2GameScore >= 6) { - if (player2GameScore - player1GameScore >= 2) { - player2SetScore += 1; - player2GameScore = 0; - player1GameScore = 0; - } - } - setCurrentPage('ServerName'); + }, + { + label: 'Volley', + action: () => { + updateActiveRow('isVolley', '1'); } - else { - addNewRow(); - if (serverScore == 40 && returnerScore == 40) { - updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']) - updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']) - setCurrentPage('PointScore'); - } - else { - updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']); - updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']); - updateActiveRow('pointScore', serverScore + '-' + returnerScore); - updateActiveRow('gameScore', data.table[data.activeRowIndex]['gameScore']); - updateActiveRow('setScore', data.table[data.activeRowIndex]['setScore']); - updateActiveRow('isPointStart', 1); - updateActiveRow('shotInRally', 1); - updateActiveRow('side', chooseSide()); - setCurrentPage('FirstServe'); - } + }, + { + label: 'Overhead', + action: () => { + updateActiveRow('isOverhead', '1'); } - } - } - else { - setCurrentPage('GroundstrokeContact'); - } + }, + { + label: 'Lob', + action: () => { + updateActiveRow('isLob', '1'); + } + }, + { + label: 'Player1AtNet', + action: () => { + updateActiveRow('atNetPlayer1', '1'); + } + }, + { + label: 'Player2AtNet', + action: () => { + updateActiveRow('atNetPlayer2', '1'); + } + }, + { + label: 'Winner', + action: () => { + updateActiveRow('isWinner', '1'); + updateActiveRow('isPointEnd', '1'); + } + }, + { + label: 'Exciting Point', + action: () => { + updateActiveRow('isExcitingPoint', '1'); + } + }, + { + courtImage: true, + label: 'Select Shot Result Location', + action: (data) => { + updateActiveRow('shotLocationX', data.x); + updateActiveRow('shotLocationY', data.y); + // assuming 0 is halfway point + if (data.x <= 0 & data.table[data.activeRowIndex]["shotContactX"] <= 0) { + updateActiveRow('shotDirection', "Down the Line"); + } + else if (data.x <= 0 & data.table[data.activeRowIndex]["shotContactX"] > 0) { + updateActiveRow('shotDirection', "Crosscourt"); + } + else if (data.x >= 0 & data.table[data.activeRowIndex]["shotContactX"] < 0) { + updateActiveRow('shotDirection', "Crosscourt"); + } + else { + updateActiveRow('shotDirection', "Down the Line"); + } + if (data.table[data.activeRowIndex]["shotContactY"] >= 0) { + if (data.y >= 0) { + updateActiveRow('isErrorNet', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.x > 157) { + updateActiveRow('isErrorWideL', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.x < -157) { + updateActiveRow('isErrorWideR', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.y < -455) { + updateActiveRow('isErrorLong', '1'); + updateActiveRow('isPointEnd', '1'); + } - } + } + else { + if (data.y <= 0) { + updateActiveRow('isErrorNet', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.x < -157) { + updateActiveRow('isErrorWideL', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.x > 157) { + updateActiveRow('isErrorWideR', '1'); + updateActiveRow('isPointEnd', '1'); + } + if (data.y > 455) { + updateActiveRow('isErrorLong', '1'); + updateActiveRow('isPointEnd', '1'); + } + } - }, - ], + if ((data.table[data.activeRowIndex]["shotContactY"] >= 0 & ((data.y >= 0 || data.y <-455) || (data.x > 157 || data.x < -157))) || + (data.table[data.activeRowIndex]["shotContactY"] < 0 & ((data.y <= 0 || data.y > 455) || (data.x > 157 || data.x < -157))) || + (data.table[data.activeRowIndex]["isWinner"] == "1")) { + serverScore = parseInt(data.table[data.activeRowIndex]['pointScore'].split("-")[0]); + returnerScore = parseInt(data.table[data.activeRowIndex]['pointScore'].split("-")[1]); + player1GameScore = parseInt(data.table[data.activeRowIndex]['gameScore'].split("-")[0]); + player2GameScore = parseInt(data.table[data.activeRowIndex]['gameScore'].split("-")[1]); + player1SetScore = parseInt(data.table[data.activeRowIndex]['setScore'].split("-")[0]); + player2SetScore = parseInt(data.table[data.activeRowIndex]['setScore'].split("-")[1]); + if (player1GameScore == 6 && player2GameScore == 6) { + updateTiebreakScore(parseInt(data.table[data.activeRowIndex]["shotInRally"]), + data.table[data.activeRowIndex]["isWinner"], + data.table[data.activeRowIndex]["serverName"]); + if (serverScore >= 7 && (serverScore - returnerScore) >= 2 ) { + player1SetScore += 1; + player1GameScore = 0; + player2GameScore = 0; + serverScore = 0; + returnerScore = 0; + setCurrentPage('ServerName'); + } + else if (returnerScore >= 7 && (returnerScore - serverScore) >= 2 ) { + player1SetScore += 1; + player1GameScore = 0; + player2GameScore = 0; + returnerScore = 0; + serverScore = 0; + setCurrentPage('ServerName'); + } + else { + if ((serverScore + returnerScore) % 2 == 1) { // need to switch scores cuz server switches + var tempServeScore = serverScore; + serverScore = returnerScore; + returnerScore = tempServeScore; + } + setCurrentPage('ServerName'); + } + } + else { + updateScore(parseInt(data.table[data.activeRowIndex]["shotInRally"]), + data.table[data.activeRowIndex]["isWinner"], + data.table[data.activeRowIndex]["serverName"]); + if (serverScore == 0 && returnerScore == 0) { + if (player1GameScore >= 6) { + if (player1GameScore - player2GameScore >= 2) { + player1SetScore += 1; + player1GameScore = 0; + player2GameScore = 0; + } + } + else if (player2GameScore >= 6) { + if (player2GameScore - player1GameScore >= 2) { + player2SetScore += 1; + player2GameScore = 0; + player1GameScore = 0; + } + } + setCurrentPage('ServerName'); + } + else { + addNewRow(); + if (serverScore == 40 && returnerScore == 40) { + updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']) + updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']) + setCurrentPage('PointScore'); + } + else { + updateActiveRow('serverFarNear', data.table[data.activeRowIndex]['serverFarNear']); + updateActiveRow('serverName', data.table[data.activeRowIndex]['serverName']); + updateActiveRow('pointScore', serverScore + '-' + returnerScore); + updateActiveRow('gameScore', data.table[data.activeRowIndex]['gameScore']); + updateActiveRow('setScore', data.table[data.activeRowIndex]['setScore']); + updateActiveRow('isPointStart', 1); + updateActiveRow('shotInRally', 1); + updateActiveRow('side', chooseSide()); + setCurrentPage('FirstServe'); + } + } + } + } + else + { + setCurrentPage('GroundstrokeContact'); + } + + } + + }, + ], }); export const columnNames = [ - 'pointScore', - 'gameScore', - 'setScore', - 'isPointStart', - 'pointStartTime', - 'isPointEnd', - 'pointEndTime', - 'pointNumber', - 'isBreakPoint', - 'shotInRally', - 'side', - 'serverName', - 'serverFarNear', - 'firstServeIn', - 'firstServeZone', - 'firstServeXCoord', - 'firstServeYCoord', - 'secondServeIn', - 'secondServeZone', - 'secondServeXCoord', - 'secondServeYCoord', - 'isAce', - 'shotContactX', - 'shotContactY', - 'shotDirection', - 'shotFhBh', - 'isSlice', - 'isVolley', - 'isOverhead', - 'isApproach', - 'isDropshot', - 'atNetPlayer1', - 'atNetPlayer2', - 'isLob', - 'shotLocationX', - 'shotLocationY', - 'isWinner', - 'isErrorWideR', - 'isErrorWideL', - 'isErrorNet', - 'isErrorLong', - 'clientTeam', - 'Date', - 'Division', - 'Event', - 'lineupPosition', - 'matchDetails', - 'matchVenue', - 'opponentTeam', - 'player1Name', - 'player2Name', - 'player1Hand', - 'player2Hand', - 'Round', - 'Surface', - 'Notes', + 'pointScore', + 'gameScore', + 'setScore', + 'isPointStart', + 'pointStartTime', + 'isPointEnd', + 'pointEndTime', + 'pointNumber', + 'isBreakPoint', + 'shotInRally', + 'side', + 'serverName', + 'serverFarNear', + 'firstServeIn', + 'firstServeZone', + 'firstServeXCoord', + 'firstServeYCoord', + 'secondServeIn', + 'secondServeZone', + 'secondServeXCoord', + 'secondServeYCoord', + 'isAce', + 'shotContactX', + 'shotContactY', + 'shotDirection', + 'shotFhBh', + 'isSlice', + 'isVolley', + 'isOverhead', + 'isApproach', + 'isDropshot', + 'isExcitingPoint', + 'atNetPlayer1', + 'atNetPlayer2', + 'isLob', + 'shotLocationX', + 'shotLocationY', + 'isWinner', + 'isErrorWideR', + 'isErrorWideL', + 'isErrorNet', + 'isErrorLong', + 'clientTeam', + 'Date', + 'Division', + 'Event', + 'lineupPosition', + 'matchDetails', + 'matchVenue', + 'opponentTeam', + 'player1Name', + 'player2Name', + 'player1Hand', + 'player2Hand', + 'Round', + 'Surface', + 'Notes', ]; \ No newline at end of file