T158 added option to add and remove headers as will
This commit is contained in:
		| @@ -221,4 +221,16 @@ | ||||
|  | ||||
| } | ||||
|  | ||||
| .btn-function-table { | ||||
|     font-size: 24px; | ||||
|     font-weight: 700; | ||||
| } | ||||
|  | ||||
| .btn-table-add { | ||||
|     color: green; | ||||
| } | ||||
|  | ||||
| .btn-table-remove { | ||||
|     color: red; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,3 @@ | ||||
| //TODO: Add sleep after PUT,POST,DELETE request. Data might not be processed before GET request | ||||
| //TODO: Add button to add new header | ||||
| //TODO: Update cookie when displayed message is changed | ||||
| //TODO: Add delete buttons for headers | ||||
| @@ -6,6 +5,7 @@ | ||||
| var clientUUID; | ||||
| var json; | ||||
| var jsonIndex = 0; | ||||
| var htable_row = 0; | ||||
| const C_UUID = 'mock-uuid'; | ||||
| function getData(){ | ||||
|     // sleep(5000); | ||||
| @@ -79,6 +79,7 @@ function addMessage(){ | ||||
|  | ||||
| function clearMock(){ | ||||
|     fillStaticFields('','','',''); | ||||
|     htable_row = 0; | ||||
|     $('#httpStatusValues').html(''); | ||||
| } | ||||
|  | ||||
| @@ -128,18 +129,45 @@ function generateHeaderTable(headers){ | ||||
|     for(var val in headers){ | ||||
|         values[index++]=headers[val]; | ||||
|     } | ||||
|  | ||||
|     for(let i=0; i<count; i++){ | ||||
|         innerHTML+= | ||||
|             '<tr class="httpStatusValue">' + | ||||
|             '<tr id="hrow' + htable_row + '" class="httpStatusValue">' + | ||||
|                 '<td>' + | ||||
|                     '<input type="text" name="headerKey" placeholder="key" class="tableField headerName" value="' + keys[i] + '"/></td>' + | ||||
|                     '<input " type="text" name="headerKey" placeholder="key" class="tableField headerName" value="' + keys[i] + '"/></td>' + | ||||
|                 '<td>' + | ||||
|                     '<input type="text" name="headerKey" placeholder="key" class="tableField" value="' + values[i] + '"/></td>' + | ||||
|                     '<input " type="text" name="headerKey" placeholder="key" class="tableField" value="' + values[i] + '"/></td>' + | ||||
|             '<td class="btn-function-table btn-table-remove" onclick="removeRow(' + htable_row + ')">X</td>' + | ||||
|             '</tr>'; | ||||
|         htable_row++; | ||||
|     } | ||||
|     return innerHTML; | ||||
| } | ||||
|  | ||||
| function removeRow(row){ | ||||
|     $('#hrow' + row).remove(); | ||||
| } | ||||
|  | ||||
| function addRow(){ | ||||
|     var table = $('#httpStatusValues'); | ||||
|     var hkey = $('#headerKeyInput'); | ||||
|     var hval = $('#headerValueInput'); | ||||
|     if(hkey.val() == 'key' || hkey.val() == '' || hval.val() == 'value' || hval.val() == '') return; | ||||
|     var innerHtml = | ||||
|         '<tr id="hrow' + htable_row + '" class="httpStatusValue">' + | ||||
|         '<td>' + | ||||
|         '<input " type="text" name="headerKey" placeholder="key" class="tableField headerName" value="' + hkey.val() + | ||||
|         '"/></td>' + | ||||
|         '<td>' + | ||||
|         '<input " type="text" name="headerKey" placeholder="key" class="tableField" value="' + hval.val() + '"/></td>' + | ||||
|         '<td class="btn-function-table btn-table-remove" onclick="removeRow(' + htable_row + ')">X</td>' + | ||||
|         '</tr>'; | ||||
|     htable_row++; | ||||
|     table.append(innerHtml); | ||||
|     hkey.val(''); | ||||
|     hval.val(''); | ||||
| } | ||||
|  | ||||
| function fillMessageList(){ | ||||
|     $("#listItems").html(''); | ||||
|     var innerHTML = ''; | ||||
|   | ||||
| @@ -59,6 +59,7 @@ | ||||
|                                 <tr> | ||||
|                                     <td class="tableHead">Header</td> | ||||
|                                     <td class="tableHead">Value</td> | ||||
|                                     <td></td> | ||||
|                                 </tr> | ||||
|                             </thead> | ||||
|                             <tbody id="httpStatusValues"> | ||||
| @@ -67,6 +68,7 @@ | ||||
|                                 <tr> | ||||
|                                     <td><input type="text" name="headerKey" id="headerKeyInput" placeholder="key" class="tableField"/></td> | ||||
|                                     <td><input type="text" name="headerValue" id="headerValueInput" placeholder="value" class="tableField"/></td> | ||||
|                                     <td id="btn-addRow" onclick="addRow()" class="btn-function-table btn-table-add">+</td> | ||||
|                                 </tr> | ||||
|                             </tfoot> | ||||
| <!--                        <input type="text" name="headerValue" id="headerValue" class="headerField" placeholder="value"/>--> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user