Added indicator to show if sorting is ascending or descending
This commit is contained in:
		| @@ -73,14 +73,30 @@ function deleteAddress(id) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function upCase(text) { | ||||||
|  |     return text[0].toUpperCase() + text.substring(1); | ||||||
|  | } | ||||||
| function sortBy(column) { | function sortBy(column) { | ||||||
|  |     // clear titles | ||||||
|  |     const titles = ['first', 'last', 'street', 'zip', 'city', 'phone'] | ||||||
|  |     titles.forEach((title) => | ||||||
|  |         document.getElementById(title).innerHTML = upCase(title) | ||||||
|  |     ) | ||||||
|  |  | ||||||
|     // switch direction on every call |     // switch direction on every call | ||||||
|     let currentSortOrder = document.getElementById(column + '_sort') |     let currentSortOrder = document.getElementById(column + '_sort') | ||||||
|  |     let currentTitleElement = document.getElementById(column) | ||||||
|  |     let currentTitle = currentTitleElement.innerHTML | ||||||
|  |  | ||||||
|  |     let newTitle = '' | ||||||
|     if (currentSortOrder.innerHTML === 'asc') { |     if (currentSortOrder.innerHTML === 'asc') { | ||||||
|         currentSortOrder.innerHTML = 'desc' |         currentSortOrder.innerHTML = 'desc' | ||||||
|  |         newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬇' | ||||||
|     } else { |     } else { | ||||||
|         currentSortOrder.innerHTML = 'asc' |         currentSortOrder.innerHTML = 'asc' | ||||||
|  |         newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬆' | ||||||
|     } |     } | ||||||
|  |     currentTitleElement.innerHTML = newTitle | ||||||
|  |  | ||||||
|     const table = document.getElementById('address_table'); |     const table = document.getElementById('address_table'); | ||||||
|     let dirty = true; |     let dirty = true; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user