Created
October 23, 2015 02:07
-
-
Save puiutucutu/c68789ad2622732094ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function debug(obj) | |
| { | |
| console.dir(obj) | |
| } | |
| jQuery(document).ready(function () { | |
| jQuery('body').on('click', '.table', function() { | |
| // alert('touched my table') | |
| }); | |
| var table = document.getElementById('geocodeTable') | |
| var geocodeButtons = document.querySelectorAll('[button-type=geocode]') | |
| var saveButtons = document.querySelectorAll('[button-type=save]') | |
| // add onclick events to each geocode button | |
| for (var i = 0, len = geocodeButtons.length; i < len; i++) { | |
| geocodeButtons[i].onclick = (function(event) { | |
| // get row index and col index | |
| var row = this.closest('tr').rowIndex | |
| var cell = this.closest('td').cellIndex | |
| // extract row information | |
| var originalAddress = table.rows[row].cells[0].innerText | |
| var originalCity = table.rows[row].cells[1].innerText | |
| var Street = table.rows[row].cells[3].innerText | |
| var Route = table.rows[row].cells[4].innerText | |
| var Locality = table.rows[row].cells[5].innerText | |
| var Sublocality = table.rows[row].cells[6].innerText | |
| var AdministrativeArea = table.rows[row].cells[7].innerText | |
| var GeocodeStatus = table.rows[row].cells[8].innerText | |
| // debug(originalAddress) | |
| // debug(originalCity) | |
| // debug(Street) | |
| // debug(Route) | |
| // debug(Locality) | |
| // debug(Sublocality) | |
| // debug(AdministrativeArea) | |
| // debug(GeocodeStatus) | |
| }) | |
| } | |
| // add onclick events to each save button | |
| for (var i = 0, len = saveButtons.length; i < len; i++) { | |
| saveButtons[i].onclick = (function(event) { | |
| // get row index and col index | |
| var row = this.closest('tr').rowIndex | |
| var cell = this.closest('td').cellIndex | |
| debug('Cell: ' + cell + ' and Row: ' + row) | |
| }) | |
| } | |
| /** | |
| * (1) on click of button collect the row cells data [DONE] | |
| * (2) ajax request to jeocode [IN PROGRESS] | |
| * (3) interpret ajax json response | |
| * (4) update table or somewhere in a new row | |
| * (5) on user click of save, store the new data to database | |
| */ | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment