From 49fb63561d6b17294d61e71879ee33c53d86e398 Mon Sep 17 00:00:00 2001 From: modzeleg Date: Wed, 14 Apr 2021 17:32:01 +0200 Subject: [PATCH] Add row button operational --- src/main/resources/static/html/mock.html | 2 +- src/main/resources/static/js/datatransfer.js | 14 ++++++++++++++ target/classes/static/html/mock.html | 2 +- target/classes/static/js/datatransfer.js | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/resources/static/html/mock.html b/src/main/resources/static/html/mock.html index 3ca70c1..1bdf5b1 100644 --- a/src/main/resources/static/html/mock.html +++ b/src/main/resources/static/html/mock.html @@ -99,7 +99,7 @@ - + diff --git a/src/main/resources/static/js/datatransfer.js b/src/main/resources/static/js/datatransfer.js index 9641794..115f619 100644 --- a/src/main/resources/static/js/datatransfer.js +++ b/src/main/resources/static/js/datatransfer.js @@ -251,6 +251,20 @@ function addRow(key, value){ headerMap.html(headersMapHtml); } +const newRowInput = function(){ + const hName = $('#headerKeyInput').val(); + const hValue = $('#headerValueInput').val(); + if(checkIfInputValid(hName) && checkIfInputValid(hValue)){ + addRow(hName, hValue); + } +} + +$('#btn-newRow').click(newRowInput); + +function checkIfInputValid(input){ + return !(input == '' || input == null || input == undefined); +} + function buildRowHtml(key, value){ return '' + '' + diff --git a/target/classes/static/html/mock.html b/target/classes/static/html/mock.html index 3ca70c1..1bdf5b1 100644 --- a/target/classes/static/html/mock.html +++ b/target/classes/static/html/mock.html @@ -99,7 +99,7 @@ - + diff --git a/target/classes/static/js/datatransfer.js b/target/classes/static/js/datatransfer.js index 9641794..115f619 100644 --- a/target/classes/static/js/datatransfer.js +++ b/target/classes/static/js/datatransfer.js @@ -251,6 +251,20 @@ function addRow(key, value){ headerMap.html(headersMapHtml); } +const newRowInput = function(){ + const hName = $('#headerKeyInput').val(); + const hValue = $('#headerValueInput').val(); + if(checkIfInputValid(hName) && checkIfInputValid(hValue)){ + addRow(hName, hValue); + } +} + +$('#btn-newRow').click(newRowInput); + +function checkIfInputValid(input){ + return !(input == '' || input == null || input == undefined); +} + function buildRowHtml(key, value){ return '' + '' +